Skip to content

Commit

Permalink
Merge pull request #5822 from brownsr/vpanelf15
Browse files Browse the repository at this point in the history
make accessibility applet suitable for vertical panels
  • Loading branch information
clefebvre committed Oct 24, 2016
2 parents 8965df1 + 9e8a064 commit 5650461
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions files/usr/share/cinnamon/applets/a11y@cinnamon.org/applet.js
@@ -1,3 +1,4 @@
const St = imports.gi.St;
const PopupMenu = imports.ui.popupMenu;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
Expand Down Expand Up @@ -38,13 +39,16 @@ MyApplet.prototype = {

_init: function(metadata, orientation, panel_height, instance_id) {
Applet.TextIconApplet.prototype._init.call(this, orientation, panel_height, instance_id);

this.setAllowedLayout(Applet.AllowedLayout.BOTH);

try {
this.metadata = metadata;
Main.systrayManager.registerRole("a11y", metadata.uuid);

this.set_applet_icon_symbolic_name("preferences-desktop-accessibility");
this.set_applet_tooltip(_("Accessibility"));
this.orientation = orientation;

this.menuManager = new PopupMenu.PopupMenuManager(this);
this.menu = new Applet.AppletPopupMenu(this, orientation);
Expand Down Expand Up @@ -86,7 +90,7 @@ MyApplet.prototype = {
this.a11y_settings = new Gio.Settings({ schema_id: A11Y_SCHEMA });

this._keyboardStateChangedId = Keymap.connect('state-changed', Lang.bind(this, this._handleStateChange));
this.set_applet_label('');
this.hide_applet_label(true);

}
catch (e) {
Expand Down Expand Up @@ -120,17 +124,46 @@ MyApplet.prototype = {
modifiers.push('Mod2');
if (state & Gdk.ModifierType.MOD3_MASK)
modifiers.push('Mod3');
this.set_applet_label(modifiers.join('+'));
}
else {
this.set_applet_label('');
let keystring = modifiers.join('+');
//
// horizontal panels - show the sticky keys in the label, vertical - in a tooltip, and hide any label
//
if (this.orientation == St.Side.LEFT || this.orientation == St.Side.RIGHT) {
this.hide_applet_label(true);
if (keystring) {
this.set_applet_tooltip(keystring);
this._applet_tooltip.show();
} else {
this.reset_tooltip();
}
} else {
this.set_applet_label(keystring);
this.hide_applet_label(false);
this.reset_tooltip();
}
} else {
this.hide_applet_label (this.orientation == St.Side.LEFT || this.orientation == St.Side.RIGHT);
this.reset_tooltip();
}
},

on_applet_clicked: function(event) {
this.menu.toggle();
},

on_orientation_changed: function(neworientation) {

this.orientation = neworientation;

this.hide_applet_label (this.orientation == St.Side.LEFT || this.orientation == St.Side.RIGHT);
this.reset_tooltip();
},

reset_tooltip: function () {
this.set_applet_tooltip(_("Accessibility"));
this._applet_tooltip.hide();
},

_buildItemExtended: function(string, initial_value, writable, on_set) {
let widget = new PopupMenu.PopupSwitchMenuItem(string, initial_value);
if (!writable)
Expand Down

0 comments on commit 5650461

Please sign in to comment.