[gnome-panel] data: add theme directory



commit 9c45e43f8bdfb5764dee3409dff92263906e6f80
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Dec 21 01:58:00 2015 +0200

    data: add theme directory

 configure.ac                                 |    4 ++
 data/Makefile.am                             |    7 +++-
 data/theme/Adwaita/Makefile.am               |    8 +++
 data/theme/Adwaita/gnome-panel-dark.css      |    2 +
 data/theme/Adwaita/gnome-panel.css           |    2 +
 data/theme/HighContrast/Makefile.am          |    8 +++
 data/theme/HighContrast/gnome-panel-dark.css |    2 +
 data/theme/HighContrast/gnome-panel.css      |    2 +
 data/theme/Makefile.am                       |   12 +++++
 data/theme/common.css                        |    1 +
 gnome-panel/main.c                           |   63 ++++++++++++++------------
 gnome-panel/panel.gresource.xml              |    7 +++
 12 files changed, 88 insertions(+), 30 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5066e76..eb97374 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,6 +284,10 @@ AC_CONFIG_FILES([
   data/48x48/Makefile
   data/scalable/Makefile
 
+  data/theme/Makefile
+  data/theme/Adwaita/Makefile
+  data/theme/HighContrast/Makefile
+
   gnome-panel/Makefile
   gnome-panel/libpanel-applet-private/Makefile
   gnome-panel/libpanel-util/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 83f82e2..70e1ad5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,9 @@
-SUBDIRS = 16x16 22x22 24x24 32x32 48x48 scalable
+NULL =
+
+SUBDIRS = \
+       16x16 22x22 24x24 32x32 48x48 scalable \
+       theme \
+       $(NULL)
 
 gsettings_applets_schemas_in_in =                                              \
        org.gnome.gnome-panel.applet.fish.gschema.xml.in.in                     \
diff --git a/data/theme/Adwaita/Makefile.am b/data/theme/Adwaita/Makefile.am
new file mode 100644
index 0000000..2fc77be
--- /dev/null
+++ b/data/theme/Adwaita/Makefile.am
@@ -0,0 +1,8 @@
+NULL =
+
+EXTRA_DIST = \
+       gnome-panel.css \
+       gnome-panel-dark.css \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/theme/Adwaita/gnome-panel-dark.css b/data/theme/Adwaita/gnome-panel-dark.css
new file mode 100644
index 0000000..3224c1f
--- /dev/null
+++ b/data/theme/Adwaita/gnome-panel-dark.css
@@ -0,0 +1,2 @@
+ import url("resource:///org/gnome/panel/Adwaita.css");
+ import url("resource:///org/gnome/gnome-panel/theme/common.css");
diff --git a/data/theme/Adwaita/gnome-panel.css b/data/theme/Adwaita/gnome-panel.css
new file mode 100644
index 0000000..3224c1f
--- /dev/null
+++ b/data/theme/Adwaita/gnome-panel.css
@@ -0,0 +1,2 @@
+ import url("resource:///org/gnome/panel/Adwaita.css");
+ import url("resource:///org/gnome/gnome-panel/theme/common.css");
diff --git a/data/theme/HighContrast/Makefile.am b/data/theme/HighContrast/Makefile.am
new file mode 100644
index 0000000..2fc77be
--- /dev/null
+++ b/data/theme/HighContrast/Makefile.am
@@ -0,0 +1,8 @@
+NULL =
+
+EXTRA_DIST = \
+       gnome-panel.css \
+       gnome-panel-dark.css \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/theme/HighContrast/gnome-panel-dark.css b/data/theme/HighContrast/gnome-panel-dark.css
new file mode 100644
index 0000000..baabdd1
--- /dev/null
+++ b/data/theme/HighContrast/gnome-panel-dark.css
@@ -0,0 +1,2 @@
+/* HightContrast theme does not have dark variant. */
+ import url("resource:///org/gnome/gnome-panel/theme/HighContrast/gnome-panel.css");
diff --git a/data/theme/HighContrast/gnome-panel.css b/data/theme/HighContrast/gnome-panel.css
new file mode 100644
index 0000000..23c1340
--- /dev/null
+++ b/data/theme/HighContrast/gnome-panel.css
@@ -0,0 +1,2 @@
+ import url("resource:///org/gnome/panel/HighContrast.css");
+ import url("resource:///org/gnome/gnome-panel/theme/common.css");
diff --git a/data/theme/Makefile.am b/data/theme/Makefile.am
new file mode 100644
index 0000000..e2e06b0
--- /dev/null
+++ b/data/theme/Makefile.am
@@ -0,0 +1,12 @@
+NULL =
+
+SUBDIRS = \
+       Adwaita \
+       HighContrast \
+       $(NULL)
+
+EXTRA_DIST = \
+       common.css \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/theme/common.css b/data/theme/common.css
new file mode 100644
index 0000000..a66a439
--- /dev/null
+++ b/data/theme/common.css
@@ -0,0 +1 @@
+/* This file will be included in both themes - Adwaita and HighContrast. */
diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index 33fd58b..acae6d5 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -31,7 +31,7 @@ GSList *panel_list = NULL;
 
 static gboolean  replace = FALSE;
 static gboolean  version = FALSE;
-static GtkCssProvider *provider = NULL;
+static GtkStyleProvider *provider = NULL;
 
 static const GOptionEntry options[] = {
   { "replace", 0, 0, G_OPTION_ARG_NONE, &replace, N_("Replace a currently running panel"), NULL },
@@ -40,44 +40,49 @@ static const GOptionEntry options[] = {
 };
 
 static void
-remove_style_provider (GdkScreen *screen)
-{
-  GtkStyleProvider *style_provider;
-
-  if (provider == NULL)
-    return;
-
-  style_provider = GTK_STYLE_PROVIDER (provider);
-  gtk_style_context_remove_provider_for_screen (screen, style_provider);
-  g_clear_object (&provider);
-}
-
-static void
-theme_changed (GtkSettings *settings)
+theme_changed (GtkSettings *settings,
+               gpointer     user_data)
 {
   GdkScreen *screen;
-  gchar *theme;
+  gchar *theme_name;
+  gboolean dark_theme;
+  guint priority;
+  gchar *resource;
+  GtkCssProvider *css;
 
   screen = gdk_screen_get_default ();
-  g_object_get (settings, "gtk-theme-name", &theme, NULL);
 
-  remove_style_provider (screen);
+  if (provider != NULL)
+    {
+      gtk_style_context_remove_provider_for_screen (screen, provider);
+      g_clear_object (&provider);
+    }
+
+  g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
 
-  if (g_strcmp0 (theme, "Adwaita") == 0 || g_strcmp0 (theme, "HighContrast") == 0)
+  if (g_strcmp0 (theme_name, "Adwaita") != 0 &&
+      g_strcmp0 (theme_name, "HighContrast") != 0)
     {
-      gchar *resource;
+      g_free (theme_name);
+      return;
+    }
 
-      provider = gtk_css_provider_new ();
+  g_object_get (settings,
+                "gtk-application-prefer-dark-theme", &dark_theme,
+                NULL);
 
-      resource = g_strdup_printf ("/org/gnome/panel/%s.css", theme);
-      gtk_css_provider_load_from_resource (provider, resource);
-      g_free (resource);
+  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" : "");
 
-      gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
-                                                 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-    }
+  css = gtk_css_provider_new ();
+  provider = GTK_STYLE_PROVIDER (css);
+
+  gtk_css_provider_load_from_resource (css, resource);
+  gtk_style_context_add_provider_for_screen (screen, provider, priority);
 
-  g_free (theme);
+  g_free (theme_name);
+  g_free (resource);
 }
 
 static gboolean
@@ -162,7 +167,7 @@ main (int argc, char **argv)
 
        settings = gtk_settings_get_default ();
        g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (theme_changed), NULL);
-       theme_changed (settings);
+       theme_changed (settings, NULL);
 
        gtk_main ();
 
diff --git a/gnome-panel/panel.gresource.xml b/gnome-panel/panel.gresource.xml
index ee9c420..58dceb0 100644
--- a/gnome-panel/panel.gresource.xml
+++ b/gnome-panel/panel.gresource.xml
@@ -1,5 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
+  <gresource prefix="/org/gnome/gnome-panel/theme">
+    <file alias="common.css">../data/theme/common.css</file>
+    <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>
+  </gresource>
   <gresource prefix="/org/gnome/panel">
     <file compressed="true">panel-addto-dialog.ui</file>
     <file compressed="true">panel-properties-dialog.ui</file>


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