[Xfce4-commits] <xfce4-mount-plugin:master> Use gtk_container_add() instead of gtk_button_set_image()

Landry Breuil noreply at xfce.org
Tue Apr 10 19:26:09 CEST 2012


Updating branch refs/heads/master
         to 6206d2a5da870f564ff281395672082e332e7c71 (commit)
       from fe290ae034b590623a7e2cd87f02bb9dc439ebea (commit)

commit 6206d2a5da870f564ff281395672082e332e7c71
Author: Landry Breuil <landry at xfce.org>
Date:   Tue Apr 10 19:19:39 2012 +0200

    Use gtk_container_add() instead of gtk_button_set_image()
    
    This way the icon is properly resized. Keep a ref to the image to remove
    it from the button before adding a new one in mounter_apply_options()
    (thx nick for the hint)

 panel-plugin/mount-plugin.c |    9 +++++++--
 panel-plugin/mount-plugin.h |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/mount-plugin.c b/panel-plugin/mount-plugin.c
index 7f58d92..3d9a0ac 100644
--- a/panel-plugin/mount-plugin.c
+++ b/panel-plugin/mount-plugin.c
@@ -565,7 +565,9 @@ create_mounter_control (XfcePanelPlugin *plugin)
     g_assert (mounter->icon!=NULL);
 
     mounter->button = gtk_button_new ();
-    gtk_button_set_image (GTK_BUTTON(mounter->button), xfce_panel_image_new_from_source (mounter->icon));
+    mounter->image = xfce_panel_image_new_from_source (mounter->icon);
+    gtk_widget_show(mounter->image);
+    gtk_container_add (GTK_CONTAINER(mounter->button), mounter->image);
     gtk_button_set_relief (GTK_BUTTON(mounter->button), GTK_RELIEF_NONE);
 
     gtk_tooltips_set_tip (tooltips, GTK_WIDGET(mounter->button), _("devices"),
@@ -651,7 +653,10 @@ mounter_apply_options (t_mounter_dialog *md)
                    "%s/icons/hicolor/scalable/apps/xfce-mount.svg",
                    PACKAGE_DATA_DIR );
 
-    gtk_button_set_image (GTK_BUTTON(mt->button), xfce_panel_image_new_from_source (mt->icon));
+    gtk_container_remove(GTK_CONTAINER(mt->button), mt->image);
+    mt->image = xfce_panel_image_new_from_source (mt->icon);
+    gtk_widget_show(mt->image);
+    gtk_container_add (GTK_CONTAINER(mt->button), mt->image);
 
     TRACE ("leaves mounter_apply_options");
 }
diff --git a/panel-plugin/mount-plugin.h b/panel-plugin/mount-plugin.h
index 8b230a3..3322ca2 100644
--- a/panel-plugin/mount-plugin.h
+++ b/panel-plugin/mount-plugin.h
@@ -73,6 +73,7 @@ typedef struct
     gboolean eject_drives;
     gboolean showed_fstab_dialog;
     GtkWidget *button;
+    GtkWidget *image;
     GtkWidget *menu;
     GPtrArray *pdisks; /* contains pointers to struct t_disk */
 } t_mounter;


More information about the Xfce4-commits mailing list