diff options
author | Havoc Pennington <hp@redhat.com> | 2001-01-01 19:01:54 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-01-01 19:01:54 +0000 |
commit | 66f87948e233899c8bb67979df74a9e728b7635c (patch) | |
tree | 19cd6883960c3c95160e0b5a21cfacab38fa5fbf /gtk/gtktreeselection.c | |
parent | e5d534b3fd7fe105f21dcbadcec8c6bce01ca0da (diff) | |
download | gtk+-66f87948e233899c8bb67979df74a9e728b7635c.tar.gz |
Adapt to GtkTreeSelection changes
2001-01-01 Havoc Pennington <hp@redhat.com>
* gtk/gtktreeview.c: Adapt to GtkTreeSelection changes
* gtk/gtktreeselection.c (_gtk_tree_selection_set_tree_view):
don't fill in tree_view->priv->selection, kind of an unexpected
side effect
* gtk/gtkcellrenderertext.c: Remove definition of _ and include
gtkintl.h
* gtk/gtkcellrenderer.c: Remove definition of _ and include
gtkintl.h
(gtk_cell_renderer_get_property): remove calls to g_value_init
* gtk/gtkcellrendererpixbuf.c: Remove definition of _ and include
gtkintl.h
* gtk/gtkcellrenderertextpixbuf.c: Remove definition of _ macro
and include gtkintl.h
(gtk_cell_renderer_text_pixbuf_class_init): remove spaces from
property names
* gtk/gtktreeselection.c (_gtk_tree_selection_new): rename, return
GtkTreeSelection
(_gtk_tree_selection_new_from_with_view): rename, return
GtkTreeSelection
(_gtk_tree_selection_set_tree_view): rename with uscore
(gtk_tree_selection_get_selected): fill in the "model" out param
first, so it gets filled in even if we return at the top of the
function
(gtk_tree_selection_real_select_all): add a comment and an else{}
to clarify this a bit
(gtk_tree_selection_real_unselect_all): add the same else{}
* gtk/gtktreeselection.h: Rename new, new_with_tree_view, and
set_tree_view to have underscore prefixes, move them to the
private header, fix return type of new_with_tree_view
(struct _GtkTreeSelection): mark struct
fields private
* gtk/gtktreemodel.c (gtk_tree_model_get_flags): return
GtkTreeModelFlags, not a guint
(gtk_tree_path_prev): return gboolean not gint
(gtk_tree_path_up): return gboolean not gint
* gtk/gtktreemodel.h (struct _GtkTreeModelIface): make get_flags
return GtkTreeModelFlags, not a guint
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_finalize): check
that child model is non-null before unrefing it
(g_value_int_compare_func): make this a qsort compare func, not
a boolean predicate
* gtk/gtktreemodelsort.h: rename gtk_tree_model_set_sort_column,
(add -umn to the end), and mark it unimplemented
(gtk_tree_model_sort_resort): remove, this wasn't implemented, and
I don't see what it's for - doesn't the model always sort itself?
(gtk_tree_model_sort_set_compare): this had the wrong signature
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_set_attributes):
Fix the docs to say that it destructively replaces existing
attributes (previously said that it added attributes).
(gtk_tree_view_column_set_visible): canonicalize bool before
equality testing. Also, check for realization before
hiding/showing the tree_column->window; if this window could exist
before realization, then it's busted and needs fixing, we can't
create GDK resources pre-realization. Also, remove
superfluous queue_resize(), since set_size() does that for us.
(gtk_tree_view_column_set_col_type): check realization before
using tree_column->window
* gtk/gtktreedatalist.c: fix filename in copyright notice
Diffstat (limited to 'gtk/gtktreeselection.c')
-rw-r--r-- | gtk/gtktreeselection.c | 113 |
1 files changed, 64 insertions, 49 deletions
diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c index 4487f3dc01..cb83222dfd 100644 --- a/gtk/gtktreeselection.c +++ b/gtk/gtktreeselection.c @@ -31,7 +31,8 @@ static gint gtk_tree_selection_real_select_node (GtkTreeSelection *selecti GtkRBNode *node, gboolean select); -enum { +enum +{ SELECTION_CHANGED, LAST_SIGNAL }; @@ -91,25 +92,25 @@ gtk_tree_selection_init (GtkTreeSelection *selection) } /** - * gtk_tree_selection_new: + * _gtk_tree_selection_new: * * Creates a new #GtkTreeSelection object. This function should not be invoked, * as each #GtkTreeView will create it's own #GtkTreeSelection. * * Return value: A newly created #GtkTreeSelection object. **/ -GtkObject * -gtk_tree_selection_new (void) +GtkTreeSelection* +_gtk_tree_selection_new (void) { - GtkObject *selection; + GtkTreeSelection *selection; - selection = GTK_OBJECT (gtk_type_new (GTK_TYPE_TREE_SELECTION)); + selection = GTK_TREE_SELECTION (gtk_type_new (GTK_TYPE_TREE_SELECTION)); return selection; } /** - * gtk_tree_selection_new_with_tree_view: + * _gtk_tree_selection_new_with_tree_view: * @tree_view: The #GtkTreeView. * * Creates a new #GtkTreeSelection object. This function should not be invoked, @@ -117,22 +118,22 @@ gtk_tree_selection_new (void) * * Return value: A newly created #GtkTreeSelection object. **/ -GtkObject * -gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view) +GtkTreeSelection* +_gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view) { - GtkObject *selection; + GtkTreeSelection *selection; g_return_val_if_fail (tree_view != NULL, NULL); g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL); - selection = gtk_tree_selection_new (); - gtk_tree_selection_set_tree_view (GTK_TREE_SELECTION (selection), tree_view); + selection = _gtk_tree_selection_new (); + _gtk_tree_selection_set_tree_view (selection, tree_view); return selection; } /** - * gtk_tree_selection_set_tree_view: + * _gtk_tree_selection_set_tree_view: * @selection: A #GtkTreeSelection. * @tree_view: The #GtkTreeView. * @@ -140,8 +141,8 @@ gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view) * it is used internally by #GtkTreeView. **/ void -gtk_tree_selection_set_tree_view (GtkTreeSelection *selection, - GtkTreeView *tree_view) +_gtk_tree_selection_set_tree_view (GtkTreeSelection *selection, + GtkTreeView *tree_view) { g_return_if_fail (selection != NULL); g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); @@ -149,9 +150,9 @@ gtk_tree_selection_set_tree_view (GtkTreeSelection *selection, g_return_if_fail (GTK_IS_TREE_VIEW (tree_view)); selection->tree_view = tree_view; - tree_view->priv->selection = selection; } +/* FIXME explain what the anchor is */ /** * gtk_tree_selection_set_type: * @selection: A #GtkTreeSelection. @@ -191,6 +192,8 @@ gtk_tree_selection_set_type (GtkTreeSelection *selection, * all. */ gtk_tree_selection_unselect_all (selection); + + /* FIXME are we properly emitting the selection_changed signal here? */ if (node && selected) GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_IS_SELECTED); } @@ -260,6 +263,9 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection, g_return_val_if_fail (selection != NULL, FALSE); g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE); + if (model) + *model = selection->tree_view->priv->model; + if (selection->tree_view->priv->anchor == NULL) return FALSE; else if (iter == NULL) @@ -277,9 +283,6 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection, */ return FALSE; - if (model) - *model = selection->tree_view->priv->model; - return gtk_tree_model_get_iter (selection->tree_view->priv->model, iter, selection->tree_view->priv->anchor); @@ -555,6 +558,8 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection) GtkRBTree *tree; GtkRBNode *node; gint dirty; + + /* Just select the last row */ dirty = gtk_tree_selection_real_unselect_all (selection); @@ -578,23 +583,27 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection) return dirty; } - - tuple = g_new (struct _TempTuple, 1); - tuple->selection = selection; - tuple->dirty = FALSE; - - _gtk_rbtree_traverse (selection->tree_view->priv->tree, - selection->tree_view->priv->tree->root, - G_PRE_ORDER, - select_all_helper, - tuple); - if (tuple->dirty) + else { + /* Mark all nodes selected */ + + tuple = g_new (struct _TempTuple, 1); + tuple->selection = selection; + tuple->dirty = FALSE; + + _gtk_rbtree_traverse (selection->tree_view->priv->tree, + selection->tree_view->priv->tree->root, + G_PRE_ORDER, + select_all_helper, + tuple); + if (tuple->dirty) + { + g_free (tuple); + return TRUE; + } g_free (tuple); - return TRUE; + return FALSE; } - g_free (tuple); - return FALSE; } /** @@ -658,24 +667,26 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection) } return FALSE; } - - tuple = g_new (struct _TempTuple, 1); - tuple->selection = selection; - tuple->dirty = FALSE; - - _gtk_rbtree_traverse (selection->tree_view->priv->tree, - selection->tree_view->priv->tree->root, - G_PRE_ORDER, - unselect_all_helper, - tuple); - - if (tuple->dirty) - { + else + { + tuple = g_new (struct _TempTuple, 1); + tuple->selection = selection; + tuple->dirty = FALSE; + + _gtk_rbtree_traverse (selection->tree_view->priv->tree, + selection->tree_view->priv->tree->root, + G_PRE_ORDER, + unselect_all_helper, + tuple); + + if (tuple->dirty) + { + g_free (tuple); + return TRUE; + } g_free (tuple); - return TRUE; + return FALSE; } - g_free (tuple); - return FALSE; } /** @@ -774,6 +785,7 @@ gtk_tree_selection_real_select_range (GtkTreeSelection *selection, start_node = start_tree->parent_node; start_tree = start_tree->parent_tree; if (start_tree == NULL) + /* FIXME should this really be silent, or should it g_warning? */ /* we've run out of tree */ /* This means we never found end node!! */ break; @@ -872,6 +884,9 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection, /* FIXME: user_func can screw up GTK_TREE_SELECTION_SINGLE. If it prevents * unselection of a node, it can keep more then one node selected. */ +/* Perhaps the correct solution is to prevent selecting the new node, if + * we fail to unselect the old node. + */ static gint gtk_tree_selection_real_select_node (GtkTreeSelection *selection, GtkRBTree *tree, |