mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
icons: add system_icon_name API, make gtkutil fall back via resolver registry
This commit is contained in:
@@ -122,6 +122,8 @@ gtkutil_image_new_from_stock (const char *stock, GtkIconSize size)
|
|||||||
{
|
{
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
const char *icon_name;
|
const char *icon_name;
|
||||||
|
const char *resolved_icon_name = NULL;
|
||||||
|
int action;
|
||||||
|
|
||||||
icon_name = gtkutil_icon_name_from_stock (stock);
|
icon_name = gtkutil_icon_name_from_stock (stock);
|
||||||
if (!icon_name && stock && g_str_has_prefix (stock, "zc-menu-"))
|
if (!icon_name && stock && g_str_has_prefix (stock, "zc-menu-"))
|
||||||
@@ -131,14 +133,13 @@ gtkutil_image_new_from_stock (const char *stock, GtkIconSize size)
|
|||||||
if (image)
|
if (image)
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
if (icon_name && g_str_has_prefix (icon_name, "zc-menu-"))
|
if (icon_resolver_menu_action_from_name (icon_name, &action))
|
||||||
{
|
resolved_icon_name = icon_resolver_system_icon_name (ICON_RESOLVER_ROLE_MENU_ACTION, action);
|
||||||
const char *fallback_icon = icon_resolver_icon_name_for_menu_custom (icon_name);
|
|
||||||
if (fallback_icon)
|
|
||||||
icon_name = fallback_icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gtk_image_new_from_icon_name (icon_name, size);
|
if (!resolved_icon_name)
|
||||||
|
resolved_icon_name = icon_name;
|
||||||
|
|
||||||
|
return gtk_image_new_from_icon_name (resolved_icon_name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
|||||||
@@ -235,6 +235,17 @@ icon_resolver_menu_action_from_custom (const char *custom_icon_name, int *action
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
icon_resolver_system_icon_name (IconResolverRole role, int item)
|
||||||
|
{
|
||||||
|
const IconRegistryEntry *entry = icon_registry_find (role, item);
|
||||||
|
|
||||||
|
if (!entry)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return entry->system_icon_name;
|
||||||
|
}
|
||||||
|
|
||||||
IconResolverThemeVariant
|
IconResolverThemeVariant
|
||||||
icon_resolver_detect_theme_variant (void)
|
icon_resolver_detect_theme_variant (void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ const char *icon_resolver_icon_name_from_stock (const char *stock_name);
|
|||||||
const char *icon_resolver_icon_name_for_menu_custom (const char *custom_icon_name);
|
const char *icon_resolver_icon_name_for_menu_custom (const char *custom_icon_name);
|
||||||
gboolean icon_resolver_menu_action_from_custom (const char *custom_icon_name, int *action_out);
|
gboolean icon_resolver_menu_action_from_custom (const char *custom_icon_name, int *action_out);
|
||||||
gboolean icon_resolver_menu_action_from_name (const char *name, int *action_out);
|
gboolean icon_resolver_menu_action_from_name (const char *name, int *action_out);
|
||||||
|
const char *icon_resolver_system_icon_name (IconResolverRole role, int item);
|
||||||
IconResolverThemeVariant icon_resolver_detect_theme_variant (void);
|
IconResolverThemeVariant icon_resolver_detect_theme_variant (void);
|
||||||
char *icon_resolver_resolve_path (IconResolverRole role, int item, GtkIconSize size,
|
char *icon_resolver_resolve_path (IconResolverRole role, int item, GtkIconSize size,
|
||||||
const char *context, IconResolverThemeVariant variant,
|
const char *context, IconResolverThemeVariant variant,
|
||||||
|
|||||||
Reference in New Issue
Block a user