From 1924ef37bed94bcd63aec93a28eaa987f4c92789 Mon Sep 17 00:00:00 2001 From: jderose9 Date: Wed, 28 Dec 2016 20:22:12 -0500 Subject: [PATCH] use strings instead of order index for combo boxes assignments in case of future reorder --- Settings.ui | 46 +++++++++---------- panel.js | 9 ++-- prefs.js | 32 ++++++------- ...shell.extensions.dash-to-panel.gschema.xml | 33 +++++++------ taskbar.js | 29 ++++-------- 5 files changed, 73 insertions(+), 76 deletions(-) diff --git a/Settings.ui b/Settings.ui index 5bdd77a..9e78af2 100644 --- a/Settings.ui +++ b/Settings.ui @@ -73,12 +73,12 @@ False center - Raise window - Minimize window - Launch new instance - Cycle through windows - Cycle windows + minimize - Quit + Raise window + Minimize window + Launch new instance + Cycle through windows + Cycle windows + minimize + Quit @@ -143,12 +143,12 @@ False center - Raise window - Minimize window - Launch new instance - Cycle windows - Cycle windows + minimize - Quit + Raise window + Minimize window + Launch new instance + Cycle through windows + Cycle windows + minimize + Quit @@ -213,12 +213,12 @@ False center - Raise window - Minimize window - Launch new instance - Cycle through windows - Cycle windows + minimize - Quit + Raise window + Minimize window + Launch new instance + Cycle through windows + Cycle windows + minimize + Quit @@ -734,11 +734,11 @@ False center - Raise window - Minimize - Launch new instance - Cycle through windows - Cycle windows + minimize + Raise window + Minimize window + Launch new instance + Cycle through windows + Cycle windows + minimize diff --git a/panel.js b/panel.js index 675414c..dd1b0b4 100644 --- a/panel.js +++ b/panel.js @@ -245,13 +245,14 @@ const taskbarPanel = new Lang.Class({ _setPanelStyle: function() { let size = this._dtpSettings.get_int('panel-size'); - let position = this._dtpSettings.get_enum('panel-position'); + let position = this._dtpSettings.get_string('panel-position'); + let isTop = position == "TOP"; this.panel.actor.set_height(size); - Main.overview._panelGhost.set_height(position ? size : 0); - this._myPanelGhost.set_height(position ? 0 : size); - position ? this.panelBox.set_anchor_point(0, 0) : + Main.overview._panelGhost.set_height(isTop ? size : 0); + this._myPanelGhost.set_height(isTop ? 0 : size); + isTop ? this.panelBox.set_anchor_point(0, 0) : this.panelBox.set_anchor_point(0,(-1)*(Main.layoutManager.primaryMonitor.height-this.panelBox.height)); }, diff --git a/prefs.js b/prefs.js index 8b41d04..5447a49 100644 --- a/prefs.js +++ b/prefs.js @@ -72,13 +72,13 @@ const Settings = new Lang.Class({ // Position and size panel // Position option - let position = this._settings.get_enum('panel-position'); + let position = this._settings.get_string('panel-position'); switch (position) { - case 0: + case 'BOTTOM': this._builder.get_object('position_bottom_button').set_active(true); break; - case 1: + case 'TOP': this._builder.get_object('position_top_button').set_active(true); break; @@ -123,20 +123,20 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.DEFAULT); - this._builder.get_object('click_action_combo').set_active(this._settings.get_enum('click-action')); + this._builder.get_object('click_action_combo').set_active_id(this._settings.get_string('click-action')); this._builder.get_object('click_action_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_enum('click-action', widget.get_active()); + this._settings.set_string('click-action', widget.get_active_id()); })); this._builder.get_object('shift_click_action_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_enum('shift-click-action', widget.get_active()); + this._settings.set_string('shift-click-action', widget.get_active_id()); })); this._builder.get_object('middle_click_action_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_enum('middle-click-action', widget.get_active()); + this._settings.set_string('middle-click-action', widget.get_active_id()); })); this._builder.get_object('shift_middle_click_action_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_enum('shift-middle-click-action', widget.get_active()); + this._settings.set_string('shift-middle-click-action', widget.get_active_id()); })); // Create dialog for middle-click options @@ -154,11 +154,11 @@ const Settings = new Lang.Class({ let box = this._builder.get_object('box_middle_click_options'); dialog.get_content_area().add(box); - this._builder.get_object('shift_click_action_combo').set_active(this._settings.get_enum('shift-click-action')); + this._builder.get_object('shift_click_action_combo').set_active_id(this._settings.get_string('shift-click-action')); - this._builder.get_object('middle_click_action_combo').set_active(this._settings.get_enum('middle-click-action')); + this._builder.get_object('middle_click_action_combo').set_active_id(this._settings.get_string('middle-click-action')); - this._builder.get_object('shift_middle_click_action_combo').set_active(this._settings.get_enum('shift-middle-click-action')); + this._builder.get_object('shift_middle_click_action_combo').set_active_id(this._settings.get_string('shift-middle-click-action')); this._settings.bind('shift-click-action', this._builder.get_object('shift_click_action_combo'), @@ -180,9 +180,9 @@ const Settings = new Lang.Class({ keys.forEach(function(val) { this._settings.set_value(val, this._settings.get_default_value(val)); }, this); - this._builder.get_object('shift_click_action_combo').set_active(this._settings.get_enum('shift-click-action')); - this._builder.get_object('middle_click_action_combo').set_active(this._settings.get_enum('middle-click-action')); - this._builder.get_object('shift_middle_click_action_combo').set_active(this._settings.get_enum('shift-middle-click-action')); + this._builder.get_object('shift_click_action_combo').set_active_id(this._settings.get_string('shift-click-action')); + this._builder.get_object('middle_click_action_combo').set_active_id(this._settings.get_string('middle-click-action')); + this._builder.get_object('shift_middle_click_action_combo').set_active_id(this._settings.get_string('shift-middle-click-action')); } else { // remove the settings box so it doesn't get destroyed; dialog.get_content_area().remove(box); @@ -231,12 +231,12 @@ const Settings = new Lang.Class({ position_bottom_button_toggled_cb: function(button) { if (button.get_active()) - this._settings.set_enum('panel-position', 0); + this._settings.set_string('panel-position', "BOTTOM"); }, position_top_button_toggled_cb: function(button) { if (button.get_active()) - this._settings.set_enum('panel-position', 1); + this._settings.set_string('panel-position', "TOP"); }, panel_size_scale_format_value_cb: function(scale, value) { diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index ff6deaa..8f22161 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -1,21 +1,26 @@ - - - - - - + + + + + + + + + + + - + - + 'BOTTOM' Panel position Panel is shown on the Bottom or Top of the screen. @@ -25,8 +30,8 @@ Panel size Set the size of the panel. - - "STATUSRIGHT" + + 'STATUSRIGHT' Location of the clock Set the location of the clock on the taskbar @@ -54,22 +59,22 @@ Activate only one window - 'cycle-windows-min' + 'CYCLE-MIN' Action when clicking on a running app Set the action that is executed when clicking on the icon of a running application - 'minimize' + 'MINIMIZE' Action when shit+clicking on a running app Set the action that is executed when shift+clicking on the icon of a running application - 'launch' + 'LAUNCH' Action when clicking on a running app Set the action that is executed when middle-clicking on the icon of a running application - 'launch' + 'LAUNCH' Action when clicking on a running app Set the action that is executed when shift+middle-clicking on the icon of a running application diff --git a/taskbar.js b/taskbar.js index 32b2e1a..5efc1b8 100644 --- a/taskbar.js +++ b/taskbar.js @@ -57,15 +57,6 @@ let LABEL_GAP = 5; let RUNNING_INDICATOR_SIZE = 3; let HFADE_WIDTH = 48; -const clickAction = { - SKIP: 0, - MINIMIZE: 1, - LAUNCH: 2, - CYCLE_WINDOWS: 3, - CYCLE_WINDOWS_MIN: 4, - QUIT: 5 -}; - function getPosition() { return Main.layoutManager.panelBox.anchor_y == 0 ? St.Side.TOP : St.Side.BOTTOM; } @@ -1366,30 +1357,30 @@ const taskbarAppIcon = new Lang.Class({ let buttonAction = 0; if (button && button == 2 ) { if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = this._dtpSettings.get_enum('shift-middle-click-action'); + buttonAction = this._dtpSettings.get_string('shift-middle-click-action'); else - buttonAction = this._dtpSettings.get_enum('middle-click-action'); + buttonAction = this._dtpSettings.get_string('middle-click-action'); } else if (button && button == 1) { if (modifiers & Clutter.ModifierType.SHIFT_MASK) - buttonAction = this._dtpSettings.get_enum('shift-click-action'); + buttonAction = this._dtpSettings.get_string('shift-click-action'); else - buttonAction = this._dtpSettings.get_enum('click-action'); + buttonAction = this._dtpSettings.get_string('click-action'); } // We customize the action only when the application is already running if (this.app.state == Shell.AppState.RUNNING) { switch (buttonAction) { - case clickAction.SKIP: + case "RAISE": activateAllWindows(this.app); break; - case clickAction.LAUNCH: + case "LAUNCH": this.animateLaunch(); this.app.open_new_window(-1); break; - case clickAction.MINIMIZE: + case "MINIMIZE": // In overview just activate the app, unless the acion is explicitely // requested with a keyboard modifier if (!Main.overview._shown || modifiers){ @@ -1411,7 +1402,7 @@ const taskbarAppIcon = new Lang.Class({ this.app.activate(); break; - case clickAction.CYCLE_WINDOWS: + case "CYCLE": if (!Main.overview._shown){ if (this.app == focusedApp) activateNextWindow(this.app, false); @@ -1422,7 +1413,7 @@ const taskbarAppIcon = new Lang.Class({ else this.app.activate(); break; - case clickAction.CYCLE_WINDOWS_MIN: + case "CYCLE-MIN": if (!Main.overview._shown){ if (this.app == focusedApp) activateNextWindow(this.app, true); @@ -1434,7 +1425,7 @@ const taskbarAppIcon = new Lang.Class({ this.app.activate(); break; - case clickAction.QUIT: + case "QUIT": closeAllWindows(this.app); break; }