[gnome-control-center/mcatanzaro/distributor-logo: 264/264] info-overview: add build option to specify a dark mode logo variant




commit 8dd1491e1f6b080c0e655edf8c23b46e331f3a0d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Mar 9 16:02:46 2021 -0600

    info-overview: add build option to specify a dark mode logo variant
    
    Let's allow distributions to specify a different logo to use when using
    a dark GTK theme. This is best-effort only since it relies on the
    convention that dark themes must end with "dark" and therefore will fail
    for a theme named "midnight" or anything that doesn't match convention.

 meson.build                                   |  5 +++++
 meson_options.txt                             |  1 +
 panels/info-overview/cc-info-overview-panel.c | 27 +++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
---
diff --git a/meson.build b/meson.build
index edaebeea3..bb0e06d9e 100644
--- a/meson.build
+++ b/meson.build
@@ -54,6 +54,11 @@ distributor_logo = get_option('distributor_logo')
 if (distributor_logo != '')
   config_h.set_quoted('DISTRIBUTOR_LOGO', distributor_logo,
                       description: 'Define to absolute path of distributor logo')
+  dark_mode_distributor_logo = get_option('dark_mode_distributor_logo')
+  if (dark_mode_distributor_logo != '')
+    config_h.set_quoted('DARK_MODE_DISTRIBUTOR_LOGO', dark_mode_distributor_logo,
+                        description: 'Define to absolute path of distributor logo for use in dark mode')
+  endif
 endif
 
 # meson does not support octal values, so it must be handled as a
diff --git a/meson_options.txt b/meson_options.txt
index 93e551373..5305c8606 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,3 +9,4 @@ option('wayland', type: 'boolean', value: true, description: 'build with Wayland
 option('profile', type: 'combo', choices: ['default','development'], value: 'default')
 option('malcontent', type: 'boolean', value: false, description: 'build with malcontent support')
 option('distributor_logo', type: 'string', description: 'absolute path to distributor logo for the About 
panel')
+option('dark_mode_distributor_logo', type: 'string', description: 'absolute path to distributor logo dark 
mode variant')
diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c
index 6cacb399d..f9e3dbed7 100644
--- a/panels/info-overview/cc-info-overview-panel.c
+++ b/panels/info-overview/cc-info-overview-panel.c
@@ -880,6 +880,7 @@ cc_info_panel_row_activated_cb (CcInfoOverviewPanel *self,
     open_software_update (self);
 }
 
+#ifdef DARK_MODE_DISTRIBUTOR_LOGO
 static gboolean
 use_dark_theme (CcInfoOverviewPanel *panel)
 {
@@ -887,6 +888,24 @@ use_dark_theme (CcInfoOverviewPanel *panel)
   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");
+
+  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");
+}
+#else
+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") ? TRUE : FALSE;
@@ -897,11 +916,19 @@ use_dark_theme (CcInfoOverviewPanel *panel)
   g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
   return (theme_name != NULL && g_str_has_suffix (theme_name, "dark")) ? TRUE : FALSE;
 }
+#endif
 
 static void
 setup_os_logo (CcInfoOverviewPanel *panel)
 {
 #ifdef DISTRIBUTOR_LOGO
+#ifdef DARK_MODE_DISTRIBUTOR_LOGO
+  if (is_dark_mode (panel))
+    {
+      gtk_image_set_from_file (panel->os_logo, DARK_MODE_DISTRIBUTOR_LOGO);
+      return;
+    }
+#endif
   gtk_image_set_from_file (panel->os_logo, DISTRIBUTOR_LOGO);
 #else
   g_autofree char *logo_name = g_get_os_info ("LOGO");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]