#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);
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)
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;
}
/* chain parent_class' handler */
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_tree_selection_parent_class)->finalize (object);
}
/**
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;
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),
{
/* 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
GtkRBNode *node,
gboolean select)
{
- gboolean selected = FALSE;
+ gboolean toggle = FALSE;
GtkTreePath *path = NULL;
select = !! select;
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;