[Goodies-commits] r7837 - xfce4-mpc-plugin/trunk/panel-plugin
Landry Breuil
landry at xfce.org
Sun Jul 26 11:39:22 CEST 2009
Author: landry
Date: 2009-07-26 09:39:22 +0000 (Sun, 26 Jul 2009)
New Revision: 7837
Modified:
xfce4-mpc-plugin/trunk/panel-plugin/xfce4-mpc-plugin.c
Log:
- rename new_button_with_img() to new_button_with_cbk(), and return
the GtkWidget created - this allows for later modification
- add button_set_sized_image() which uses xfce_themed_icon_load() to
create the icon and resize it to the appropriate value
- smoothly resize buttons when mpc_set_size() is called, this greatly
improves look on small panels.
Buttons size is finally consistent with panel size.
Modified: xfce4-mpc-plugin/trunk/panel-plugin/xfce4-mpc-plugin.c
===================================================================
--- xfce4-mpc-plugin/trunk/panel-plugin/xfce4-mpc-plugin.c 2009-07-25 23:23:20 UTC (rev 7836)
+++ xfce4-mpc-plugin/trunk/panel-plugin/xfce4-mpc-plugin.c 2009-07-26 09:39:22 UTC (rev 7837)
@@ -44,6 +44,15 @@
}
static void
+button_set_sized_image(GtkWidget *button, gchar *icon, gint size)
+{
+ GtkWidget *image;
+ image = gtk_image_new_from_pixbuf(xfce_themed_icon_load(icon, size));
+ gtk_button_set_image(GTK_BUTTON(button), image);
+ gtk_widget_show (button);
+}
+
+static void
mpc_set_orientation (XfcePanelPlugin * plugin, GtkOrientation orientation, t_mpc * mpc)
{
DBG ("!");
@@ -72,6 +81,11 @@
else
gtk_widget_set_size_request (GTK_WIDGET (mpc->frame), size, -1);
}
+
+ button_set_sized_image(mpc->prev, "gtk-media-previous-ltr", size - 2);
+ button_set_sized_image(mpc->next, "gtk-media-next-ltr", size - 2);
+ button_set_sized_image(mpc->toggle, "gtk-media-pause", size - 2);
+ button_set_sized_image(mpc->stop, "gtk-media-stop", size - 2);
return TRUE;
}
@@ -621,19 +635,14 @@
mpd_status_set_volume(mpc->mo,curvol);
}
-static void
-new_button_with_img(XfcePanelPlugin * plugin, GtkWidget *parent, GtkWidget *button, gchar *icon, gpointer cb, gpointer data)
+static GtkWidget*
+new_button_with_cbk(XfcePanelPlugin * plugin, GtkWidget *parent, gpointer cb, gpointer data)
{
- GtkWidget *image;
-
- button = (GtkWidget*) xfce_create_panel_button();
- image = gtk_image_new_from_stock(icon,GTK_ICON_SIZE_BUTTON); /* FIXME for small panels */
-
- gtk_button_set_image(GTK_BUTTON(button),image);
+ GtkWidget *button = xfce_create_panel_button();
xfce_panel_plugin_add_action_widget (plugin, button);
- gtk_widget_show (GTK_WIDGET(button));
g_signal_connect (G_OBJECT(button), "button_press_event", G_CALLBACK(cb), data);
gtk_box_pack_start (GTK_BOX(parent), button, TRUE,TRUE,0);
+ return button;
}
static t_mpc*
@@ -661,10 +670,10 @@
gtk_container_add (GTK_CONTAINER(mpc->ebox), mpc->box);
gtk_container_add (GTK_CONTAINER(mpc->frame), mpc->ebox);
- new_button_with_img(plugin, mpc->box, mpc->prev, GTK_STOCK_MEDIA_PREVIOUS, G_CALLBACK(prev), mpc);
- new_button_with_img(plugin, mpc->box, mpc->stop, GTK_STOCK_MEDIA_STOP, G_CALLBACK(stop), mpc);
- new_button_with_img(plugin, mpc->box, mpc->toggle, GTK_STOCK_MEDIA_PAUSE, G_CALLBACK(toggle), mpc);
- new_button_with_img(plugin, mpc->box, mpc->next, GTK_STOCK_MEDIA_NEXT, G_CALLBACK(next), mpc);
+ mpc->prev = new_button_with_cbk(plugin, mpc->box, G_CALLBACK(prev), mpc);
+ mpc->stop = new_button_with_cbk(plugin, mpc->box, G_CALLBACK(stop), mpc);
+ mpc->toggle = new_button_with_cbk(plugin, mpc->box, G_CALLBACK(toggle), mpc);
+ mpc->next = new_button_with_cbk(plugin, mpc->box, G_CALLBACK(next), mpc);
mpc->random = gtk_check_menu_item_new_with_label (_("Random"));
g_signal_connect (G_OBJECT(mpc->random), "toggled", G_CALLBACK (mpc_random_toggled), mpc);
More information about the Goodies-commits
mailing list