1997-11-24 22:37:52 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* 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
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtktree.h"
|
1997-12-17 23:41:42 +00:00
|
|
|
#include "gtktreeitem.h"
|
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtksignal.h"
|
|
|
|
#include "gtklist.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SELECTION_CHANGED,
|
|
|
|
SELECT_CHILD,
|
|
|
|
UNSELECT_CHILD,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
1998-01-30 23:47:09 +00:00
|
|
|
static void gtk_tree_class_init (GtkTreeClass *klass);
|
|
|
|
static void gtk_tree_init (GtkTree *tree);
|
1997-12-17 23:41:42 +00:00
|
|
|
static void gtk_tree_destroy (GtkObject *object);
|
|
|
|
static void gtk_tree_map (GtkWidget *widget);
|
|
|
|
static void gtk_tree_unmap (GtkWidget *widget);
|
|
|
|
static void gtk_tree_realize (GtkWidget *widget);
|
|
|
|
static void gtk_tree_draw (GtkWidget *widget,
|
|
|
|
GdkRectangle *area);
|
|
|
|
static gint gtk_tree_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
|
|
|
static gint gtk_tree_motion_notify (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event);
|
|
|
|
static gint gtk_tree_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static gint gtk_tree_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static void gtk_tree_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition);
|
|
|
|
static void gtk_tree_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void gtk_tree_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
static void gtk_tree_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
1997-12-17 23:41:42 +00:00
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
|
|
|
|
|
|
|
static void gtk_real_tree_select_child (GtkTree *tree,
|
|
|
|
GtkWidget *child);
|
|
|
|
static void gtk_real_tree_unselect_child (GtkTree *tree,
|
|
|
|
GtkWidget *child);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1998-06-16 05:20:05 +00:00
|
|
|
static GtkType gtk_tree_child_type (GtkContainer *container);
|
1997-12-17 23:41:42 +00:00
|
|
|
|
|
|
|
static GtkContainerClass *parent_class = NULL;
|
1998-03-09 15:16:28 +00:00
|
|
|
static guint tree_signals[LAST_SIGNAL] = { 0 };
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1998-06-16 05:20:05 +00:00
|
|
|
GtkType
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_tree_get_type (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1998-06-16 05:20:05 +00:00
|
|
|
static GtkType tree_type = 0;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (!tree_type)
|
|
|
|
{
|
1998-11-30 19:07:15 +00:00
|
|
|
static const GtkTypeInfo tree_info =
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
"GtkTree",
|
|
|
|
sizeof (GtkTree),
|
|
|
|
sizeof (GtkTreeClass),
|
|
|
|
(GtkClassInitFunc) gtk_tree_class_init,
|
|
|
|
(GtkObjectInitFunc) gtk_tree_init,
|
1998-07-04 15:31:30 +00:00
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
1998-06-28 07:46:10 +00:00
|
|
|
(GtkClassInitFunc) NULL,
|
1997-11-24 22:37:52 +00:00
|
|
|
};
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
tree_type = gtk_type_unique (gtk_container_get_type (), &tree_info);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
return tree_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_class_init (GtkTreeClass *class)
|
|
|
|
{
|
1997-12-17 23:41:42 +00:00
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkContainerClass *container_class;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
object_class = (GtkObjectClass*) class;
|
|
|
|
widget_class = (GtkWidgetClass*) class;
|
|
|
|
container_class = (GtkContainerClass*) class;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
parent_class = gtk_type_class (gtk_container_get_type ());
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree_signals[SELECTION_CHANGED] =
|
|
|
|
gtk_signal_new ("selection_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GtkTreeClass, selection_changed),
|
1998-07-21 04:13:42 +00:00
|
|
|
gtk_marshal_NONE__NONE,
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_TYPE_NONE, 0);
|
|
|
|
tree_signals[SELECT_CHILD] =
|
|
|
|
gtk_signal_new ("select_child",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GtkTreeClass, select_child),
|
1998-07-21 04:13:42 +00:00
|
|
|
gtk_marshal_NONE__POINTER,
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_WIDGET);
|
|
|
|
tree_signals[UNSELECT_CHILD] =
|
|
|
|
gtk_signal_new ("unselect_child",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GtkTreeClass, unselect_child),
|
1998-07-21 04:13:42 +00:00
|
|
|
gtk_marshal_NONE__POINTER,
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_WIDGET);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_object_class_add_signals (object_class, tree_signals, LAST_SIGNAL);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
object_class->destroy = gtk_tree_destroy;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
widget_class->map = gtk_tree_map;
|
|
|
|
widget_class->unmap = gtk_tree_unmap;
|
|
|
|
widget_class->realize = gtk_tree_realize;
|
|
|
|
widget_class->draw = gtk_tree_draw;
|
|
|
|
widget_class->expose_event = gtk_tree_expose;
|
|
|
|
widget_class->motion_notify_event = gtk_tree_motion_notify;
|
|
|
|
widget_class->button_press_event = gtk_tree_button_press;
|
|
|
|
widget_class->button_release_event = gtk_tree_button_release;
|
|
|
|
widget_class->size_request = gtk_tree_size_request;
|
|
|
|
widget_class->size_allocate = gtk_tree_size_allocate;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
container_class->add = gtk_tree_add;
|
1998-03-02 23:16:39 +00:00
|
|
|
container_class->remove =
|
1998-08-18 03:59:41 +00:00
|
|
|
(void (*)(GtkContainer *, GtkWidget *)) gtk_tree_remove_item;
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
container_class->forall = gtk_tree_forall;
|
1998-06-16 05:20:05 +00:00
|
|
|
container_class->child_type = gtk_tree_child_type;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
class->selection_changed = NULL;
|
|
|
|
class->select_child = gtk_real_tree_select_child;
|
|
|
|
class->unselect_child = gtk_real_tree_unselect_child;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
1998-06-16 05:20:05 +00:00
|
|
|
static GtkType
|
|
|
|
gtk_tree_child_type (GtkContainer *container)
|
|
|
|
{
|
|
|
|
return GTK_TYPE_TREE_ITEM;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
static void
|
|
|
|
gtk_tree_init (GtkTree *tree)
|
|
|
|
{
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->children = NULL;
|
|
|
|
tree->root_tree = NULL;
|
|
|
|
tree->selection = NULL;
|
|
|
|
tree->tree_owner = NULL;
|
|
|
|
tree->selection_mode = GTK_SELECTION_SINGLE;
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->indent_value = 9;
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->current_indent = 0;
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->level = 0;
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->view_mode = GTK_TREE_VIEW_LINE;
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->view_line = 1;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_tree_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
return GTK_WIDGET (gtk_type_new (gtk_tree_get_type ()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_append (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *tree_item)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (tree_item != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
gtk_tree_insert(tree, tree_item, -1);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_prepend (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *tree_item)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (tree_item != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
gtk_tree_insert(tree, tree_item, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_insert (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *tree_item,
|
1997-11-24 22:37:52 +00:00
|
|
|
gint position)
|
|
|
|
{
|
1997-12-17 23:41:42 +00:00
|
|
|
gint nchildren;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (tree_item != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
/* set parent widget to item */
|
1998-03-11 04:05:15 +00:00
|
|
|
gtk_widget_set_parent (tree_item, GTK_WIDGET (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (tree_item->parent))
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
if (GTK_WIDGET_REALIZED (tree_item->parent) &&
|
|
|
|
!GTK_WIDGET_REALIZED (tree_item))
|
|
|
|
gtk_widget_realize (tree_item);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
if (GTK_WIDGET_MAPPED (tree_item->parent) &&
|
|
|
|
!GTK_WIDGET_MAPPED (tree_item))
|
|
|
|
gtk_widget_map (tree_item);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
nchildren = g_list_length (tree->children);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if ((position < 0) || (position > nchildren))
|
|
|
|
position = nchildren;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (position == nchildren)
|
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
tree->children = g_list_append(tree->children, tree_item);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
tree->children = g_list_insert(tree->children, tree_item, position);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (tree))
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (container != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (container));
|
|
|
|
g_return_if_fail (widget != NULL);
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (widget));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (container);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
|
|
|
if (GTK_WIDGET_VISIBLE (widget->parent))
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_REALIZED (widget->parent) &&
|
|
|
|
!GTK_WIDGET_REALIZED (widget))
|
|
|
|
gtk_widget_realize (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_MAPPED (widget->parent) &&
|
|
|
|
!GTK_WIDGET_MAPPED (widget))
|
|
|
|
gtk_widget_map (widget);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->children = g_list_append (tree->children, widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (!tree->selection && (tree->selection_mode == GTK_SELECTION_BROWSE))
|
|
|
|
{
|
|
|
|
gtk_tree_select_child (tree, widget);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container))
|
|
|
|
gtk_widget_queue_resize (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_tree_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *item;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_val_if_fail (widget != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE (widget), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (widget);
|
|
|
|
item = gtk_get_event_widget ((GdkEvent*) event);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-24 01:43:21 +00:00
|
|
|
while (item && !GTK_IS_TREE_ITEM (item))
|
1997-12-17 23:41:42 +00:00
|
|
|
item = item->parent;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-24 01:43:21 +00:00
|
|
|
if (!item || (item->parent != widget))
|
|
|
|
return FALSE;
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
switch(event->button)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
gtk_tree_select_child (tree, item);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if(GTK_TREE_ITEM(item)->subtree) gtk_tree_item_expand(GTK_TREE_ITEM(item));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if(GTK_TREE_ITEM(item)->subtree) gtk_tree_item_collapse(GTK_TREE_ITEM(item));
|
|
|
|
break;
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_tree_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *item;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_val_if_fail (widget != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE (widget), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (widget);
|
|
|
|
item = gtk_get_event_widget ((GdkEvent*) event);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gtk_tree_child_position (GtkTree *tree,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
gint pos;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_val_if_fail (tree != NULL, -1);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE (tree), -1);
|
|
|
|
g_return_val_if_fail (child != NULL, -1);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
pos = 0;
|
|
|
|
children = tree->children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
if (child == GTK_WIDGET (children->data))
|
|
|
|
return pos;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
pos += 1;
|
|
|
|
children = children->next;
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_clear_items (GtkTree *tree,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
GList *clear_list;
|
|
|
|
GList *tmp_list;
|
|
|
|
guint nchildren;
|
|
|
|
guint index;
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-03-11 04:05:15 +00:00
|
|
|
|
|
|
|
nchildren = g_list_length (tree->children);
|
|
|
|
|
|
|
|
if (nchildren > 0)
|
|
|
|
{
|
|
|
|
if ((end < 0) || (end > nchildren))
|
|
|
|
end = nchildren;
|
|
|
|
|
|
|
|
if (start >= end)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tmp_list = g_list_nth (tree->children, start);
|
|
|
|
clear_list = NULL;
|
|
|
|
index = start;
|
|
|
|
while (tmp_list && index <= end)
|
|
|
|
{
|
|
|
|
widget = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
index++;
|
|
|
|
|
|
|
|
clear_list = g_list_prepend (clear_list, widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_remove_items (tree, clear_list);
|
|
|
|
}
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (object != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (object));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (object);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-01-30 23:47:09 +00:00
|
|
|
|
|
|
|
gtk_widget_ref (child);
|
|
|
|
gtk_widget_unparent (child);
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_widget_destroy (child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (child);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_list_free (tree->children);
|
1998-01-30 23:47:09 +00:00
|
|
|
tree->children = NULL;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-01-30 23:47:09 +00:00
|
|
|
if (tree->root_tree == tree)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
for (node = tree->selection; node; node = node->next)
|
|
|
|
gtk_widget_unref ((GtkWidget *)node->data);
|
|
|
|
g_list_free (tree->selection);
|
|
|
|
tree->selection = NULL;
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_draw (GtkWidget *widget,
|
|
|
|
GdkRectangle *area)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *subtree;
|
|
|
|
GtkWidget *child;
|
|
|
|
GdkRectangle child_area;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
|
|
|
g_return_if_fail (area != NULL);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
|
|
{
|
|
|
|
tree = GTK_TREE (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (gtk_widget_intersect (child, area, &child_area))
|
|
|
|
gtk_widget_draw (child, &child_area);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if((subtree = GTK_TREE_ITEM(child)->subtree) &&
|
|
|
|
GTK_WIDGET_VISIBLE(subtree) &&
|
|
|
|
gtk_widget_intersect (subtree, area, &child_area))
|
|
|
|
gtk_widget_draw (subtree, &child_area);
|
|
|
|
}
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_tree_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child;
|
|
|
|
GdkEventExpose child_event;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_val_if_fail (widget != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE (widget), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
|
|
{
|
|
|
|
tree = GTK_TREE (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
child_event = *event;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_NO_WINDOW (child) &&
|
|
|
|
gtk_widget_intersect (child, &event->area, &child_event.area))
|
|
|
|
gtk_widget_event (child, (GdkEvent*) &child_event);
|
|
|
|
}
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
gtk_tree_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (container != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (container));
|
|
|
|
g_return_if_fail (callback != NULL);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (container);
|
|
|
|
children = tree->children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
(* callback) (child, callback_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_map (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
|
|
|
tree = GTK_TREE (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if(GTK_IS_TREE(widget->parent))
|
|
|
|
{
|
|
|
|
/* set root tree for this tree */
|
|
|
|
tree->root_tree = GTK_TREE(widget->parent)->root_tree;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->level = GTK_TREE(GTK_WIDGET(tree)->parent)->level+1;
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->indent_value = GTK_TREE(GTK_WIDGET(tree)->parent)->indent_value;
|
|
|
|
tree->current_indent = GTK_TREE(GTK_WIDGET(tree)->parent)->current_indent +
|
|
|
|
tree->indent_value;
|
|
|
|
tree->view_mode = GTK_TREE(GTK_WIDGET(tree)->parent)->view_mode;
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->view_line = GTK_TREE(GTK_WIDGET(tree)->parent)->view_line;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tree->root_tree = tree;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (child) &&
|
|
|
|
!GTK_WIDGET_MAPPED (child))
|
|
|
|
gtk_widget_map (child);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-12 07:28:41 +00:00
|
|
|
if (GTK_TREE_ITEM (child)->subtree)
|
|
|
|
{
|
|
|
|
child = GTK_WIDGET (GTK_TREE_ITEM (child)->subtree);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-12 07:28:41 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
|
|
|
|
gtk_widget_map (child);
|
|
|
|
}
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1999-01-15 16:00:39 +00:00
|
|
|
|
|
|
|
gdk_window_show (widget->window);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gtk_tree_motion_notify (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (widget != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GTK_IS_TREE (widget), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("gtk_tree_motion_notify\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GdkWindowAttr attributes;
|
|
|
|
gint attributes_mask;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
|
|
|
attributes.x = widget->allocation.x;
|
|
|
|
attributes.y = widget->allocation.y;
|
|
|
|
attributes.width = widget->allocation.width;
|
|
|
|
attributes.height = widget->allocation.height;
|
|
|
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
attributes.visual = gtk_widget_get_visual (widget);
|
|
|
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
1998-03-12 09:14:03 +00:00
|
|
|
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-01-18 15:09:10 +00:00
|
|
|
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
|
1997-12-17 23:41:42 +00:00
|
|
|
gdk_window_set_user_data (widget->window, widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
widget->style = gtk_style_attach (widget->style, widget->window);
|
1998-02-13 05:26:33 +00:00
|
|
|
gdk_window_set_background (widget->window,
|
|
|
|
&widget->style->base[GTK_STATE_NORMAL]);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
1998-02-23 18:14:47 +00:00
|
|
|
void
|
1998-03-02 23:16:39 +00:00
|
|
|
gtk_tree_remove_item (GtkTree *container,
|
|
|
|
GtkWidget *widget)
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
|
|
|
GList *item_list;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (container != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (container));
|
|
|
|
g_return_if_fail (widget != NULL);
|
1998-02-23 18:14:47 +00:00
|
|
|
g_return_if_fail (container == GTK_TREE (widget->parent));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
item_list = g_list_append (NULL, widget);
|
1997-12-17 23:41:42 +00:00
|
|
|
|
|
|
|
gtk_tree_remove_items (GTK_TREE (container), item_list);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_list_free (item_list);
|
|
|
|
}
|
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
/* used by gtk_tree_remove_items to make the function independant of
|
|
|
|
order in list of items to remove.
|
|
|
|
Sort item bu depth in tree */
|
|
|
|
static gint
|
|
|
|
gtk_tree_sort_item_by_depth(GtkWidget* a, GtkWidget* b)
|
|
|
|
{
|
|
|
|
if((GTK_TREE(a->parent)->level) < (GTK_TREE(b->parent)->level))
|
|
|
|
return 1;
|
|
|
|
if((GTK_TREE(a->parent)->level) > (GTK_TREE(b->parent)->level))
|
|
|
|
return -1;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
void
|
|
|
|
gtk_tree_remove_items (GtkTree *tree,
|
|
|
|
GList *items)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GList *selected_widgets;
|
|
|
|
GList *tmp_list;
|
1998-03-02 00:32:52 +00:00
|
|
|
GList *sorted_list;
|
|
|
|
GtkTree *real_tree;
|
|
|
|
GtkTree *root_tree;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("+ gtk_tree_remove_items [ tree %#x items list %#x ]\n", (int)tree, (int)items);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-05-01 04:23:59 +00:00
|
|
|
/* We may not yet be mapped, so we actively have to find our
|
|
|
|
* root tree
|
|
|
|
*/
|
|
|
|
if (tree->root_tree)
|
|
|
|
root_tree = tree->root_tree;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *tmp = GTK_WIDGET (tree);
|
|
|
|
while (tmp->parent && GTK_IS_TREE (tmp->parent))
|
|
|
|
tmp = tmp->parent;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-05-01 04:23:59 +00:00
|
|
|
root_tree = GTK_TREE (tmp);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = items;
|
|
|
|
selected_widgets = NULL;
|
1998-03-02 00:32:52 +00:00
|
|
|
sorted_list = NULL;
|
1997-12-17 23:41:42 +00:00
|
|
|
widget = NULL;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* sort list by depth\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
while (tmp_list)
|
1998-03-02 00:32:52 +00:00
|
|
|
{
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message ("* item [%#x] depth [%d]\n",
|
|
|
|
(int)tmp_list->data,
|
|
|
|
(int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
sorted_list = g_list_insert_sorted(sorted_list,
|
|
|
|
tmp_list->data,
|
|
|
|
(GCompareFunc)gtk_tree_sort_item_by_depth);
|
|
|
|
tmp_list = g_list_next(tmp_list);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
|
|
|
/* print sorted list */
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* sorted list result\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
tmp_list = sorted_list;
|
|
|
|
while(tmp_list)
|
|
|
|
{
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* item [%#x] depth [%d]\n",
|
|
|
|
(int)tmp_list->data,
|
|
|
|
(int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level);
|
1998-03-02 00:32:52 +00:00
|
|
|
tmp_list = g_list_next(tmp_list);
|
|
|
|
}
|
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* scan sorted list\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
tmp_list = sorted_list;
|
1997-12-17 23:41:42 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
widget = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* item [%#x] subtree [%#x]\n",
|
|
|
|
(int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget));
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
/* get real owner of this widget */
|
|
|
|
real_tree = GTK_TREE(widget->parent);
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* subtree having this widget [%#x]\n", (int)real_tree);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
|
|
|
|
if (widget->state == GTK_STATE_SELECTED)
|
1998-03-02 00:32:52 +00:00
|
|
|
{
|
|
|
|
selected_widgets = g_list_prepend (selected_widgets, widget);
|
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* selected widget - adding it in selected list [%#x]\n",
|
|
|
|
(int)selected_widgets);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-05-01 04:23:59 +00:00
|
|
|
/* remove this item from its real parent */
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* remove widget from its owner tree\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
real_tree->children = g_list_remove (real_tree->children, widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
/* remove subtree associate at this item if it exist */
|
|
|
|
if(GTK_TREE_ITEM(widget)->subtree)
|
|
|
|
{
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* remove subtree associate at this item [%#x]\n",
|
|
|
|
(int) GTK_TREE_ITEM(widget)->subtree);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_MAPPED (GTK_TREE_ITEM(widget)->subtree))
|
|
|
|
gtk_widget_unmap (GTK_TREE_ITEM(widget)->subtree);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_widget_unparent (GTK_TREE_ITEM(widget)->subtree);
|
1998-01-30 23:47:09 +00:00
|
|
|
GTK_TREE_ITEM(widget)->subtree = NULL;
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
/* really remove widget for this item */
|
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* unmap and unparent widget [%#x]\n", (int)widget);
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_MAPPED (widget))
|
|
|
|
gtk_widget_unmap (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_widget_unparent (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
/* delete subtree if there is no children in it */
|
|
|
|
if(real_tree->children == NULL &&
|
|
|
|
real_tree != root_tree)
|
|
|
|
{
|
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* owner tree don't have children ... destroy it\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
|
|
|
gtk_tree_item_remove_subtree(GTK_TREE_ITEM(real_tree->tree_owner));
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* next item in list\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (selected_widgets)
|
|
|
|
{
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* scan selected item list\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = selected_widgets;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
widget = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* widget [%#x] subtree [%#x]\n",
|
|
|
|
(int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget));
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
|
|
|
|
|
|
|
/* remove widget of selection */
|
|
|
|
root_tree->selection = g_list_remove (root_tree->selection, widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
/* unref it to authorize is destruction */
|
|
|
|
gtk_widget_unref (widget);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
/* emit only one selection_changed signal */
|
|
|
|
gtk_signal_emit (GTK_OBJECT (root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* free selected_widgets list\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
g_list_free (selected_widgets);
|
1998-03-02 00:32:52 +00:00
|
|
|
g_list_free (sorted_list);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (root_tree->children && !root_tree->selection &&
|
|
|
|
(root_tree->selection_mode == GTK_SELECTION_BROWSE))
|
|
|
|
{
|
1998-03-02 00:32:52 +00:00
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* BROWSE mode, select another item\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
1997-12-17 23:41:42 +00:00
|
|
|
widget = root_tree->children->data;
|
|
|
|
gtk_tree_select_child (root_tree, widget);
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (root_tree))
|
1998-03-02 00:32:52 +00:00
|
|
|
{
|
|
|
|
#ifdef TREE_DEBUG
|
1998-08-18 03:59:41 +00:00
|
|
|
g_message("* query queue resizing for root_tree\n");
|
1998-03-02 00:32:52 +00:00
|
|
|
#endif /* TREE_DEBUG */
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (root_tree));
|
|
|
|
}
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
void
|
|
|
|
gtk_tree_select_child (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *tree_item)
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (tree_item != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (tree), tree_signals[SELECT_CHILD], tree_item);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_select_item (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
gint item)
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
|
|
|
GList *tmp_list;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = g_list_nth (tree->children, item);
|
|
|
|
if (tmp_list)
|
|
|
|
gtk_tree_select_child (tree, GTK_WIDGET (tmp_list->data));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child, *subtree;
|
|
|
|
GtkAllocation child_allocation;
|
|
|
|
GList *children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
|
|
|
g_return_if_fail (allocation != NULL);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (widget);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
widget->allocation = *allocation;
|
|
|
|
if (GTK_WIDGET_REALIZED (widget))
|
|
|
|
gdk_window_move_resize (widget->window,
|
|
|
|
allocation->x, allocation->y,
|
|
|
|
allocation->width, allocation->height);
|
|
|
|
|
|
|
|
if (tree->children)
|
|
|
|
{
|
|
|
|
child_allocation.x = GTK_CONTAINER (tree)->border_width;
|
|
|
|
child_allocation.y = GTK_CONTAINER (tree)->border_width;
|
1999-01-14 06:04:55 +00:00
|
|
|
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (child))
|
|
|
|
{
|
1999-02-10 02:35:09 +00:00
|
|
|
GtkRequisition child_requisition;
|
|
|
|
gtk_widget_get_child_requisition (child, &child_requisition);
|
|
|
|
|
|
|
|
child_allocation.height = child_requisition.height;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_widget_size_allocate (child, &child_allocation);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
child_allocation.y += child_allocation.height;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if((subtree = GTK_TREE_ITEM(child)->subtree))
|
|
|
|
if(GTK_WIDGET_VISIBLE (subtree))
|
|
|
|
{
|
|
|
|
child_allocation.height = subtree->requisition.height;
|
|
|
|
gtk_widget_size_allocate (subtree, &child_allocation);
|
|
|
|
child_allocation.y += child_allocation.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition)
|
|
|
|
{
|
|
|
|
GtkTree *tree;
|
|
|
|
GtkWidget *child, *subtree;
|
|
|
|
GList *children;
|
1999-02-10 02:35:09 +00:00
|
|
|
GtkRequisition child_requisition;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
|
|
|
g_return_if_fail (requisition != NULL);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree = GTK_TREE (widget);
|
|
|
|
requisition->width = 0;
|
|
|
|
requisition->height = 0;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
children = tree->children;
|
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
child = children->data;
|
|
|
|
children = children->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (child))
|
|
|
|
{
|
1999-02-10 02:35:09 +00:00
|
|
|
gtk_widget_size_request (child, &child_requisition);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1999-02-10 02:35:09 +00:00
|
|
|
requisition->width = MAX (requisition->width, child_requisition.width);
|
|
|
|
requisition->height += child_requisition.height;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if((subtree = GTK_TREE_ITEM(child)->subtree) &&
|
|
|
|
GTK_WIDGET_VISIBLE (subtree))
|
|
|
|
{
|
1999-02-10 02:35:09 +00:00
|
|
|
gtk_widget_size_request (subtree, &child_requisition);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
requisition->width = MAX (requisition->width,
|
1999-02-10 02:35:09 +00:00
|
|
|
child_requisition.width);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1999-02-10 02:35:09 +00:00
|
|
|
requisition->height += child_requisition.height;
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
requisition->width += GTK_CONTAINER (tree)->border_width * 2;
|
|
|
|
requisition->height += GTK_CONTAINER (tree)->border_width * 2;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
requisition->width = MAX (requisition->width, 1);
|
|
|
|
requisition->height = MAX (requisition->height, 1);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tree_unmap (GtkWidget *widget)
|
|
|
|
{
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (widget));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
|
|
|
|
gdk_window_hide (widget->window);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_unselect_child (GtkTree *tree,
|
1998-03-11 04:05:15 +00:00
|
|
|
GtkWidget *tree_item)
|
1997-12-17 23:41:42 +00:00
|
|
|
{
|
1998-03-11 04:05:15 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (tree_item != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-03-11 04:05:15 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree), tree_signals[UNSELECT_CHILD], tree_item);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_unselect_item (GtkTree *tree,
|
|
|
|
gint item)
|
|
|
|
{
|
|
|
|
GList *tmp_list;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = g_list_nth (tree->children, item);
|
|
|
|
if (tmp_list)
|
|
|
|
gtk_tree_unselect_child (tree, GTK_WIDGET (tmp_list->data));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_real_tree_select_child (GtkTree *tree,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GList *selection, *root_selection;
|
|
|
|
GList *tmp_list;
|
|
|
|
GtkWidget *tmp_item;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (child));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
root_selection = tree->root_tree->selection;
|
1998-01-30 23:47:09 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
switch (tree->root_tree->selection_mode)
|
|
|
|
{
|
|
|
|
case GTK_SELECTION_SINGLE:
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
selection = root_selection;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
/* remove old selection list */
|
|
|
|
while (selection)
|
|
|
|
{
|
|
|
|
tmp_item = selection->data;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (tmp_item != child)
|
|
|
|
{
|
|
|
|
gtk_tree_item_deselect (GTK_TREE_ITEM (tmp_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = selection;
|
|
|
|
selection = selection->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
root_selection = g_list_remove_link (root_selection, tmp_list);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (tmp_item);
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_list_free (tmp_list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
selection = selection->next;
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (child->state == GTK_STATE_NORMAL)
|
|
|
|
{
|
|
|
|
gtk_tree_item_select (GTK_TREE_ITEM (child));
|
|
|
|
root_selection = g_list_prepend (root_selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_ref (child);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
|
|
|
else if (child->state == GTK_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
gtk_tree_item_deselect (GTK_TREE_ITEM (child));
|
|
|
|
root_selection = g_list_remove (root_selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (child);
|
1997-12-17 23:41:42 +00:00
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-01-30 23:47:09 +00:00
|
|
|
tree->root_tree->selection = root_selection;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree->root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
1998-02-21 14:11:40 +00:00
|
|
|
break;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
case GTK_SELECTION_BROWSE:
|
|
|
|
selection = root_selection;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
while (selection)
|
|
|
|
{
|
|
|
|
tmp_item = selection->data;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (tmp_item != child)
|
|
|
|
{
|
|
|
|
gtk_tree_item_deselect (GTK_TREE_ITEM (tmp_item));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tmp_list = selection;
|
|
|
|
selection = selection->next;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
root_selection = g_list_remove_link (root_selection, tmp_list);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (tmp_item);
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
g_list_free (tmp_list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
selection = selection->next;
|
|
|
|
}
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1998-01-30 23:47:09 +00:00
|
|
|
tree->root_tree->selection = root_selection;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
if (child->state == GTK_STATE_NORMAL)
|
|
|
|
{
|
|
|
|
gtk_tree_item_select (GTK_TREE_ITEM (child));
|
|
|
|
root_selection = g_list_prepend (root_selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_ref (child);
|
|
|
|
tree->root_tree->selection = root_selection;
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree->root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
|
|
|
}
|
|
|
|
break;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
case GTK_SELECTION_MULTIPLE:
|
|
|
|
if (child->state == GTK_STATE_NORMAL)
|
|
|
|
{
|
|
|
|
gtk_tree_item_select (GTK_TREE_ITEM (child));
|
|
|
|
root_selection = g_list_prepend (root_selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_ref (child);
|
|
|
|
tree->root_tree->selection = root_selection;
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree->root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
|
|
|
}
|
|
|
|
else if (child->state == GTK_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
gtk_tree_item_deselect (GTK_TREE_ITEM (child));
|
|
|
|
root_selection = g_list_remove (root_selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (child);
|
|
|
|
tree->root_tree->selection = root_selection;
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree->root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
|
|
|
}
|
|
|
|
break;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
case GTK_SELECTION_EXTENDED:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_real_tree_unselect_child (GtkTree *tree,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE_ITEM (child));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
switch (tree->selection_mode)
|
|
|
|
{
|
|
|
|
case GTK_SELECTION_SINGLE:
|
|
|
|
case GTK_SELECTION_MULTIPLE:
|
|
|
|
case GTK_SELECTION_BROWSE:
|
|
|
|
if (child->state == GTK_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
GtkTree* root_tree = GTK_TREE_ROOT_TREE(tree);
|
|
|
|
gtk_tree_item_deselect (GTK_TREE_ITEM (child));
|
|
|
|
root_tree->selection = g_list_remove (root_tree->selection, child);
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_unref (child);
|
1997-12-17 23:41:42 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (tree->root_tree),
|
|
|
|
tree_signals[SELECTION_CHANGED]);
|
|
|
|
}
|
|
|
|
break;
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
case GTK_SELECTION_EXTENDED:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_set_selection_mode (GtkTree *tree,
|
|
|
|
GtkSelectionMode mode)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->selection_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_set_view_mode (GtkTree *tree,
|
|
|
|
GtkTreeViewMode mode)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-17 23:41:42 +00:00
|
|
|
tree->view_mode = mode;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
1997-12-19 05:41:45 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gtk_tree_set_view_lines (GtkTree *tree,
|
|
|
|
guint flag)
|
|
|
|
{
|
|
|
|
g_return_if_fail (tree != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_TREE (tree));
|
1998-08-18 03:59:41 +00:00
|
|
|
|
1997-12-19 05:41:45 +00:00
|
|
|
tree->view_line = flag;
|
|
|
|
}
|