[libpeas] Remove bad API from PeasGtkPluginManagerView



commit fa1aeb1ecb601e126644373c6b37f47b2dddae87
Author: Garrett Regier <alias301 gmail com>
Date:   Sat Mar 26 04:41:23 2011 -0700

    Remove bad API from PeasGtkPluginManagerView
    
    It would get or set the selected iter, but could return
    an iter that was meant to be used with the filter's model
    and not the view's model which made it awkward to use.

 libpeas-gtk/peas-gtk-plugin-manager-view.c |   73 +++++++---------------------
 libpeas-gtk/peas-gtk-plugin-manager-view.h |    5 --
 2 files changed, 17 insertions(+), 61 deletions(-)
---
diff --git a/libpeas-gtk/peas-gtk-plugin-manager-view.c b/libpeas-gtk/peas-gtk-plugin-manager-view.c
index e8289cd..009fcca 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager-view.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager-view.c
@@ -853,6 +853,7 @@ void
 peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view,
                                                gboolean                  show_builtin)
 {
+  GtkTreeSelection *selection;
   GtkTreeIter iter;
   gboolean iter_set;
 
@@ -863,9 +864,14 @@ peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view,
   if (view->priv->show_builtin == show_builtin)
     return;
 
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+
   /* We must get the selected iter before setting if builtin
      plugins should be shown so the proper model is set */
-  iter_set = peas_gtk_plugin_manager_view_get_selected_iter (view, &iter);
+  iter_set = gtk_tree_selection_get_selected (selection, NULL, &iter);
+
+  if (iter_set)
+    convert_iter_to_child_iter (view, &iter);
 
   view->priv->show_builtin = show_builtin;
 
@@ -889,8 +895,8 @@ peas_gtk_plugin_manager_view_set_show_builtin (PeasGtkPluginManagerView *view,
       g_object_unref (model);
     }
 
-  if (iter_set)
-    peas_gtk_plugin_manager_view_set_selected_iter (view, &iter);
+  if (iter_set && convert_child_iter_to_iter (view, &iter))
+    gtk_tree_selection_select_iter (selection, &iter);
 
   g_object_notify (G_OBJECT (view), "show-builtin");
 }
@@ -912,57 +918,6 @@ peas_gtk_plugin_manager_view_get_show_builtin (PeasGtkPluginManagerView *view)
 }
 
 /**
- * peas_gtk_plugin_manager_view_set_selected_iter:
- * @view: A #PeasGtkPluginManagerView.
- * @iter: A #GtkTreeIter.
- *
- * Selects @iter.
- */
-void
-peas_gtk_plugin_manager_view_set_selected_iter (PeasGtkPluginManagerView *view,
-                                                GtkTreeIter              *iter)
-{
-  GtkTreeSelection *selection;
-
-  g_return_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view));
-  g_return_if_fail (iter != NULL);
-
-  if (!convert_child_iter_to_iter (view, iter))
-    return;
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
-  gtk_tree_selection_select_iter (selection, iter);
-}
-
-/**
- * peas_gtk_plugin_manager_view_get_selected_iter:
- * @view: A #PeasGtkPluginManagerView.
- * @iter: A #GtkTreeIter.
- *
- * Returns if @iter was set to the selected plugin.
- *
- * Returns: if @iter was set.
- */
-gboolean
-peas_gtk_plugin_manager_view_get_selected_iter (PeasGtkPluginManagerView *view,
-                                                GtkTreeIter              *iter)
-{
-  GtkTreeSelection *selection;
-
-  g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view), FALSE);
-  g_return_val_if_fail (iter != NULL, FALSE);
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
-
-  if (!gtk_tree_selection_get_selected (selection, NULL, iter))
-    return FALSE;
-
-  convert_iter_to_child_iter (view, iter);
-
-  return TRUE;
-}
-
-/**
  * peas_gtk_plugin_manager_view_set_selected_plugin:
  * @view: A #PeasGtkPluginManagerView.
  * @info: A #PeasPluginInfo.
@@ -1000,13 +955,19 @@ peas_gtk_plugin_manager_view_set_selected_plugin (PeasGtkPluginManagerView *view
 PeasPluginInfo *
 peas_gtk_plugin_manager_view_get_selected_plugin (PeasGtkPluginManagerView *view)
 {
+  GtkTreeSelection *selection;
   GtkTreeIter iter;
   PeasPluginInfo *info = NULL;
 
   g_return_val_if_fail (PEAS_GTK_IS_PLUGIN_MANAGER_VIEW (view), NULL);
 
-  if (peas_gtk_plugin_manager_view_get_selected_iter (view, &iter))
-    info = peas_gtk_plugin_manager_store_get_plugin (view->priv->store, &iter);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+
+  if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+    {
+      convert_iter_to_child_iter (view, &iter);
+      info = peas_gtk_plugin_manager_store_get_plugin (view->priv->store, &iter);
+    }
 
   return info;
 }
diff --git a/libpeas-gtk/peas-gtk-plugin-manager-view.h b/libpeas-gtk/peas-gtk-plugin-manager-view.h
index 1ce9d1a..1980dfd 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager-view.h
+++ b/libpeas-gtk/peas-gtk-plugin-manager-view.h
@@ -67,11 +67,6 @@ void            peas_gtk_plugin_manager_view_set_show_builtin     (PeasGtkPlugin
                                                                    gboolean                  show_builtin);
 gboolean        peas_gtk_plugin_manager_view_get_show_builtin     (PeasGtkPluginManagerView *view);
 
-void            peas_gtk_plugin_manager_view_set_selected_iter    (PeasGtkPluginManagerView *view,
-                                                                   GtkTreeIter              *iter);
-gboolean        peas_gtk_plugin_manager_view_get_selected_iter    (PeasGtkPluginManagerView *view,
-                                                                   GtkTreeIter              *iter);
-
 void            peas_gtk_plugin_manager_view_set_selected_plugin  (PeasGtkPluginManagerView *view,
                                                                    PeasPluginInfo           *info);
 PeasPluginInfo *peas_gtk_plugin_manager_view_get_selected_plugin  (PeasGtkPluginManagerView *view);



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