info-overview: Look for -text and -dark logo variants
When loading the LOGO icon name from /etc/os-release, append -text to prefer a textual variant of the logo if it exists, and -dark if the theme variant is dark. This allows distributors to ship textual and dark variants of their logos without adding more fields to /etc/os-release, or more code specific to logo handling for specific distributions. $LOGO: default icon $LOGO-dark: default icon when dark theme is used $LOGO-text: icon with text $LOGO-text-dark: icon with text when dark theme is used
This commit is contained in:
parent
f3312c6577
commit
a3b8964a19
2 changed files with 23 additions and 1 deletions
|
@ -884,13 +884,34 @@ cc_info_panel_row_activated_cb (CcInfoOverviewPanel *self,
|
|||
open_software_update (self);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_asset_suffix (CcInfoOverviewPanel *panel)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkSettings *settings;
|
||||
g_autofree char *theme_name = NULL;
|
||||
|
||||
theme_name = g_strdup (g_getenv ("GTK_THEME"));
|
||||
if (theme_name != NULL)
|
||||
return g_str_has_suffix (theme_name, "dark") ? "-dark" : "";
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (panel));
|
||||
settings = gtk_settings_get_for_screen (screen);
|
||||
|
||||
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
|
||||
return (theme_name != NULL && g_str_has_suffix (theme_name, "dark")) ? "-dark" : "";
|
||||
}
|
||||
|
||||
static void
|
||||
setup_os_logo (CcInfoOverviewPanel *panel)
|
||||
{
|
||||
g_autofree char *logo_name = g_get_os_info ("LOGO");
|
||||
if (logo_name != NULL)
|
||||
{
|
||||
gtk_image_set_from_icon_name (panel->os_logo, logo_name, GTK_ICON_SIZE_INVALID);
|
||||
g_autofree char *logo_name_with_variant = NULL;
|
||||
|
||||
logo_name_with_variant = g_strdup_printf ("%s-text%s", logo_name, get_asset_suffix (panel));
|
||||
gtk_image_set_from_icon_name (panel->os_logo, logo_name_with_variant, GTK_ICON_SIZE_INVALID);
|
||||
gtk_image_set_pixel_size (panel->os_logo, 256);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<object class="GtkImage" id="os_logo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_fallback">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue