mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Updated GTK3 menu item creation in menu_quick_item and create_icon_menu to use GtkBox with GtkImage and GtkLabel while keeping GTK2 image menu items intact.
Reworked GTK3 channel list context menu items to use GtkBox-packed images and mnemonic labels, preserving GTK2 behavior under !HAVE_GTK3. Added GTK3 menu item layouts for spell entry actions and suggestion menu with icon-name images and mnemonic labels, while retaining GTK2 image menu items.
This commit is contained in:
@@ -682,33 +682,44 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv)
|
||||
#if HAVE_GTK3
|
||||
{
|
||||
GtkWidget *item;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (_("_Join Channel"));
|
||||
item = gtk_menu_item_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
image = gtk_image_new_from_icon_name (ICON_CHANLIST_JOIN, GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
|
||||
gtk_widget_show (image);
|
||||
label = gtk_label_new_with_mnemonic (_("_Join Channel"));
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (item), box);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (chanlist_join), serv);
|
||||
gtk_widget_show (item);
|
||||
gtk_widget_show_all (item);
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (_("_Copy Channel Name"));
|
||||
item = gtk_menu_item_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
image = gtk_image_new_from_icon_name (ICON_CHANLIST_COPY, GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
|
||||
gtk_widget_show (image);
|
||||
label = gtk_label_new_with_mnemonic (_("_Copy Channel Name"));
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (item), box);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (chanlist_copychannel), serv);
|
||||
gtk_widget_show (item);
|
||||
gtk_widget_show_all (item);
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (_("Copy _Topic Text"));
|
||||
item = gtk_menu_item_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
image = gtk_image_new_from_icon_name (ICON_CHANLIST_COPY, GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
|
||||
gtk_widget_show (image);
|
||||
label = gtk_label_new_with_mnemonic (_("Copy _Topic Text"));
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (item), box);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (chanlist_copytopic), serv);
|
||||
gtk_widget_show (item);
|
||||
gtk_widget_show_all (item);
|
||||
}
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
|
||||
@@ -277,10 +277,16 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||
{
|
||||
if (icon)
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
GtkWidget *box;
|
||||
GtkWidget *label_widget;
|
||||
#endif
|
||||
/*if (flags & XCMENU_MARKUP)
|
||||
item = gtk_image_menu_item_new_with_markup (label);
|
||||
else*/
|
||||
#if !HAVE_GTK3
|
||||
item = gtk_image_menu_item_new_with_mnemonic (label);
|
||||
#endif
|
||||
img = NULL;
|
||||
if (access (icon, R_OK) == 0) /* try fullpath */
|
||||
img = gtk_image_new_from_file (icon);
|
||||
@@ -303,8 +309,19 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
#if HAVE_GTK3
|
||||
item = gtk_menu_item_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
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);
|
||||
#endif
|
||||
if (img)
|
||||
#if !HAVE_GTK3
|
||||
gtk_image_menu_item_set_image ((GtkImageMenuItem *)item, img);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2002,9 +2019,22 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock)
|
||||
}
|
||||
else
|
||||
img = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name));
|
||||
#if HAVE_GTK3
|
||||
{
|
||||
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
GtkWidget *label_widget = gtk_label_new_with_mnemonic (labeltext);
|
||||
|
||||
item = gtk_menu_item_new ();
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
item = gtk_image_menu_item_new_with_mnemonic (labeltext);
|
||||
gtk_image_menu_item_set_image ((GtkImageMenuItem *)item, img);
|
||||
gtk_widget_show (img);
|
||||
#endif
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "../common/zoitechatc.h"
|
||||
#include "palette.h"
|
||||
#include "xtext.h"
|
||||
#include "gtkutil.h"
|
||||
|
||||
/*
|
||||
* Bunch of poop to make enchant into a runtime dependency rather than a
|
||||
@@ -682,10 +683,24 @@ build_spelling_menu(SexySpellEntry *entry, const gchar *word)
|
||||
|
||||
/* + Add to Dictionary */
|
||||
label = g_strdup_printf(_("Add \"%s\" to Dictionary"), word);
|
||||
mi = gtk_image_menu_item_new_with_label(label);
|
||||
g_free(label);
|
||||
#if HAVE_GTK3
|
||||
{
|
||||
const char *icon_name = gtkutil_icon_name_from_stock (GTK_STOCK_ADD);
|
||||
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
GtkWidget *image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
GtkWidget *label_widget = gtk_label_new_with_mnemonic (label);
|
||||
|
||||
mi = gtk_menu_item_new ();
|
||||
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 (mi), box);
|
||||
}
|
||||
#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
|
||||
g_free(label);
|
||||
|
||||
if (g_slist_length(entry->priv->dict_list) == 1) {
|
||||
dict = (struct EnchantDict *) entry->priv->dict_list->data;
|
||||
@@ -726,8 +741,23 @@ 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);
|
||||
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
GtkWidget *image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
GtkWidget *label_widget = gtk_label_new_with_mnemonic (_("Ignore All"));
|
||||
|
||||
mi = gtk_menu_item_new ();
|
||||
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 (mi), box);
|
||||
}
|
||||
#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
|
||||
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);
|
||||
@@ -760,9 +790,24 @@ 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);
|
||||
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
GtkWidget *label_widget = gtk_label_new_with_mnemonic (_("Spelling Suggestions"));
|
||||
|
||||
icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (mi), box);
|
||||
}
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
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
|
||||
|
||||
word = gtk_editable_get_chars(GTK_EDITABLE(entry), start, end);
|
||||
g_assert(word != NULL);
|
||||
|
||||
Reference in New Issue
Block a user