Skip to content

Commit 3d7d132

Browse files
authored
Application: hold or release with indicator state (#474)
1 parent f3d1842 commit 3d7d132

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/MainWindow.vala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow {
106106
MonitorApp.settings.set_int ("window-height", window_height);
107107
MonitorApp.settings.set_boolean ("is-maximized", this.is_maximized);
108108

109-
if (MonitorApp.settings.get_boolean ("indicator-state")) {
110-
this.hide_on_delete ();
111-
} else {
109+
if (!MonitorApp.settings.get_boolean ("indicator-state")) {
112110
dbusserver.indicator_state (false);
113-
application.quit ();
114111
}
115112

116-
return true;
113+
return Gdk.EVENT_PROPAGATE;
117114
});
118115

119116
dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state"));

src/Monitor.vala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Monitor {
99
private MainWindow window = null;
1010
public string[] args;
1111

12+
private bool held = false;
1213
private static bool start_in_background = false;
1314
private static bool status_background = false;
1415
private const GLib.OptionEntry[] CMD_OPTIONS = {
@@ -41,6 +42,20 @@ namespace Monitor {
4142
// Controls the direction of the sort indicators
4243
Gtk.Settings.get_default ().set ("gtk-alternative-sort-arrows", true, null);
4344

45+
if (settings.get_boolean ("indicator-state")) {
46+
held = true;
47+
hold ();
48+
}
49+
50+
settings.changed["indicator-state"].connect (() => {
51+
if (settings.get_boolean ("indicator-state")) {
52+
held = true;
53+
hold ();
54+
} else if (held) {
55+
release ();
56+
}
57+
});
58+
4459
var quit_action = new SimpleAction ("quit", null);
4560
add_action (quit_action);
4661
quit_action.activate.connect (() => {

0 commit comments

Comments
 (0)