[glide] Start to make a proper list store for themes



commit 9bebcf69110dd96a10b7efdca5f1850a5c492f0a
Author: Robert Carr <racarr Valentine localdomain>
Date:   Tue May 25 14:50:03 2010 -0400

    Start to make a proper list store for themes

 libglide/glide-theme-chooser.c |   41 ++++++++++++++++++++++++++++++++++++++++
 libglide/glide-theme-manager.c |    4 +-
 libglide/glide-window.c        |    2 +-
 3 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/libglide/glide-theme-chooser.c b/libglide/glide-theme-chooser.c
index 6fcad2f..366a2be 100644
--- a/libglide/glide-theme-chooser.c
+++ b/libglide/glide-theme-chooser.c
@@ -75,6 +75,45 @@ glide_theme_chooser_set_property (GObject *object,
     }
 }
 
+static GtkListStore *
+glide_theme_chooser_get_list_store (GlideThemeChooser *chooser)
+{
+  GtkListStore *ret = gtk_list_store_new (1, G_TYPE_STRING);
+  GtkTreeIter iter;
+  GList *t;
+  
+  for (t = chooser->priv->themes; t; t = t->next)
+    {
+      GlideTheme *theme = (GlideTheme *)t->data;
+      const gchar *name;
+      
+      if (!theme)
+	continue;
+      name = glide_theme_get_name (theme);
+      
+      gtk_list_store_append (ret, &iter);
+      gtk_list_store_set (ret, &iter, 0, name, -1);
+    }
+  return ret;
+}
+
+static GtkWidget *
+glide_theme_chooser_make_treeview (GlideThemeChooser *chooser)
+{
+  GtkWidget *ret = gtk_tree_view_new ();
+  
+  gtk_tree_view_set_model (GTK_TREE_VIEW (ret), GTK_TREE_MODEL (glide_theme_chooser_get_list_store (chooser)));
+  return ret;
+}
+
+static void
+glide_theme_chooser_setup_ui (GlideThemeChooser *chooser)
+{
+  GtkWidget *tree_view = glide_theme_chooser_make_treeview (chooser);
+  
+  gtk_container_add (GTK_CONTAINER (chooser), tree_view);
+}
+
 static void
 glide_theme_chooser_init (GlideThemeChooser *chooser)
 {
@@ -84,6 +123,8 @@ glide_theme_chooser_init (GlideThemeChooser *chooser)
   glide_theme_manager_refresh_theme_list ();
   glide_theme_manager_load_all ();
   chooser->priv->themes = glide_theme_manager_get_themes ();
+  
+  glide_theme_chooser_setup_ui (chooser);
 }
 
 static void
diff --git a/libglide/glide-theme-manager.c b/libglide/glide-theme-manager.c
index d85d6bc..8d13291 100644
--- a/libglide/glide-theme-manager.c
+++ b/libglide/glide-theme-manager.c
@@ -32,7 +32,7 @@ static GHashTable *loaded_themes = NULL;
 GList *
 glide_theme_manager_get_themes ()
 {
-  return g_hash_table_get_keys (loaded_themes);
+  return g_hash_table_get_values (loaded_themes);
 }
 
 static gboolean
@@ -61,7 +61,7 @@ glide_theme_manager_load_theme (const gchar *theme_path)
   GlideTheme *ret;
   
   if (G_UNLIKELY (loaded_themes == NULL))
-    loaded_themes = g_hash_table_new (g_str_hash, g_direct_equal);
+    loaded_themes = g_hash_table_new (g_str_hash, g_str_equal);
 
   if (ret = g_hash_table_lookup (loaded_themes, theme_path)){}
   else
diff --git a/libglide/glide-window.c b/libglide/glide-window.c
index ec61988..017f0f2 100644
--- a/libglide/glide-window.c
+++ b/libglide/glide-window.c
@@ -434,7 +434,7 @@ glide_window_new_document_real (GlideWindow *w)
   GlideSlide *s;
   GtkWidget *chooser = glide_theme_chooser_new ();
 
-  gtk_widget_show (chooser);
+  gtk_widget_show_all (chooser);
 
   glide_window_set_document (w, d);
   s = glide_document_append_slide (d);



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