aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-10 15:30:37 -0600
committerTed Gould <ted@gould.cx>2010-03-10 15:30:37 -0600
commit37f0f3400bce36b98e89595bdbb694bec7139ee2 (patch)
tree96733435fffd973a59e7291695b17b10181461ce
parentba4a73a9ea33a1996ff7965dd7996b54901b385a (diff)
downloadlibayatana-indicator-37f0f3400bce36b98e89595bdbb694bec7139ee2.tar.gz
libayatana-indicator-37f0f3400bce36b98e89595bdbb694bec7139ee2.tar.bz2
libayatana-indicator-37f0f3400bce36b98e89595bdbb694bec7139ee2.zip
Doing dynamic size calculation based on the font if we have a prop set telling us to do so.
-rw-r--r--libindicator/indicator-image-helper.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c
index 3e8c627..76ac3c2 100644
--- a/libindicator/indicator-image-helper.c
+++ b/libindicator/indicator-image-helper.c
@@ -15,8 +15,22 @@ refresh_image (GtkImage * image)
GtkIconTheme * default_theme = gtk_icon_theme_get_default();
g_return_if_fail(default_theme != NULL);
+ gint icon_size = 22;
+
+ GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(image));
+ GValue styleprop = {0};
+ gtk_style_get_style_property(style, GTK_TYPE_IMAGE, "x-ayatana-indicator-dynamic", &styleprop);
+
+ if (G_VALUE_HOLDS_BOOLEAN(&styleprop) && g_value_get_boolean(&styleprop)) {
+ PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(image));
+ PangoFontMetrics * metrics = pango_context_get_metrics(context, style->font_desc, pango_context_get_language(context));
+ icon_size = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)) + PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
+ g_debug("Looking for icon size %d", icon_size);
+ pango_font_metrics_unref(metrics);
+ }
+
/* Look through the themes for that icon */
- GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, 22, 0);
+ GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
if (icon_info == NULL) {
g_warning("Unable to find icon in theme.");
return;