Minor improvements to the hide and show effect
This commit is contained in:
parent
080b1e8b2c
commit
ee26a51b34
@ -250,7 +250,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
if (old != current)
|
||||
{
|
||||
string msg = (current ? "Connected to" : "Disconnected from")+" the VPN";
|
||||
string msg = (current ? "Connected to" : "Disconnected from") + " the VPN";
|
||||
string icon = "/usr/lib/melon-vpn/MiniMelonVPN" + (current ? "Online" : "Icon") + ".png";
|
||||
Notification pop = new Notification("Melon VPN", msg, icon);
|
||||
pop.Show();
|
||||
@ -301,25 +301,13 @@ public partial class MainWindow : Window
|
||||
{
|
||||
IsHidden = false;
|
||||
|
||||
Visible = true;
|
||||
// Present triggers `Visible = true;`
|
||||
// it is then called again once the window is visible
|
||||
// so it triggers `Deiconify();`
|
||||
Present();
|
||||
SkipPagerHint = false;
|
||||
SkipTaskbarHint = false;
|
||||
|
||||
// Just wait before triggering these to get
|
||||
// the right effect
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// Deiconify and Present seem to do the same
|
||||
// thing but sometimes Deiconify doesn't work
|
||||
Deiconify();
|
||||
Present();
|
||||
})
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
thread.Start();
|
||||
|
||||
UpdateTrayMenu();
|
||||
}
|
||||
|
||||
@ -382,8 +370,19 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
void OnRefreshClicked(object sender, EventArgs e)
|
||||
void OnRefreshClicked(object sender, EventArgs e) => Refresh();
|
||||
|
||||
protected void OnVisibilityNotifyEvent(object o, VisibilityNotifyEventArgs args)
|
||||
{
|
||||
Refresh();
|
||||
// Calling present again forces the window to `Deiconify();`
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Present();
|
||||
})
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
@ -25,5 +25,6 @@ public partial class MainWindow
|
||||
this.DefaultHeight = 86;
|
||||
this.Show();
|
||||
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
|
||||
this.VisibilityNotifyEvent += new global::Gtk.VisibilityNotifyEventHandler(this.OnVisibilityNotifyEvent);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
<property name="Title" translatable="yes">MainWindow</property>
|
||||
<property name="WindowPosition">CenterOnParent</property>
|
||||
<signal name="DeleteEvent" handler="OnDeleteEvent" />
|
||||
<signal name="VisibilityNotifyEvent" handler="OnVisibilityNotifyEvent" />
|
||||
<child>
|
||||
<widget class="Gtk.Fixed" id="fixed1">
|
||||
<property name="MemberName" />
|
||||
|
Loading…
Reference in New Issue
Block a user