implement hidable panel icon

closes #25
This commit is contained in:
Wolfgang Rumpler 2018-07-29 16:02:38 +02:00
parent 79b63613f1
commit 4b0dcb35e9
6 changed files with 164 additions and 7 deletions

View file

@ -22,35 +22,58 @@ const Timer = Self.imports.timer;
const Gio = imports.gi.Gio;
// Settings
const Convenience = Self.imports.convenience;
const Prefs = Self.imports.settings;
let wallpaperController;
let extensionMeta;
let panelEntry;
let settings;
let hidePanelIconHandler = null;
function init(metaData) {
extensionMeta = metaData;
settings = new Prefs.Settings();
wallpaperController = new WallpaperController.WallpaperController(metaData);
}
function enable() {
// enable Extension
// UI
panelEntry = new RandomWallpaperEntry(0, "Random wallpaper");
// add to panel
Main.panel.addToStatusArea("random-wallpaper-menu", panelEntry);
hidePanelIconHandler = settings.observe('hide-panel-icon', updatePanelMenuVisibility);
updatePanelMenuVisibility();
}
function disable() {
// disable Extension
panelEntry.destroy();
// remove all signal handlers
if (hidePanelIconHandler !== null) {
settings.disconnect(hidePanelIconHandler);
}
// cleanup the timer singleton
let timer = new Timer.AFTimer();
timer.cleanup();
}
function updatePanelMenuVisibility(isVisible) {
if (settings.get('hide-panel-icon', 'boolean')) {
panelEntry.actor.hide();
} else {
panelEntry.actor.show();
}
}
var RandomWallpaperEntry = new Lang.Class({
Extends: PanelMenu.Button,
Name: "RandomWallpaperEntry",

View file

@ -136,6 +136,10 @@ var RandomWallpaperSettings = new Lang.Class({
this._settings.bind('disable-hover-preview',
this._builder.get_object('disable-hover-preview'),
'active',
Gio.SettingsBindFlags.DEFAULT)
this._settings.bind('hide-panel-icon',
this._builder.get_object('hide-panel-icon'),
'active',
Gio.SettingsBindFlags.DEFAULT);
},

View file

@ -69,6 +69,12 @@
<description>Disables the preview of the background while hovering the history list</description>
</key>
<key type='b' name='hide-panel-icon'>
<default>false</default>
<summary>Hide the panel icon</summary>
<description>Removes the panel icon from the gnome shell.</description>
</key>
</schema>
<schema path="/org/gnome/shell/extensions/space-iflow-randomwallpaper/desktopper/"

View file

@ -20,7 +20,11 @@ var Settings = new Lang.Class({
},
observe: function (key, callback) {
this._settings.connect('changed::' + key, callback);
return this._settings.connect('changed::' + key, callback);
},
disconnect: function (handler) {
return this._settings.disconnect(handler);
},
set: function (key, type, value) {
@ -33,10 +37,5 @@ var Settings = new Lang.Class({
get: function (key, type) {
return this._settings['get_' + type](key);
},
getSourceAdapter: function () {
global.log(this._settings.get_enum('source'));
return null;
}
});

View file

@ -321,6 +321,131 @@ You can also define a prefix that will be added to the image URL.</property>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">15</property>
<property name="bottom_padding">15</property>
<property name="left_padding">15</property>
<property name="right_padding">15</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">10</property>
<property name="baseline_row">2</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkLabel" id="hide-panel-icon-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Hide the panel icon</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="hide-panel-icon-description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">This option hides the panel icon. Therefore, you won't be able to access the history and the settings through the panel menu. Enabling this option currently is only reasonable in conjunction with the Auto-Fetching feature.</property>
<property name="use_underline">True</property>
<property name="wrap">True</property>
<property name="max_width_chars">1</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="hide-panel-icon-warning">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">10</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Only enable this option if you know how to open the settings without the panel icon!</property>
<property name="use_underline">True</property>
<property name="wrap">True</property>
<property name="max_width_chars">1</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="underline" value="True"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSwitch" id="hide-panel-icon">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>