2000-10-05 01:04:57 +00:00
|
|
|
/* gtktreemodel.c
|
|
|
|
* 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 <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2001-02-17 00:16:08 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include <gobject/gvaluecollector.h>
|
2000-10-05 01:04:57 +00:00
|
|
|
#include "gtktreemodel.h"
|
2001-02-28 21:37:50 +00:00
|
|
|
#include "gtktreeview.h"
|
|
|
|
#include "gtktreeprivate.h"
|
2001-03-07 14:49:21 +00:00
|
|
|
#include "gtksignal.h"
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
struct _GtkTreePath
|
|
|
|
{
|
|
|
|
gint depth;
|
|
|
|
gint *indices;
|
|
|
|
};
|
|
|
|
|
2001-02-21 19:59:23 +00:00
|
|
|
static void gtk_tree_model_base_init (gpointer g_class);
|
|
|
|
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkType
|
|
|
|
gtk_tree_model_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType tree_model_type = 0;
|
|
|
|
|
2001-03-23 00:35:19 +00:00
|
|
|
if (! tree_model_type)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
static const GTypeInfo tree_model_info =
|
|
|
|
{
|
2000-10-16 23:11:55 +00:00
|
|
|
sizeof (GtkTreeModelIface), /* class_size */
|
2001-02-21 19:59:23 +00:00
|
|
|
gtk_tree_model_base_init, /* base_init */
|
2000-10-05 01:04:57 +00:00
|
|
|
NULL, /* base_finalize */
|
2000-12-21 05:27:06 +00:00
|
|
|
NULL,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
0,
|
|
|
|
0, /* n_preallocs */
|
|
|
|
NULL
|
2000-10-05 01:04:57 +00:00
|
|
|
};
|
|
|
|
|
urg, removed implementation of gtk_marshal_VOID__INT_INT_INT_INT. if
Wed Oct 25 20:47:41 2000 Tim Janik <timj@gtk.org>
* gtk/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): urg, removed
implementation of gtk_marshal_VOID__INT_INT_INT_INT. if people do that,
couldn't they at least give it a non-standard name?
* gtk/gtktextlayout.c: arg! yet another implementation of
gtk_marshal_VOID__INT_INT_INT_INT(), is this a conspiracy?
* gtk/gtktextbuffer.c: gotcha! captured a vagabonding
gtk_marshal_VOID__INT_POINTER_INT() implementation, braught it back
home. now i know this _is_ a conspiracy.
* gtk/gtkwidget.c (gtk_widget_class_init): marshaller fixups for
::state-changed.
* gtk/gtkaccelgroup.c (gtk_accel_group_create_remove):
(gtk_accel_group_create_add): marshaller signature fixups.
* gtk/gtklistitem.c (gtk_list_item_class_init): signal creation fixups,
pass in GTK_TYPE_SCROLL_TYPE instead of GTK_TYPE_ENUM.
* gtk/gtkobject.[hc]: removed GTK_CONNECTED flag, it's not valid
anymore.
Tue Oct 24 23:59:21 2000 Tim Janik <timj@gtk.org>
* docs/reference/Makefile.am: disabled SUBDIRS for the moment, since
due to the signal system changes, it wouldn't build currently. to
be fixed soon.
* docs/Changes-2.0.txt: GtkSignal/GSignal updates.
* gtk/gtkwidget.c: ::direction_changed takes an enum as argument,
so it needs gtk_marshal_VOID__ENUM() instead of
gtk_marshal_NONE__UINT().
* gdk/gdk*.c: adapted type registration functions.
* gtk/gtkbindings.c:
* gtk/gtkaccelgroup.c: operate on GSignalQuery, GtkSignalQuery is
gone.
* gtk/gtkenums.h: define GtkSignalRunType in terms of GSignalType.
* gtk/gtkobject.c:
(gtk_object_destroy):
(gtk_object_shutdown): fixed recursion guards. basically we have to
catch the case where any of GObject.shutdown() or gtk_object_destroy()
is called during ::destroy, and avoid recursion there.
* gtk/gtktypeutils.c:
* gtk/maketypes.awk: awk-script hackup to provide gtk_type_init() with
boxed_copy/boxed_free. this needs a more general solution based on a
publically installed code-generator utility.
* gtk/gtktypeutils.[hc]: compat aliased GTK_TYPE_BOXED to G_TYPE_BOXED,
glib's gobject has support for that now.
define GtkSignalMarshaller in terms of GSignalCMarshaller.
Mon Oct 23 09:36:42 2000 Tim Janik <timj@gtk.org>
* gtk/gtksignal.[hc]:
* gtk/gtkmarshal.[hc]:
* gtk/Makefile.am: generate marshallers with glib-genmarshal and don't
compile gtkmarshal.c on its own anymore, just include it in gtksignal.c.
removed #include <gtkmarshal.h>s all over the place, gtksignal.h takes
care of that.
* *.c: marshaller name fixups.
* gtk/gtkmarshal.list: added a comment briefing the format.
Sun Oct 22 23:14:39 2000 Tim Janik <timj@gtk.org>
* gtk/gtksignal.[hc]: nuked old implementation. we mostly have
compatibility macros here now. more specifically, most of
the API is preserved (yes, _most_, nonwithstanding the
following exceptions listed, the API is stil lHUGE ;)
things that got removed completely:
GtkSignalQuery, gtk_signal_query(), gtk_signal_n_emissions(),
gtk_signal_n_emissions_by_name(), gtk_signal_handlers_destroy(),
gtk_signal_set_funcs(), gtk_signal_handler_pending_by_id(),
gtk_signal_add_emission_hook(), gtk_signal_add_emission_hook_full(),
gtk_signal_remove_emission_hook().
non-functional functions variants:
gtk_signal_add_emission_hook(), gtk_signal_remove_emission_hook().
the GtkCallbackMarshal argument to gtk_signal_connect_full() is
not supported anymore.
(gtk_signal_compat_matched): new internal function to aid
implementation of the compatibility macros, it provides
functionality to block/unblock/disconnect handlers based
on func/data.
* gtk/gtkenums.h: define GtkSignalRunType in terms of GSignalType,
* *.c: adaptions to new type registration API signatures.
Fri Oct 20 15:26:33 2000 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.[hc]: removed G_TYPE_GTK_POINTER cludge.
2000-10-25 22:34:14 +00:00
|
|
|
tree_model_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeModel", &tree_model_info, 0);
|
2001-03-08 21:36:34 +00:00
|
|
|
g_type_interface_add_prerequisite (tree_model_type, G_TYPE_OBJECT);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tree_model_type;
|
|
|
|
}
|
|
|
|
|
2001-02-21 19:59:23 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_model_base_init (gpointer g_class)
|
|
|
|
{
|
2001-03-23 00:35:19 +00:00
|
|
|
static gboolean initialized = FALSE;
|
2001-02-21 23:49:22 +00:00
|
|
|
|
2001-03-23 00:35:19 +00:00
|
|
|
if (! initialized)
|
2001-02-21 19:59:23 +00:00
|
|
|
{
|
2001-04-02 20:56:55 +00:00
|
|
|
g_signal_newc ("range_changed",
|
2001-02-21 19:59:23 +00:00
|
|
|
GTK_TYPE_TREE_MODEL,
|
2001-02-21 23:49:22 +00:00
|
|
|
G_SIGNAL_RUN_LAST,
|
2001-04-02 20:56:55 +00:00
|
|
|
G_STRUCT_OFFSET (GtkTreeModelIface, range_changed),
|
2001-03-08 16:36:17 +00:00
|
|
|
NULL, NULL,
|
2001-04-02 20:56:55 +00:00
|
|
|
gtk_marshal_VOID__BOXED_BOXED_BOXED_BOXED,
|
|
|
|
G_TYPE_NONE, 4,
|
|
|
|
GTK_TYPE_TREE_PATH,
|
|
|
|
GTK_TYPE_TREE_ITER,
|
2001-02-21 19:59:23 +00:00
|
|
|
GTK_TYPE_TREE_PATH,
|
|
|
|
GTK_TYPE_TREE_ITER);
|
|
|
|
g_signal_newc ("inserted",
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
2001-02-21 23:49:22 +00:00
|
|
|
G_SIGNAL_RUN_LAST,
|
2001-02-21 19:59:23 +00:00
|
|
|
G_STRUCT_OFFSET (GtkTreeModelIface, inserted),
|
2001-03-08 16:36:17 +00:00
|
|
|
NULL, NULL,
|
2001-02-21 19:59:23 +00:00
|
|
|
gtk_marshal_VOID__BOXED_BOXED,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
GTK_TYPE_TREE_PATH,
|
|
|
|
GTK_TYPE_TREE_ITER);
|
2001-03-05 19:43:24 +00:00
|
|
|
g_signal_newc ("has_child_toggled",
|
2001-02-21 19:59:23 +00:00
|
|
|
GTK_TYPE_TREE_MODEL,
|
2001-02-21 23:49:22 +00:00
|
|
|
G_SIGNAL_RUN_LAST,
|
2001-03-05 19:43:24 +00:00
|
|
|
G_STRUCT_OFFSET (GtkTreeModelIface, has_child_toggled),
|
2001-03-08 16:36:17 +00:00
|
|
|
NULL, NULL,
|
2001-02-21 19:59:23 +00:00
|
|
|
gtk_marshal_VOID__BOXED_BOXED,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
GTK_TYPE_TREE_PATH,
|
|
|
|
GTK_TYPE_TREE_ITER);
|
|
|
|
g_signal_newc ("deleted",
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
2001-02-21 23:49:22 +00:00
|
|
|
G_SIGNAL_RUN_LAST,
|
2001-02-21 19:59:23 +00:00
|
|
|
G_STRUCT_OFFSET (GtkTreeModelIface, deleted),
|
2001-03-08 16:36:17 +00:00
|
|
|
NULL, NULL,
|
2001-02-21 23:49:22 +00:00
|
|
|
gtk_marshal_VOID__BOXED,
|
2001-02-21 19:59:23 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_TREE_PATH);
|
2001-03-23 00:35:19 +00:00
|
|
|
g_signal_newc ("reordered",
|
|
|
|
GTK_TYPE_TREE_MODEL,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkTreeModelIface, reordered),
|
|
|
|
NULL, NULL,
|
2001-03-28 01:54:14 +00:00
|
|
|
gtk_marshal_VOID__BOXED_BOXED_POINTER,
|
|
|
|
G_TYPE_NONE, 3,
|
2001-03-23 00:35:19 +00:00
|
|
|
GTK_TYPE_TREE_PATH,
|
2001-03-28 01:54:14 +00:00
|
|
|
GTK_TYPE_TREE_ITER,
|
2001-03-23 00:35:19 +00:00
|
|
|
G_TYPE_POINTER);
|
|
|
|
initialized = TRUE;
|
2001-02-21 19:59:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_new:
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Creates a new #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: A newly created #GtkTreePath.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
/* GtkTreePath Operations */
|
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_path_new (void)
|
|
|
|
{
|
|
|
|
GtkTreePath *retval;
|
|
|
|
retval = (GtkTreePath *) g_new (GtkTreePath, 1);
|
|
|
|
retval->depth = 0;
|
|
|
|
retval->indices = NULL;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_new_from_string:
|
|
|
|
* @path: The string representation of a path.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-05-16 18:16:57 +00:00
|
|
|
* Creates a new #GtkTreePath initialized to @path. @path is expected to be a
|
|
|
|
* colon separated list of numbers. For example, the string "10:4:0" would
|
|
|
|
* create a path of depth 3 pointing to the 11th child of the root node, the 5th
|
|
|
|
* child of that 11th child, and the 1st child of that 5th child. If an invalid
|
|
|
|
* path is past in, NULL is returned.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-05-16 18:16:57 +00:00
|
|
|
* Return value: A newly created #GtkTreePath, or NULL
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_path_new_from_string (gchar *path)
|
|
|
|
{
|
|
|
|
GtkTreePath *retval;
|
2001-05-16 18:16:57 +00:00
|
|
|
gchar *orig_path = path;
|
2000-10-05 01:04:57 +00:00
|
|
|
gchar *ptr;
|
|
|
|
gint i;
|
|
|
|
|
2001-05-16 18:16:57 +00:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
g_return_val_if_fail (*path != '\000', NULL);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
retval = gtk_tree_path_new ();
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
i = strtol (path, &ptr, 10);
|
|
|
|
gtk_tree_path_append_index (retval, i);
|
|
|
|
|
2001-05-16 18:16:57 +00:00
|
|
|
if (i < 0)
|
|
|
|
{
|
|
|
|
g_warning (G_STRLOC"Negative numbers in path %s passed to gtk_tree_path_new_from_string", orig_path);
|
|
|
|
gtk_tree_path_free (retval);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
if (*ptr == '\000')
|
|
|
|
break;
|
2001-05-16 18:16:57 +00:00
|
|
|
if (ptr == path || *ptr != ':')
|
|
|
|
{
|
|
|
|
g_warning (G_STRLOC"Invalid path %s passed to gtk_tree_path_new_from_string", orig_path);
|
|
|
|
gtk_tree_path_free (retval);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-10-05 01:04:57 +00:00
|
|
|
path = ptr + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_to_string:
|
|
|
|
* @path: A #GtkTreePath
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Generates a string representation of the path. This string is a ':'
|
|
|
|
* separated list of numbers. For example, "4:10:0:3" would be an acceptable return value for this string.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: A newly allocated string. Must be freed with #g_free.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gchar *
|
|
|
|
gtk_tree_path_to_string (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
gchar *retval, *ptr;
|
|
|
|
gint i;
|
|
|
|
|
2001-05-16 18:16:57 +00:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
if (path->depth == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ptr = retval = (gchar *) g_new0 (char *, path->depth*8);
|
|
|
|
sprintf (retval, "%d", path->indices[0]);
|
|
|
|
while (*ptr != '\000')
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
for (i = 1; i < path->depth; i++)
|
|
|
|
{
|
|
|
|
sprintf (ptr, ":%d", path->indices[i]);
|
|
|
|
while (*ptr != '\000')
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_new_root:
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Creates a new root #GtkTreePath. The string representation of this path is
|
|
|
|
* "0"
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: A new #GtkTreePath.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_path_new_root (void)
|
|
|
|
{
|
|
|
|
GtkTreePath *retval;
|
|
|
|
|
|
|
|
retval = gtk_tree_path_new ();
|
|
|
|
gtk_tree_path_append_index (retval, 0);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_append_index:
|
|
|
|
* @path: A #GtkTreePath.
|
|
|
|
* @index: The index.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Appends a new index to a path. As a result, the depth of the path is
|
|
|
|
* increased.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_path_append_index (GtkTreePath *path,
|
|
|
|
gint index)
|
|
|
|
{
|
2000-10-17 22:21:01 +00:00
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
g_return_if_fail (index >= 0);
|
|
|
|
|
2001-02-13 05:44:47 +00:00
|
|
|
path->depth += 1;
|
|
|
|
path->indices = g_realloc (path->indices, path->depth * sizeof(gint));
|
2000-10-05 01:04:57 +00:00
|
|
|
path->indices[path->depth - 1] = index;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_prepend_index:
|
|
|
|
* @path: A #GtkTreePath.
|
|
|
|
* @index: The index.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Prepends a new index to a path. As a result, the depth of the path is
|
|
|
|
* increased.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_path_prepend_index (GtkTreePath *path,
|
|
|
|
gint index)
|
|
|
|
{
|
|
|
|
gint *new_indices = g_new (gint, ++path->depth);
|
|
|
|
if (path->indices == NULL)
|
|
|
|
{
|
|
|
|
path->indices = new_indices;
|
|
|
|
path->indices[0] = index;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy (new_indices + 1, path->indices, (path->depth - 1)*sizeof (gint));
|
|
|
|
g_free (path->indices);
|
|
|
|
path->indices = new_indices;
|
|
|
|
path->indices[0] = index;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_get_depth:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Returns the current depth of @path.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: The depth of @path
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gint
|
|
|
|
gtk_tree_path_get_depth (GtkTreePath *path)
|
|
|
|
{
|
2000-10-17 22:21:01 +00:00
|
|
|
g_return_val_if_fail (path != NULL, 0);
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
return path->depth;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_get_indices:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Returns the current indices of @path. This is an array of integers, each
|
|
|
|
* representing a node in a tree.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: The current indices, or NULL.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gint *
|
|
|
|
gtk_tree_path_get_indices (GtkTreePath *path)
|
|
|
|
{
|
2000-10-17 22:21:01 +00:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
return path->indices;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_free:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Frees @path.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_path_free (GtkTreePath *path)
|
|
|
|
{
|
2000-11-13 19:23:24 +00:00
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
g_free (path->indices);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_copy:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Creates a new #GtkTreePath as a copy of @path.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: A new #GtkTreePath.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_path_copy (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreePath *retval;
|
|
|
|
|
2000-11-13 19:23:24 +00:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
2000-10-05 01:04:57 +00:00
|
|
|
retval = g_new (GtkTreePath, 1);
|
|
|
|
retval->depth = path->depth;
|
|
|
|
retval->indices = g_new (gint, path->depth);
|
|
|
|
memcpy (retval->indices, path->indices, path->depth * sizeof (gint));
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_compare:
|
|
|
|
* @a: A #GtkTreePath.
|
|
|
|
* @b: A #GtkTreePath to compare with.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-04-23 23:03:53 +00:00
|
|
|
* Compares two paths. If @a appears before @b in a tree, then -1, is returned.
|
|
|
|
* If @b appears before @a, then 1 is returned. If the two nodes are equal,
|
2000-10-17 22:21:01 +00:00
|
|
|
* then 0 is returned.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: The relative positions of @a and @b
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gint
|
2000-10-17 22:21:01 +00:00
|
|
|
gtk_tree_path_compare (const GtkTreePath *a,
|
|
|
|
const GtkTreePath *b)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
|
|
|
gint p = 0, q = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (a != NULL, 0);
|
|
|
|
g_return_val_if_fail (b != NULL, 0);
|
|
|
|
g_return_val_if_fail (a->depth > 0, 0);
|
|
|
|
g_return_val_if_fail (b->depth > 0, 0);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (a->indices[p] == b->indices[q])
|
|
|
|
continue;
|
2001-04-23 23:03:53 +00:00
|
|
|
return (a->indices[p] < b->indices[q]?-1:1);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
while (++p < a->depth && ++q < b->depth);
|
|
|
|
if (a->depth == b->depth)
|
|
|
|
return 0;
|
2001-04-23 23:03:53 +00:00
|
|
|
return (a->depth < b->depth?-1:1);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_is_ancestor:
|
|
|
|
* @path: a #GtkTreePath
|
|
|
|
* @descendant: another #GtkTreePath
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2001-01-31 00:57:49 +00:00
|
|
|
* Return value: %TRUE if @descendant is contained inside @path
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_path_is_ancestor (GtkTreePath *path,
|
|
|
|
GtkTreePath *descendant)
|
|
|
|
{
|
|
|
|
gint i;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (descendant != NULL, FALSE);
|
|
|
|
|
|
|
|
/* can't be an ancestor if we're deeper */
|
|
|
|
if (path->depth >= descendant->depth)
|
|
|
|
return FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
i = 0;
|
|
|
|
while (i < path->depth)
|
|
|
|
{
|
|
|
|
if (path->indices[i] != descendant->indices[i])
|
|
|
|
return FALSE;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_path_is_descendant:
|
|
|
|
* @path: a #GtkTreePath
|
|
|
|
* @ancestor: another #GtkTreePath
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2001-01-31 00:57:49 +00:00
|
|
|
* Return value: %TRUE if @ancestor contains @path somewhere below it
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_path_is_descendant (GtkTreePath *path,
|
|
|
|
GtkTreePath *ancestor)
|
|
|
|
{
|
|
|
|
gint i;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (ancestor != NULL, FALSE);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
/* can't be a descendant if we're shallower in the tree */
|
|
|
|
if (path->depth <= ancestor->depth)
|
|
|
|
return FALSE;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
i = 0;
|
|
|
|
while (i < ancestor->depth)
|
|
|
|
{
|
|
|
|
if (path->indices[i] != ancestor->indices[i])
|
|
|
|
return FALSE;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_next:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Moves the @path to point to the next node at the current depth.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_path_next (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (path != NULL);
|
2000-10-17 22:21:01 +00:00
|
|
|
g_return_if_fail (path->depth > 0);
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
path->indices[path->depth - 1] ++;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_prev:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Moves the @path to point to the previous node at the current depth, if it exists.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-30 23:21:38 +00:00
|
|
|
* Return value: TRUE if @path has a previous node, and the move was made.
|
2000-10-17 22:21:01 +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
|
|
|
gboolean
|
2000-10-05 01:04:57 +00:00
|
|
|
gtk_tree_path_prev (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
if (path->indices[path->depth - 1] == 0)
|
2000-10-05 01:04:57 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2001-01-31 00:57:49 +00:00
|
|
|
path->indices[path->depth - 1] -= 1;
|
2000-10-05 01:04:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_up:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Moves the @path to point to it's parent node, if it has a parent.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: TRUE if @path has a parent, and the move was made.
|
|
|
|
**/
|
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
|
|
|
gboolean
|
2000-10-05 01:04:57 +00:00
|
|
|
gtk_tree_path_up (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
|
|
|
|
if (path->depth == 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
path->depth--;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_path_down:
|
|
|
|
* @path: A #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Moves @path to point to the first child of the current path.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
|
|
|
gtk_tree_path_down (GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
gtk_tree_path_append_index (path, 0);
|
|
|
|
}
|
|
|
|
|
2000-11-09 16:52:17 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_iter_copy:
|
|
|
|
* @iter: A #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Creates a dynamically allocated tree iterator as a copy of @iter. This
|
|
|
|
* function is not intended for use in applications, because you can just copy
|
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
|
|
|
* the structs by value (GtkTreeIter new_iter = iter;). You
|
2000-11-09 16:52:17 +00:00
|
|
|
* must free this iter with gtk_tree_iter_free ().
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Return value: a newly allocated copy of @iter.
|
|
|
|
**/
|
|
|
|
GtkTreeIter *
|
|
|
|
gtk_tree_iter_copy (GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreeIter *retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (iter != NULL, NULL);
|
|
|
|
|
|
|
|
retval = g_new (GtkTreeIter, 1);
|
|
|
|
*retval = *iter;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_iter_free:
|
|
|
|
* @iter: A dynamically allocated tree iterator.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Free an iterator that has been allocated on the heap. This function is
|
|
|
|
* mainly used for language bindings.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_tree_iter_free (GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
g_return_if_fail (iter != NULL);
|
|
|
|
|
|
|
|
g_free (iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_flags:
|
|
|
|
* @tree_model: A #GtkTreeModel.
|
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
|
|
|
* Returns a set of flags supported by this interface. The flags are a bitwise
|
2001-06-14 23:25:52 +00:00
|
|
|
* combination of #GtkTreeModelFlags. The flags supported should not change
|
|
|
|
* during the lifecycle of the tree_model.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Return value: The flags supported by this interface.
|
|
|
|
**/
|
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
|
|
|
GtkTreeModelFlags
|
2000-11-09 16:52:17 +00:00
|
|
|
gtk_tree_model_get_flags (GtkTreeModel *tree_model)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (tree_model != NULL, 0);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), 0);
|
|
|
|
|
|
|
|
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_flags)
|
|
|
|
return (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_flags) (tree_model);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_n_columns:
|
|
|
|
* @tree_model: A #GtkTreeModel.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Returns the number of columns supported by the #tree_model
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: The number of columns.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gint
|
|
|
|
gtk_tree_model_get_n_columns (GtkTreeModel *tree_model)
|
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, 0);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), 0);
|
2000-10-16 23:11:55 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_n_columns != NULL, 0);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
2000-10-16 23:11:55 +00:00
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_n_columns) (tree_model);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 16:52:17 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_column_type:
|
|
|
|
* @tree_model: A #GtkTreeModel.
|
|
|
|
* @index: The column index.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Returns the type of the column.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Return value: The type of the column.
|
|
|
|
**/
|
|
|
|
GType
|
|
|
|
gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
|
|
|
|
gint index)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (tree_model != NULL, G_TYPE_INVALID);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), G_TYPE_INVALID);
|
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_column_type != NULL, G_TYPE_INVALID);
|
|
|
|
g_return_val_if_fail (index >= 0, G_TYPE_INVALID);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_column_type) (tree_model, index);
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_get_iter:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The uninitialized #GtkTreeIter.
|
|
|
|
* @path: The #GtkTreePath.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Sets @iter to a valid iterator pointing to @path. If the model does not
|
|
|
|
* provide an implementation of this function, it is implemented in terms of
|
|
|
|
* @gtk_tree_model_iter_nth_child.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE, if @iter was set.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean
|
|
|
|
gtk_tree_model_get_iter (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
2000-10-26 00:36:47 +00:00
|
|
|
GtkTreeIter parent;
|
|
|
|
gint *indices;
|
|
|
|
gint depth, i;
|
|
|
|
|
2001-05-22 19:18:47 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
|
2000-10-26 00:36:47 +00:00
|
|
|
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_iter != NULL)
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_iter) (tree_model, iter, path);
|
|
|
|
|
|
|
|
indices = gtk_tree_path_get_indices (path);
|
|
|
|
depth = gtk_tree_path_get_depth (path);
|
|
|
|
|
|
|
|
g_return_val_if_fail (depth > 0, FALSE);
|
|
|
|
|
|
|
|
if (! gtk_tree_model_iter_nth_child (tree_model, iter, NULL, indices[0]))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 1; i < depth; i++)
|
|
|
|
{
|
|
|
|
parent = *iter;
|
|
|
|
if (! gtk_tree_model_iter_nth_child (tree_model, iter, &parent, indices[i]))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-05-22 19:18:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_iter_root:
|
|
|
|
* @tree_model: A #GtkTreeModel.
|
|
|
|
* @iter: The uninitialized #GtkTreeIter.
|
|
|
|
*
|
|
|
|
* Gets the root iter, if it exists.
|
|
|
|
*
|
|
|
|
* Return value: TRUE, if @iter was set.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_model_get_iter_root (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
gboolean retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_root ();
|
|
|
|
retval = gtk_tree_model_get_iter (tree_model, iter, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2001-01-10 23:44:22 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_first:
|
|
|
|
* @tree_model: a #GtkTreeModel
|
|
|
|
* @iter: iterator to initialize
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-01-10 23:44:22 +00:00
|
|
|
* Initialized @iter with the first iterator in the tree (the one at the
|
|
|
|
* root path) and returns %TRUE, or returns %FALSE if there are no
|
|
|
|
* iterable locations in the model (i.e. the tree is empty).
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-01-10 23:44:22 +00:00
|
|
|
* Return value: %TRUE if @iter was initialized
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_model_get_first (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
gboolean retval;
|
|
|
|
GtkTreePath *path;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-01-10 23:44:22 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_root ();
|
|
|
|
|
|
|
|
retval = gtk_tree_model_get_iter (tree_model, iter, path);
|
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_path:
|
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Returns a newly created #GtkTreePath referenced by @iter. This path should
|
2000-10-17 22:21:01 +00:00
|
|
|
* be freed with #gtk_tree_path_free.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Return value: a newly created #GtkTreePath.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_model_get_path (GtkTreeModel *tree_model,
|
2000-10-26 00:36:47 +00:00
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, NULL);
|
|
|
|
g_return_val_if_fail (iter != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), NULL);
|
2000-10-16 23:11:55 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_path != NULL, NULL);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_path) (tree_model, iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-27 23:34:58 +00:00
|
|
|
* gtk_tree_model_get_value:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter.
|
|
|
|
* @column: The column to lookup the value at.
|
2000-10-17 22:21:01 +00:00
|
|
|
* @value: An empty #GValue to set.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-17 22:21:01 +00:00
|
|
|
* Sets initializes and sets @value to that at @column. When done with value,
|
|
|
|
* #g_value_unset needs to be called on it.
|
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
void
|
2000-10-27 23:34:58 +00:00
|
|
|
gtk_tree_model_get_value (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint column,
|
|
|
|
GValue *value)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (iter != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
g_return_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->get_value != NULL);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
2000-10-27 23:34:58 +00:00
|
|
|
(* GTK_TREE_MODEL_GET_IFACE (tree_model)->get_value) (tree_model, iter, column, value);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_next:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Sets @iter to point to the node following it at the current level. If there
|
|
|
|
* is no next @iter, FALSE is returned and @iter is set to be invalid.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE if @iter has been changed to the next node.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gboolean
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_model_iter_next (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_next != NULL, FALSE);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_next) (tree_model, iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_children:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-30 23:21:38 +00:00
|
|
|
* @iter: The new #GtkTreeIter to be set to the child.
|
|
|
|
* @parent: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Sets @iter to point to the first child of @parent. If @parent has no children,
|
|
|
|
* FALSE is returned and @iter is set to be invalid. @parent will remain a valid
|
|
|
|
* node after this function has been called.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE, if @child has been set to the first child.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean
|
|
|
|
gtk_tree_model_iter_children (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkTreeIter *parent)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_children != NULL, FALSE);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_children) (tree_model, iter, parent);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_has_child:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter to test for children.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Returns TRUE if @iter has children, FALSE otherwise.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE if @iter has children.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gboolean
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_model_iter_has_child (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_has_child != NULL, FALSE);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_has_child) (tree_model, iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_n_children:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-11-09 16:52:17 +00:00
|
|
|
* @iter: The #GtkTreeIter, or NULL.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Returns the number of children that @iter has. If @iter is NULL, then the
|
|
|
|
* number of toplevel nodes is returned.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: The number of children of @iter.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-05 01:04:57 +00:00
|
|
|
gint
|
2000-10-26 00:36:47 +00:00
|
|
|
gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, 0);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), 0);
|
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_n_children != NULL, 0);
|
2000-10-26 00:36:47 +00:00
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_n_children) (tree_model, iter);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_nth_child:
|
2000-10-17 22:21:01 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
2000-10-26 00:36:47 +00:00
|
|
|
* @iter: The #GtkTreeIter to set to the nth child.
|
|
|
|
* @parent: The #GtkTreeIter to get the child from, or NULL.
|
|
|
|
* @n: Then index of the desired child.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-11-09 16:52:17 +00:00
|
|
|
* Sets @iter to be the child of @parent, using the given index. The first
|
|
|
|
* index is 0. If the index is too big, or @parent has no children, @iter is
|
|
|
|
* set to an invalid iterator and FALSE is returned. @parent will remain a
|
|
|
|
* valid node after this function has been called. If @parent is NULL, then the
|
|
|
|
* root node is assumed.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE, if @parent has an nth child.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean
|
|
|
|
gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkTreeIter *parent,
|
2000-10-17 22:21:01 +00:00
|
|
|
gint n)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-10-27 23:34:58 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (n >= 0, FALSE);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_nth_child != NULL, FALSE);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_nth_child) (tree_model, iter, parent, n);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-10-17 22:21:01 +00:00
|
|
|
/**
|
2000-10-26 00:36:47 +00:00
|
|
|
* gtk_tree_model_iter_parent:
|
|
|
|
* @tree_model: A #GtkTreeModel
|
2000-10-30 23:21:38 +00:00
|
|
|
* @iter: The new #GtkTreeIter to set to the parent.
|
|
|
|
* @child: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Sets @iter to be the parent of @child. If @child is at the toplevel, and
|
|
|
|
* doesn't have a parent, then @iter is set to an invalid iterator and FALSE
|
|
|
|
* is returned. @child will remain a valid node after this function has been
|
|
|
|
* called.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2000-10-26 00:36:47 +00:00
|
|
|
* Return value: TRUE, if @iter is set to the parent of @child.
|
2000-10-17 22:21:01 +00:00
|
|
|
**/
|
2000-10-26 00:36:47 +00:00
|
|
|
gboolean
|
|
|
|
gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkTreeIter *child)
|
2000-10-05 01:04:57 +00:00
|
|
|
{
|
2000-11-09 16:52:17 +00:00
|
|
|
g_return_val_if_fail (tree_model != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
|
|
|
|
g_return_val_if_fail (iter != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (child != NULL, FALSE);
|
2000-10-26 00:36:47 +00:00
|
|
|
g_return_val_if_fail (GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_parent != NULL, FALSE);
|
|
|
|
|
|
|
|
return (* GTK_TREE_MODEL_GET_IFACE (tree_model)->iter_parent) (tree_model, iter, child);
|
2000-10-05 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 16:52:17 +00:00
|
|
|
/**
|
2001-03-09 00:19:11 +00:00
|
|
|
* gtk_tree_model_ref_node:
|
2000-11-09 16:52:17 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
|
|
|
* @iter: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-03-09 00:19:11 +00:00
|
|
|
* Lets the tree ref the node. This is an optional method for models to
|
|
|
|
* implement. To be more specific, models may ignore this call as it exists
|
|
|
|
* primarily for performance reasons.
|
|
|
|
*
|
|
|
|
* This function is primarily meant as a way for views to let caching model know
|
|
|
|
* when nodes are being displayed (and hence, whether or not to cache that
|
|
|
|
* node.) For example, a file-system based model would not want to keep the
|
|
|
|
* entire file-heirarchy in memory, just the sections that are currently being
|
|
|
|
* displayed by every current view.
|
2000-11-09 16:52:17 +00:00
|
|
|
**/
|
|
|
|
void
|
2001-03-09 00:19:11 +00:00
|
|
|
gtk_tree_model_ref_node (GtkTreeModel *tree_model,
|
2000-11-09 16:52:17 +00:00
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
|
2001-03-09 00:19:11 +00:00
|
|
|
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->ref_node)
|
|
|
|
(* GTK_TREE_MODEL_GET_IFACE (tree_model)->ref_node) (tree_model, iter);
|
2000-11-09 16:52:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-03-09 00:19:11 +00:00
|
|
|
* gtk_tree_model_unref_node:
|
2000-11-09 16:52:17 +00:00
|
|
|
* @tree_model: A #GtkTreeModel.
|
|
|
|
* @iter: The #GtkTreeIter.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-03-09 00:19:11 +00:00
|
|
|
* Lets the tree unref the node. This is an optional method for models to
|
|
|
|
* implement. To be more specific, models may ignore this call as it exists
|
|
|
|
* primarily for performance reasons.
|
|
|
|
*
|
|
|
|
* For more information on what this means, please see #gtk_tree_model_ref_node.
|
|
|
|
* Please note that nodes that are deleted are not unreffed.
|
2000-11-09 16:52:17 +00:00
|
|
|
**/
|
|
|
|
void
|
2001-03-09 00:19:11 +00:00
|
|
|
gtk_tree_model_unref_node (GtkTreeModel *tree_model,
|
2000-11-09 16:52:17 +00:00
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
|
2001-03-09 00:19:11 +00:00
|
|
|
if (GTK_TREE_MODEL_GET_IFACE (tree_model)->unref_node)
|
|
|
|
(* GTK_TREE_MODEL_GET_IFACE (tree_model)->unref_node) (tree_model, iter);
|
2000-11-09 16:52:17 +00:00
|
|
|
}
|
2001-02-17 00:16:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_model_get:
|
|
|
|
* @tree_model: a #GtkTreeModel
|
|
|
|
* @iter: a row in @tree_model
|
|
|
|
* @Varargs: pairs of column number and value return locations, terminated by -1
|
|
|
|
*
|
|
|
|
* Gets the value of one or more cells in the row referenced by @iter.
|
|
|
|
* The variable argument list should contain integer column numbers,
|
|
|
|
* each column number followed by a place to store the value being
|
|
|
|
* retrieved. The list is terminated by a -1. For example, to get a
|
|
|
|
* value from column 0 with type %G_TYPE_STRING, you would
|
|
|
|
* write: gtk_tree_model_set (model, iter, 0, &place_string_here, -1),
|
|
|
|
* where place_string_here is a gchar* to be filled with the string.
|
|
|
|
* If appropriate, the returned values have to be freed or unreferenced.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-02-17 00:16:08 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_tree_model_get (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list var_args;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
|
|
|
|
va_start (var_args, iter);
|
|
|
|
gtk_tree_model_get_valist (tree_model, iter, var_args);
|
|
|
|
va_end (var_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_model_get_valist:
|
|
|
|
* @tree_model: a #GtkTreeModel
|
|
|
|
* @iter: a row in @tree_model
|
|
|
|
* @var_args: va_list of column/return location pairs
|
|
|
|
*
|
|
|
|
* See gtk_tree_model_get(), this version takes a va_list for
|
|
|
|
* language bindings to use.
|
2001-02-28 21:37:50 +00:00
|
|
|
*
|
2001-02-17 00:16:08 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_tree_model_get_valist (GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
va_list var_args)
|
|
|
|
{
|
|
|
|
gint column;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
|
|
|
|
column = va_arg (var_args, gint);
|
|
|
|
|
|
|
|
while (column != -1)
|
|
|
|
{
|
|
|
|
GValue value = { 0, };
|
|
|
|
gchar *error = NULL;
|
|
|
|
|
|
|
|
if (column >= gtk_tree_model_get_n_columns (tree_model))
|
|
|
|
{
|
|
|
|
g_warning ("%s: Invalid column number %d accessed (remember to end your list of columns with a -1)", G_STRLOC, column);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_model_get_value (GTK_TREE_MODEL (tree_model), iter, column, &value);
|
|
|
|
|
2001-02-19 22:51:15 +00:00
|
|
|
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
2001-02-17 00:16:08 +00:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("%s: %s", G_STRLOC, error);
|
|
|
|
g_free (error);
|
|
|
|
|
|
|
|
/* we purposely leak the value here, it might not be
|
|
|
|
* in a sane state if an error condition occoured
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
column = va_arg (var_args, gint);
|
|
|
|
}
|
|
|
|
}
|
2001-02-22 01:56:08 +00:00
|
|
|
|
|
|
|
void
|
2001-04-02 20:56:55 +00:00
|
|
|
gtk_tree_model_range_changed (GtkTreeModel *tree_model,
|
|
|
|
GtkTreePath *start_path,
|
|
|
|
GtkTreeIter *start_iter,
|
|
|
|
GtkTreePath *end_path,
|
|
|
|
GtkTreeIter *end_iter)
|
2001-02-22 01:56:08 +00:00
|
|
|
{
|
2001-06-15 23:03:27 +00:00
|
|
|
gint i;
|
2001-02-22 01:56:08 +00:00
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
2001-04-02 20:56:55 +00:00
|
|
|
g_return_if_fail (start_path != NULL);
|
|
|
|
g_return_if_fail (start_iter != NULL);
|
|
|
|
g_return_if_fail (end_path != NULL);
|
|
|
|
g_return_if_fail (end_iter != NULL);
|
|
|
|
|
2001-06-15 23:03:27 +00:00
|
|
|
#ifndef G_DISABLE_CHECKS
|
|
|
|
g_return_if_fail (start_path->depth == end_path->depth);
|
|
|
|
for (i = 0; i < start_path->depth - 1; i++)
|
|
|
|
if (start_path->indices[i] != end_path->indices[i])
|
|
|
|
{
|
|
|
|
g_warning ("Concurrent paths were not passed in to gtk_tree_model_range_changed.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2001-04-02 20:56:55 +00:00
|
|
|
g_signal_emit_by_name (tree_model, "range_changed",
|
|
|
|
start_path, start_iter,
|
|
|
|
end_path, end_iter);
|
2001-02-22 01:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_model_inserted (GtkTreeModel *tree_model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
g_return_if_fail (iter != NULL);
|
|
|
|
|
|
|
|
g_signal_emit_by_name (tree_model, "inserted", path, iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-05 19:43:24 +00:00
|
|
|
gtk_tree_model_has_child_toggled (GtkTreeModel *tree_model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter)
|
2001-02-22 01:56:08 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
g_return_if_fail (iter != NULL);
|
|
|
|
|
2001-03-05 19:43:24 +00:00
|
|
|
g_signal_emit_by_name (tree_model, "has_child_toggled", path, iter);
|
2001-02-22 01:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_model_deleted (GtkTreeModel *tree_model,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
g_signal_emit_by_name (tree_model, "deleted", path);
|
|
|
|
}
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-03-23 00:35:19 +00:00
|
|
|
void
|
|
|
|
gtk_tree_model_reordered (GtkTreeModel *tree_model,
|
|
|
|
GtkTreePath *path,
|
2001-03-28 03:09:03 +00:00
|
|
|
GtkTreeIter *iter,
|
2001-03-23 00:35:19 +00:00
|
|
|
gint *new_order)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree_model != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
|
|
|
|
g_return_if_fail (new_order != NULL);
|
|
|
|
|
2001-03-28 03:09:03 +00:00
|
|
|
g_signal_emit_by_name (tree_model, "reordered", path, iter, new_order);
|
2001-03-23 00:35:19 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-03-23 22:21:06 +00:00
|
|
|
/*
|
|
|
|
* GtkTreeRowReference
|
|
|
|
*/
|
2001-02-28 21:37:50 +00:00
|
|
|
|
|
|
|
#define ROW_REF_DATA_STRING "gtk-tree-row-refs"
|
|
|
|
|
|
|
|
struct _GtkTreeRowReference
|
|
|
|
{
|
|
|
|
GObject *proxy;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
} RowRefList;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
release_row_references (gpointer data)
|
|
|
|
{
|
|
|
|
RowRefList *refs = data;
|
|
|
|
GSList *tmp_list = NULL;
|
|
|
|
|
|
|
|
tmp_list = refs->list;
|
|
|
|
while (tmp_list != NULL)
|
|
|
|
{
|
|
|
|
GtkTreeRowReference *reference = tmp_list->data;
|
|
|
|
|
|
|
|
if (reference->proxy == (GObject *)reference->model)
|
|
|
|
reference->model = NULL;
|
|
|
|
reference->proxy = NULL;
|
|
|
|
|
|
|
|
/* we don't free the reference, users are responsible for that. */
|
|
|
|
|
|
|
|
tmp_list = g_slist_next (tmp_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (refs->list);
|
|
|
|
g_free (refs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_row_ref_inserted_callback (GObject *object,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
RowRefList *refs = g_object_get_data (data, ROW_REF_DATA_STRING);
|
|
|
|
|
|
|
|
GSList *tmp_list;
|
|
|
|
|
|
|
|
if (refs == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* This function corrects the path stored in the reference to
|
|
|
|
* account for an insertion. Note that it's called _after_ the insertion
|
|
|
|
* with the path to the newly-inserted row. Which means that
|
|
|
|
* the inserted path is in a different "coordinate system" than
|
|
|
|
* the old path (e.g. if the inserted path was just before the old path,
|
|
|
|
* then inserted path and old path will be the same, and old path must be
|
|
|
|
* moved down one).
|
|
|
|
*/
|
|
|
|
|
|
|
|
tmp_list = refs->list;
|
|
|
|
|
|
|
|
while (tmp_list != NULL)
|
|
|
|
{
|
|
|
|
GtkTreeRowReference *reference = tmp_list->data;
|
|
|
|
|
|
|
|
if (reference->path)
|
|
|
|
{
|
|
|
|
gint depth = gtk_tree_path_get_depth (path);
|
|
|
|
gint ref_depth = gtk_tree_path_get_depth (reference->path);
|
|
|
|
|
|
|
|
if (ref_depth >= depth)
|
|
|
|
{
|
|
|
|
gint *indices = gtk_tree_path_get_indices (path);
|
|
|
|
gint *ref_indices = gtk_tree_path_get_indices (reference->path);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
/* This is the depth that might affect us. */
|
|
|
|
i = depth - 1;
|
|
|
|
|
|
|
|
if (indices[i] <= ref_indices[i])
|
|
|
|
ref_indices[i] += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_list = g_slist_next (tmp_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_row_ref_deleted_callback (GObject *object,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
RowRefList *refs = g_object_get_data (data, ROW_REF_DATA_STRING);
|
|
|
|
GSList *tmp_list;
|
|
|
|
|
|
|
|
if (refs == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* This function corrects the path stored in the reference to
|
|
|
|
* account for an deletion. Note that it's called _after_ the
|
|
|
|
* deletion with the old path of the just-deleted row. Which means
|
|
|
|
* that the deleted path is the same now-defunct "coordinate system"
|
|
|
|
* as the path saved in the reference, which is what we want to fix.
|
|
|
|
*
|
|
|
|
* Note that this is different from the situation in "inserted," so
|
|
|
|
* while you might think you can cut-and-paste between these
|
|
|
|
* functions, it's not going to work. ;-)
|
|
|
|
*/
|
|
|
|
|
|
|
|
tmp_list = refs->list;
|
|
|
|
|
|
|
|
while (tmp_list != NULL)
|
|
|
|
{
|
|
|
|
GtkTreeRowReference *reference = tmp_list->data;
|
|
|
|
|
|
|
|
if (reference->path)
|
|
|
|
{
|
|
|
|
gint depth = gtk_tree_path_get_depth (path);
|
|
|
|
gint ref_depth = gtk_tree_path_get_depth (reference->path);
|
|
|
|
|
|
|
|
if (ref_depth >= depth)
|
|
|
|
{
|
|
|
|
/* Need to adjust path upward */
|
|
|
|
gint *indices = gtk_tree_path_get_indices (path);
|
|
|
|
gint *ref_indices = gtk_tree_path_get_indices (reference->path);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
i = depth - 1;
|
|
|
|
if (indices[i] < ref_indices[i])
|
|
|
|
ref_indices[i] -= 1;
|
|
|
|
else if (indices[i] == ref_indices[i])
|
|
|
|
{
|
|
|
|
/* the referenced node itself, or its parent, was
|
|
|
|
* deleted, mark invalid
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_path_free (reference->path);
|
|
|
|
reference->path = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
tmp_list = g_slist_next (tmp_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-30 01:26:30 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_row_ref_reordered_callback (GObject *object,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint *new_order,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
RowRefList *refs = g_object_get_data (data, ROW_REF_DATA_STRING);
|
|
|
|
GSList *tmp_list;
|
|
|
|
gint length;
|
|
|
|
|
|
|
|
if (refs == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tmp_list = refs->list;
|
|
|
|
|
|
|
|
while (tmp_list != NULL)
|
|
|
|
{
|
|
|
|
GtkTreeRowReference *reference = tmp_list->data;
|
|
|
|
|
|
|
|
length = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (reference->model), iter);
|
|
|
|
|
|
|
|
if (length < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((reference->path) &&
|
|
|
|
(gtk_tree_path_is_ancestor (path, reference->path)))
|
|
|
|
{
|
|
|
|
gint ref_depth = gtk_tree_path_get_depth (reference->path);
|
|
|
|
gint depth = gtk_tree_path_get_depth (path);
|
|
|
|
|
|
|
|
if (ref_depth > depth)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gint *indices = gtk_tree_path_get_indices (reference->path);
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
if (new_order[i] == indices[depth])
|
|
|
|
{
|
|
|
|
indices[depth] = i;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_list = g_slist_next (tmp_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-02-28 21:37:50 +00:00
|
|
|
static void
|
|
|
|
connect_ref_callbacks (GtkTreeModel *model)
|
|
|
|
{
|
|
|
|
g_signal_connect_data (G_OBJECT (model),
|
|
|
|
"inserted",
|
|
|
|
(GCallback) gtk_tree_row_ref_inserted_callback,
|
|
|
|
model,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
g_signal_connect_data (G_OBJECT (model),
|
|
|
|
"deleted",
|
|
|
|
(GCallback) gtk_tree_row_ref_deleted_callback,
|
|
|
|
model,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
FALSE);
|
2001-03-30 01:26:30 +00:00
|
|
|
|
|
|
|
g_signal_connect_data (G_OBJECT (model),
|
|
|
|
"reordered",
|
|
|
|
(GCallback) gtk_tree_row_ref_reordered_callback,
|
|
|
|
model,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
FALSE);
|
2001-02-28 21:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disconnect_ref_callbacks (GtkTreeModel *model)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_matched (G_OBJECT (model),
|
|
|
|
G_SIGNAL_MATCH_FUNC,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_tree_row_ref_inserted_callback,
|
|
|
|
NULL);
|
|
|
|
g_signal_handlers_disconnect_matched (G_OBJECT (model),
|
|
|
|
G_SIGNAL_MATCH_FUNC,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_tree_row_ref_deleted_callback,
|
|
|
|
NULL);
|
2001-03-30 01:26:30 +00:00
|
|
|
g_signal_handlers_disconnect_matched (G_OBJECT (model),
|
|
|
|
G_SIGNAL_MATCH_FUNC,
|
|
|
|
0, 0, NULL,
|
|
|
|
gtk_tree_row_ref_reordered_callback,
|
|
|
|
NULL);
|
2001-02-28 21:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkTreeRowReference *
|
|
|
|
gtk_tree_row_reference_new (GtkTreeModel *model,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (model != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
|
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
|
|
|
return gtk_tree_row_reference_new_proxy (G_OBJECT (model), model, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkTreeRowReference *
|
|
|
|
gtk_tree_row_reference_new_proxy (GObject *proxy,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreeRowReference *reference;
|
|
|
|
RowRefList *refs;
|
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_OBJECT (proxy), NULL);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
|
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
|
|
|
|
|
|
|
reference = g_new (GtkTreeRowReference, 1);
|
|
|
|
|
2001-05-25 23:10:49 +00:00
|
|
|
g_object_ref (proxy);
|
|
|
|
g_object_ref (model);
|
2001-02-28 21:37:50 +00:00
|
|
|
reference->proxy = proxy;
|
|
|
|
reference->model = model;
|
|
|
|
reference->path = gtk_tree_path_copy (path);
|
|
|
|
|
|
|
|
refs = g_object_get_data (G_OBJECT (proxy), ROW_REF_DATA_STRING);
|
|
|
|
|
|
|
|
if (refs == NULL)
|
|
|
|
{
|
|
|
|
refs = g_new (RowRefList, 1);
|
|
|
|
refs->list = NULL;
|
|
|
|
|
2001-03-02 00:49:32 +00:00
|
|
|
if (G_OBJECT (model) == proxy)
|
2001-02-28 21:37:50 +00:00
|
|
|
connect_ref_callbacks (model);
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (proxy),
|
|
|
|
ROW_REF_DATA_STRING,
|
|
|
|
refs, release_row_references);
|
|
|
|
}
|
|
|
|
|
|
|
|
refs->list = g_slist_prepend (refs->list, reference);
|
|
|
|
|
|
|
|
return reference;
|
|
|
|
}
|
|
|
|
|
2001-06-18 23:44:41 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_row_reference_get_path:
|
|
|
|
* @reference: A #GtkTreeRowReference
|
|
|
|
*
|
|
|
|
* Returns a path that the row reference currently points to, or NULL if
|
|
|
|
*
|
|
|
|
* Return value: A current path, or NULL.
|
|
|
|
**/
|
2001-02-28 21:37:50 +00:00
|
|
|
GtkTreePath *
|
|
|
|
gtk_tree_row_reference_get_path (GtkTreeRowReference *reference)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (reference != NULL, NULL);
|
|
|
|
|
|
|
|
if (reference->proxy == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (reference->path == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gtk_tree_path_copy (reference->path);
|
|
|
|
}
|
|
|
|
|
2001-06-18 23:44:41 +00:00
|
|
|
/**
|
|
|
|
* gtk_tree_row_reference_valid:
|
|
|
|
* @reference: A #GtkTreeRowReference, or NULL
|
|
|
|
*
|
|
|
|
* Returns TRUE if the %reference is non-NULL and refers to a current valid
|
|
|
|
* path.
|
|
|
|
*
|
|
|
|
* Return value: TRUE if %reference points to a valid path.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gtk_tree_row_reference_valid (GtkTreeRowReference *reference)
|
|
|
|
{
|
|
|
|
if (reference == NULL || reference->path == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_tree_row_reference_free:
|
|
|
|
* @reference: A #GtkTreeRowReference, or NULL
|
|
|
|
*
|
|
|
|
* Free's %reference. %reference may be NULL.
|
|
|
|
**/
|
2001-02-28 21:37:50 +00:00
|
|
|
void
|
|
|
|
gtk_tree_row_reference_free (GtkTreeRowReference *reference)
|
|
|
|
{
|
|
|
|
RowRefList *refs;
|
|
|
|
|
2001-06-18 23:44:41 +00:00
|
|
|
if (reference == NULL)
|
|
|
|
return;
|
2001-02-28 21:37:50 +00:00
|
|
|
|
2001-05-25 23:10:49 +00:00
|
|
|
refs = g_object_get_data (G_OBJECT (reference->proxy), ROW_REF_DATA_STRING);
|
|
|
|
|
|
|
|
if (refs == NULL)
|
|
|
|
{
|
|
|
|
g_warning (G_STRLOC": bad row reference, proxy has no outstanding row references");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
refs->list = g_slist_remove (refs->list, reference);
|
|
|
|
|
|
|
|
if (refs->list == NULL)
|
2001-02-28 21:37:50 +00:00
|
|
|
{
|
2001-05-25 23:10:49 +00:00
|
|
|
disconnect_ref_callbacks (reference->model);
|
|
|
|
g_object_set_data (G_OBJECT (reference->proxy),
|
|
|
|
ROW_REF_DATA_STRING,
|
|
|
|
NULL);
|
2001-02-28 21:37:50 +00:00
|
|
|
}
|
2001-05-25 23:10:49 +00:00
|
|
|
g_object_unref (reference->proxy);
|
|
|
|
g_object_unref (reference->model);
|
2001-02-28 21:37:50 +00:00
|
|
|
|
|
|
|
if (reference->path)
|
|
|
|
gtk_tree_path_free (reference->path);
|
|
|
|
|
|
|
|
g_free (reference);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_row_reference_inserted (GObject *proxy,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (G_IS_OBJECT (proxy));
|
|
|
|
|
|
|
|
gtk_tree_row_ref_inserted_callback (NULL, path, NULL, proxy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_row_reference_deleted (GObject *proxy,
|
|
|
|
GtkTreePath *path)
|
|
|
|
{
|
|
|
|
g_return_if_fail (G_IS_OBJECT (proxy));
|
|
|
|
|
|
|
|
gtk_tree_row_ref_deleted_callback (NULL, path, proxy);
|
|
|
|
}
|
2001-03-30 01:26:30 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_row_reference_reordered (GObject *proxy,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gint *new_order)
|
|
|
|
{
|
|
|
|
g_return_if_fail (G_IS_OBJECT (proxy));
|
|
|
|
|
|
|
|
gtk_tree_row_ref_reordered_callback (NULL, path, iter, new_order, proxy);
|
|
|
|
}
|
|
|
|
|