mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 16:00:18 +00:00
Added GTK3 icon-name menu item helper and used it when building icon-based menu items in the main menu paths, while keeping the GtkImageMenuItem fallback for GTK2 intact.
Guarded GTK3 chanlist icon menu item creation to handle missing icon names safely while still creating the boxed menu layout. Applied the same GTK3 icon-name guard for the sexy-spell-entry menu items while preserving GTK2 code paths.
This commit is contained in:
@@ -130,12 +130,13 @@ chanlist_menu_item_new_with_icon (const char *label, const char *icon_name)
|
||||
{
|
||||
GtkWidget *item;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image;
|
||||
GtkWidget *image = NULL;
|
||||
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);
|
||||
if (icon_name)
|
||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
if (image)
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
|
||||
@@ -279,6 +279,17 @@ menu_item_new_with_image_and_label (GtkWidget *image, const char *label)
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
menu_item_new_with_icon_name_and_label (const char *icon_name, const char *label)
|
||||
{
|
||||
GtkWidget *image = NULL;
|
||||
|
||||
if (icon_name)
|
||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
|
||||
return menu_item_new_with_image_and_label (image, label);
|
||||
}
|
||||
#endif
|
||||
|
||||
GtkWidget *
|
||||
@@ -288,7 +299,7 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||
GtkWidget *img, *item;
|
||||
char *path;
|
||||
#if HAVE_GTK3
|
||||
const char *icon_name;
|
||||
const char *icon_name = NULL;
|
||||
#endif
|
||||
|
||||
if (!label)
|
||||
@@ -313,7 +324,6 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
icon_name = gtkutil_icon_name_from_stock (icon);
|
||||
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
img = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
|
||||
@@ -323,7 +333,10 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||
}
|
||||
|
||||
#if HAVE_GTK3
|
||||
item = menu_item_new_with_image_and_label (img, label);
|
||||
if (img)
|
||||
item = menu_item_new_with_image_and_label (img, label);
|
||||
else
|
||||
item = menu_item_new_with_icon_name_and_label (icon_name, label);
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
item = gtk_image_menu_item_new_with_mnemonic (label);
|
||||
@@ -2021,7 +2034,6 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock)
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
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);
|
||||
@@ -2030,7 +2042,10 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock)
|
||||
else
|
||||
img = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name));
|
||||
#if HAVE_GTK3
|
||||
item = menu_item_new_with_image_and_label (img, labeltext);
|
||||
if (is_stock)
|
||||
item = menu_item_new_with_icon_name_and_label (icon_name, labeltext);
|
||||
else
|
||||
item = menu_item_new_with_image_and_label (img, labeltext);
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
item = gtk_image_menu_item_new_with_mnemonic (labeltext);
|
||||
|
||||
@@ -635,12 +635,13 @@ sexy_spell_entry_menu_item_new_with_icon (const char *label, const char *icon_na
|
||||
{
|
||||
GtkWidget *item;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image;
|
||||
GtkWidget *image = NULL;
|
||||
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);
|
||||
if (icon_name)
|
||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
if (image)
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
|
||||
Reference in New Issue
Block a user