[Xfce4-commits] [panel-plugins/xfce4-mpc-plugin] 02/05: Add a convenience helper to resize a button and its GtkImage
noreply at xfce.org
noreply at xfce.org
Tue Nov 1 15:28:41 CET 2016
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository panel-plugins/xfce4-mpc-plugin.
commit dd9a3f618df880916732de1816cf9a86e0d6820e
Author: Landry Breuil <landry at xfce.org>
Date: Tue Nov 1 15:24:21 2016 +0100
Add a convenience helper to resize a button and its GtkImage
Load the image on the fly so that it's properly resized, inspired by fsguard code.
---
panel-plugin/xfce4-mpc-plugin.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/panel-plugin/xfce4-mpc-plugin.c b/panel-plugin/xfce4-mpc-plugin.c
index 18b4e90..4f11a0e 100644
--- a/panel-plugin/xfce4-mpc-plugin.c
+++ b/panel-plugin/xfce4-mpc-plugin.c
@@ -33,6 +33,8 @@
#define DEFAULT_MPD_PORT 6600
#define DIALOG_ENTRY_WIDTH 20
+static void resize_button(GtkWidget *, gint);
+
static void
mpc_free (XfcePanelPlugin * plugin, t_mpc * mpc)
{
@@ -681,6 +683,21 @@ scroll_cb(GtkWidget *widget, GdkEventScroll* event, t_mpc* mpc)
mpd_status_set_volume(mpc->mo,curvol);
}
+static void
+resize_button(GtkWidget *btn, gint size)
+{
+ GtkIconTheme *icon_theme;
+ GdkPixbuf *pixbuf, *scaled;
+ GtkWidget *image = g_object_get_data(G_OBJECT(btn), "image");
+ gchar *icon = g_object_get_data(G_OBJECT(image), "icon-name");
+ icon_theme = gtk_icon_theme_get_default();
+ DBG("Resizing button, loading icon %s and rescaling it to size %d", icon, size / 2 - 2);
+ pixbuf = gtk_icon_theme_load_icon (icon_theme, icon, size / 2 - 2, 0, NULL);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
+ g_object_unref (G_OBJECT (pixbuf));
+ gtk_widget_set_size_request (btn, size, size);
+}
+
static GtkWidget*
new_button_with_cbk(XfcePanelPlugin * plugin, GtkWidget *parent, gchar* icon, gpointer cb, gpointer data)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list