diff options
author | infirit <[email protected]> | 2014-11-23 11:57:27 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-23 11:57:27 +0100 |
commit | 935fb2b0b116ea263fbbed6fffe71a829e6ffdb8 (patch) | |
tree | 65ecaea0612e588a37c8380869739dee42c308cb | |
parent | dba401f22f4aa533d74bb5429e807fbc3c42ec00 (diff) | |
download | mate-panel-935fb2b0b116ea263fbbed6fffe71a829e6ffdb8.tar.bz2 mate-panel-935fb2b0b116ea263fbbed6fffe71a829e6ffdb8.tar.xz |
Gtk3: showdesktop: Port gtk_widget_get_style to GtkStyleContext
Based on gnome-panel commit: d27ef4de9ba872e5afc5e60430c7a16549158f61
From: Germán Póo-Caamaño <[email protected]>
-rw-r--r-- | applets/wncklet/showdesktop.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/applets/wncklet/showdesktop.c b/applets/wncklet/showdesktop.c index ae4afc43..534d74fd 100644 --- a/applets/wncklet/showdesktop.c +++ b/applets/wncklet/showdesktop.c @@ -132,7 +132,13 @@ static void button_size_allocated(GtkWidget* button, GtkAllocation* allocation, static void update_icon(ShowDesktopData* sdd) { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder padding; +#else GtkStyle* style; +#endif int width, height; GdkPixbuf* icon; GdkPixbuf* scaled; @@ -145,6 +151,26 @@ static void update_icon(ShowDesktopData* sdd) if (!sdd->icon_theme) return; +#if GTK_CHECK_VERSION (3, 0, 0) + state = gtk_widget_get_state_flags (sdd->button); + context = gtk_widget_get_style_context (sdd->button); + gtk_style_context_get_padding (context, state, &padding); + gtk_style_context_get_style (context, + "focus-line-width", &focus_width, + "focus-padding", &focus_pad, + NULL); + + switch (sdd->orient) { + case GTK_ORIENTATION_HORIZONTAL: + thickness = padding.top + padding.bottom; + break; + case GTK_ORIENTATION_VERTICAL: + thickness = padding.left + padding.right; + break; + } + + icon_size = sdd->size - 2 * (focus_width + focus_pad) + thickness; +#else gtk_widget_style_get (sdd->button, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); style = gtk_widget_get_style(sdd->button); @@ -160,6 +186,7 @@ static void update_icon(ShowDesktopData* sdd) } icon_size = sdd->size - 2 * (focus_width + focus_pad + thickness); +#endif if (icon_size < 22) icon_size = 16; |