[libdazzle] shortcuts: search for default them if theme is not set



commit 3a66f2daa8cff13c68789bd66d2c8b1e8f052b13
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 12 23:46:30 2017 -0700

    shortcuts: search for default them if theme is not set
    
    If we do not have priv->theme set, we need to resolve it from the loaded
    themes. If we fail to find that, return the internal theme as a last
    resort.

 src/shortcuts/dzl-shortcut-manager.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-manager.c b/src/shortcuts/dzl-shortcut-manager.c
index 98aeb5f..a28a5a9 100644
--- a/src/shortcuts/dzl-shortcut-manager.c
+++ b/src/shortcuts/dzl-shortcut-manager.c
@@ -489,12 +489,21 @@ dzl_shortcut_manager_get_theme (DzlShortcutManager *self)
 
   priv = dzl_shortcut_manager_get_instance_private (self);
 
-  if (priv->theme == NULL)
-    priv->theme = g_object_new (DZL_TYPE_SHORTCUT_THEME,
-                                "name", "default",
-                                NULL);
+  if G_LIKELY (priv->theme != NULL)
+    return priv->theme;
+
+  for (guint i = 0; i < priv->themes->len; i++)
+    {
+      DzlShortcutTheme *theme = g_ptr_array_index (priv->themes, i);
 
-  return priv->theme;
+      if (g_strcmp0 (dzl_shortcut_theme_get_name (theme), "default") == 0)
+        {
+          priv->theme = g_object_ref (theme);
+          return priv->theme;
+        }
+    }
+
+  return priv->internal_theme;
 }
 
 /**


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