From 11a5deca1b40d8b819edd821e9d3ef5768f329aa Mon Sep 17 00:00:00 2001 From: zapashcanon Date: Tue, 25 Sep 2018 13:44:09 +0200 Subject: [PATCH] GSConnect support and more safety checks --- powerful-topbar@leo.ndrs.fr/extension.js | 62 +++++++++++++------ powerful-topbar@leo.ndrs.fr/prefs.js | 2 + ...ell.extensions.powerful-topbar.gschema.xml | 5 ++ 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/powerful-topbar@leo.ndrs.fr/extension.js b/powerful-topbar@leo.ndrs.fr/extension.js index cd67e6c..c0d68d5 100644 --- a/powerful-topbar@leo.ndrs.fr/extension.js +++ b/powerful-topbar@leo.ndrs.fr/extension.js @@ -19,6 +19,7 @@ const SETTING_SHOW_BLUETOOTH_INDICATOR = 'show-bluetooth-indicator'; const SETTING_SHOW_POWER_INDICATOR = 'show-power-indicator'; const SETTING_SHOW_POWER_PERCENTAGE_LABEL = 'show-power-percentage-label'; const SETTING_SHOW_NIGHTLIGHT_INDICATOR = 'show-nightlight-indicator'; +const SETTING_SHOW_GSCONNECT_INDICATOR = 'show-gsconnect-indicator'; const SETTING_REMOVE_ROUNDED_CORNERS = 'remove-rounded-corners'; function init() { @@ -51,6 +52,7 @@ function disable() { show_status_area_component_indicator('aggregateMenu', '_power', '_indicator'); show_status_area_component_indicator('aggregateMenu', '_power', '_percentageLabel'); show_status_area_component_indicator('aggregateMenu', '_nightLight', '_indicator'); + show_status_area_component_indicator('aggregateMenu', '_gsconnect', '_indicator'); restore_rounded_corners(); } @@ -73,6 +75,7 @@ function auto() { auto_status_area_component_indicator('aggregateMenu', '_power', '_indicator', SETTING_SHOW_POWER_INDICATOR); auto_status_area_component_indicator('aggregateMenu', '_power', '_percentageLabel', SETTING_SHOW_POWER_PERCENTAGE_LABEL); auto_status_area_component_indicator('aggregateMenu', '_nightLight', '_indicator', SETTING_SHOW_NIGHTLIGHT_INDICATOR); + auto_status_area_component_indicator('aggregateMenu', '_gsconnect', '_indicator', SETTING_SHOW_GSCONNECT_INDICATOR); auto_rounded_corners(); } @@ -130,63 +133,86 @@ function show_status_area(areaName) { function hide_status_area_component(areaName, componentName) { let area = Topbar.statusArea[areaName]; - let component = area[componentName]; - if (component != null) { - component.hide(); + if (area != null) { + let component = area[componentName]; + + if (component != null) { + component.hide(); + } } } function show_status_area_component(areaName, componentName) { let area = Topbar.statusArea[areaName]; - let component = area[componentName]; - if (component != null) { - component.show(); + if (area != null) { + let component = area[componentName]; + + if (component != null) { + component.show(); + } } } function hide_status_area_component_indicator(areaName, componentName, indicatorName) { let area = Topbar.statusArea[areaName]; - let component = area[componentName]; - let indicator = component[indicatorName]; - if (indicator != null) { - indicator.hide(); + if (area != null) { + let component = area[componentName]; + if (component != null) { + let indicator = component[indicatorName]; + if (indicator != null) { + indicator.hide(); + } + } } } function show_status_area_component_indicator(areaName, componentName, indicatorName) { let area = Topbar.statusArea[areaName]; - let component = area[componentName]; - let indicator = component[indicatorName]; - if (indicator != null) { - indicator.show(); + if (area != null) { + let component = area[componentName]; + if (component != null) { + let indicator = component[indicatorName]; + if (indicator != null) { + indicator.show(); + } + } } } function remove_rounded_corners() { let leftCorner = Topbar._leftCorner.actor; + + if (leftCorner != null) { + leftCorner.add_style_class_name('straight-panel-corner'); + } + let rightCorner = Topbar._rightCorner.actor; - if (leftCorner != null && rightCorner != null) { - leftCorner.add_style_class_name('straight-panel-corner'); + if (rightCorner != null) { rightCorner.add_style_class_name('straight-panel-corner'); } } function restore_rounded_corners() { + let leftCorner = Topbar._leftCorner.actor; + + if (leftCorner != null) { + leftCorner.remove_style_class_name('straight-panel-corner'); + } + let rightCorner = Topbar._rightCorner.actor; - if (leftCorner != null && rightCorner != null) { - leftCorner.remove_style_class_name('straight-panel-corner'); + if (rightCorner != null) { rightCorner.remove_style_class_name('straight-panel-corner'); } } diff --git a/powerful-topbar@leo.ndrs.fr/prefs.js b/powerful-topbar@leo.ndrs.fr/prefs.js index c9917a8..d47c68c 100644 --- a/powerful-topbar@leo.ndrs.fr/prefs.js +++ b/powerful-topbar@leo.ndrs.fr/prefs.js @@ -19,6 +19,7 @@ const SETTING_SHOW_BLUETOOTH_INDICATOR = 'show-bluetooth-indicator'; const SETTING_SHOW_POWER_INDICATOR = 'show-power-indicator'; const SETTING_SHOW_POWER_PERCENTAGE_LABEL = 'show-power-percentage-label'; const SETTING_SHOW_NIGHTLIGHT_INDICATOR = 'show-nightlight-indicator'; +const SETTING_SHOW_GSCONNECT_INDICATOR = 'show-gsconnect-indicator'; const SETTING_REMOVE_ROUNDED_CORNERS = 'remove-rounded-corners'; const PowerfulTopbarPrefsWidget = new GObject.Class({ @@ -54,6 +55,7 @@ const PowerfulTopbarPrefsWidget = new GObject.Class({ this._create_switch(SETTING_SHOW_BLUETOOTH_INDICATOR); this._create_switch(SETTING_SHOW_POWER_INDICATOR); this._create_switch(SETTING_SHOW_NIGHTLIGHT_INDICATOR); + this._create_switch(SETTING_SHOW_GSCONNECT_INDICATOR); this._create_switch(SETTING_SHOW_POWER_PERCENTAGE_LABEL); this._create_switch(SETTING_REMOVE_ROUNDED_CORNERS); diff --git a/powerful-topbar@leo.ndrs.fr/schemas/org.gnome.shell.extensions.powerful-topbar.gschema.xml b/powerful-topbar@leo.ndrs.fr/schemas/org.gnome.shell.extensions.powerful-topbar.gschema.xml index 13e76bf..6512ff3 100644 --- a/powerful-topbar@leo.ndrs.fr/schemas/org.gnome.shell.extensions.powerful-topbar.gschema.xml +++ b/powerful-topbar@leo.ndrs.fr/schemas/org.gnome.shell.extensions.powerful-topbar.gschema.xml @@ -61,6 +61,11 @@ Show nightlight's indicator Show nightlight's indicator + + false + Show GSConnect's indicator + Show GSConnect's indicator + false Show power's percentage