[gnome-flashback] data: add theme directory



commit d5b783c40e81efd08c77412813f4e7aef3389db4
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Dec 28 07:28:52 2015 +0200

    data: add theme directory

 configure.ac                                     |    3 +
 data/Makefile.am                                 |    1 +
 data/theme/Adwaita/Makefile.am                   |    8 +++
 data/theme/Adwaita/gnome-flashback-dark.css      |    1 +
 data/theme/Adwaita/gnome-flashback.css           |    1 +
 data/theme/HighContrast/Makefile.am              |    8 +++
 data/theme/HighContrast/gnome-flashback-dark.css |    2 +
 data/theme/HighContrast/gnome-flashback.css      |    1 +
 data/theme/Makefile.am                           |    8 +++
 gnome-flashback/flashback.gresource.xml          |    6 ++
 gnome-flashback/gf-application.c                 |   65 ++++++++++-----------
 11 files changed, 70 insertions(+), 34 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dcfd2b1..dc9a045 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,6 +251,9 @@ AC_CONFIG_FILES([
   data/menus/Makefile
   data/schemas/Makefile
   data/sessions/Makefile
+  data/theme/Makefile
+  data/theme/Adwaita/Makefile
+  data/theme/HighContrast/Makefile
   data/xsessions/Makefile
 
   gnome-flashback/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index c6ed0fe..31130aa 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,6 +7,7 @@ SUBDIRS = \
        menus \
        schemas \
        sessions \
+       theme \
        xsessions \
        $(NULL)
 
diff --git a/data/theme/Adwaita/Makefile.am b/data/theme/Adwaita/Makefile.am
new file mode 100644
index 0000000..69103ce
--- /dev/null
+++ b/data/theme/Adwaita/Makefile.am
@@ -0,0 +1,8 @@
+NULL =
+
+EXTRA_DIST = \
+       gnome-flashback.css \
+       gnome-flashback-dark.css \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/theme/Adwaita/gnome-flashback-dark.css b/data/theme/Adwaita/gnome-flashback-dark.css
new file mode 100644
index 0000000..6011e28
--- /dev/null
+++ b/data/theme/Adwaita/gnome-flashback-dark.css
@@ -0,0 +1 @@
+ import url("resource:///org/gnome/gnome-flashback/Adwaita.css");
diff --git a/data/theme/Adwaita/gnome-flashback.css b/data/theme/Adwaita/gnome-flashback.css
new file mode 100644
index 0000000..6011e28
--- /dev/null
+++ b/data/theme/Adwaita/gnome-flashback.css
@@ -0,0 +1 @@
+ import url("resource:///org/gnome/gnome-flashback/Adwaita.css");
diff --git a/data/theme/HighContrast/Makefile.am b/data/theme/HighContrast/Makefile.am
new file mode 100644
index 0000000..69103ce
--- /dev/null
+++ b/data/theme/HighContrast/Makefile.am
@@ -0,0 +1,8 @@
+NULL =
+
+EXTRA_DIST = \
+       gnome-flashback.css \
+       gnome-flashback-dark.css \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/theme/HighContrast/gnome-flashback-dark.css 
b/data/theme/HighContrast/gnome-flashback-dark.css
new file mode 100644
index 0000000..9cb298a
--- /dev/null
+++ b/data/theme/HighContrast/gnome-flashback-dark.css
@@ -0,0 +1,2 @@
+/* HightContrast theme does not have dark variant. */
+ import url("resource:///org/gnome/gnome-flashback/theme/HighContrast/gnome-panel.css");
diff --git a/data/theme/HighContrast/gnome-flashback.css b/data/theme/HighContrast/gnome-flashback.css
new file mode 100644
index 0000000..a63d3e8
--- /dev/null
+++ b/data/theme/HighContrast/gnome-flashback.css
@@ -0,0 +1 @@
+ import url("resource:///org/gnome/gnome-flashback/HighContrast.css");
diff --git a/data/theme/Makefile.am b/data/theme/Makefile.am
new file mode 100644
index 0000000..9765ab1
--- /dev/null
+++ b/data/theme/Makefile.am
@@ -0,0 +1,8 @@
+NULL =
+
+SUBDIRS = \
+       Adwaita \
+       HighContrast \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/flashback.gresource.xml b/gnome-flashback/flashback.gresource.xml
index fce86b0..1d7b838 100644
--- a/gnome-flashback/flashback.gresource.xml
+++ b/gnome-flashback/flashback.gresource.xml
@@ -1,5 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
+  <gresource prefix="/org/gnome/gnome-flashback/theme">
+    <file alias="Adwaita/gnome-flashback.css">../data/theme/Adwaita/gnome-flashback.css</file>
+    <file alias="Adwaita/gnome-flashback-dark.css">../data/theme/Adwaita/gnome-flashback-dark.css</file>
+    <file alias="HighContrast/gnome-flashback.css">../data/theme/HighContrast/gnome-flashback.css</file>
+    <file 
alias="HighContrast/gnome-flashback-dark.css">../data/theme/HighContrast/gnome-flashback-dark.css</file>
+  </gresource>
   <gresource prefix="/org/gnome/gnome-flashback">
     <file>Adwaita.css</file>
     <file>HighContrast.css</file>
diff --git a/gnome-flashback/gf-application.c b/gnome-flashback/gf-application.c
index 655df98..7b22e0e 100644
--- a/gnome-flashback/gf-application.c
+++ b/gnome-flashback/gf-application.c
@@ -48,7 +48,7 @@ struct _GfApplication
 
   GSettings              *settings;
 
-  GtkCssProvider         *provider;
+  GtkStyleProvider       *provider;
 
   GsdAutomountManager    *automount;
   FlashbackDisplayConfig *config;
@@ -73,54 +73,53 @@ struct _GfApplication
 G_DEFINE_TYPE (GfApplication, gf_application, G_TYPE_OBJECT)
 
 static void
-remove_style_provider (GfApplication *application,
-                       GdkScreen     *screen)
-{
-  GtkStyleProvider *provider;
-
-  if (application->provider == NULL)
-    return;
-
-  provider = GTK_STYLE_PROVIDER (application->provider);
-  gtk_style_context_remove_provider_for_screen (screen, provider);
-  g_clear_object (&application->provider);
-}
-
-static void
 theme_changed (GtkSettings *settings,
                GParamSpec  *pspec,
                gpointer     user_data)
 {
   GfApplication *application;
   GdkScreen *screen;
-  gchar *theme;
+  gchar *theme_name;
+  gboolean dark_theme;
+  guint priority;
+  gchar *resource;
+  GtkCssProvider *css;
 
   application = GF_APPLICATION (user_data);
   screen = gdk_screen_get_default ();
 
-  g_object_get (settings, "gtk-theme-name", &theme, NULL);
+  if (application->provider != NULL)
+    {
+      gtk_style_context_remove_provider_for_screen (screen, application->provider);
+      g_clear_object (&application->provider);
+    }
 
-  remove_style_provider (application, screen);
+  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;
-      GtkStyleProvider *provider;
-      gint priority;
+      g_free (theme_name);
+      return;
+    }
 
-      application->provider = gtk_css_provider_new ();
+  g_object_get (settings,
+                "gtk-application-prefer-dark-theme", &dark_theme,
+                NULL);
 
-      resource = g_strdup_printf ("/org/gnome/gnome-flashback/%s.css", theme);
-      gtk_css_provider_load_from_resource (application->provider, resource);
-      g_free (resource);
+  priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
+  resource = g_strdup_printf ("/org/gnome/gnome-flashback/theme/%s/gnome-flashback%s.css",
+                              theme_name, dark_theme ? "-dark" : "");
 
-      provider = GTK_STYLE_PROVIDER (application->provider);
-      priority = GTK_STYLE_PROVIDER_PRIORITY_APPLICATION;
+  css = gtk_css_provider_new ();
+  application->provider =  GTK_STYLE_PROVIDER (css);
 
-      gtk_style_context_add_provider_for_screen (screen, provider, priority);
-    }
+  gtk_css_provider_load_from_resource (css, resource);
+  gtk_style_context_add_provider_for_screen (screen, application->provider,
+                                             priority);
 
-  g_free (theme);
+  g_free (theme_name);
+  g_free (resource);
 }
 
 static void
@@ -175,10 +174,8 @@ static void
 gf_application_dispose (GObject *object)
 {
   GfApplication *application;
-  GdkScreen *screen;
 
   application = GF_APPLICATION (object);
-  screen = gdk_screen_get_default ();
 
   if (application->bus_name)
     {
@@ -188,7 +185,7 @@ gf_application_dispose (GObject *object)
 
   g_clear_object (&application->settings);
 
-  remove_style_provider (application, screen);
+  g_clear_object (&application->provider);
 
   g_clear_object (&application->automount);
   g_clear_object (&application->config);


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