diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index e39c2992..451c7ae4 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -107,7 +107,6 @@ chanlist_box_new (void) #endif } -#if HAVE_GTK3 static GtkWidget * chanlist_icon_button (const char *label, const char *icon_name, GCallback callback, gpointer userdata) @@ -130,6 +129,7 @@ chanlist_icon_menu_item (const char *label, const char *icon_name, GCallback callback, gpointer userdata) { GtkWidget *item; +#if HAVE_GTK3 GtkWidget *box; GtkWidget *image; GtkWidget *label_widget; @@ -141,12 +141,19 @@ chanlist_icon_menu_item (const char *label, const char *icon_name, gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (item), box); +#endif +#if !HAVE_GTK3 + GtkWidget *image; + + item = gtk_image_menu_item_new_with_mnemonic (label); + image = gtk_image_new_from_stock (icon_name, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); +#endif g_signal_connect (G_OBJECT (item), "activate", callback, userdata); gtk_widget_show_all (item); return item; } -#endif static gboolean @@ -701,7 +708,6 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv) g_object_unref (menu); g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (chanlist_menu_destroy), NULL); -#if HAVE_GTK3 { GtkWidget *item; @@ -717,15 +723,6 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv) G_CALLBACK (chanlist_copytopic), serv); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } -#endif -#if !HAVE_GTK3 - mg_create_icon_item (_("_Join Channel"), ICON_CHANLIST_JOIN, menu, - chanlist_join, serv); - mg_create_icon_item (_("_Copy Channel Name"), ICON_CHANLIST_COPY, menu, - chanlist_copychannel, serv); - mg_create_icon_item (_("Copy _Topic Text"), ICON_CHANLIST_COPY, menu, - chanlist_copytopic, serv); -#endif chan = chanlist_get_selected (serv, FALSE); menu_addfavoritemenu (serv, menu, chan, FALSE); diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 622e584a..ee00a2d2 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -353,27 +353,6 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags, return item; } -#if HAVE_GTK3 -static GtkWidget * -menu_icon_name_item_new (const char *label, const char *icon_name) -{ - GtkWidget *item; - GtkWidget *box; - GtkWidget *image; - GtkWidget *label_widget; - - item = gtk_menu_item_new (); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); - label_widget = gtk_label_new_with_mnemonic (label); - gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (item), box); - - return item; -} -#endif - static void menu_quick_item_with_callback (void *callback, char *label, GtkWidget * menu, void *arg) @@ -2026,13 +2005,17 @@ GtkWidget * create_icon_menu (char *labeltext, void *stock_name, int is_stock) { GtkWidget *item, *img; +#if HAVE_GTK3 + GtkWidget *box; + GtkWidget *label_widget; + const char *icon_name; +#endif if (is_stock) { #if HAVE_GTK3 - const char *icon_name = gtkutil_icon_name_from_stock (stock_name); - - item = menu_icon_name_item_new (labeltext, icon_name); + icon_name = gtkutil_icon_name_from_stock (stock_name); + img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); #endif #if !HAVE_GTK3 img = gtk_image_new_from_stock (stock_name, GTK_ICON_SIZE_MENU); @@ -2041,16 +2024,13 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock) else img = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name)); #if HAVE_GTK3 - if (!is_stock) - { - GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - GtkWidget *label_widget = gtk_label_new_with_mnemonic (labeltext); - - item = gtk_menu_item_new (); + item = gtk_menu_item_new (); + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + label_widget = gtk_label_new_with_mnemonic (labeltext); + if (img) gtk_box_pack_start (GTK_BOX (box), img, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (item), box); - } + gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0); + gtk_container_add (GTK_CONTAINER (item), box); #endif #if !HAVE_GTK3 item = gtk_image_menu_item_new_with_mnemonic (labeltext); diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index c657611e..19b5d751 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -629,15 +629,17 @@ build_suggestion_menu(SexySpellEntry *entry, GtkWidget *menu, struct EnchantDict enchant_dict_free_suggestions(dict, suggestions); } -#if HAVE_GTK3 static GtkWidget * -sexy_spell_entry_icon_menu_item (const char *label, const char *icon_name) +sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name) { GtkWidget *item; +#if HAVE_GTK3 GtkWidget *box; GtkWidget *image; GtkWidget *label_widget; + const char *icon_name; + icon_name = gtkutil_icon_name_from_stock (stock_name); item = gtk_menu_item_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); @@ -645,10 +647,17 @@ sexy_spell_entry_icon_menu_item (const char *label, const char *icon_name) gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (item), box); +#endif +#if !HAVE_GTK3 + GtkWidget *image; + + item = gtk_image_menu_item_new_with_label (label); + image = gtk_image_new_from_stock (stock_name, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); +#endif return item; } -#endif static GtkWidget * build_spelling_menu(SexySpellEntry *entry, const gchar *word) @@ -704,17 +713,7 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word) /* + Add to Dictionary */ label = g_strdup_printf(_("Add \"%s\" to Dictionary"), word); -#if HAVE_GTK3 - { - const char *icon_name = gtkutil_icon_name_from_stock (GTK_STOCK_ADD); - - mi = sexy_spell_entry_icon_menu_item (label, icon_name); - } -#endif -#if !HAVE_GTK3 - mi = gtk_image_menu_item_new_with_label(label); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU)); -#endif + mi = sexy_spell_entry_icon_menu_item (label, GTK_STOCK_ADD); g_free(label); if (g_slist_length(entry->priv->dict_list) == 1) { @@ -756,17 +755,7 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word) gtk_menu_shell_append(GTK_MENU_SHELL(topmenu), mi); /* - Ignore All */ -#if HAVE_GTK3 - { - const char *icon_name = gtkutil_icon_name_from_stock (GTK_STOCK_REMOVE); - - mi = sexy_spell_entry_icon_menu_item (_("Ignore All"), icon_name); - } -#endif -#if !HAVE_GTK3 - mi = gtk_image_menu_item_new_with_label(_("Ignore All")); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU)); -#endif + mi = sexy_spell_entry_icon_menu_item (_("Ignore All"), GTK_STOCK_REMOVE); g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(ignore_all), entry); gtk_widget_show_all(mi); gtk_menu_shell_append(GTK_MENU_SHELL(topmenu), mi); @@ -799,20 +788,7 @@ sexy_spell_entry_populate_popup(SexySpellEntry *entry, GtkMenu *menu, gpointer d gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), mi); /* Above the separator, show the suggestions menu */ -#if HAVE_GTK3 - { - const char *icon_name = gtkutil_icon_name_from_stock (GTK_STOCK_SPELL_CHECK); - - mi = sexy_spell_entry_icon_menu_item (_("Spelling Suggestions"), icon_name); - } -#endif -#if !HAVE_GTK3 - GtkWidget *icon; - - icon = gtk_image_new_from_stock(GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); - mi = gtk_image_menu_item_new_with_label(_("Spelling Suggestions")); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), icon); -#endif + mi = sexy_spell_entry_icon_menu_item (_("Spelling Suggestions"), GTK_STOCK_SPELL_CHECK); word = gtk_editable_get_chars(GTK_EDITABLE(entry), start, end); g_assert(word != NULL);