Skip to content

Commit

Permalink
Support non-square icons
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Mar 28, 2015
1 parent c98b8a5 commit 8375a59
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/snitem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ namespace StatusNotifier
this.query_tooltip.connect(query_tooltip_cb);
this.popup_menu.connect(context_menu);
icon_theme.changed.connect(()=>{
image.set_from_gicon(image.gicon,IconSize.INVALID);
if (image.storage_type == ImageType.GICON)
image.set_from_gicon(image.gicon,IconSize.INVALID);
else
iface_new_icon_cb();
});
this.parent_set.connect((prev)=>{
if (get_applet() != null)
Expand Down Expand Up @@ -402,6 +405,17 @@ namespace StatusNotifier
if ((attention_icon ?? main_icon ?? overlay_icon) != null)
{
image.set_from_gicon(icon,IconSize.INVALID);
var icon_info = icon_theme.lookup_by_gicon(icon,image.pixel_size,IconLookupFlags.GENERIC_FALLBACK);
if (icon_info != null)
{
var icon_pixbuf = icon_info.load_icon();
var aspect_ratio = (double) icon_pixbuf.width / (double) icon_pixbuf.height;
if (aspect_ratio != 1)
{
icon_pixbuf = icon_pixbuf.scale_simple((int)Math.round(aspect_ratio*image.pixel_size),image.pixel_size,Gdk.InterpType.BILINEAR);
image.set_from_pixbuf(icon_pixbuf);
}
}
image.show();
}
else
Expand Down

0 comments on commit 8375a59

Please sign in to comment.