From 935fb2b0b116ea263fbbed6fffe71a829e6ffdb8 Mon Sep 17 00:00:00 2001 From: infirit Date: Sun, 23 Nov 2014 11:57:27 +0100 Subject: Gtk3: showdesktop: Port gtk_widget_get_style to GtkStyleContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on gnome-panel commit: d27ef4de9ba872e5afc5e60430c7a16549158f61 From: Germán Póo-Caamaño --- applets/wncklet/showdesktop.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'applets/wncklet') 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; -- cgit v1.2.1