[gnome-panel] theme: update



commit 2a21a16ca1371dd19ae38e55fc290b87623f85de
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Dec 27 23:01:44 2019 +0200

    theme: update
    
    - redo theme loading
    - add HighContrastInverse
    - update css
    
    common.css should include all css that will be usefull to all
    themes (supported and unsupported).
    
    fallback.css should include extra css that might be needed to make
    panel and applets usable with unsupported themes.
    
    https://gitlab.gnome.org/GNOME/gnome-panel/issues/19

 data/theme/Adwaita/gnome-panel-dark.css         | 38 ++-----------
 data/theme/Adwaita/gnome-panel.css              | 39 +------------
 data/theme/HighContrast/Makefile.am             |  2 +-
 data/theme/HighContrast/gnome-panel-dark.css    |  2 -
 data/theme/HighContrast/gnome-panel-inverse.css | 72 ++++++++++++++++++++++++
 data/theme/HighContrast/gnome-panel.css         | 42 +-------------
 data/theme/common.css                           | 37 +++++++++++++
 data/theme/fallback.css                         | 33 +----------
 gnome-panel/main.c                              | 73 ++++++++++++++++++++++---
 gnome-panel/panel.gresource.xml                 |  2 +-
 10 files changed, 189 insertions(+), 151 deletions(-)
---
diff --git a/data/theme/Adwaita/gnome-panel-dark.css b/data/theme/Adwaita/gnome-panel-dark.css
index fb00ae99c..c64e069d0 100644
--- a/data/theme/Adwaita/gnome-panel-dark.css
+++ b/data/theme/Adwaita/gnome-panel-dark.css
@@ -32,39 +32,21 @@ gp-calendar-window label,
   color: #ffffff;
 }
 
-gp-applet.separator > separator {
-  margin: 2px 4px;
-}
-
-#clock-applet-button,
-#showdesktop-button {
-  padding: 0px 4px;
-  border: 0;
-  border-radius: 0;
+.gnome-panel-menu-bar > menuitem:hover > label,
+panel-applet > menubar > menuitem:hover > label,
+gp-applet > menubar > menuitem:hover > .gp-text-color,
+gp-applet > menubar > menuitem:hover > box > .gp-text-color {
+  font-weight: normal;
+  color: #ffffff;
 }
 
 wnck-pager:selected {
   background-color: #215d9c;
 }
 
