mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Guarded GTK3 chanlist menu item image creation on a non-null icon name before packing into the menu item box.
Updated GTK3 create_icon_menu to build menu items with explicit image/label composition using icon names or pixbufs before packing into the box. Adjusted GTK3 spell entry icon menu item to create the image only when an icon name is available.
This commit is contained in:
@@ -136,7 +136,7 @@ chanlist_icon_menu_item (const char *label, const char *icon_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);
|
||||
image = icon_name ? gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU) : NULL;
|
||||
label_widget = gtk_label_new_with_mnemonic (label);
|
||||
if (image)
|
||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||
|
||||
@@ -2004,33 +2004,43 @@ menu_set_fullscreen (session_gui *gui, int full)
|
||||
GtkWidget *
|
||||
create_icon_menu (char *labeltext, void *stock_name, int is_stock)
|
||||
{
|
||||
GtkWidget *item, *img;
|
||||
GtkWidget *item;
|
||||
#if HAVE_GTK3
|
||||
GtkWidget *box;
|
||||
GtkWidget *label_widget;
|
||||
GtkWidget *image = NULL;
|
||||
const char *icon_name;
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
GtkWidget *img;
|
||||
#endif
|
||||
|
||||
if (is_stock)
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
icon_name = gtkutil_icon_name_from_stock (stock_name);
|
||||
img = NULL;
|
||||
if (icon_name)
|
||||
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||
image = 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);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
image = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name));
|
||||
#endif
|
||||
#if !HAVE_GTK3
|
||||
img = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name));
|
||||
#endif
|
||||
}
|
||||
#if HAVE_GTK3
|
||||
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);
|
||||
if (image)
|
||||
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
|
||||
|
||||
@@ -642,7 +642,8 @@ sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name)
|
||||
icon_name = gtkutil_icon_name_from_stock (stock_name);
|
||||
item = gtk_menu_item_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
image = icon_name ? gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU) : NULL;
|
||||
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