[glide] Use new theme manager stuff to set default theme



commit 9fd8b0a609b33dbbed629fe27988525689749a6a
Author: Robert Carr <racarr Valentine localdomain>
Date:   Tue May 25 14:02:37 2010 -0400

    Use new theme manager stuff to set default theme

 data/themes/default/Makefile.am |    2 +-
 libglide/glide-theme-manager.c  |   40 ++++++++++++++++++++++++++++++++++++--
 libglide/glide-theme-manager.h  |    6 ++++-
 libglide/glide.c                |   10 ++------
 4 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/data/themes/default/Makefile.am b/data/themes/default/Makefile.am
index 9d50619..b7bf476 100644
--- a/data/themes/default/Makefile.am
+++ b/data/themes/default/Makefile.am
@@ -1,4 +1,4 @@
-themedir=$(datadir)/glide/themes/default
+themedir=$(datadir)/glide/themes
 theme_DATA = default.glide-theme
 
 theme_FILES = theme.json background.png
diff --git a/libglide/glide-theme-manager.c b/libglide/glide-theme-manager.c
index 3de6ba5..7bf40e3 100644
--- a/libglide/glide-theme-manager.c
+++ b/libglide/glide-theme-manager.c
@@ -29,8 +29,28 @@
 static GList *themes = NULL;
 static GHashTable *loaded_themes = NULL;
 
+static gboolean
+glide_theme_manager_theme_hash_find (gpointer key,
+				     gpointer value,
+				     gpointer user_data)
+{
+  const gchar *theme_path = (const gchar *)key;
+  GlideTheme *theme = (GlideTheme *)value;
+  const gchar *name = (const gchar *)user_data;
+  
+  if (!strcmp (glide_theme_get_name (theme), name))
+    return TRUE;
+  return FALSE;
+}
+
+GlideTheme *
+glide_theme_manager_get_theme (const gchar *theme_name)
+{
+  return g_hash_table_find (loaded_themes, (GHRFunc)glide_theme_manager_theme_hash_find, (gpointer)theme_name);
+}
+
 GlideTheme *
-glide_theme_manager_get_theme (const gchar *theme_path)
+glide_theme_manager_load_theme (const gchar *theme_path)
 {
   GlideTheme *ret;
   
@@ -47,6 +67,18 @@ glide_theme_manager_get_theme (const gchar *theme_path)
 }
 
 void
+glide_theme_manager_load_all ()
+{
+  GList *t;
+  
+  for (t = themes; t; t = t->next)
+    {
+      const gchar *p = (const gchar *)t->data;
+      glide_theme_manager_load_theme (p);
+    }
+}
+
+void
 glide_theme_manager_refresh_theme_list ()
 {
   GDir *dir;
@@ -80,8 +112,10 @@ glide_theme_manager_refresh_theme_list ()
       
       if (g_str_has_suffix (theme_file, "glide-theme"))
 	{
-	  GLIDE_NOTE (THEME_MANAGER, "Found theme: %s", theme_file);
-	  themes = g_list_append (themes, g_strdup(theme_file));
+	  gchar *full_path = g_build_filename (theme_dir, theme_file, NULL);
+
+	  GLIDE_NOTE (THEME_MANAGER, "Found theme: %s",full_path);
+	  themes = g_list_append (themes, full_path);
 	}
     }
 
diff --git a/libglide/glide-theme-manager.h b/libglide/glide-theme-manager.h
index c6ff510..13e9209 100644
--- a/libglide/glide-theme-manager.h
+++ b/libglide/glide-theme-manager.h
@@ -24,7 +24,11 @@
 
 G_BEGIN_DECLS
 
-GlideTheme *glide_theme_manager_get_theme (const gchar *theme_path);
+GlideTheme *glide_theme_manager_get_theme (const gchar *theme_name);
+
+GlideTheme *glide_theme_manager_load_theme (const gchar *theme_path);
+void glide_theme_manager_load_all ();
+
 void glide_theme_manager_refresh_theme_list ();
 
 G_END_DECLS
diff --git a/libglide/glide.c b/libglide/glide.c
index b6df91c..865cf40 100644
--- a/libglide/glide.c
+++ b/libglide/glide.c
@@ -118,13 +118,10 @@ glide_parse_args (int *argc, char ***argv)
 static void
 glide_load_default_theme ()
 {
-  gchar *theme_dir = glide_dirs_get_glide_theme_dir ();
-  gchar *theme_path = g_strconcat (theme_dir, "/default/default.glide-theme", NULL);
-  
-  default_theme = glide_theme_new (theme_path);
+  glide_theme_manager_refresh_theme_list ();
+  glide_theme_manager_load_all ();
   
-  g_free (theme_dir);
-  g_free (theme_path);
+  default_theme = glide_theme_manager_get_theme ("Default Glide Theme");
 }
 
 /**
@@ -143,7 +140,6 @@ glide_init (int *argc, char ***argv)
   gboolean res = glide_parse_args (argc, argv);
 
   glide_animation_manager_register_animations ();
-  glide_theme_manager_refresh_theme_list ();
   glide_load_default_theme ();
 
   return res;



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