[glide] Some cleanup and refactoring to theme chooser code



commit 88a64577bc0fe9614ec07e67e78d01189472ecb6
Author: Robert Carr <racarr Valentine localdomain>
Date:   Tue May 25 15:58:26 2010 -0400

    Some cleanup and refactoring to theme chooser code

 libglide/glide-theme-chooser-priv.h |    1 +
 libglide/glide-theme-chooser.c      |   40 ++++++++++++++++++++++++++--------
 2 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/libglide/glide-theme-chooser-priv.h b/libglide/glide-theme-chooser-priv.h
index 6a27a04..4569c2e 100644
--- a/libglide/glide-theme-chooser-priv.h
+++ b/libglide/glide-theme-chooser-priv.h
@@ -29,6 +29,7 @@ struct _GlideThemeChooserPrivate
   GList *themes;
   
   GtkWidget *preview;
+  GtkWidget *tree_view;
   
   GlideTheme *theme;
 };
diff --git a/libglide/glide-theme-chooser.c b/libglide/glide-theme-chooser.c
index 7f10ee6..048cc28 100644
--- a/libglide/glide-theme-chooser.c
+++ b/libglide/glide-theme-chooser.c
@@ -90,32 +90,43 @@ glide_theme_chooser_set_property (GObject *object,
     }
 }
 
-static void
-glide_theme_chooser_cursor_changed (GtkTreeView *tree_view, 
-				    gpointer user_data)
+static GlideTheme *
+glide_theme_chooser_get_selection (GlideThemeChooser *chooser)
 {
-  GlideThemeChooser *chooser = (GlideThemeChooser *)user_data;
   GtkTreePath *path;
   GtkTreeModel *model;
   GtkTreeIter iter;
+  GlideTheme *theme = NULL;
+
   
-  gtk_tree_view_get_cursor (tree_view, &path, NULL);
-  model = gtk_tree_view_get_model (tree_view);
+  gtk_tree_view_get_cursor (GTK_TREE_VIEW (chooser->priv->tree_view), &path, NULL);
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (chooser->priv->tree_view));
   
   if (gtk_tree_model_get_iter (model, &iter, path))
     {
-      GlideTheme *theme;
       gchar *name;
       
       gtk_tree_model_get (model, &iter, 0, &name, -1);
       
       theme = glide_theme_manager_get_theme (name);
-      glide_theme_preview_set_theme (GLIDE_THEME_PREVIEW (chooser->priv->preview), theme);
       g_free (name);
-
-      GLIDE_NOTE(THEME_CHOOSER, "Theme selected: %s", name);
     }
   
+  return theme;
+}
+
+static void
+glide_theme_chooser_cursor_changed (GtkTreeView *tree_view, 
+				    gpointer user_data)
+{
+  GlideThemeChooser *chooser = (GlideThemeChooser *)user_data;
+  GlideTheme *theme = glide_theme_chooser_get_selection (chooser);
+
+  if (theme)
+    {
+      glide_theme_preview_set_theme (GLIDE_THEME_PREVIEW (chooser->priv->preview), theme);
+      GLIDE_NOTE(THEME_CHOOSER, "Theme selected: %s", glide_theme_get_name (theme));
+    }  
 }
 
 static GtkListStore *
@@ -154,6 +165,8 @@ glide_theme_chooser_make_treeview (GlideThemeChooser *chooser)
   
   g_signal_connect (ret, "cursor-changed", G_CALLBACK (glide_theme_chooser_cursor_changed), chooser);
   
+  chooser->priv->tree_view = ret;
+  
   return ret;
 }
 
@@ -176,6 +189,13 @@ glide_theme_chooser_make_top_hbox (GlideThemeChooser *chooser)
   return ret;  
 }
 
+static void
+glide_theme_chooser_new_clicked (GtkWidget *button,
+				 gpointer user_data)
+{
+  GlideThemeChooser *chooser = (GlideThemeChooser *)user_data;
+}
+
 static GtkWidget *
 glide_theme_chooser_make_bottom_hbox (GlideThemeChooser *chooser)
 {



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