Skip to content
Browse files

add global hotkey and accordingly extend preferences

  • Loading branch information...
1 parent 20485a7 commit 3f7c9ca0a7c3c004949a1e4769d7f0bf8be0c86e @tbaugis tbaugis committed Aug 13, 2012
View
18 extension.js
@@ -20,6 +20,7 @@ const GLib = imports.gi.GLib
const Lang = imports.lang;
const St = imports.gi.St;
const Shell = imports.gi.Shell;
+const Meta = imports.gi.Meta;
const Main = imports.ui.main;
const Gio = imports.gi.Gio;
const PopupMenu = imports.ui.popupMenu;
@@ -272,6 +273,10 @@ HamsterExtension.prototype = {
this.menu.open();
},
+ toggle: function() {
+ this.menu.toggle();
+ },
+
refreshActivities: function() {
this.activityEntry.autocompleteActivities = [];
this.refresh();
@@ -489,20 +494,21 @@ function ExtensionController(extensionMeta) {
this._checkCalendar(Main.panel._centerBox);
- /* FIXME - none of these works right now
- Main.wm.setKeybindingHandler('activate_hamster_window', this.extension.show);
- Meta.keybindings_set_custom_handler('activate_hamster_window',
- this.extension.show);
- */
+ global.display.add_keybinding("show-hamster-dropdown",
+ this.extension._settings,
+ Meta.KeyBindingFlags.NONE,
+ Lang.bind(this.extension, this.extension.toggle)
+ );
},
disable: function() {
+ global.display.remove_keybinding("show-hamster-dropdown");
+
this._checkCalendar(Main.panel._rightBox);
Main.panel._rightBox.remove_actor(this.extension.actor);
Main.panel._menus.removeMenu(this.extension.menu);
-
this.extension.actor.destroy();
}
}
View
27 prefs.js
@@ -63,6 +63,21 @@ const HamsterSettingsWidget = new GObject.Class({
vbox.add(appearanceCombo);
+
+
+ label = new Gtk.Label({margin_top: 20});
+ label.set_markup("<b>Global hotkey</b>")
+ label.set_alignment(0, 0.5)
+ this.add(label);
+
+ vbox = new Gtk.VBox({margin: 10});
+ this.add(vbox);
+ let entry = new Gtk.Entry({margin_bottom: 10,
+ margin_top: 5,
+ text: this._settings.get_strv("show-hamster-dropdown")[0]})
+ vbox.add(entry)
+ entry.connect('changed', Lang.bind(this, this._onHotkeyChange));
+
vbox.add(new Gtk.Label({label: "Reload gnome shell after updating prefs (alt+f2 > r)",
margin_top: 70}));
},
@@ -86,6 +101,18 @@ const HamsterSettingsWidget = new GObject.Class({
this._settings.set_int("panel-appearance", newAppearance)
},
+
+ _onHotkeyChange: function(widget, bananas) {
+ //global.log(widget, bananas)
+ let hotkey = widget.get_text()
+ let [key, mods] = Gtk.accelerator_parse(hotkey);
+
+ if (key != 0) {
+ let parsedName = Gtk.accelerator_name(key, mods);
+ this._settings.set_strv("show-hamster-dropdown", [parsedName]);
+ }
+
+ }
});
function init() {
View
BIN schemas/gschemas.compiled
Binary file not shown.
View
5 schemas/org.gnome.shell.extensions.project-hamster.gschema.xml
@@ -12,5 +12,10 @@
<summary>Appearance in the panel.</summary>
<description>Sets the panel appearance. 0 - label, 1 - icon, 2 - label and icon.</description>
</key>
+
+ <key type="as" name="show-hamster-dropdown">
+ <default><![CDATA[['<Super>h']]]></default>
+ <summary>Global key combination to show the drop-down.</summary>
+ </key>
</schema>
</schemalist>

0 comments on commit 3f7c9ca

Please sign in to comment.
Something went wrong with that request. Please try again.