mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-23 05:50:18 +00:00
Updated GTK3 menu quick items to build a GtkMenuItem with a box, icon-name image, and mnemonic label before packing into the menu item.
Ensured chanlist GTK3 icon menu items always create images from icon names before packing with the mnemonic label. Adjusted spell entry GTK3 icon menu items to create icon-name images for the boxed menu item layout.
This commit is contained in:
@@ -136,8 +136,7 @@ chanlist_icon_menu_item (const char *label, const char *icon_name,
|
|||||||
|
|
||||||
item = gtk_menu_item_new ();
|
item = gtk_menu_item_new ();
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
if (icon_name)
|
image = 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);
|
|
||||||
label_widget = gtk_label_new_with_mnemonic (label);
|
label_widget = gtk_label_new_with_mnemonic (label);
|
||||||
if (image)
|
if (image)
|
||||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||||
|
|||||||
@@ -261,47 +261,6 @@ menu_toggle_item (char *label, GtkWidget *menu, void *callback, void *userdata,
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_GTK3
|
|
||||||
static GtkWidget *
|
|
||||||
menu_item_new_with_image_and_label (GtkWidget *image, const char *label)
|
|
||||||
{
|
|
||||||
GtkWidget *item;
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *label_widget;
|
|
||||||
|
|
||||||
item = gtk_menu_item_new ();
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
||||||
label_widget = gtk_label_new_with_mnemonic (label);
|
|
||||||
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);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
menu_item_new_with_icon_name_and_label (const char *icon_name, const char *label)
|
|
||||||
{
|
|
||||||
GtkWidget *item;
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *image = NULL;
|
|
||||||
GtkWidget *label_widget;
|
|
||||||
|
|
||||||
item = gtk_menu_item_new ();
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
||||||
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);
|
|
||||||
gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0);
|
|
||||||
gtk_container_add (GTK_CONTAINER (item), box);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
||||||
gpointer userdata, char *icon)
|
gpointer userdata, char *icon)
|
||||||
@@ -310,6 +269,9 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
|||||||
char *path;
|
char *path;
|
||||||
#if HAVE_GTK3
|
#if HAVE_GTK3
|
||||||
const char *icon_name = NULL;
|
const char *icon_name = NULL;
|
||||||
|
GtkWidget *box;
|
||||||
|
GtkWidget *image = NULL;
|
||||||
|
GtkWidget *label_widget;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!label)
|
if (!label)
|
||||||
@@ -343,10 +305,17 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_GTK3
|
#if HAVE_GTK3
|
||||||
if (img)
|
item = gtk_menu_item_new ();
|
||||||
item = menu_item_new_with_image_and_label (img, label);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
else
|
if (icon_name)
|
||||||
item = menu_item_new_with_icon_name_and_label (icon_name, label);
|
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||||
|
else if (img)
|
||||||
|
image = img;
|
||||||
|
label_widget = gtk_label_new_with_mnemonic (label);
|
||||||
|
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
|
#endif
|
||||||
#if !HAVE_GTK3
|
#if !HAVE_GTK3
|
||||||
item = gtk_image_menu_item_new_with_mnemonic (label);
|
item = gtk_image_menu_item_new_with_mnemonic (label);
|
||||||
|
|||||||
@@ -642,8 +642,7 @@ sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name)
|
|||||||
icon_name = gtkutil_icon_name_from_stock (stock_name);
|
icon_name = gtkutil_icon_name_from_stock (stock_name);
|
||||||
item = gtk_menu_item_new ();
|
item = gtk_menu_item_new ();
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
if (icon_name)
|
image = icon_name ? gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU) : NULL;
|
||||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
|
||||||
label_widget = gtk_label_new_with_mnemonic (label);
|
label_widget = gtk_label_new_with_mnemonic (label);
|
||||||
if (image)
|
if (image)
|
||||||
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user