Standardized GTK3 menu-related icon constants to use the bundled zc-menu-* icon set (from data/icons/menu) in the places that had direct equivalents, including raw log, URL grabber, channel list actions, tray menu, and plugin load action.

Updated menu_quick_item() so zc-menu-* icons now fall back to the light variant if the current theme variant is unavailable, which helps avoid missing icons.

    Added centralized zc-menu-* resource loading to gtkutil_image_new_from_stock() (theme-variant detection + light fallback), so menu/button icon rendering uses the same bundled source path consistently.
This commit is contained in:
2026-02-17 23:49:59 -07:00
parent 8642d8bde4
commit bc2b1bd509
7 changed files with 90 additions and 10 deletions

View File

@@ -46,11 +46,11 @@
#include "custom-list.h"
#if HAVE_GTK3
#define ICON_CHANLIST_JOIN "go-jump"
#define ICON_CHANLIST_JOIN "zc-menu-join"
#define ICON_CHANLIST_COPY "edit-copy"
#define ICON_CHANLIST_FIND "edit-find"
#define ICON_CHANLIST_FIND "zc-menu-find"
#define ICON_CHANLIST_REFRESH "view-refresh"
#define ICON_CHANLIST_SAVE "document-save-as"
#define ICON_CHANLIST_SAVE "zc-menu-save"
#endif
#if !HAVE_GTK3
#define ICON_CHANLIST_JOIN GTK_STOCK_JUMP_TO

View File

@@ -121,12 +121,88 @@ gtkutil_icon_name_from_stock (const char *stock_name)
}
#endif
#if HAVE_GTK3
static const char *
gtkutil_menu_icon_theme_variant (void)
{
GtkSettings *settings;
gboolean prefer_dark = FALSE;
char *theme_name = NULL;
char *theme_name_lower = NULL;
const char *theme_variant = "light";
settings = gtk_settings_get_default ();
if (settings)
{
g_object_get (G_OBJECT (settings), "gtk-application-prefer-dark-theme", &prefer_dark, NULL);
g_object_get (G_OBJECT (settings), "gtk-theme-name", &theme_name, NULL);
}
if (theme_name)
theme_name_lower = g_ascii_strdown (theme_name, -1);
if (prefer_dark || (theme_name_lower && g_strrstr (theme_name_lower, "dark")))
theme_variant = "dark";
g_free (theme_name_lower);
g_free (theme_name);
return theme_variant;
}
static GtkWidget *
gtkutil_menu_icon_image_new (const char *icon_name, GtkIconSize size)
{
GtkWidget *image = NULL;
GdkPixbuf *pixbuf = NULL;
char *resource_path;
const char *variant;
if (!icon_name || !g_str_has_prefix (icon_name, "zc-menu-"))
return NULL;
variant = gtkutil_menu_icon_theme_variant ();
resource_path = g_strdup_printf ("/icons/menu/%s/%s.svg", variant, icon_name + strlen ("zc-menu-"));
if (!g_resources_get_info (resource_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL, NULL, NULL))
{
g_free (resource_path);
resource_path = g_strdup_printf ("/icons/menu/light/%s.svg", icon_name + strlen ("zc-menu-"));
}
pixbuf = gdk_pixbuf_new_from_resource_at_scale (resource_path, -1, -1, TRUE, NULL);
if (pixbuf)
{
image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
g_free (resource_path);
if (image)
{
GtkIconSize tmp_size;
gint width;
gint height;
tmp_size = size;
if (gtk_icon_size_lookup (tmp_size, &width, &height))
gtk_image_set_pixel_size (GTK_IMAGE (image), MAX (width, height));
}
return image;
}
#endif
GtkWidget *
gtkutil_image_new_from_stock (const char *stock, GtkIconSize size)
{
#if HAVE_GTK3
GtkWidget *image;
const char *icon_name = gtkutil_icon_name_from_stock (stock);
image = gtkutil_menu_icon_image_new (icon_name, size);
if (image)
return image;
return gtk_image_new_from_icon_name (icon_name, size);
#elif !HAVE_GTK3
return gtk_image_new_from_stock (stock, size);

View File

@@ -330,7 +330,11 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
if (custom_icon)
{
image = menu_icon_image_from_data_icons (custom_icon, menu_icon_theme_variant ());
if (!image)
image = menu_icon_image_from_data_icons (custom_icon, "light");
}
if (!image && icon_name)
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
else if (img)

View File

@@ -43,8 +43,8 @@ typedef struct _GtkStatusIcon GtkStatusIcon;
#include <libappindicator/app-indicator.h>
#endif
#endif
#define ICON_TRAY_PREFERENCES "preferences-system"
#define ICON_TRAY_QUIT "application-exit"
#define ICON_TRAY_PREFERENCES "zc-menu-preferences"
#define ICON_TRAY_QUIT "zc-menu-quit"
#else
#define ICON_TRAY_PREFERENCES GTK_STOCK_PREFERENCES
#define ICON_TRAY_QUIT GTK_STOCK_QUIT

View File

@@ -65,7 +65,7 @@ plugingui_get_target_session (void)
}
#if HAVE_GTK3
#define ICON_PLUGIN_LOAD "document-open"
#define ICON_PLUGIN_LOAD "zc-menu-load-plugin"
#define ICON_PLUGIN_UNLOAD "edit-delete"
#define ICON_PLUGIN_RELOAD "view-refresh"
#endif

View File

@@ -43,8 +43,8 @@
#include "fkeys.h"
#if HAVE_GTK3
#define ICON_RAWLOG_CLEAR "edit-clear"
#define ICON_RAWLOG_SAVE_AS "document-save-as"
#define ICON_RAWLOG_CLEAR "zc-menu-clear"
#define ICON_RAWLOG_SAVE_AS "zc-menu-save"
#endif
#if !HAVE_GTK3
#define ICON_RAWLOG_CLEAR GTK_STOCK_CLEAR

View File

@@ -34,9 +34,9 @@
#include "urlgrab.h"
#if HAVE_GTK3
#define ICON_URLGRAB_CLEAR "edit-clear"
#define ICON_URLGRAB_CLEAR "zc-menu-clear"
#define ICON_URLGRAB_COPY "edit-copy"
#define ICON_URLGRAB_SAVE_AS "document-save-as"
#define ICON_URLGRAB_SAVE_AS "zc-menu-save"
#endif
#if !HAVE_GTK3
#define ICON_URLGRAB_CLEAR GTK_STOCK_CLEAR