From fc9065679da65a0a17889ea9167a5651be0491fb Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Sun, 23 Feb 2014 11:15:04 +0100 Subject: [PATCH] Add switches to decide which position to reset --- ....shell.extensions.panel-osd.gschema.xml.in | 10 +- data/panel-osd-settings.ui | 108 ++++++++++++++++-- src/prefs.js | 51 ++++++++- 3 files changed, 154 insertions(+), 15 deletions(-) diff --git a/data/org.gnome.shell.extensions.panel-osd.gschema.xml.in b/data/org.gnome.shell.extensions.panel-osd.gschema.xml.in index 7017da0..d0061d2 100644 --- a/data/org.gnome.shell.extensions.panel-osd.gschema.xml.in +++ b/data/org.gnome.shell.extensions.panel-osd.gschema.xml.in @@ -5,7 +5,15 @@ <_summary>Horizontal position of notification. - 0.0 + 100.0 + <_summary>Vertical position of notification. + + + false + <_summary>Horizontal position of notification. + + + false <_summary>Vertical position of notification. diff --git a/data/panel-osd-settings.ui b/data/panel-osd-settings.ui index 55e1c8a..b54b625 100644 --- a/data/panel-osd-settings.ui +++ b/data/panel-osd-settings.ui @@ -1,7 +1,7 @@ - + 100 0.10000000000000001 @@ -13,9 +13,8 @@ 2 + 1 False - 5 - 14 vertical @@ -23,8 +22,9 @@ False True 0 + 0 Horizontal position [%] from 0% (left) to 100% (right) - start + end False @@ -68,6 +68,8 @@ True False True + 0 + 0 Vertical position [%] from 0% (bottom) to 100% (top) start False @@ -111,16 +113,100 @@ - - Reset to defaults + True - True - True - end + False + + + True + False + start + 5 + 10 + + + True + True + 10 + 10 + + + 0 + 0 + 1 + 1 + + + + + True + True + + + 0 + 1 + 1 + 1 + + + + + True + False + start + True + Reset horizontal position to defaults + + + 1 + 0 + 1 + 1 + + + + + True + False + start + True + Reset vertical position to defaults + + + 1 + 1 + 1 + 1 + + + + + True + True + 0 + + + + + Reset + True + True + True + center + 20 + True + True + + + False + True + 1 + + - False - True + True + False 6 diff --git a/src/prefs.js b/src/prefs.js index 6f7ceec..575369f 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -16,6 +16,8 @@ const EXTENSIONDIR = Me.dir.get_path(); const PANEL_OSD_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd'; const PANEL_OSD_X_POS_KEY = 'x-pos'; const PANEL_OSD_Y_POS_KEY = 'y-pos'; +const PANEL_OSD_ALLOW_X_RESET = 'x-res'; +const PANEL_OSD_ALLOW_Y_RESET = 'y-res'; const PanelOsdPrefsWidget = new GObject.Class({ Name: 'PanelOsdExtension.Prefs.Widget', @@ -68,9 +70,28 @@ const PanelOsdPrefsWidget = new GObject.Class({ })); - this.Window.get_object("button-reset").connect("clicked", Lang.bind(this, function() { - this.x_scale.set_value(50); - this.y_scale.set_value(0); + this.switch_x_reset = this.Window.get_object("switch-x-reset"); + this.switch_y_reset = this.Window.get_object("switch-y-reset"); + this.reset_button = this.Window.get_object("button-reset"); + + this.switch_x_reset.connect("notify::active", Lang.bind(this, function() { + this.x_reset = arguments[0].active; + this.reset_button.sensitive = this.x_reset || this.y_reset; + })); + + this.switch_y_reset.connect("notify::active", Lang.bind(this, function() { + this.y_reset = arguments[0].active; + this.reset_button.sensitive = this.x_reset || this.y_reset; + })); + + this.switch_x_reset.set_active(this.x_reset); + this.switch_y_reset.set_active(this.y_reset); + + this.reset_button.sensitive = this.x_reset || this.y_reset; + + this.reset_button.connect("clicked", Lang.bind(this, function() { + this.x_reset && this.x_scale.set_value(50); + this.y_reset && this.y_scale.set_value(100); })); @@ -102,6 +123,30 @@ const PanelOsdPrefsWidget = new GObject.Class({ if (!this.Settings) this.loadConfig(); this.Settings.set_double(PANEL_OSD_Y_POS_KEY, v); + }, + + get x_reset() { + if (!this.Settings) + this.loadConfig(); + return this.Settings.get_boolean(PANEL_OSD_ALLOW_X_RESET); + }, + + set x_reset(v) { + if (!this.Settings) + this.loadConfig(); + this.Settings.set_boolean(PANEL_OSD_ALLOW_X_RESET, v); + }, + + get y_reset() { + if (!this.Settings) + this.loadConfig(); + return this.Settings.get_boolean(PANEL_OSD_ALLOW_Y_RESET); + }, + + set y_reset(v) { + if (!this.Settings) + this.loadConfig(); + this.Settings.set_boolean(PANEL_OSD_ALLOW_Y_RESET, v); } });