changeset 3668:5b82f99d028d

[gaim-migrate @ 3798] Just getting some things set up committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 13 Oct 2002 23:06:22 +0000
parents 11ab2a5f6677
children f82c5470044e
files src/dialogs.c src/ui.h src/util.c
diffstat 3 files changed, 189 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Sun Oct 13 16:38:05 2002 +0000
+++ b/src/dialogs.c	Sun Oct 13 23:06:22 2002 +0000
@@ -4583,6 +4583,52 @@
 
 #endif /* USE_PERL */
 
+GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *icon)
+{
+	GtkWidget *button, *image,  *bbox;
+
+	button = gtk_toggle_button_new();
+	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+
+	bbox = gtk_vbox_new(FALSE, 0);
+
+	gtk_container_add (GTK_CONTAINER(button), bbox);
+
+	image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
+	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
+
+	gtk_widget_show_all(bbox);
+	return button;
+}
+
+GtkWidget *gaim_pixbuf_button_from_stock(char *text, char *icon, GaimButtonStyle style)
+{
+	GtkWidget *button, *image, *label, *bbox;
+	button = gtk_button_new();
+
+	if (style == GAIM_BUTTON_HORIZONTAL)
+			bbox = gtk_hbox_new(FALSE, 5);
+	else
+			bbox = gtk_vbox_new(FALSE, 0);
+
+	gtk_container_add (GTK_CONTAINER(button), bbox);
+
+	if (icon) {
+		image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
+		gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
+	}
+	
+	if (text) {
+		label = gtk_label_new(NULL);
+		gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
+		gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
+		gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
+	}
+
+	gtk_widget_show_all(bbox);
+	return button;
+}
+
 GtkWidget *gaim_pixbuf_button(char *text, char *iconfile, GaimButtonStyle style)
 {
 	GtkWidget *button, *image, *label, *bbox;
--- a/src/ui.h	Sun Oct 13 16:38:05 2002 +0000
+++ b/src/ui.h	Sun Oct 13 23:06:22 2002 +0000
@@ -124,6 +124,7 @@
 	GtkWidget *smiley_dialog;
 	GtkWidget *link_dialog;
 	GtkWidget *log_dialog;
+	GtkSizeGroup *sg;
 	int makesound;
 	char fontface[128];
 	int hasfont;
@@ -457,6 +458,8 @@
 extern GtkWidget *picture_button(GtkWidget *, char *, char **);
 extern GtkWidget *picture_button2(GtkWidget *, char *, char **, short);
 extern GtkWidget *gaim_pixbuf_button(char *, char *, GaimButtonStyle);
+extern GtkWidget *gaim_pixbuf_button_from_stock(char *, char *, GaimButtonStyle);
+extern GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *);
 extern int file_is_dir(const char *, GtkWidget *);
 extern void update_privacy_connections();
 extern void show_privacy_options();
@@ -506,5 +509,8 @@
 /* Fucnctions in util.c */
 extern GtkWidget *gaim_pixmap(char *, char *);
 extern GdkPixbuf *gaim_pixbuf(char *, char *);
+extern GtkWidget *gaim_new_item_with_pixmap(GtkWidget *, const char *, char **, GtkSignalFunc, gpointer, guint, guint, char *);
+extern GtkWidget *gaim_new_item_from_stock(GtkWidget *, const char *, const char *, GtkSignalFunc, gpointer, guint, guint, char *);
+extern GtkWidget *gaim_new_item_from_pixbuf(GtkWidget *, const char *, char *, GtkSignalFunc, gpointer, guint, guint, char *);
 
 #endif /* _UI_H_ */
--- a/src/util.c	Sun Oct 13 16:38:05 2002 +0000
+++ b/src/util.c	Sun Oct 13 23:06:22 2002 +0000
@@ -1450,3 +1450,140 @@
 
 		return pixbuf;
 }
