void-packages/srcpkgs/cinnamon/patches/keyboard_applet.patch

134 lines
5.6 KiB
Diff
Raw Normal View History

2013-12-16 17:09:19 +01:00
--- a/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js
+++ b/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js
@@ -1,9 +1,10 @@
const Applet = imports.ui.applet;
-const Gkbd = imports.gi.Gkbd;
const Lang = imports.lang;
-const Cinnamon = imports.gi.Cinnamon;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
const St = imports.gi.St;
const Gtk = imports.gi.Gtk;
+const CinnamonDesktop = imports.gi.CinnamonDesktop;
const Main = imports.ui.main;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
@@ -16,11 +17,12 @@ function LayoutMenuItem() {
LayoutMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
- _init: function(config, id, indicator, long_name) {
+ _init: function(ipsettings, id, index, indicator, long_name) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
- this._config = config;
+ this._ipsettings = ipsettings;
this._id = id;
+ this._index = index;
this.label = new St.Label({ text: long_name });
this.indicator = indicator;
this.addActor(this.label);
@@ -29,7 +31,7 @@ LayoutMenuItem.prototype = {
activate: function(event) {
PopupMenu.PopupBaseMenuItem.prototype.activate.call(this);
- this._config.lock_group(this._id);
+ this._ipsettings.set_value('current', GLib.Variant.new_uint32(this._index));
}
};
@@ -62,18 +64,18 @@ MyApplet.prototype = {
this._syncConfig,
null);
- this._config = Gkbd.Configuration.get();
- this._config.connect('changed', Lang.bind(this, this._syncConfig));
- this._config.connect('group-changed', Lang.bind(this, this._syncGroup));
+ this._xkbInfo = new CinnamonDesktop.XkbInfo();
+ this._ipsettings = new Gio.Settings({ schema: 'org.cinnamon.desktop.input-sources' });
+ this._ipsettings.connect('changed::sources', Lang.bind(this, this._syncConfig));
+ this._ipsettings.connect('changed::current', Lang.bind(this, this._syncGroup));
- this._config.start_listen();
this._syncConfig();
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, function() {
Main.overview.hide();
- Util.spawn(['gkbd-keyboard-display', '-g', String(this._config.get_current_group() + 1)]);
+ Util.spawn(['gkbd-keyboard-display', '-l', this._selectedLayout._id]);
}));
this.menu.addAction(_("Show Character Table"), Lang.bind(this, function() {
Main.overview.hide();
@@ -113,8 +115,8 @@ MyApplet.prototype = {
},
_syncConfig: function() {
- let groups = this._config.get_group_names();
- if (groups.length > 1) {
+ let sources = this._ipsettings.get_value('sources');
+ if (sources.n_children() > 1) {
this.actor.show();
} else {
this.menu.close();
@@ -127,25 +129,30 @@ MyApplet.prototype = {
for (let i = 0; i < this._labelActors.length; i++)
this._labelActors[i].destroy();
- let short_names = this._adjustGroupNames(this._config.get_short_group_names());
this._selectedLayout = null;
this._layoutItems = [ ];
this._labelActors = [ ];
- for (let i = 0; i < groups.length; i++) {
- let icon_name = this._config.get_group_name(i);
+ for (let i = 0; i < sources.n_children(); i++) {
+ let [type, id] = sources.get_child_value(i).deep_unpack();
+ let displayName = id;
+ let shortName = id;
+ let xkbLayout = id;
+ if (type == 'xkb') {
+ [_exists, displayName, shortName, xkbLayout, _xkbVariant] = this._xkbInfo.get_layout_info(id);
+ } // TODO: errorhandling, handle 'ibus'
+ let icon_name = xkbLayout; // FIXME: Really?
let actor;
if (this._showFlags)
actor = new St.Icon({ icon_name: icon_name, icon_type: St.IconType.FULLCOLOR, style_class: 'popup-menu-icon' });
else
- actor = new St.Label({ text: short_names[i] });
- let item = new LayoutMenuItem(this._config, i, actor, groups[i]);
- item._short_group_name = short_names[i];
+ actor = new St.Label({ text: shortName });
+ let item = new LayoutMenuItem(this._ipsettings, id, i, actor, displayName);
item._icon_name = icon_name;
this._layoutItems.push(item);
this.menu.addMenuItem(item, i);
- let shortLabel = new St.Label({ text: short_names[i] });
+ let shortLabel = new St.Label({ text: shortName });
this._labelActors.push(shortLabel);
}
@@ -153,17 +160,17 @@ MyApplet.prototype = {
},
_syncGroup: function() {
- let selected = this._config.get_current_group();
+ let current = this._ipsettings.get_uint('current');
if (this._selectedLayout) {
this._selectedLayout.setShowDot(false);
this._selectedLayout = null;
}
- let item = this._layoutItems[selected];
+ let item = this._layoutItems[current];
item.setShowDot(true);
- let selectedLabel = this._labelActors[selected];
+ let selectedLabel = this._labelActors[current];
if (this._showFlags) {
this.set_applet_icon_name(item._icon_name);