]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktreeselection.c
Display an error when we come to the root.
[~andy/gtk] / gtk / gtktreeselection.c
index 90a0dac1745200e0d6ba76f38a58e7e9632f8718..e7aad5bff7de32c6ca01bbc240438405c076790f 100644 (file)
@@ -26,9 +26,6 @@
 #include "gtkintl.h"
 #include "gtkalias.h"
 
-static void gtk_tree_selection_init              (GtkTreeSelection      *selection);
-static void gtk_tree_selection_class_init        (GtkTreeSelectionClass *class);
-
 static void gtk_tree_selection_finalize          (GObject               *object);
 static gint gtk_tree_selection_real_select_all   (GtkTreeSelection      *selection);
 static gint gtk_tree_selection_real_unselect_all (GtkTreeSelection      *selection);
@@ -43,36 +40,9 @@ enum
   LAST_SIGNAL
 };
 
-static GObjectClass *parent_class = NULL;
 static guint tree_selection_signals [LAST_SIGNAL] = { 0 };
 
-GType
-gtk_tree_selection_get_type (void)
-{
-  static GType selection_type = 0;
-
-  if (!selection_type)
-    {
-      static const GTypeInfo selection_info =
-      {
-        sizeof (GtkTreeSelectionClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-        (GClassInitFunc) gtk_tree_selection_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-        sizeof (GtkTreeSelection),
-       0,              /* n_preallocs */
-        (GInstanceInitFunc) gtk_tree_selection_init
-      };
-
-      selection_type =
-       g_type_register_static (G_TYPE_OBJECT, I_("GtkTreeSelection"),
-                               &selection_info, 0);
-    }
-
-  return selection_type;
-}
+G_DEFINE_TYPE (GtkTreeSelection, gtk_tree_selection, G_TYPE_OBJECT)
 
 static void
 gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
@@ -80,7 +50,6 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
   GObjectClass *object_class;
 
   object_class = (GObjectClass*) class;
-  parent_class = g_type_class_peek_parent (class);
 
   object_class->finalize = gtk_tree_selection_finalize;
   class->changed = NULL;
@@ -115,7 +84,7 @@ gtk_tree_selection_finalize (GObject *object)
     }
 
   /* chain parent_class' handler */
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (gtk_tree_selection_parent_class)->finalize (object);
 }
 
 /**
@@ -1262,44 +1231,11 @@ gtk_tree_selection_unselect_range (GtkTreeSelection *selection,
     g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
 }
 
-static gboolean
-tree_column_is_sensitive (GtkTreeViewColumn *column,
-                         GtkTreeModel      *model,
-                         GtkTreeIter       *iter)
-{
-  GList *cells, *list;
-  gboolean sensitive;
-  gboolean visible;
-
-  gtk_tree_view_column_cell_set_cell_data (column, model,
-                                          iter, FALSE, FALSE);
-
-  cells = gtk_tree_view_column_get_cell_renderers (column);
-
-  list = cells;
-  while (list)
-    {
-      g_object_get (list->data,
-                   "sensitive", &sensitive,
-                   "visible", &visible,
-                   NULL);
-      
-      if (visible && sensitive)
-       break;
-
-      list = list->next;
-    }
-  g_list_free (cells);
-
-  return sensitive;
-}
-
-static gboolean
-row_is_selectable (GtkTreeSelection *selection,
-                  GtkRBNode        *node,
-                  GtkTreePath      *path)
+gboolean
+_gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
+                                      GtkRBNode        *node,
+                                      GtkTreePath      *path)
 {
-  GList *list;
   GtkTreeIter iter;
   gboolean sensitive = FALSE;
 
@@ -1315,19 +1251,6 @@ row_is_selectable (GtkTreeSelection *selection,
        return FALSE;
     }
 
-  for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
-    {
-      GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
-
-      if (!column->visible)
-       continue;
-
-      sensitive = tree_column_is_sensitive (column, selection->tree_view->priv->model, &iter);
-    }
-
-  if (!sensitive)
-    return FALSE;
-
   if (selection->user_func)
     return (*selection->user_func) (selection, selection->tree_view->priv->model, path,
                                    GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),
@@ -1386,7 +1309,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
            {
              /* We only want to select the new node if we can unselect the old one,
               * and we can select the new one. */
-             dirty = row_is_selectable (selection, node, path);
+             dirty = _gtk_tree_selection_row_is_selectable (selection, node, path);
 
              /* if dirty is FALSE, we weren't able to select the new one, otherwise, we try to
               * unselect the new one
@@ -1502,7 +1425,7 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
                                     GtkRBNode        *node,
                                     gboolean          select)
 {
-  gboolean selected = FALSE;
+  gboolean toggle = FALSE;
   GtkTreePath *path = NULL;
 
   select = !! select;
@@ -1510,11 +1433,11 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
   if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
     {
       path = _gtk_tree_view_find_path (selection->tree_view, tree, node);
-      selected = row_is_selectable (selection, node, path);
+      toggle = _gtk_tree_selection_row_is_selectable (selection, node, path);
       gtk_tree_path_free (path);
     }
 
-  if (selected == TRUE)
+  if (toggle)
     {
       node->flags ^= GTK_RBNODE_IS_SELECTED;