Skip to content

Commit

Permalink
keyboard applet: Allow flag icon to properly scale its size to match
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtwebster committed Nov 8, 2016
1 parent f9f9b23 commit cd50fca
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions files/usr/share/cinnamon/applets/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit cd50fca

Please sign in to comment.