Mercurial > pidgin
changeset 6372:9dd4bb3cf1df
[gaim-migrate @ 6877]
Moved some utility functions out of dialogs.c and into gtkutils.c.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 05 Aug 2003 11:08:40 +0000 |
parents | 8f94cce8faa5 |
children | 4d61775a5741 |
files | src/dialogs.c src/gaimrc.c src/gtkutils.c src/gtkutils.h src/ui.h |
diffstat | 5 files changed, 101 insertions(+), 120 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dialogs.c Tue Aug 05 10:55:04 2003 +0000 +++ b/src/dialogs.c Tue Aug 05 11:08:40 2003 +0000 @@ -25,7 +25,6 @@ #include "multi.h" #include "notify.h" #include "prefs.h" -#include "privacy.h" #include "prpl.h" #include "request.h" #include "status.h" @@ -3496,100 +3495,3 @@ _("OK"), G_CALLBACK(do_rename_group), _("Cancel"), NULL, g); } - -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(const char *text, const char *icon, - GaimButtonOrientation style) -{ - GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; - button = gtk_button_new(); - - if (style == GAIM_BUTTON_HORIZONTAL) { - bbox = gtk_hbox_new(FALSE, 5); - ibox = gtk_hbox_new(FALSE, 0); - lbox = gtk_hbox_new(FALSE, 0); - } else { - bbox = gtk_vbox_new(FALSE, 5); - ibox = gtk_vbox_new(FALSE, 0); - lbox = gtk_vbox_new(FALSE, 0); - } - - gtk_container_add (GTK_CONTAINER(button), bbox); - - gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); - gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); - - if (icon) { - image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); - gtk_box_pack_end(GTK_BOX(ibox), 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(lbox), label, FALSE, FALSE, 0); - } - - gtk_widget_show_all(bbox); - return button; -} - -GtkWidget *gaim_pixbuf_button(char *text, char *iconfile, GaimButtonOrientation style) -{ - GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; - button = gtk_button_new(); - - if (style == GAIM_BUTTON_HORIZONTAL) { - bbox = gtk_hbox_new(FALSE, 5); - ibox = gtk_hbox_new(FALSE, 0); - lbox = gtk_hbox_new(FALSE, 0); - } else { - bbox = gtk_vbox_new(FALSE, 5); - ibox = gtk_vbox_new(FALSE, 0); - lbox = gtk_vbox_new(FALSE, 0); - } - - gtk_container_add (GTK_CONTAINER(button), bbox); - - gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); - gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); - - if (iconfile) { - char *filename; - filename = g_build_filename (DATADIR, "pixmaps", "gaim", "buttons", iconfile, NULL); - gaim_debug(GAIM_DEBUG_MISC, "gaim_pixbuf_button", - "Loading: %s\n", filename); - image = gtk_image_new_from_file(filename); - gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, FALSE, 0); - g_free(filename); - } - - 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(lbox), label, FALSE, FALSE, 0); - } - - gtk_widget_show_all(bbox); - return button; -}
--- a/src/gaimrc.c Tue Aug 05 10:55:04 2003 +0000 +++ b/src/gaimrc.c Tue Aug 05 11:08:40 2003 +0000 @@ -38,6 +38,7 @@ #include "gtkpounce.h" #include "gtksound.h" #include "gtkplugin.h" +#include "gtkutils.h" /* for people like myself, who are too lazy to add an away msg :) */ #define BORING_DEFAULT_AWAY_MSG _("sorry, i ran out for a while. bbl")
--- a/src/gtkutils.c Tue Aug 05 10:55:04 2003 +0000 +++ b/src/gtkutils.c Tue Aug 05 11:08:40 2003 +0000 @@ -451,7 +451,7 @@ GtkWidget *menuitem; menuitem = gtk_check_menu_item_new_with_mnemonic(str); - if(menu) + if (menu) gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); if (sf) @@ -464,6 +464,68 @@ return menuitem; } +GtkWidget * +gaim_pixbuf_toolbar_button_from_stock(const 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(const char *text, const char *icon, + GaimButtonOrientation style) +{ + GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; + + button = gtk_button_new(); + + if (style == GAIM_BUTTON_HORIZONTAL) { + bbox = gtk_hbox_new(FALSE, 5); + ibox = gtk_hbox_new(FALSE, 0); + lbox = gtk_hbox_new(FALSE, 0); + } + else { + bbox = gtk_vbox_new(FALSE, 5); + ibox = gtk_vbox_new(FALSE, 0); + lbox = gtk_vbox_new(FALSE, 0); + } + + gtk_container_add (GTK_CONTAINER(button), bbox); + + gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); + gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); + + if (icon) { + image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); + gtk_box_pack_end(GTK_BOX(ibox), 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(lbox), label, FALSE, FALSE, 0); + } + + gtk_widget_show_all(bbox); + + return button; +} + + 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; @@ -926,5 +988,3 @@ break; } } - -
--- a/src/gtkutils.h Tue Aug 05 10:55:04 2003 +0000 +++ b/src/gtkutils.h Tue Aug 05 11:08:40 2003 +0000 @@ -27,6 +27,22 @@ #include "gtkconv.h" #include "prpl.h" +typedef enum +{ + GAIM_BUTTON_HORIZONTAL, + GAIM_BUTTON_VERTICAL + +} GaimButtonOrientation; + +typedef enum +{ + GAIM_BUTTON_NONE = 0, + GAIM_BUTTON_TEXT, + GAIM_BUTTON_IMAGE, + GAIM_BUTTON_TEXT_IMAGE + +} GaimButtonStyle; + /** * Sets up a gtkimhtml widget, loads it with smileys, and sets the * default signal handlers. @@ -168,6 +184,27 @@ guint accel_mods, char *mod); /** + * Creates a button with the specified text and stock icon. + * + * @param text The text for the button. + * @param icon The stock icon name. + * @param style The orientation of the button. + * + * @return The button. + */ +GtkWidget *gaim_pixbuf_button_from_stock(const char *text, const char *icon, + GaimButtonOrientation style); + +/** + * Creates a toolbar button with the stock icon. + * + * @param icon The stock icon name. + * + * @return The button. + */ +GtkWidget *gaim_pixbuf_toolbar_button_from_stock(const char *stock); + +/** * Creates a HIG preferences frame. * * @param parent The widget to put the frame into.
--- a/src/ui.h Tue Aug 05 10:55:04 2003 +0000 +++ b/src/ui.h Tue Aug 05 11:08:40 2003 +0000 @@ -87,22 +87,6 @@ #define GAIM_WARNING 2 #define GAIM_INFO 3 -typedef enum -{ - GAIM_BUTTON_HORIZONTAL, - GAIM_BUTTON_VERTICAL - -} GaimButtonOrientation; - -typedef enum -{ - GAIM_BUTTON_NONE = 0, - GAIM_BUTTON_TEXT, - GAIM_BUTTON_IMAGE, - GAIM_BUTTON_TEXT_IMAGE - -} GaimButtonStyle; - /* XXX CUI: away messages aren't really anything more than char* but we need two char*'s * for the UI so that people can name their away messages when they save them. So these * are really a UI function and struct away_message should be removed from the core. */ @@ -220,9 +204,6 @@ extern void cancel_font(GtkWidget *widget, GaimConversation *c); extern void apply_font(GtkWidget *widget, GtkFontSelection *fontsel); extern void show_rename_group(GtkWidget *, struct group *); -extern GtkWidget *gaim_pixbuf_button(char *, char *, GaimButtonOrientation); -extern GtkWidget *gaim_pixbuf_button_from_stock(const char *, const char *, GaimButtonOrientation); -extern GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *); extern void destroy_fontsel(GtkWidget *w, gpointer d); extern void join_chat();