-na-tray-applet {
-  -NaTrayApplet-icon-padding: 2;
-  -NaTrayApplet-icon-size: 16;
-}
-
 gp-arrow-button {
-  min-width: 20px;
-  min-height: 0px;
-
   border: 1px solid #1c1f1f;
-  border-radius: 3px;
   background-image: linear-gradient(to bottom, #343a3a, #2f3434 60%, #2a2f2f);
-  margin: 2px;
-}
-
-.vertical gp-arrow-button {
-  min-width: 0px;
-  min-height: 20px;
 }
 
 gp-arrow-button:hover {
@@ -75,14 +57,6 @@ gp-arrow-button:active {
   background-image: linear-gradient(to bottom, #232727, #2d3232);
 }
 
-.horizontal sn-item {
-  padding: 0px 3px;
-}
-
-.vertical sn-item {
-  padding: 3px 0px;
-}
-
 #tasklist-button,
 #tasklist-button:hover,
 #tasklist-button:active,
diff --git a/data/theme/Adwaita/gnome-panel.css b/data/theme/Adwaita/gnome-panel.css
index 2b9f8be67..90305f5f3 100644
--- a/data/theme/Adwaita/gnome-panel.css
+++ b/data/theme/Adwaita/gnome-panel.css
@@ -34,44 +34,19 @@ gp-calendar-window label,
 
 .gnome-panel-menu-bar > menuitem:hover > label,
 panel-applet > menubar > menuitem:hover > label,
-gp-applet > menubar > menuitem:hover > label,
-gp-applet > menubar > menuitem:hover > box > label {
+gp-applet > menubar > menuitem:hover > .gp-text-color,
+gp-applet > menubar > menuitem:hover > box > .gp-text-color {
+  font-weight: normal;
   color: #ffffff;
 }
 
-gp-applet.separator > separator {
-  margin: 2px 4px;
-}
-
-#clock-applet-button,
-#showdesktop-button {
-  padding: 0px 4px;
-  border: 0;
-  border-radius: 0;
-}
-
 wnck-pager:selected {
   background-color: #4a90d9;
 }
 
-na-tray-applet {
-  -NaTrayApplet-icon-padding: 2;
-  -NaTrayApplet-icon-size: 16;
-}
-
 gp-arrow-button {
-  min-width: 20px;
-  min-height: 0px;
-
   border: 1px solid #9d9d99;
-  border-radius: 3px;
   background-image: linear-gradient(to bottom, #e8e8e7, #dededd 60%, #cfcfcd);
-  margin: 2px;
-}
-
-.vertical gp-arrow-button {
-  min-width: 0px;
-  min-height: 20px;
 }
 
 gp-arrow-button:hover {
@@ -82,14 +57,6 @@ gp-arrow-button:active {
   background-image: linear-gradient(to bottom, #c8c8c5, #dcdcda);
 }
 
-.horizontal sn-item {
-  padding: 0px 3px;
-}
-
-.vertical sn-item {
-  padding: 3px 0px;
-}
-
 #tasklist-button,
 #tasklist-button:hover,
 #tasklist-button:active,
diff --git a/data/theme/HighContrast/Makefile.am b/data/theme/HighContrast/Makefile.am
index 2fc77bed1..3ed4c4bb4 100644
--- a/data/theme/HighContrast/Makefile.am
+++ b/data/theme/HighContrast/Makefile.am
@@ -2,7 +2,7 @@ NULL =
 
 EXTRA_DIST = \
        gnome-panel.css \
-       gnome-panel-dark.css \
+       gnome-panel-inverse.css \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/data/theme/HighContrast/gnome-panel-inverse.css b/data/theme/HighContrast/gnome-panel-inverse.css
new file mode 100644
index 000000000..97f404d75
--- /dev/null
+++ b/data/theme/HighContrast/gnome-panel-inverse.css
@@ -0,0 +1,72 @@
+@import url("resource:///org/gnome/gnome-panel/theme/common.css");
+
+panel-toplevel {
+  background-color: #000000;
+}
+
+.gp-text-color {
+  color: #ffffff;
+}
+
+.gnome-panel-menu-bar,
+panel-applet > menubar,
+gp-applet > menubar {
+  background: transparent;
+  box-shadow: none;
+}
+
+.gnome-panel-menu-bar menuitem:hover,
+panel-applet > menubar menuitem:hover,
+gp-applet > menubar menuitem:hover {
+  background-color: #000000;
+}
+
+.gnome-panel-menu-bar > menuitem > label,
+panel-applet > menubar > menuitem > label,
+gp-applet > menubar > menuitem > label,
+gp-applet > menubar > menuitem > box > label,
+gp-calendar-window label,
+#tasklist-button label,
+#clock-applet-button label,
+#showdesktop-button label {
+  font-weight: normal;
+  color: #ffffff;
+}
+
+.gnome-panel-menu-bar > menuitem:hover > label,
+.gnome-panel-menu-bar > menuitem:hover > image,
+panel-applet > menubar > menuitem:hover > label,
+panel-applet > menubar > menuitem:hover > image,
+gp-applet > menubar > menuitem:hover > .gp-text-color,
+gp-applet > menubar > menuitem:hover > box > .gp-text-color  {
+  color: #ffffff;
+}
+
+#tasklist-button:checked,
+#clock-applet-button:checked,
+#showdesktop-button:checked {
+  background-color: #000000;
+}
+
+#tasklist-button:checked label,
+#clock-applet-button:checked label,
+#showdesktop-button:checked label {
+  color: #ffffff;
+}
+
+wnck-pager:selected {
+  background-color: #000000;
+}
+
+gp-arrow-button {
+  border: 2px solid #7f7f7f;
+  background-color: #000000;
+}
+
+gp-arrow-button:hover {
+  background-color: #000000;
+}
+
+gp-arrow-button:active {
+  background-color: #ffffff;
+}
diff --git a/data/theme/HighContrast/gnome-panel.css b/data/theme/HighContrast/gnome-panel.css
index 5ad49ba3a..f03e95498 100644
--- a/data/theme/HighContrast/gnome-panel.css
+++ b/data/theme/HighContrast/gnome-panel.css
@@ -34,27 +34,14 @@ gp-calendar-window label,
 }
 
 .gnome-panel-menu-bar > menuitem:hover > label,
-panel-applet > menubar > menuitem:hover > label,
-gp-applet > menubar > menuitem:hover > label,
-gp-applet > menubar > menuitem:hover > box > label,
 .gnome-panel-menu-bar > menuitem:hover > image,
+panel-applet > menubar > menuitem:hover > label,
 panel-applet > menubar > menuitem:hover > image,
-gp-applet > menubar > menuitem:hover > image {
+gp-applet > menubar > menuitem:hover > .gp-text-color,
+gp-applet > menubar > menuitem:hover > box > .gp-text-color {
   color: #ffffff;
 }
 
-gp-applet.separator > separator {
-  margin: 2px 4px;
-}
-
-#tasklist-button,
-#clock-applet-button,
-#showdesktop-button {
-  padding: 0px 4px;
-  border: 0;
-  border-radius: 0;
-}
-
 #tasklist-button:checked,
 #clock-applet-button:checked,
 #showdesktop-button:checked {
@@ -71,24 +58,9 @@ wnck-pager:selected {
   background-color: #000000;
 }
 
-na-tray-applet {
-  -NaTrayApplet-icon-padding: 2;
-  -NaTrayApplet-icon-size: 16;
-}
-
 gp-arrow-button {
-  min-width: 20px;
-  min-height: 0px;
-
   border: 2px solid #7f7f7f;
-  border-radius: 3px;
   background-color: #ffffff;
-  margin: 2px;
-}
-
-.vertical gp-arrow-button {
-  min-width: 0px;
-  min-height: 20px;
 }
 
 gp-arrow-button:hover {
@@ -98,11 +70,3 @@ gp-arrow-button:hover {
 gp-arrow-button:active {
   background-color: #000000;
 }
-
-.horizontal sn-item {
-  padding: 0px 3px;
-}
-
-.vertical sn-item {
-  padding: 3px 0px;
-}
diff --git a/data/theme/common.css b/data/theme/common.css
index 078ad40f6..63584cb16 100644
--- a/data/theme/common.css
+++ b/data/theme/common.css
@@ -50,3 +50,40 @@ panel-toplevel.horizontal gp-menu-button .icon {
 panel-toplevel.vertical gp-menu-button .icon {
   padding: 4px 0;
 }
+
+na-tray-applet {
+  -NaTrayApplet-icon-padding: 2;
+  -NaTrayApplet-icon-size: 16;
+}
+
+gp-applet.separator > separator {
+  margin: 2px 4px;
+}
+
+.horizontal sn-item {
+  padding: 0px 3px;
+}
+
+.vertical sn-item {
+  padding: 3px 0px;
+}
+
+#tasklist-button,
+#clock-applet-button,
+#showdesktop-button {
+  padding: 0px 4px;
+  border: 0;
+  border-radius: 0;
+}
+
+gp-arrow-button {
+  min-width: 20px;
+  min-height: 0px;
+  border-radius: 3px;
+  margin: 2px;
+}
+
+.vertical gp-arrow-button {
+  min-width: 0px;
+  min-height: 20px;
+}
diff --git a/data/theme/fallback.css b/data/theme/fallback.css
index a955b949e..7379570ef 100644
--- a/data/theme/fallback.css
+++ b/data/theme/fallback.css
@@ -1,32 +1 @@
-.gp-image-menu-item > image {
-  min-height: 16px;
-  min-width: 16px;
-}
-
-.gp-image-menu-item:not(.image-only) > image:dir(ltr) {
-  margin-right: 5px;
-}
-
-.gp-image-menu-item:not(.image-only) > image:dir(rtl) {
-  margin-left: 5px;
-}
-
-panel-toplevel.left gp-applet > menubar > .gp-image-menu-item:not(.image-only) > image:dir(ltr) {
-  margin-right: 0px;
-  margin-top: 5px;
-}
-
-panel-toplevel.left gp-applet > menubar > .gp-image-menu-item:not(.image-only) > image:dir(rtl) {
-  margin-left: 0px;
-  margin-bottom: 5px;
-}
-
-panel-toplevel.right gp-applet > menubar > .gp-image-menu-item:not(.image-only) > image:dir(ltr) {
-  margin-right: 0px;
-  margin-bottom: 5px;
-}
-
-panel-toplevel.right gp-applet > menubar > .gp-image-menu-item:not(.image-only) > image:dir(rtl) {
-  margin-left: 0px;
-  margin-top: 5px;
-}
+@import url("resource:///org/gnome/gnome-panel/theme/common.css");
diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index 0843abb9b..29e0d7957 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -39,13 +39,72 @@ static const GOptionEntry options[] = {
   { NULL }
 };
 
+typedef struct
+{
+  const char *name;
+  const char *dir;
+  const char *variant;
+  gboolean    has_dark_variant;
+} GpSupportedTheme;
+
+static GpSupportedTheme supported_themes[] =
+{
+  { "Adwaita", "Adwaita", NULL, TRUE },
+  { "Adwaita-dark", "Adwaita", "dark", FALSE },
+  { "HighContrast", "HighContrast", NULL, FALSE },
+  { "HighContrastInverse", "HighContrast", "inverse", FALSE },
+  { NULL, NULL, FALSE, FALSE }
+};
+
+static char *
+get_theme_resource (GpSupportedTheme *theme,
+                    gboolean          prefer_dark)
+{
+  char *filename;
+  const char *resource_base;
+  char *resource;
+
+  if (theme->variant != NULL)
+    filename = g_strdup_printf ("gnome-panel-%s.css", theme->variant);
+  else if (theme->has_dark_variant && prefer_dark)
+    filename = g_strdup ("gnome-panel-dark.css");
+  else
+    filename = g_strdup ("gnome-panel.css");
+
+  resource_base = "/org/gnome/gnome-panel/theme";
+  resource = g_strdup_printf ("%s/%s/%s", resource_base, theme->dir, filename);
+  g_free (filename);
+
+  return resource;
+}
+
+static gboolean
+is_theme_supported (const char        *theme_name,
+                    GpSupportedTheme **theme)
+{
+  int i;
+
+  for (i = 0; supported_themes[i].name != NULL; i++)
+    {
+      if (g_strcmp0 (supported_themes[i].name, theme_name) == 0)
+        {
+          *theme = &supported_themes[i];
+          return TRUE;
+        }
+    }
+
+  return FALSE;
+}
+
 static void
 theme_changed (GtkSettings *settings,
+               GParamSpec  *pspec,
                gpointer     user_data)
 {
   GdkScreen *screen;
   gchar *theme_name;
   gboolean dark_theme;
+  GpSupportedTheme *theme;
   guint priority;
   gchar *resource;
   GtkCssProvider *css;
@@ -63,17 +122,15 @@ theme_changed (GtkSettings *settings,
                 "gtk-application-prefer-dark-theme", &dark_theme,
                 NULL);
 
-  if (g_strcmp0 (theme_name, "Adwaita") != 0 &&
-      g_strcmp0 (theme_name, "HighContrast") != 0)
+  if (is_theme_supported (theme_name, &theme))
     {
-      priority = GTK_STYLE_PROVIDER_PRIORITY_FALLBACK;
-      resource = g_strdup ("/org/gnome/gnome-panel/theme/fallback.css");
+      resource = get_theme_resource (theme, dark_theme);
+      priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
     }
   else
     {
-      priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
-      resource = g_strdup_printf ("/org/gnome/gnome-panel/theme/%s/gnome-panel%s.css",
-                                  theme_name, dark_theme ? "-dark" : "");
+      resource = g_strdup ("/org/gnome/gnome-panel/theme/fallback.css");
+      priority = GTK_STYLE_PROVIDER_PRIORITY_FALLBACK;
     }
 
   css = gtk_css_provider_new ();
@@ -106,7 +163,7 @@ theme_variant_changed_cb (GSettings   *settings,
                     variant == PANEL_THEME_VARIANT_DARK, NULL);
     }
 
-  theme_changed (gtk_settings, NULL);
+  theme_changed (gtk_settings, NULL, NULL);
 }
 
 static gboolean
diff --git a/gnome-panel/panel.gresource.xml b/gnome-panel/panel.gresource.xml
index 784b49abd..9e2525361 100644
--- a/gnome-panel/panel.gresource.xml
+++ b/gnome-panel/panel.gresource.xml
@@ -4,7 +4,7 @@
     <file alias="Adwaita/gnome-panel.css">../data/theme/Adwaita/gnome-panel.css</file>
     <file alias="Adwaita/gnome-panel-dark.css">../data/theme/Adwaita/gnome-panel-dark.css</file>
     <file alias="HighContrast/gnome-panel.css">../data/theme/HighContrast/gnome-panel.css</file>
-    <file alias="HighContrast/gnome-panel-dark.css">../data/theme/HighContrast/gnome-panel-dark.css</file>
+    <file 
alias="HighContrast/gnome-panel-inverse.css">../data/theme/HighContrast/gnome-panel-inverse.css</file>
     <file alias="common.css">../data/theme/common.css</file>
     <file alias="fallback.css">../data/theme/fallback.css</file>
   </gresource>


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