aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-gtk-utils.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-04-15 09:08:52 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-04-15 09:08:52 +0800
commit0cf177cc2dc95096b9235adc242f3c698f1d9bee (patch)
tree3d9f7edd23e3d6f9bea68b4b067dd7984d7cd403 /e-util/e-gtk-utils.c
parentfb04925566a101e3d0995cf715ea2128e801548c (diff)
downloadgsoc2013-evolution-0cf177cc2dc95096b9235adc242f3c698f1d9bee.tar.gz
gsoc2013-evolution-0cf177cc2dc95096b9235adc242f3c698f1d9bee.tar.zst
gsoc2013-evolution-0cf177cc2dc95096b9235adc242f3c698f1d9bee.zip
Utility function to create a button with a stock icon.
2003-04-14 Not Zed <NotZed@Ximian.com> * e-gtk-utils.c (e_gtk_button_new_with_icon): Utility function to create a button with a stock icon. svn path=/trunk/; revision=20843
Diffstat (limited to 'e-util/e-gtk-utils.c')
-rw-r--r--e-util/e-gtk-utils.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/e-util/e-gtk-utils.c b/e-util/e-gtk-utils.c
index 9b9c7f99b7..345f092e8d 100644
--- a/e-util/e-gtk-utils.c
+++ b/e-util/e-gtk-utils.c
@@ -28,6 +28,12 @@
#include <gtk/gtklayout.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkwidget.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkalignment.h>
#include <gdk/gdkx.h>
@@ -167,3 +173,46 @@ e_make_widget_backing_stored (GtkWidget *widget)
{
g_signal_connect (widget, "realize", G_CALLBACK (widget_realize_callback_for_backing_store), NULL);
}
+
+
+/**
+ * e_gtk_button_new_with_icon:
+ * @text: The mnemonic text for the label.
+ * @stock: The name of the stock item to get the icon from.
+ *
+ * Create a gtk button with a custom label and a stock icon.
+ *
+ *
+ * Return value: The widget.
+ **/
+GtkWidget *
+e_gtk_button_new_with_icon(const char *text, const char *stock)
+{
+ GtkWidget *button, *label;
+ GtkStockItem item;
+
+ button = gtk_button_new();
+ label = gtk_label_new_with_mnemonic(text);
+ gtk_label_set_mnemonic_widget((GtkLabel *)label, button);
+
+ if (gtk_stock_lookup(stock, &item)) {
+ GtkWidget *image, *hbox, *align;
+
+ printf("new stock button '%s' label '%s'\n", stock, text);
+
+ image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_BUTTON);
+ hbox = gtk_hbox_new(FALSE, 2);
+ align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+ gtk_box_pack_start((GtkBox *)hbox, image, FALSE, FALSE, 0);
+ gtk_box_pack_end((GtkBox *)hbox, label, FALSE, FALSE, 0);
+ gtk_container_add((GtkContainer *)align, hbox);
+ gtk_container_add((GtkContainer *)button, align);
+ gtk_widget_show_all(align);
+ } else {
+ gtk_misc_set_alignment((GtkMisc *)label, 0.5, 0.5);
+ gtk_container_add((GtkContainer *)button, label);
+ gtk_widget_show(label);
+ }
+
+ return button;
+}