[libdazzle] theming: start unifying how we load theme data for libdazzle



commit 22bfc1c604ec3f71a61c3e68e2fa0629444c79e2
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 5 02:44:32 2017 -0700

    theming: start unifying how we load theme data for libdazzle
    
    This also switches back to "themes" instead of "css" for the theming
    directory. I find that a bit easier to remember.
    
    This moves a bunch of the theming stuff into a data directory which will
    hopefully be easy to get contributors to add new theming support. One of
    the main reasons Builder looks so poor on non-Adwaita is that we need to
    encourage themes to help us out here, given all the custom widgets.
    
    Although, maybe with dazzle broken out of Builder, it will be easier for
    them to just support it from their theming files.

 data/themes/Adwaita.css                            |    5 ++
 .../themes/Adwaita/Adwaita-panels.css              |    0
 data/themes/shared.css                             |    4 ++
 .../themes/shared/shared-progressbutton.css        |    0
 data/themes/shared/shared-stacklist.css            |   37 ++++++++++++++
 data/themes/shared/shared-suggestions.css          |   53 ++++++++++++++++++++
 src/dazzle.gresources.xml                          |   14 ++++--
 src/suggestions/dzl-suggestion-entry.c             |    2 -
 src/suggestions/dzl-suggestion-entry.css           |   53 --------------------
 src/suggestions/dzl-suggestion-popover.c           |    2 +-
 src/theming/dzl-theme-manager.c                    |   12 ++--
 src/widgets/dzl-progress-button.c                  |    3 -
 src/widgets/dzl-stack-list.c                       |    3 +-
 src/widgets/dzl-stack-list.css                     |   37 --------------
 14 files changed, 117 insertions(+), 108 deletions(-)
