[gnome-control-center/wip/hadess/logo-inherit: 42/44] info-overview: Look for -text and -dark logo variants
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/hadess/logo-inherit: 42/44] info-overview: Look for -text and -dark logo variants
- Date: Fri, 21 May 2021 15:00:22 +0000 (UTC)
commit a3b8964a1936274dc4021455648d51edb11b520d
Author: Bastien Nocera <hadess hadess net>
Date: Fri Apr 23 12:30:15 2021 +0200
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
panels/info-overview/cc-info-overview-panel.c | 23 ++++++++++++++++++++++-
panels/info-overview/cc-info-overview-panel.ui | 1 +
2 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c
index 7e1aefcad..c68b30f34 100644
--- a/panels/info-overview/cc-info-overview-panel.c
+++ b/panels/info-overview/cc-info-overview-panel.c
@@ -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
diff --git a/panels/info-overview/cc-info-overview-panel.ui b/panels/info-overview/cc-info-overview-panel.ui
index 3fb1599f4..95afe867c 100644
--- a/panels/info-overview/cc-info-overview-panel.ui
+++ b/panels/info-overview/cc-info-overview-panel.ui
@@ -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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]