+
+GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
+{
+	GtkWidget *menuitem;
+	GtkWidget *hbox;
+	GtkWidget *label;
+	GtkWidget *image;
+
+	if (icon == NULL)
+		menuitem = gtk_menu_item_new_with_mnemonic(_(str));
+	else 
+		menuitem = gtk_image_menu_item_new_with_mnemonic(_(str));
+
+	if (menu)
+		gtk_menu_append(GTK_MENU(menu), menuitem);
+
+	if (sf)
+		gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
+
+	if (icon != NULL) {
+		image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
+		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
+	}
+
+	if (mod) {
+		label = gtk_label_new(mod);
+		gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+		gtk_widget_show(label);
+	}
+/*
+	if (accel_key) {
+		gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
+					   accel_mods, GTK_ACCEL_LOCKED);
+	}
+*/
+
+	gtk_widget_show_all(menuitem);
+
+	return menuitem;
+}
+
+GtkWidget *gaim_new_item_from_pixbuf(GtkWidget *menu, const char *str, char *iconname, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
+{
+	GtkWidget *menuitem;
+	GtkWidget *hbox;
+	GtkWidget *label;
+	GtkWidget *image;
+
+	if (iconname == NULL)
+		menuitem = gtk_menu_item_new_with_mnemonic(_(str));
+	else 
+		menuitem = gtk_image_menu_item_new_with_mnemonic(_(str));
+
+	if (menu)
+		gtk_menu_append(GTK_MENU(menu), menuitem);
+
+	if (sf)
+		gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
+
+	if (iconname != NULL) {
+		char *filename;
+
+		filename = g_build_filename (DATADIR, "pixmaps", "gaim", "menus", iconname, NULL);
+		debug_printf("Loading: %s\n", filename);
+		image = gtk_image_new_from_file(filename);
+		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
+		g_free(filename);
+	}
+
+	if (mod) {
+		label = gtk_label_new(mod);
+		gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+		gtk_widget_show(label);
+	}
+/*
+	if (accel_key) {
+		gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
+					   accel_mods, GTK_ACCEL_LOCKED);
+	}
+*/
+
+	gtk_widget_show_all(menuitem);
+
+	return menuitem;
+}
+
+
+GtkWidget *gaim_new_item_with_pixmap(GtkWidget *menu, const char *str, char **xpm, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
+{
+	GtkWidget *menuitem;
+	GtkWidget *hbox;
+	GtkWidget *label;
+	GtkWidget *pixmap;
+	GdkPixmap *pm;
+	GdkBitmap *mask;
+
+	menuitem = gtk_menu_item_new();
+	if (menu)
+		gtk_menu_append(GTK_MENU(menu), menuitem);
+	if (sf)
+		/* passing 1 is necessary so if we sign off closing the account editor doesn't exit */
+		gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, data);
+	gtk_widget_show(menuitem);
+
+	/* Create our container */
+	hbox = gtk_hbox_new(FALSE, 2);
+	gtk_container_add(GTK_CONTAINER(menuitem), hbox);
+	gtk_widget_show(hbox);
+
+	/* Create our pixmap and pack it */
+	gtk_widget_realize(menu->parent);
+	pm = gdk_pixmap_create_from_xpm_d(menu->parent->window, &mask, NULL, xpm);
+	pixmap = gtk_pixmap_new(pm, mask);
+	gtk_widget_show(pixmap);
+	gdk_pixmap_unref(pm);
+	gdk_bitmap_unref(mask);
+	gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 2);
+
+	/* Create our label and pack it */
+	label = gtk_label_new(str);
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+	gtk_widget_show(label);
+
+	if (mod) {
+		label = gtk_label_new(mod);
+		gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+		gtk_widget_show(label);
+	}
+/*
+	if (accel_key) {
+		gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
+					   accel_mods, GTK_ACCEL_LOCKED);
+	}
+*/
+	return menuitem;
+}
+