---
diff --git a/data/themes/Adwaita.css b/data/themes/Adwaita.css
new file mode 100644
index 0000000..7e13657
--- /dev/null
+++ b/data/themes/Adwaita.css
@@ -0,0 +1,5 @@
+/* Theme agnostic or base-layer CSS styling */
+@import url("resource:///org/gnome/dazzle/themes/shared.css");
+
+/* Theme specific styling */
+@import url("resource:///org/gnome/dazzle/themes/Adwaita/Adwaita-panels.css");
diff --git a/src/panel/Adwaita.css b/data/themes/Adwaita/Adwaita-panels.css
similarity index 100%
rename from src/panel/Adwaita.css
rename to data/themes/Adwaita/Adwaita-panels.css
diff --git a/data/themes/shared.css b/data/themes/shared.css
new file mode 100644
index 0000000..2233134
--- /dev/null
+++ b/data/themes/shared.css
@@ -0,0 +1,4 @@
+/* Theme agnostic or base-layer CSS styling */
+@import url("resource:///org/gnome/dazzle/themes/shared/shared-progressbutton.css");
+@import url("resource:///org/gnome/dazzle/themes/shared/shared-stacklist.css");
+@import url("resource:///org/gnome/dazzle/themes/shared/shared-suggestions.css");
diff --git a/src/widgets/dzl-progress-button.css b/data/themes/shared/shared-progressbutton.css
similarity index 100%
rename from src/widgets/dzl-progress-button.css
rename to data/themes/shared/shared-progressbutton.css
diff --git a/data/themes/shared/shared-stacklist.css b/data/themes/shared/shared-stacklist.css
new file mode 100644
index 0000000..14e0e07
--- /dev/null
+++ b/data/themes/shared/shared-stacklist.css
@@ -0,0 +1,37 @@
+dzlstacklist row {
+  padding: 3px 0;
+  color: @theme_fg_color;
+}
+dzlstacklist row label.dim-label {
+  font-size: smaller;
+}
+dzlstacklist row:backdrop {
+  color: @theme_unfocused_fg_color;
+}
+dzlstacklist row image {
+  margin: 6px 12px;
+  min-height: 16px;
+  min-width: 16px;
+  opacity: 0.7;
+}
+dzlstacklist list.stack-header {
+  background-color: @theme_base_color;
+  border-bottom: 1px solid @borders;
+}
+dzlstacklist list.stack-header:backdrop {
+  background-color: @theme_unfocused_base_color;
+  border-color: @unfocused_borders;
+}
+dzlstacklist list.stack-header row:not(:last-child) {
+  border-bottom: 1px solid rgba(0,0,0,0.1);
+}
+dzlstacklist list:not(.stack-header) row:active,
+dzlstacklist list:not(.stack-header) row:selected,
+dzlstacklist list.stack-header row:not(:last-child):active,
+dzlstacklist list.stack-header row:not(:last-child):selected {
+  color: @theme_selected_fg_color;
+  background-color: @theme_selected_bg_color;
+}
+dzlstacklist list.stack-header row:last-child label:not(.dim-label) {
+  font-weight: bold;
+}
diff --git a/data/themes/shared/shared-suggestions.css b/data/themes/shared/shared-suggestions.css
new file mode 100644
index 0000000..21ef977
--- /dev/null
+++ b/data/themes/shared/shared-suggestions.css
@@ -0,0 +1,53 @@
+dzlsuggestionpopover {
+  background: transparent;
+}
+
+dzlsuggestionpopover > revealer > box {
+  margin: 0px 0px 60px 0px;
+  border-radius: 0 0 7px 7px;
+  border: 1px solid @borders;
+  border-top: none;
+  box-shadow: 0px -10px 30px #000;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow {
+  background: alpha(@content_view_bg, 0.95);
+  border-radius: 0 0 7px 7px;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list {
+  background: transparent;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row:first-child {
+  transition: none;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row {
+  transition: none;
+  border-bottom: 1px solid alpha(@borders, 0.2);
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row:selected .title {
+  color: @theme_selected_fg_color;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row .title {
+  color: @theme_selected_bg_color;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > 
row:first-child:selected {
+  border-radius: 0;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > 
row:last-child:selected:not(:first-child) {
+  border-radius: 0 0 7px 7px;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row > box {
+  margin: 4px 8px 4px 8px;
+}
+
+dzlsuggestionpopover > revealer > box > elastic > scrolledwindow > viewport > list > row:last-child {
+  border-bottom: none;
+}
diff --git a/src/dazzle.gresources.xml b/src/dazzle.gresources.xml
index 73eed6b..d6237f1 100644
--- a/src/dazzle.gresources.xml
+++ b/src/dazzle.gresources.xml
@@ -14,10 +14,16 @@
     <file compressed="true" preprocess="xml-stripblanks" 
alias="enter-keyboard-shortcut.svg">shortcuts/enter-keyboard-shortcut.svg</file>
   </gresource>
 
-  <gresource prefix="/org/gnome/dazzle/css">
-    <file compressed="true" alias="dzl-progress-button.css">widgets/dzl-progress-button.css</file>
-    <file compressed="true" alias="dzl-stack-list.css">widgets/dzl-stack-list.css</file>
-    <file compressed="true" alias="dzl-suggestion-entry.css">suggestions/dzl-suggestion-entry.css</file>
+  <gresource prefix="/org/gnome/dazzle/themes">
+    <!-- Adwaita CSS theme -->
+    <file compressed="true" alias="Adwaita.css">../data/themes/Adwaita.css</file>
+    <file compressed="true" 
alias="Adwaita/Adwaita-panels.css">../data/themes/Adwaita/Adwaita-panels.css</file>
+
+    <!-- Default and Fallback Theme -->
+    <file compressed="true" alias="shared.css">../data/themes/shared.css</file>
+    <file compressed="true" 
alias="shared/shared-progressbutton.css">../data/themes/shared/shared-progressbutton.css</file>
+    <file compressed="true" alias="shared-stacklist.css">../data/themes/shared/shared-stacklist.css</file>
+    <file compressed="true" 
alias="shared-suggestions.css">../data/themes/shared/shared-suggestions.css</file>
   </gresource>
 
 </gresources>
diff --git a/src/suggestions/dzl-suggestion-entry.c b/src/suggestions/dzl-suggestion-entry.c
index 83c4222..96b1b90 100644
--- a/src/suggestions/dzl-suggestion-entry.c
+++ b/src/suggestions/dzl-suggestion-entry.c
@@ -451,8 +451,6 @@ dzl_suggestion_entry_class_init (DzlSuggestionEntryClass *klass)
                                 G_CALLBACK (dzl_suggestion_entry_activate_suggestion),
                                 NULL, NULL, NULL, G_TYPE_NONE, 0);
 
-  dzl_gtk_widget_class_add_css_resource (widget_class, "/org/gnome/dazzle/css/dzl-suggestion-entry.css");
-
   bindings = gtk_binding_set_by_class (klass);
   gtk_binding_entry_add_signal (bindings, GDK_KEY_Escape, 0, "hide-suggestions", 0);
   gtk_binding_entry_add_signal (bindings, GDK_KEY_space, GDK_CONTROL_MASK, "show-suggestions", 0);
diff --git a/src/suggestions/dzl-suggestion-popover.c b/src/suggestions/dzl-suggestion-popover.c
index ac8a040..3763325 100644
--- a/src/suggestions/dzl-suggestion-popover.c
+++ b/src/suggestions/dzl-suggestion-popover.c
@@ -543,7 +543,7 @@ dzl_suggestion_popover_class_init (DzlSuggestionPopoverClass *klass)
   gtk_widget_class_bind_template_child (widget_class, DzlSuggestionPopover, list_box);
   gtk_widget_class_bind_template_child (widget_class, DzlSuggestionPopover, scrolled_window);
 
-  gtk_widget_class_set_css_name (widget_class, "suggestionpopover");
+  gtk_widget_class_set_css_name (widget_class, "dzlsuggestionpopover");
 
   g_type_ensure (DZL_TYPE_ELASTIC_BIN);
 }
diff --git a/src/theming/dzl-theme-manager.c b/src/theming/dzl-theme-manager.c
index 78805d3..9554b19 100644
--- a/src/theming/dzl-theme-manager.c
+++ b/src/theming/dzl-theme-manager.c
@@ -69,11 +69,11 @@ dzl_theme_manager_new (void)
  *
  * This will automatically register resources found within @resource_path.
  *
- * If the @resource_path contains a directory named "css", that directory will
- * be traversed for files matching the theme name and variant. For example, if
- * using the Adwaita theme, "css/Adwaita.css" will be loaded. If the dark
- * variant is being used, "css/Adwaita-dark.css" will be loaeded. If no
- * matching theme file is located, "css/shared.css" will be loaded.
+ * If the @resource_path contains a directory named "themes", that directory
+ * will be traversed for files matching the theme name and variant. For
+ * example, if using the Adwaita theme, "themes/Adwaita.css" will be loaded. If
+ * the dark variant is being used, "themes/Adwaita-dark.css" will be loaeded. If
+ * no matching theme file is located, "themes/shared.css" will be loaded.
  *
  * The "icons" sub-directory will be used to locate icon themes.
  */
@@ -93,7 +93,7 @@ dzl_theme_manager_add_resource_path (DzlThemeManager *self,
    * current application theme, using @resource_path/css as the base directory
    * to locate theming files.
    */
-  css_dir = g_build_filename (resource_path, "css", NULL);
+  css_dir = g_build_filename (resource_path, "themes", NULL);
   provider = dzl_css_provider_new (css_dir);
   g_hash_table_insert (self->providers_by_path, g_strdup (resource_path), g_object_ref (provider));
   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
diff --git a/src/widgets/dzl-progress-button.c b/src/widgets/dzl-progress-button.c
index ed5b36e..2c01152 100644
--- a/src/widgets/dzl-progress-button.c
+++ b/src/widgets/dzl-progress-button.c
@@ -175,7 +175,6 @@ static void
 dzl_progress_button_class_init (DzlProgressButtonClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->dispose = dzl_progress_button_dispose;
   object_class->get_property = dzl_progress_button_get_property;
@@ -190,8 +189,6 @@ dzl_progress_button_class_init (DzlProgressButtonClass *klass)
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
-
-  dzl_gtk_widget_class_add_css_resource (widget_class, "/org/gnome/dazzle/css/dzl-progress-button.css");
 }
 
 GtkWidget *
diff --git a/src/widgets/dzl-stack-list.c b/src/widgets/dzl-stack-list.c
index 1646a4b..480aa06 100644
--- a/src/widgets/dzl-stack-list.c
+++ b/src/widgets/dzl-stack-list.c
@@ -424,8 +424,7 @@ dzl_stack_list_class_init (DzlStackListClass *klass)
                   1,
                   GTK_TYPE_LIST_BOX_ROW);
 
-  gtk_widget_class_set_css_name (widget_class, "stacklist");
-  dzl_gtk_widget_class_add_css_resource (widget_class, "/org/gnome/dazzle/css/dzl-stack-list.css");
+  gtk_widget_class_set_css_name (widget_class, "dzlstacklist");
 }
 
 static void


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