2000-10-05 01:04:57 +00:00
|
|
|
/* gtktreeselection.h
|
|
|
|
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gtktreeselection.h"
|
|
|
|
#include "gtktreeprivate.h"
|
|
|
|
#include "gtkrbtree.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2000-10-05 01:04:57 +00:00
|
|
|
#include "gtksignal.h"
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
static void gtk_tree_selection_init (GtkTreeSelection *selection);
|
|
|
|
static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class);
|
2001-02-28 00:35:25 +00:00
|
|
|
|
|
|
|
static void gtk_tree_selection_finalize (GObject *object);
|
2000-10-06 00:06:00 +00:00
|
|
|
static gint gtk_tree_selection_real_select_all (GtkTreeSelection *selection);
|
|
|
|
static gint gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection);
|
|
|
|
static gint gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
gboolean select);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
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
2001-01-01 19:01:54 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-06-07 22:33:14 +00:00
|
|
|
CHANGED,
|
2000-10-05 01:04:57 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-06-07 22:33:14 +00:00
|
|
|
static GObjectClass *parent_class = NULL;
|
2001-08-22 22:27:41 +00:00
|
|
|
static guint tree_selection_signals [LAST_SIGNAL] = { 0 };
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
GtkType
|
|
|
|
gtk_tree_selection_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType 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
|
|
|
|
};
|
|
|
|
|
2001-06-07 22:33:14 +00:00
|
|
|
selection_type = g_type_register_static (G_TYPE_OBJECT, "GtkTreeSelection", &selection_info, 0);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return selection_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
|
|
|
|
{
|
2001-02-28 00:35:25 +00:00
|
|
|
GObjectClass *object_class;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
object_class = (GObjectClass*) class;
|
2000-10-05 01:04:57 +00:00
|
|
|
parent_class = g_type_class_peek_parent (class);
|
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
object_class->finalize = gtk_tree_selection_finalize;
|
2001-06-07 22:33:14 +00:00
|
|
|
class->changed = NULL;
|
doh, this was broken beyond believe.
Tue Dec 12 23:46:44 2000 Tim Janik <timj@gtk.org>
* gtk/stock-icons/Makefile.am: doh, this was broken beyond believe.
* gtk/gtkbox.c: change property types from (u)long to (u)int for
::position and ::padding.
* gtk/gtkcontainer.c: make ::border_width an INT property.
* gtk/gtkpacker.c: make ::position an INT property.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_adjustment_changed):
guard against NULL h/v scrollbars, since this is used at construction
time.
* gtk/gtkclist.[hc]: nuked gtk_clist_construct(), implemented
internal gtk_clist_constructor().
* gtk/gtkctree.[hc]: nuked gtk_ctree_construct(), implemented
gtk_ctree_constructor().
* gtk/gtkprogressbar.c (gtk_progress_bar_class_init): property
::pulse_step should use ARG_PULSE_STEP, not ARG_FRACTION.
* docs/reference/Makefile.am: fun stuff, disabled docs generation
again, gtk-scan.c needs to introspec paramspecs, not GtkAgs.
* gtk/gtkwidget.[hc]:
removed gtk_widget_setv(), gtk_widget_getv(), gtk_widget_newv()
and gtk_widget_get().
(gtk_widget_new): use g_object_new_valist().
(gtk_widget_set): use g_object_set_valist().
* gtk/gtkobject.[hc]:
removed gtk_object_arg_get_info(), gtk_object_getv(),
gtk_object_query_args(), gtk_object_newv(),
gtk_object_class_add_signals(),
gtk_object_class_user_signal_new(),
gtk_object_class_user_signal_newv(),
gtk_object_arg_set(), gtk_object_arg_get(),
gtk_object_args_collect(),
gtk_object_default_construct(),
gtk_object_constructed(),
GTK_CONSTRUCTED and GTK_OBJECT_CONSTRUCTED().
removed nsignals, signals and n_args members from GtkObjectClass.
(gtk_object_new): use g_object_new_valist().
(gtk_object_set): use g_object_set_valist().
(gtk_object_get): use g_object_get_valist().
* gtk/gtkcompat.h: define gtk_object_default_construct().
* gtk/gtktypeutils.c (gtk_type_new): create constructed objects via
g_object_new().
* gtk/*.c: removed gtk_object_class_add_signals() from class_init()
fucntions, cleaned up method assignments (make sure your structures
are setup properly before calling out). removed all GTK_CONSTRUCTED
hacks ;)
2000-12-13 01:34:41 +00:00
|
|
|
|
2001-06-07 22:33:14 +00:00
|
|
|
tree_selection_signals[CHANGED] =
|
|
|
|
gtk_signal_new ("changed",
|
2000-10-05 01:04:57 +00:00
|
|
|
GTK_RUN_FIRST,
|
|
|
|
GTK_CLASS_TYPE (object_class),
|
2001-06-07 22:33:14 +00:00
|
|
|
GTK_SIGNAL_OFFSET (GtkTreeSelectionClass, changed),
|
2001-11-17 23:28:51 +00:00
|
|
|
_gtk_marshal_VOID__VOID,
|
2000-10-06 00:06:00 +00:00
|
|
|
GTK_TYPE_NONE, 0);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_selection_init (GtkTreeSelection *selection)
|
|
|
|
{
|
2001-08-27 19:19:24 +00:00
|
|
|
selection->type = GTK_SELECTION_SINGLE;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_selection_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
if (GTK_TREE_SELECTION (object)->destroy)
|
|
|
|
(* GTK_TREE_SELECTION (object)->destroy) (GTK_TREE_SELECTION (object)->user_data);
|
2001-08-17 16:33:04 +00:00
|
|
|
|
|
|
|
/* chain parent_class' handler */
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-28 00:35:25 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
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
2001-01-01 19:01:54 +00:00
|
|
|
* _gtk_tree_selection_new:
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Creates a new #GtkTreeSelection object. This function should not be invoked,
|
|
|
|
* as each #GtkTreeView will create it's own #GtkTreeSelection.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Return value: A newly created #GtkTreeSelection object.
|
|
|
|
**/
|
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
2001-01-01 19:01:54 +00:00
|
|
|
GtkTreeSelection*
|
|
|
|
_gtk_tree_selection_new (void)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
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
2001-01-01 19:01:54 +00:00
|
|
|
GtkTreeSelection *selection;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-06-07 22:33:14 +00:00
|
|
|
selection = GTK_TREE_SELECTION (g_object_new (GTK_TYPE_TREE_SELECTION, NULL));
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
return selection;
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
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
2001-01-01 19:01:54 +00:00
|
|
|
* _gtk_tree_selection_new_with_tree_view:
|
2000-10-16 07:03:54 +00:00
|
|
|
* @tree_view: The #GtkTreeView.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Creates a new #GtkTreeSelection object. This function should not be invoked,
|
|
|
|
* as each #GtkTreeView will create it's own #GtkTreeSelection.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Return value: A newly created #GtkTreeSelection object.
|
|
|
|
**/
|
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
2001-01-01 19:01:54 +00:00
|
|
|
GtkTreeSelection*
|
|
|
|
_gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
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
2001-01-01 19:01:54 +00:00
|
|
|
GtkTreeSelection *selection;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), NULL);
|
|
|
|
|
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
2001-01-01 19:01:54 +00:00
|
|
|
selection = _gtk_tree_selection_new ();
|
|
|
|
_gtk_tree_selection_set_tree_view (selection, tree_view);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
return selection;
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
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
2001-01-01 19:01:54 +00:00
|
|
|
* _gtk_tree_selection_set_tree_view:
|
2000-10-16 07:03:54 +00:00
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @tree_view: The #GtkTreeView.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Sets the #GtkTreeView of @selection. This function should not be invoked, as
|
|
|
|
* it is used internally by #GtkTreeView.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
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
2001-01-01 19:01:54 +00:00
|
|
|
_gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
|
|
|
|
GtkTreeView *tree_view)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
if (tree_view != NULL)
|
|
|
|
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
|
|
|
|
|
|
|
|
selection->tree_view = tree_view;
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
2001-01-04 21:33:24 +00:00
|
|
|
* gtk_tree_selection_set_mode:
|
2000-10-16 07:03:54 +00:00
|
|
|
* @selection: A #GtkTreeSelection.
|
2001-06-24 15:34:48 +00:00
|
|
|
* @type: The selection mode
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-06-24 15:34:48 +00:00
|
|
|
* Sets the selection mode of the @selection. If the previous type was
|
2001-10-18 22:05:23 +00:00
|
|
|
* #GTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was
|
2001-08-27 19:19:24 +00:00
|
|
|
* previously selected.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
2001-08-27 19:19:24 +00:00
|
|
|
gtk_tree_selection_set_mode (GtkTreeSelection *selection,
|
|
|
|
GtkSelectionMode type)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2001-10-31 20:20:12 +00:00
|
|
|
GtkTreeSelectionFunc tmp_func;
|
2000-10-05 01:04:57 +00:00
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
|
|
|
|
if (selection->type == type)
|
|
|
|
return;
|
|
|
|
|
2001-10-31 20:20:12 +00:00
|
|
|
|
|
|
|
if (type == GTK_SELECTION_NONE)
|
|
|
|
{
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
|
|
|
/* We do this so that we unconditionally unset all rows
|
|
|
|
*/
|
|
|
|
tmp_func = selection->user_func;
|
|
|
|
selection->user_func = NULL;
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
|
|
|
selection->user_func = tmp_func;
|
|
|
|
}
|
|
|
|
else if (type == GTK_SELECTION_SINGLE ||
|
|
|
|
type == GTK_SELECTION_BROWSE)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
GtkRBTree *tree = NULL;
|
|
|
|
GtkRBNode *node = NULL;
|
|
|
|
gint selected = FALSE;
|
2001-10-31 20:20:12 +00:00
|
|
|
GtkTreePath *anchor_path = NULL;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
{
|
2001-01-27 00:50:38 +00:00
|
|
|
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
|
|
|
|
|
|
|
|
if (anchor_path)
|
|
|
|
{
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
anchor_path,
|
|
|
|
&tree,
|
|
|
|
&node);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
if (node && GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
selected = TRUE;
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
2001-10-31 20:20:12 +00:00
|
|
|
|
|
|
|
/* We do this so that we unconditionally unset all rows
|
2000-10-16 07:03:54 +00:00
|
|
|
*/
|
2001-10-31 20:20:12 +00:00
|
|
|
tmp_func = selection->user_func;
|
|
|
|
selection->user_func = NULL;
|
2000-10-05 01:04:57 +00:00
|
|
|
gtk_tree_selection_unselect_all (selection);
|
2001-10-31 20:20:12 +00:00
|
|
|
selection->user_func = tmp_func;
|
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
2001-01-01 19:01:54 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (node && selected)
|
2001-10-31 20:20:12 +00:00
|
|
|
_gtk_tree_selection_internal_select_node (selection,
|
|
|
|
node,
|
|
|
|
tree,
|
|
|
|
anchor_path,
|
|
|
|
0);
|
2001-11-02 00:13:30 +00:00
|
|
|
if (anchor_path)
|
|
|
|
gtk_tree_path_free (anchor_path);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
2001-10-31 20:20:12 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
selection->type = type;
|
|
|
|
}
|
|
|
|
|
2001-06-24 15:34:48 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_get_mode:
|
|
|
|
* @selection: a #GtkTreeSelection
|
|
|
|
*
|
|
|
|
* Gets the selection mode for @selection. See
|
|
|
|
* gtk_tree_selection_set_mode().
|
|
|
|
*
|
|
|
|
* Return value: the current selection mode
|
|
|
|
**/
|
2001-08-27 19:19:24 +00:00
|
|
|
GtkSelectionMode
|
2001-06-24 15:34:48 +00:00
|
|
|
gtk_tree_selection_get_mode (GtkTreeSelection *selection)
|
|
|
|
{
|
2001-08-27 19:19:24 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), GTK_SELECTION_SINGLE);
|
2001-06-24 15:34:48 +00:00
|
|
|
|
|
|
|
return selection->type;
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_set_select_function:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @func: The selection function.
|
|
|
|
* @data: The selection function's data.
|
2001-02-28 00:35:25 +00:00
|
|
|
* @destroy: The destroy function for user data. May be NULL.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Sets the selection function. If set, this function is called before any node
|
|
|
|
* is selected or unselected, giving some control over which nodes are selected.
|
2001-10-08 05:01:09 +00:00
|
|
|
* The select function should return %TRUE if the state of the node may be toggled,
|
|
|
|
* and %FALSE if the state of the node should be left unchanged.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_set_select_function (GtkTreeSelection *selection,
|
|
|
|
GtkTreeSelectionFunc func,
|
2001-02-28 00:35:25 +00:00
|
|
|
gpointer data,
|
|
|
|
GtkDestroyNotify destroy)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
|
|
|
selection->user_func = func;
|
|
|
|
selection->user_data = data;
|
2001-02-28 00:35:25 +00:00
|
|
|
selection->destroy = destroy;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_get_user_data:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Returns the user data for the selection function.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Return value: The user data.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gpointer
|
|
|
|
gtk_tree_selection_get_user_data (GtkTreeSelection *selection)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), NULL);
|
|
|
|
|
|
|
|
return selection->user_data;
|
|
|
|
}
|
|
|
|
|
2001-09-08 18:23:47 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_get_tree_view:
|
|
|
|
* @selection: A #GtkTreeSelection
|
|
|
|
*
|
|
|
|
* Returns the tree view associated with @selection.
|
|
|
|
*
|
|
|
|
* Return value: A #GtkTreeView
|
|
|
|
**/
|
|
|
|
GtkTreeView *
|
2001-01-04 23:36:19 +00:00
|
|
|
gtk_tree_selection_get_tree_view (GtkTreeSelection *selection)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), NULL);
|
|
|
|
|
|
|
|
return selection->tree_view;
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_get_selected:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
2000-11-09 16:52:17 +00:00
|
|
|
* @model: A pointer set to the #GtkTreeModel, or NULL.
|
2000-10-30 23:21:38 +00:00
|
|
|
* @iter: The #GtkTreeIter, or NULL.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Sets @iter to the currently selected node if @selection is set to
|
2001-08-27 19:19:24 +00:00
|
|
|
* #GTK_SELECTION_SINGLE or #GTK_SELECTION_BROWSE. @iter may be NULL if you
|
|
|
|
* just want to test if @selection has any selected nodes. @model is filled
|
|
|
|
* with the current model as a convenience. This function will not work if you
|
|
|
|
* use @selection is #GTK_SELECTION_MULTIPLE.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-30 23:21:38 +00:00
|
|
|
* Return value: TRUE, if there is a selected node.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean
|
2000-11-09 16:52:17 +00:00
|
|
|
gtk_tree_selection_get_selected (GtkTreeSelection *selection,
|
|
|
|
GtkTreeModel **model,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2001-01-27 00:50:38 +00:00
|
|
|
GtkTreePath *anchor_path;
|
|
|
|
gboolean retval;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
2001-08-27 19:19:24 +00:00
|
|
|
g_return_val_if_fail (selection->type != GTK_SELECTION_MULTIPLE, FALSE);
|
2001-02-28 00:35:25 +00:00
|
|
|
g_return_val_if_fail (selection->tree_view != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
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
2001-01-01 19:01:54 +00:00
|
|
|
if (model)
|
|
|
|
*model = selection->tree_view->priv->model;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (selection->tree_view->priv->anchor == NULL)
|
2000-10-26 00:36:47 +00:00
|
|
|
return FALSE;
|
2001-01-27 00:50:38 +00:00
|
|
|
|
|
|
|
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
|
|
|
|
|
|
|
|
if (anchor_path == NULL)
|
|
|
|
return FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
if (iter == NULL)
|
|
|
|
{
|
|
|
|
gtk_tree_path_free (anchor_path);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
retval = FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (!_gtk_tree_view_find_node (selection->tree_view,
|
2001-01-27 00:50:38 +00:00
|
|
|
anchor_path,
|
|
|
|
&tree,
|
|
|
|
&node) &&
|
2000-10-05 01:04:57 +00:00
|
|
|
! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
2001-01-27 00:50:38 +00:00
|
|
|
{
|
|
|
|
/* We don't want to return the anchor if it isn't actually selected.
|
|
|
|
*/
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = gtk_tree_model_get_iter (selection->tree_view->priv->model,
|
|
|
|
iter,
|
|
|
|
anchor_path);
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
gtk_tree_path_free (anchor_path);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
return retval;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_selected_foreach:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @func: The function to call for each selected node.
|
|
|
|
* @data: user data to pass to the function.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Calls a function for each selected node.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
|
|
|
GtkTreeSelectionForeachFunc func,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GtkRBNode *node;
|
2000-10-26 00:36:47 +00:00
|
|
|
GtkTreeIter iter;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
|
|
|
g_return_if_fail (selection->tree_view->priv->model != NULL);
|
|
|
|
|
|
|
|
if (func == NULL ||
|
|
|
|
selection->tree_view->priv->tree == NULL ||
|
|
|
|
selection->tree_view->priv->tree->root == NULL)
|
|
|
|
return;
|
|
|
|
|
2001-08-27 19:19:24 +00:00
|
|
|
if (selection->type == GTK_SELECTION_SINGLE ||
|
|
|
|
selection->type == GTK_SELECTION_BROWSE)
|
2001-04-03 19:13:08 +00:00
|
|
|
{
|
2001-06-29 07:28:08 +00:00
|
|
|
if (gtk_tree_row_reference_valid (selection->tree_view->priv->anchor))
|
|
|
|
{
|
|
|
|
path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
|
|
|
|
gtk_tree_model_get_iter (selection->tree_view->priv->model, &iter, path);
|
|
|
|
(* func) (selection->tree_view->priv->model, path, &iter, data);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2001-04-03 19:13:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
tree = selection->tree_view->priv->tree;
|
|
|
|
node = selection->tree_view->priv->tree->root;
|
2001-06-29 07:28:08 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
while (node->left != tree->nil)
|
|
|
|
node = node->left;
|
|
|
|
|
|
|
|
/* find the node internally */
|
|
|
|
path = gtk_tree_path_new_root ();
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_model_get_iter (selection->tree_view->priv->model,
|
|
|
|
&iter, path);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
2001-06-29 07:28:08 +00:00
|
|
|
(* func) (selection->tree_view->priv->model, path, &iter, data);
|
2000-10-05 01:04:57 +00:00
|
|
|
if (node->children)
|
|
|
|
{
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean has_child;
|
|
|
|
GtkTreeIter tmp;
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
tree = node->children;
|
|
|
|
node = tree->root;
|
|
|
|
while (node->left != tree->nil)
|
|
|
|
node = node->left;
|
2000-10-26 00:36:47 +00:00
|
|
|
tmp = iter;
|
|
|
|
has_child = gtk_tree_model_iter_children (selection->tree_view->priv->model, &iter, &tmp);
|
2001-06-29 07:28:08 +00:00
|
|
|
gtk_tree_path_append_index (path, 0);
|
2000-10-05 01:04:57 +00:00
|
|
|
/* Sanity Check! */
|
2000-10-26 00:36:47 +00:00
|
|
|
TREE_VIEW_INTERNAL_ASSERT_VOID (has_child);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gboolean done = FALSE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
node = _gtk_rbtree_next (tree, node);
|
|
|
|
if (node != NULL)
|
|
|
|
{
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean has_next;
|
|
|
|
|
|
|
|
has_next = gtk_tree_model_iter_next (selection->tree_view->priv->model, &iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
done = TRUE;
|
2001-06-29 07:28:08 +00:00
|
|
|
gtk_tree_path_next (path);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
/* Sanity Check! */
|
2000-10-26 00:36:47 +00:00
|
|
|
TREE_VIEW_INTERNAL_ASSERT_VOID (has_next);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean has_parent;
|
|
|
|
GtkTreeIter tmp_iter = iter;
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
node = tree->parent_node;
|
|
|
|
tree = tree->parent_tree;
|
|
|
|
if (tree == NULL)
|
2001-06-29 07:28:08 +00:00
|
|
|
{
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
/* we've run out of tree */
|
|
|
|
/* We're done with this function */
|
|
|
|
return;
|
|
|
|
}
|
2000-10-26 00:36:47 +00:00
|
|
|
has_parent = gtk_tree_model_iter_parent (selection->tree_view->priv->model, &iter, &tmp_iter);
|
2001-06-29 07:28:08 +00:00
|
|
|
gtk_tree_path_up (path);
|
2000-10-05 01:04:57 +00:00
|
|
|
/* Sanity check */
|
2000-10-26 00:36:47 +00:00
|
|
|
TREE_VIEW_INTERNAL_ASSERT_VOID (has_parent);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!done);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (TRUE);
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_select_path:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @path: The #GtkTreePath to be selected.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Select the row at @path.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_select_path (GtkTreeSelection *selection,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkRBNode *node;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
GdkModifierType state = 0;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
path,
|
|
|
|
&tree,
|
|
|
|
&node);
|
|
|
|
|
|
|
|
if (node == NULL || GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
return;
|
|
|
|
|
2001-08-27 19:19:24 +00:00
|
|
|
if (selection->type == GTK_SELECTION_MULTIPLE)
|
2000-10-05 01:04:57 +00:00
|
|
|
state = GDK_CONTROL_MASK;
|
|
|
|
|
|
|
|
_gtk_tree_selection_internal_select_node (selection,
|
|
|
|
node,
|
|
|
|
tree,
|
|
|
|
path,
|
|
|
|
state);
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_unselect_path:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @path: The #GtkTreePath to be unselected.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Unselects the row at @path.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_unselect_path (GtkTreeSelection *selection,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkRBNode *node;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
path,
|
|
|
|
&tree,
|
|
|
|
&node);
|
|
|
|
|
|
|
|
if (node == NULL || !GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
_gtk_tree_selection_internal_select_node (selection,
|
|
|
|
node,
|
|
|
|
tree,
|
|
|
|
path,
|
|
|
|
GDK_CONTROL_MASK);
|
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_selection_select_iter:
|
2000-10-16 07:03:54 +00:00
|
|
|
* @selection: A #GtkTreeSelection.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter to be selected.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Selects the specified iterator.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_selection_select_iter (GtkTreeSelection *selection,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
|
|
|
g_return_if_fail (selection->tree_view->priv->model != NULL);
|
2001-01-27 20:50:52 +00:00
|
|
|
g_return_if_fail (iter != NULL);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (selection->tree_view->priv->model,
|
2000-10-26 00:36:47 +00:00
|
|
|
iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
if (path == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_selection_select_path (selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_selection_unselect_iter:
|
2000-10-16 07:03:54 +00:00
|
|
|
* @selection: A #GtkTreeSelection.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter to be unselected.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Unselects the specified iterator.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_selection_unselect_iter (GtkTreeSelection *selection,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_if_fail (selection->tree_view->priv->model != NULL);
|
2001-01-27 20:50:52 +00:00
|
|
|
g_return_if_fail (iter != NULL);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (selection->tree_view->priv->model,
|
2000-10-26 00:36:47 +00:00
|
|
|
iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
if (path == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_selection_select_path (selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2001-10-10 05:35:12 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_path_is_selected:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @path: A #GtkTreePath to check selection on.
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the row pointed to by @path is currently selected. If @path
|
|
|
|
* does not point to a valid location, %FALSE is returned
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if @path is selected.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkRBNode *node;
|
|
|
|
GtkRBTree *tree;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (selection->tree_view != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
|
|
|
|
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
path,
|
|
|
|
&tree,
|
|
|
|
&node);
|
|
|
|
|
|
|
|
if ((node == NULL) || !GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_selection_iter_is_selected:
|
|
|
|
* @selection: A #GtkTreeSelection
|
|
|
|
* @iter: A valid #GtkTreeIter
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the row pointed to by @path is currently selected.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE, if @iter is selected
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
gboolean retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (selection->tree_view != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (selection->tree_view->priv->model, iter);
|
|
|
|
if (path == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
retval = gtk_tree_selection_path_is_selected (selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
/* Wish I was in python, right now... */
|
|
|
|
struct _TempTuple {
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
gint dirty;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
select_all_helper (GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
Fix GtkTreeNode *node ->GtkTreeNode node issue.
2000-10-15 <jrb@redhat.com>
* gtk/gtktreeview.c, gtk/gtktreeview.h, gtk/gtktreestore.h,
gtk/gtktreestore.c, gtk/gtkliststore.h, gtk/gtkliststore.c,
gtk/gtkmodelsimple.c, gtk/gtkmodelsimple.h, gtk/gtktreedatalist.c,
gtk/gtktreemodel.h, gtk/gtktreeselection.c,
gtk/gtktreeselection.h: Fix GtkTreeNode *node ->GtkTreeNode node
issue.
2000-10-15 17:46:23 +00:00
|
|
|
gpointer data)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
struct _TempTuple *tuple = data;
|
|
|
|
|
|
|
|
if (node->children)
|
|
|
|
_gtk_rbtree_traverse (node->children,
|
|
|
|
node->children->root,
|
|
|
|
G_PRE_ORDER,
|
|
|
|
select_all_helper,
|
|
|
|
data);
|
|
|
|
if (!GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
{
|
2000-10-06 00:06:00 +00:00
|
|
|
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, TRUE) || tuple->dirty;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
|
|
|
|
/* We have a real_{un,}select_all function that doesn't emit the signal, so we
|
|
|
|
* can use it in other places without fear of the signal being emitted.
|
|
|
|
*/
|
|
|
|
static gint
|
|
|
|
gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
struct _TempTuple *tuple;
|
2001-03-10 01:34:48 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (selection->tree_view->priv->tree == NULL)
|
|
|
|
return FALSE;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-03-10 01:34:48 +00:00
|
|
|
/* 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)
|
2000-10-06 00:06:00 +00:00
|
|
|
{
|
|
|
|
g_free (tuple);
|
2001-03-10 01:34:48 +00:00
|
|
|
return TRUE;
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
2001-03-10 01:34:48 +00:00
|
|
|
g_free (tuple);
|
|
|
|
return FALSE;
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_select_all:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-08-27 19:19:24 +00:00
|
|
|
* Selects all the nodes. @selection is must be set to #GTK_SELECTION_MULTIPLE
|
|
|
|
* mode.
|
2000-10-16 07:03:54 +00:00
|
|
|
**/
|
2000-10-06 00:06:00 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_select_all (GtkTreeSelection *selection)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
2001-08-13 17:23:41 +00:00
|
|
|
if (selection->tree_view->priv->tree == NULL)
|
|
|
|
return;
|
2001-09-27 20:49:34 +00:00
|
|
|
g_return_if_fail (selection->type == GTK_SELECTION_MULTIPLE);
|
2000-10-06 00:06:00 +00:00
|
|
|
|
|
|
|
if (gtk_tree_selection_real_select_all (selection))
|
2001-06-07 22:33:14 +00:00
|
|
|
g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unselect_all_helper (GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
Fix GtkTreeNode *node ->GtkTreeNode node issue.
2000-10-15 <jrb@redhat.com>
* gtk/gtktreeview.c, gtk/gtktreeview.h, gtk/gtktreestore.h,
gtk/gtktreestore.c, gtk/gtkliststore.h, gtk/gtkliststore.c,
gtk/gtkmodelsimple.c, gtk/gtkmodelsimple.h, gtk/gtktreedatalist.c,
gtk/gtktreemodel.h, gtk/gtktreeselection.c,
gtk/gtktreeselection.h: Fix GtkTreeNode *node ->GtkTreeNode node
issue.
2000-10-15 17:46:23 +00:00
|
|
|
gpointer data)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
struct _TempTuple *tuple = data;
|
|
|
|
|
|
|
|
if (node->children)
|
|
|
|
_gtk_rbtree_traverse (node->children,
|
|
|
|
node->children->root,
|
|
|
|
G_PRE_ORDER,
|
|
|
|
unselect_all_helper,
|
|
|
|
data);
|
|
|
|
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
|
|
|
{
|
2000-10-06 00:06:00 +00:00
|
|
|
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, FALSE) || tuple->dirty;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
static gint
|
|
|
|
gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
struct _TempTuple *tuple;
|
|
|
|
|
2001-08-27 19:19:24 +00:00
|
|
|
if (selection->type == GTK_SELECTION_SINGLE ||
|
|
|
|
selection->type == GTK_SELECTION_BROWSE)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
GtkRBTree *tree = NULL;
|
|
|
|
GtkRBNode *node = NULL;
|
2001-01-27 00:50:38 +00:00
|
|
|
GtkTreePath *anchor_path;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (selection->tree_view->priv->anchor == NULL)
|
2000-10-06 00:06:00 +00:00
|
|
|
return FALSE;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
|
|
|
|
|
|
|
|
if (anchor_path == NULL)
|
|
|
|
return FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
2001-01-27 00:50:38 +00:00
|
|
|
anchor_path,
|
2000-10-05 01:04:57 +00:00
|
|
|
&tree,
|
|
|
|
&node);
|
2001-01-27 00:50:38 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free (anchor_path);
|
remove validation idle
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy_layout): remove
validation idle
* demos/gtk-demo/main.c (create_tree): adjust to changes in text
cell renderer
* demos/pixbuf-demo.c (timeout): remove deprecated
gtk_widget_draw
* demos/testpixbuf-save.c (main): remove deprecated
gtk_drawing_area_size
* gtk/gtktreeview.c (gtk_tree_view_size_allocate): allocate
buttons even if the model isn't setup. gtk_tree_view_check_dirty()
at the start of the allocation.
(gtk_tree_view_check_dirty): handle column->button == NULL, handle
unsetup or NULL model.
* gtk/gtkstyle.c (gtk_default_draw_flat_box): drawing for the
even/odd/sorted cells in the tree view.
* gtk/gtktreeselection.c (gtk_tree_selection_real_unselect_all):
bugfixes
* gtk/gtktreeview.c: assorted bugfixy stuff. Draw the row
backgrounds with draw_flat_box using different detail for even/odd
rows.
* gtk/gtkrbtree.c, gtkrbtree.h: Keep track of the parity of each
row, so we can draw the alternating colors thing
* gtk/gtktexttag.c (gtk_text_tag_set_property): if we change a
property from a synonym property, notify for the synonym.
Also, nuke the background_gdk_set and foreground_gdk_set synonyms
(gtk_text_tag_get_property): Always return the font, even if
all its fields aren't set
* gtk/gtkcellrenderertext.h (struct _GtkCellRendererText): don't
store the attr list; it leaves us with no way to change attributes
in _render according to the render flags, and no way to implement
get_property. Instead store all the specific text attributes.
Separate whether an attribute is enabled from its value. Sync all
properties with GtkTextTag, make them all consistent, etc.
* gtk/gtkcellrenderer.h: Add a flag GTK_CELL_RENDERER_SORTED so
renderers can highlight the sort row/column
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_get_property): use
accessor functions to get values; this has the side effect of
showing up which accessor functions were missing. Added those.
* gtk/gtktreeviewcolumn.h: Replace set_justification with
set_alignment, to be consistent with GtkLabel, GtkMisc
* gtk/gtktreeviewcolumn.c: Added code to display sort indicator
arrow.
* gtk/Makefile.am (gtk_public_h_sources): add gtktreesortable.h
* gtk/gtktreesortable.h: updates in here
2001-02-08 23:36:53 +00:00
|
|
|
|
|
|
|
if (tree == NULL)
|
|
|
|
return FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
2000-10-06 00:06:00 +00:00
|
|
|
{
|
2001-02-28 00:35:25 +00:00
|
|
|
if (gtk_tree_selection_real_select_node (selection, tree, node, FALSE))
|
|
|
|
{
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
|
|
|
selection->tree_view->priv->anchor = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
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
2001-01-01 19:01:54 +00:00
|
|
|
else
|
2001-02-28 21:37:50 +00:00
|
|
|
{
|
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
2001-01-01 19:01:54 +00:00
|
|
|
tuple = g_new (struct _TempTuple, 1);
|
|
|
|
tuple->selection = selection;
|
|
|
|
tuple->dirty = FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
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
2001-01-01 19:01:54 +00:00
|
|
|
_gtk_rbtree_traverse (selection->tree_view->priv->tree,
|
|
|
|
selection->tree_view->priv->tree->root,
|
|
|
|
G_PRE_ORDER,
|
|
|
|
unselect_all_helper,
|
|
|
|
tuple);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
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
2001-01-01 19:01:54 +00:00
|
|
|
if (tuple->dirty)
|
|
|
|
{
|
|
|
|
g_free (tuple);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-10-06 00:06:00 +00:00
|
|
|
g_free (tuple);
|
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
2001-01-01 19:01:54 +00:00
|
|
|
return FALSE;
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_unselect_all:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Unselects all the nodes.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
2000-10-06 00:06:00 +00:00
|
|
|
gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
2001-08-13 17:23:41 +00:00
|
|
|
if (selection->tree_view->priv->tree == NULL)
|
|
|
|
return;
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (selection->tree_view->priv->tree == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_real_unselect_all (selection))
|
2001-06-07 22:33:14 +00:00
|
|
|
g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_tree_selection_real_select_range (GtkTreeSelection *selection,
|
|
|
|
GtkTreePath *start_path,
|
|
|
|
GtkTreePath *end_path)
|
|
|
|
{
|
|
|
|
GtkRBNode *start_node, *end_node;
|
|
|
|
GtkRBTree *start_tree, *end_tree;
|
|
|
|
gboolean dirty = FALSE;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
switch (gtk_tree_path_compare (start_path, end_path))
|
|
|
|
{
|
2001-04-23 23:03:53 +00:00
|
|
|
case 1:
|
2000-10-05 01:04:57 +00:00
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
end_path,
|
|
|
|
&start_tree,
|
|
|
|
&start_node);
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
start_path,
|
|
|
|
&end_tree,
|
|
|
|
&end_node);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
start_path,
|
|
|
|
&start_tree,
|
|
|
|
&start_node);
|
|
|
|
end_tree = start_tree;
|
|
|
|
end_node = start_node;
|
|
|
|
break;
|
2001-04-23 23:03:53 +00:00
|
|
|
case -1:
|
2000-10-05 01:04:57 +00:00
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
start_path,
|
|
|
|
&start_tree,
|
|
|
|
&start_node);
|
|
|
|
_gtk_tree_view_find_node (selection->tree_view,
|
|
|
|
end_path,
|
|
|
|
&end_tree,
|
|
|
|
&end_node);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
g_return_val_if_fail (start_node != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (end_node != NULL, FALSE);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2001-08-22 22:27:41 +00:00
|
|
|
dirty |= gtk_tree_selection_real_select_node (selection, start_tree, start_node, TRUE);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
if (start_node == end_node)
|
2000-10-06 00:06:00 +00:00
|
|
|
break;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
if (start_node->children)
|
|
|
|
{
|
|
|
|
start_tree = start_node->children;
|
|
|
|
start_node = start_tree->root;
|
|
|
|
while (start_node->left != start_tree->nil)
|
|
|
|
start_node = start_node->left;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-22 22:27:41 +00:00
|
|
|
_gtk_rbtree_next_full (start_tree, start_node, &start_tree, &start_node);
|
|
|
|
if (start_tree == NULL)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2001-08-22 22:27:41 +00:00
|
|
|
/* we just ran out of tree. That means someone passed in bogus values.
|
|
|
|
*/
|
|
|
|
return dirty;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (TRUE);
|
2000-10-06 00:06:00 +00:00
|
|
|
|
|
|
|
return dirty;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 07:03:54 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_selection_select_range:
|
|
|
|
* @selection: A #GtkTreeSelection.
|
|
|
|
* @start_path: The initial node of the range.
|
|
|
|
* @end_path: The final node of the range.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-16 07:03:54 +00:00
|
|
|
* Selects a range of nodes, determined by @start_path and @end_path inclusive.
|
|
|
|
**/
|
2000-10-06 00:06:00 +00:00
|
|
|
void
|
|
|
|
gtk_tree_selection_select_range (GtkTreeSelection *selection,
|
|
|
|
GtkTreePath *start_path,
|
|
|
|
GtkTreePath *end_path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
|
|
|
g_return_if_fail (selection->tree_view != NULL);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (gtk_tree_selection_real_select_range (selection, start_path, end_path))
|
2001-06-29 07:28:08 +00:00
|
|
|
g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
2001-02-28 00:35:25 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
/* Called internally by gtktreeview.c It handles actually selecting the tree.
|
|
|
|
*/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
_gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
|
|
|
|
GtkRBNode *node,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GdkModifierType state)
|
|
|
|
{
|
|
|
|
gint flags;
|
2000-10-06 00:06:00 +00:00
|
|
|
gint dirty = FALSE;
|
2001-01-27 00:50:38 +00:00
|
|
|
GtkTreePath *anchor_path = NULL;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
2001-10-31 20:20:12 +00:00
|
|
|
if (selection->type == GTK_SELECTION_NONE)
|
|
|
|
return;
|
2001-02-28 00:35:25 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
|
|
|
|
|
2001-08-27 19:19:24 +00:00
|
|
|
if (selection->type == GTK_SELECTION_SINGLE ||
|
|
|
|
selection->type == GTK_SELECTION_BROWSE)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2001-02-28 00:35:25 +00:00
|
|
|
/* Did we try to select the same node again? */
|
2001-08-27 19:19:24 +00:00
|
|
|
if (selection->type == GTK_SELECTION_SINGLE &&
|
|
|
|
anchor_path && gtk_tree_path_compare (path, anchor_path) == 0)
|
2001-02-28 00:35:25 +00:00
|
|
|
{
|
|
|
|
if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
dirty = gtk_tree_selection_real_unselect_all (selection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (anchor_path)
|
|
|
|
{
|
2002-01-10 00:11:32 +00:00
|
|
|
/* We only want to select the new node if we can unselect the old one,
|
|
|
|
* and we can select the new one. */
|
|
|
|
if (selection->user_func)
|
|
|
|
{
|
|
|
|
if ((*selection->user_func) (selection, selection->tree_view->priv->model, path,
|
|
|
|
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),
|
|
|
|
selection->user_data))
|
|
|
|
dirty = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dirty = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if dirty is FALSE, we weren't able to select the new one, otherwise, we try to
|
|
|
|
* unselect the new one
|
|
|
|
*/
|
|
|
|
if (dirty)
|
|
|
|
dirty = gtk_tree_selection_real_unselect_all (selection);
|
|
|
|
|
|
|
|
/* if dirty is TRUE at this point, we successfully unselected the
|
|
|
|
* old one, and can then select the new one */
|
2001-02-28 00:35:25 +00:00
|
|
|
if (dirty)
|
|
|
|
{
|
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
|
|
|
if (gtk_tree_selection_real_select_node (selection, tree, node, TRUE))
|
|
|
|
{
|
|
|
|
selection->tree_view->priv->anchor =
|
2001-02-28 21:37:50 +00:00
|
|
|
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
|
2001-02-28 00:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gtk_tree_selection_real_select_node (selection, tree, node, TRUE))
|
|
|
|
{
|
|
|
|
dirty = TRUE;
|
|
|
|
selection->tree_view->priv->anchor =
|
2001-02-28 21:37:50 +00:00
|
|
|
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
|
2001-02-28 00:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
2001-08-27 19:19:24 +00:00
|
|
|
else if (selection->type == GTK_SELECTION_MULTIPLE)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2001-02-28 00:35:25 +00:00
|
|
|
if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (anchor_path == NULL))
|
|
|
|
{
|
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
selection->tree_view->priv->anchor =
|
2001-02-28 21:37:50 +00:00
|
|
|
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
|
2001-02-28 00:35:25 +00:00
|
|
|
dirty = gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
|
|
|
|
}
|
|
|
|
else if ((state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) == (GDK_SHIFT_MASK|GDK_CONTROL_MASK))
|
|
|
|
{
|
|
|
|
gtk_tree_selection_select_range (selection,
|
|
|
|
anchor_path,
|
|
|
|
path);
|
|
|
|
}
|
|
|
|
else if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
flags = node->flags;
|
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
selection->tree_view->priv->anchor =
|
2001-02-28 21:37:50 +00:00
|
|
|
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
|
2000-10-06 00:06:00 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
if ((flags & GTK_RBNODE_IS_SELECTED) == GTK_RBNODE_IS_SELECTED)
|
|
|
|
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
|
|
|
|
else
|
|
|
|
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
|
|
|
|
}
|
|
|
|
else if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
dirty = gtk_tree_selection_real_unselect_all (selection);
|
|
|
|
dirty |= gtk_tree_selection_real_select_range (selection,
|
|
|
|
anchor_path,
|
|
|
|
path);
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
else
|
2001-02-28 00:35:25 +00:00
|
|
|
{
|
|
|
|
dirty = gtk_tree_selection_real_unselect_all (selection);
|
2001-01-27 00:50:38 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
if (selection->tree_view->priv->anchor)
|
|
|
|
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
selection->tree_view->priv->anchor =
|
2001-02-28 21:37:50 +00:00
|
|
|
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
|
|
|
|
|
2001-02-28 00:35:25 +00:00
|
|
|
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
2000-10-06 00:06:00 +00:00
|
|
|
|
2001-01-27 00:50:38 +00:00
|
|
|
if (anchor_path)
|
|
|
|
gtk_tree_path_free (anchor_path);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (dirty)
|
2001-06-07 22:33:14 +00:00
|
|
|
g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
2000-10-13 00:34:38 +00:00
|
|
|
/* NOTE: Any {un,}selection ever done _MUST_ be done through this function!
|
|
|
|
*/
|
2000-10-16 07:03:54 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
static gint
|
|
|
|
gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
|
|
|
GtkRBTree *tree,
|
|
|
|
GtkRBNode *node,
|
|
|
|
gboolean select)
|
|
|
|
{
|
|
|
|
gboolean selected = FALSE;
|
|
|
|
GtkTreePath *path = NULL;
|
|
|
|
|
2002-01-10 00:11:32 +00:00
|
|
|
select = !! select;
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
|
|
|
|
{
|
|
|
|
path = _gtk_tree_view_find_path (selection->tree_view, tree, node);
|
|
|
|
if (selection->user_func)
|
|
|
|
{
|
2001-10-08 05:01:09 +00:00
|
|
|
if ((*selection->user_func) (selection, selection->tree_view->priv->model, path,
|
|
|
|
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),
|
|
|
|
selection->user_data))
|
2000-10-06 00:06:00 +00:00
|
|
|
selected = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
selected = TRUE;
|
2000-11-18 23:59:30 +00:00
|
|
|
gtk_tree_path_free (path);
|
2000-10-06 00:06:00 +00:00
|
|
|
}
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
if (selected == TRUE)
|
|
|
|
{
|
|
|
|
node->flags ^= GTK_RBNODE_IS_SELECTED;
|
|
|
|
|
2002-01-02 23:51:03 +00:00
|
|
|
_gtk_tree_view_queue_draw_node (selection->tree_view, tree, node, NULL);
|
|
|
|
|
2000-10-06 00:06:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|