[libgd] Move MainView.(un)select_all to MainViewGeneric



commit 52c4268dd9fb1a6a4251eec9ec164a535ede4bc9
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Oct 25 04:32:33 2012 +0300

    Move MainView.(un)select_all to MainViewGeneric
    
    MainView still keeps these methods but only as proxies.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686832

 libgd/gd-main-view-generic.c |   48 ++++++++++++++++++++++++++++++++++++++++++
 libgd/gd-main-view-generic.h |    2 +
 libgd/gd-main-view.c         |   29 +++---------------------
 3 files changed, 54 insertions(+), 25 deletions(-)
---
diff --git a/libgd/gd-main-view-generic.c b/libgd/gd-main-view-generic.c
index da7c888..6459b80 100644
--- a/libgd/gd-main-view-generic.c
+++ b/libgd/gd-main-view-generic.c
@@ -132,6 +132,54 @@ model_get_selection_uris (GtkTreeModel *model)
   return (gchar **) g_ptr_array_free (ptr_array, FALSE);
 }
 
+static gboolean
+set_selection_foreach (GtkTreeModel *model,
+                       GtkTreePath *path,
+                       GtkTreeIter *iter,
+                       gpointer user_data)
+{
+  gboolean selection = GPOINTER_TO_INT (user_data);
+
+  gtk_list_store_set (GTK_LIST_STORE (model), iter,
+                      GD_MAIN_COLUMN_SELECTED, selection,
+                      -1);
+
+  return FALSE;
+}
+
+static void
+set_all_selection (GdMainViewGeneric *self,
+                   GtkTreeModel *model,
+                   gboolean selection)
+{
+  GtkTreeModel *actual_model;
+
+  if (GTK_IS_TREE_MODEL_FILTER (model))
+    actual_model = gtk_tree_model_filter_get_model (model);
+  else
+    actual_model = model;
+
+  gtk_tree_model_foreach (actual_model,
+                          set_selection_foreach,
+                          GINT_TO_POINTER (selection));
+}
+
+void
+gd_main_view_generic_select_all (GdMainViewGeneric *self)
+{
+  GtkTreeModel *model = gd_main_view_generic_get_model (self);
+
+  set_all_selection (self, model, TRUE);
+}
+
+void
+gd_main_view_generic_unselect_all (GdMainViewGeneric *self)
+{
+  GtkTreeModel *model = gd_main_view_generic_get_model (self);
+
+  set_all_selection (self, model, FALSE);
+}
+
 void
 _gd_main_view_generic_dnd_common (GtkTreeModel *model,
                                   gboolean selection_mode,
diff --git a/libgd/gd-main-view-generic.h b/libgd/gd-main-view-generic.h
index 4e086c0..ffaaa6d 100644
--- a/libgd/gd-main-view-generic.h
+++ b/libgd/gd-main-view-generic.h
@@ -96,6 +96,8 @@ void gd_main_view_generic_set_selection_mode (GdMainViewGeneric *self,
 GtkTreePath * gd_main_view_generic_get_path_at_pos (GdMainViewGeneric *self,
                                                     gint x,
                                                     gint y);
+void gd_main_view_generic_select_all (GdMainViewGeneric *self);
+void gd_main_view_generic_unselect_all (GdMainViewGeneric *self);
 
 /* private */
 void _gd_main_view_generic_dnd_common (GtkTreeModel *model,
diff --git a/libgd/gd-main-view.c b/libgd/gd-main-view.c
index 8443eba..c9244c1 100644
--- a/libgd/gd-main-view.c
+++ b/libgd/gd-main-view.c
@@ -849,39 +849,18 @@ gd_main_view_get_selection (GdMainView *self)
   return g_list_reverse (retval);
 }
 
-static gboolean
-set_selection_foreach (GtkTreeModel *model,
-                       GtkTreePath *path,
-                       GtkTreeIter *iter,
-                       gpointer user_data)
-{
-  gboolean selection = GPOINTER_TO_INT (user_data);
-
-  gtk_list_store_set (GTK_LIST_STORE (model), iter,
-                      GD_MAIN_COLUMN_SELECTED, selection,
-                      -1);
-
-  return FALSE;
-}
-
 void
 gd_main_view_select_all (GdMainView *self)
 {
-  gboolean selection = TRUE;
+  GdMainViewGeneric *generic = get_generic (self);
 
-  gtk_tree_model_foreach (self->priv->model,
-                          set_selection_foreach,
-                          GINT_TO_POINTER (selection));
-  g_signal_emit (self, signals[VIEW_SELECTION_CHANGED], 0);
+  gd_main_view_generic_select_all (generic);
 }
 
 void
 gd_main_view_unselect_all (GdMainView *self)
 {
-  gboolean selection = FALSE;
+  GdMainViewGeneric *generic = get_generic (self);
 
-  gtk_tree_model_foreach (self->priv->model,
-                          set_selection_foreach,
-                          GINT_TO_POINTER (selection));
-  g_signal_emit (self, signals[VIEW_SELECTION_CHANGED], 0);
+  gd_main_view_generic_unselect_all (generic);
 }



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