From cd50fcab4ec6808d2350b2ef985b931d32e1bdf9 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Mon, 7 Nov 2016 21:32:38 -0500 Subject: [PATCH] keyboard applet: Allow flag icon to properly scale its size to match the panel and preferences. Monkey patch some St.Icon methods to the EmblemedIcon class so we can use the existing applet icon sizing calculations by pretending we're just another icon hanging around, getting things done. --- .../applets/keyboard@cinnamon.org/applet.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js index 5cb557bed5..2c581de00d 100644 --- a/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js @@ -31,7 +31,7 @@ EmblemedIcon.prototype = { _style_changed: function(actor) { let icon_size = 0.5 + this.actor.get_theme_node().get_length("icon-size"); - this.actor.width = this.actor.height = icon_size; + this.actor.natural_width = this.actor.natural_height = icon_size; }, _repaint: function(actor) { @@ -79,6 +79,22 @@ EmblemedIcon.prototype = { this.id); cr.$dispose(); + }, + + /* Monkey patch St.Icon functions used in js/ui/applet.js IconApplet so + we can use its _setStyle() function for figuring out how big we should + be + */ + get_icon_type: function() { + return St.IconType.FULLCOLOR; + }, + + set_icon_size: function(size) { + this.actor.width = this.actor.height = size; + }, + + set_style_class_name: function(name) { + return; } } @@ -241,7 +257,6 @@ MyApplet.prototype = { this.set_applet_tooltip(this._config.get_current_name()); - let actor = null; let handled = false; if (this.show_flags) { @@ -250,9 +265,11 @@ MyApplet.prototype = { let file = Gio.file_new_for_path("/usr/share/iso-flag-png/" + name + ".png"); if (file.query_exists(null)) { - actor = new EmblemedIcon(file.get_path(), this._config.get_current_flag_id(), "applet-icon").actor; + this._applet_icon = new EmblemedIcon(file.get_path(), this._config.get_current_flag_id(), "applet-icon"); + this._applet_icon_box.set_child(this._applet_icon.actor); + + this._setStyle(); - this._applet_icon_box.set_child(actor); this.set_applet_label(""); handled = true;