applied gtk-bolliet-980310-0.patch.gz which adds more checks and

Wed Mar 11 04:35:06 1998  Tim Janik  <timj@gimp.org>

        * gtk/gtklist.c:
        * gtk/gtktree.h:
        * gtk/gtktree.c:
        * gtk/gtktreeitem.h:
        * gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
        more checks and implements gtk_tree_clear_items. made a bunch of style
        and indentation fixes.
This commit is contained in:
Tim Janik 1998-03-11 04:05:15 +00:00 committed by Tim Janik
parent 2ff460a6c8
commit 309d7377e7
19 changed files with 284 additions and 163 deletions

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -1,3 +1,13 @@
Wed Mar 11 04:35:06 1998 Tim Janik <timj@gimp.org>
* gtk/gtklist.c:
* gtk/gtktree.h:
* gtk/gtktree.c:
* gtk/gtktreeitem.h:
* gtk/gtktreeitem.c: applied gtk-bolliet-980310-0.patch.gz which adds
more checks and implements gtk_tree_clear_items. made a bunch of style
and indentation fixes.
Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org> Wed Mar 11 03:35:17 1998 Tim Janik <timj@gimp.org>
* gtk/gtktooltips.h: * gtk/gtktooltips.h:

View File

@ -40,7 +40,7 @@ static gint navailable_depths;
static GdkVisualType available_types[6]; static GdkVisualType available_types[6];
static gint navailable_types; static gint navailable_types;
static char* visual_names[] = static gchar* visual_names[] =
{ {
"static gray", "static gray",
"grayscale", "grayscale",

View File

@ -40,7 +40,7 @@ static gint navailable_depths;
static GdkVisualType available_types[6]; static GdkVisualType available_types[6];
static gint navailable_types; static gint navailable_types;
static char* visual_names[] = static gchar* visual_names[] =
{ {
"static gray", "static gray",
"grayscale", "grayscale",

View File

@ -28,9 +28,9 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#define GTK_BUTTON(obj) GTK_CHECK_CAST (obj, gtk_button_get_type (), GtkButton) #define GTK_BUTTON(obj) (GTK_CHECK_CAST ((obj), gtk_button_get_type (), GtkButton))
#define GTK_BUTTON_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_button_get_type (), GtkButtonClass) #define GTK_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), gtk_button_get_type (), GtkButtonClass))
#define GTK_IS_BUTTON(obj) GTK_CHECK_TYPE (obj, gtk_button_get_type ()) #define GTK_IS_BUTTON(obj) (GTK_CHECK_TYPE ((obj), gtk_button_get_type ()))
typedef struct _GtkButton GtkButton; typedef struct _GtkButton GtkButton;

View File

@ -308,6 +308,11 @@ void
gtk_container_add (GtkContainer *container, gtk_container_add (GtkContainer *container,
GtkWidget *widget) GtkWidget *widget)
{ {
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget); gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
} }
@ -317,6 +322,9 @@ gtk_container_remove (GtkContainer *container,
{ {
g_return_if_fail (container != NULL); g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_CONTAINER (widget->parent) == container);
if (container->focus_child == widget) if (container->focus_child == widget)
container->focus_child = NULL; container->focus_child = NULL;

View File

@ -1832,10 +1832,3 @@ gtk_entry_select_region (GtkEntry *entry,
{ {
gtk_editable_select_region (GTK_EDITABLE(entry), start, end); gtk_editable_select_region (GTK_EDITABLE(entry), start, end);
} }
void
gtk_entry_set_max_length (GtkEntry *entry,
guint16 max)
{
entry->text_max_length = max;
}

View File

@ -398,8 +398,8 @@ gtk_list_clear_items (GtkList *list,
GList *start_list; GList *start_list;
GList *end_list; GList *end_list;
GList *tmp_list; GList *tmp_list;
gint nchildren; guint nchildren;
gint selection_changed; gboolean selection_changed;
g_return_if_fail (list != NULL); g_return_if_fail (list != NULL);
g_return_if_fail (GTK_IS_LIST (list)); g_return_if_fail (GTK_IS_LIST (list));
@ -819,6 +819,7 @@ gtk_list_add (GtkContainer *container,
g_return_if_fail (container != NULL); g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_LIST (container)); g_return_if_fail (GTK_IS_LIST (container));
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_LIST_ITEM (widget));
list = GTK_LIST (container); list = GTK_LIST (container);

View File

@ -181,48 +181,52 @@ gtk_tree_new ()
void void
gtk_tree_append (GtkTree *tree, gtk_tree_append (GtkTree *tree,
GtkWidget *child) GtkWidget *tree_item)
{ {
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (child)); 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_tree_insert(tree, child, -1); gtk_tree_insert(tree, tree_item, -1);
} }
void void
gtk_tree_prepend (GtkTree *tree, gtk_tree_prepend (GtkTree *tree,
GtkWidget *child) GtkWidget *tree_item)
{ {
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (child)); g_return_if_fail (GTK_IS_TREE (tree));
g_return_if_fail (tree_item != NULL);
gtk_tree_insert(tree, child, 0); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
gtk_tree_insert(tree, tree_item, 0);
} }
void void
gtk_tree_insert (GtkTree *tree, gtk_tree_insert (GtkTree *tree,
GtkWidget *child, GtkWidget *tree_item,
gint position) gint position)
{ {
gint nchildren; gint nchildren;
g_return_if_fail (tree != NULL || child != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM(child)); 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));
/* set parent widget to item */ /* set parent widget to item */
gtk_widget_set_parent (child, GTK_WIDGET (tree)); gtk_widget_set_parent (tree_item, GTK_WIDGET (tree));
if (GTK_WIDGET_VISIBLE (child->parent)) if (GTK_WIDGET_VISIBLE (tree_item->parent))
{ {
if (GTK_WIDGET_REALIZED (child->parent) && if (GTK_WIDGET_REALIZED (tree_item->parent) &&
!GTK_WIDGET_REALIZED (child)) !GTK_WIDGET_REALIZED (tree_item))
gtk_widget_realize (child); gtk_widget_realize (tree_item);
if (GTK_WIDGET_MAPPED (child->parent) && if (GTK_WIDGET_MAPPED (tree_item->parent) &&
!GTK_WIDGET_MAPPED (child)) !GTK_WIDGET_MAPPED (tree_item))
gtk_widget_map (child); gtk_widget_map (tree_item);
} }
nchildren = g_list_length (tree->children); nchildren = g_list_length (tree->children);
@ -232,11 +236,11 @@ gtk_tree_insert (GtkTree *tree,
if (position == nchildren) if (position == nchildren)
{ {
tree->children = g_list_append(tree->children, child); tree->children = g_list_append(tree->children, tree_item);
} }
else else
{ {
tree->children = g_list_insert(tree->children, child, position); tree->children = g_list_insert(tree->children, tree_item, position);
} }
if (GTK_WIDGET_VISIBLE (tree)) if (GTK_WIDGET_VISIBLE (tree))
@ -253,6 +257,7 @@ gtk_tree_add (GtkContainer *container,
g_return_if_fail (container != NULL); g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_TREE (container)); g_return_if_fail (GTK_IS_TREE (container));
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (widget));
tree = GTK_TREE (container); tree = GTK_TREE (container);
@ -363,9 +368,39 @@ gtk_tree_clear_items (GtkTree *tree,
gint start, gint start,
gint end) gint end)
{ {
GtkWidget *widget;
GList *clear_list;
GList *tmp_list;
guint nchildren;
guint index;
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (GTK_IS_TREE (tree));
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);
}
} }
static void static void
@ -616,7 +651,6 @@ gtk_tree_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window); widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (widget->window, gdk_window_set_background (widget->window,
&widget->style->base[GTK_STATE_NORMAL]); &widget->style->base[GTK_STATE_NORMAL]);
} }
void void
@ -630,8 +664,7 @@ gtk_tree_remove_item (GtkTree *container,
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (container == GTK_TREE (widget->parent)); g_return_if_fail (container == GTK_TREE (widget->parent));
item_list = g_list_alloc (); item_list = g_list_append (NULL, widget);
item_list->data = widget;
gtk_tree_remove_items (GTK_TREE (container), item_list); gtk_tree_remove_items (GTK_TREE (container), item_list);
@ -679,8 +712,10 @@ gtk_tree_remove_items (GtkTree *tree,
#ifdef TREE_DEBUG #ifdef TREE_DEBUG
g_print("* sort list by depth\n"); g_print("* sort list by depth\n");
#endif /* TREE_DEBUG */ #endif /* TREE_DEBUG */
while(tmp_list)
while (tmp_list)
{ {
#ifdef TREE_DEBUG #ifdef TREE_DEBUG
g_print("* item [%#x] depth [%d]\n", g_print("* item [%#x] depth [%d]\n",
(int)tmp_list->data, (int)tmp_list->data,
@ -709,6 +744,7 @@ gtk_tree_remove_items (GtkTree *tree,
#ifdef TREE_DEBUG #ifdef TREE_DEBUG
g_print("* scan sorted list\n"); g_print("* scan sorted list\n");
#endif /* TREE_DEBUG */ #endif /* TREE_DEBUG */
tmp_list = sorted_list; tmp_list = sorted_list;
while (tmp_list) while (tmp_list)
{ {
@ -835,11 +871,14 @@ gtk_tree_remove_items (GtkTree *tree,
void void
gtk_tree_select_child (GtkTree *tree, gtk_tree_select_child (GtkTree *tree,
GtkWidget *child) GtkWidget *tree_item)
{ {
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], child); gtk_signal_emit (GTK_OBJECT (tree), tree_signals[SELECT_CHILD], tree_item);
} }
void void
@ -848,7 +887,6 @@ gtk_tree_select_item (GtkTree *tree,
{ {
GList *tmp_list; GList *tmp_list;
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (GTK_IS_TREE (tree));
@ -979,9 +1017,14 @@ gtk_tree_unmap (GtkWidget *widget)
void void
gtk_tree_unselect_child (GtkTree *tree, gtk_tree_unselect_child (GtkTree *tree,
GtkWidget *child) GtkWidget *tree_item)
{ {
gtk_signal_emit (GTK_OBJECT (tree), tree_signals[UNSELECT_CHILD], child); 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[UNSELECT_CHILD], tree_item);
} }
void void
@ -990,7 +1033,6 @@ gtk_tree_unselect_item (GtkTree *tree,
{ {
GList *tmp_list; GList *tmp_list;
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (GTK_IS_TREE (tree));
@ -1008,7 +1050,6 @@ gtk_real_tree_select_child (GtkTree *tree,
GList *tmp_list; GList *tmp_list;
GtkWidget *tmp_item; GtkWidget *tmp_item;
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (GTK_IS_TREE (tree));
g_return_if_fail (child != NULL); g_return_if_fail (child != NULL);
@ -1129,7 +1170,6 @@ static void
gtk_real_tree_unselect_child (GtkTree *tree, gtk_real_tree_unselect_child (GtkTree *tree,
GtkWidget *child) GtkWidget *child)
{ {
g_return_if_fail (tree != NULL); g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (GTK_IS_TREE (tree));
g_return_if_fail (child != NULL); g_return_if_fail (child != NULL);

View File

@ -79,11 +79,11 @@ struct _GtkTreeClass
guint gtk_tree_get_type (void); guint gtk_tree_get_type (void);
GtkWidget* gtk_tree_new (void); GtkWidget* gtk_tree_new (void);
void gtk_tree_append (GtkTree *tree, void gtk_tree_append (GtkTree *tree,
GtkWidget *child); GtkWidget *tree_item);
void gtk_tree_prepend (GtkTree *tree, void gtk_tree_prepend (GtkTree *tree,
GtkWidget *child); GtkWidget *tree_item);
void gtk_tree_insert (GtkTree *tree, void gtk_tree_insert (GtkTree *tree,
GtkWidget *child, GtkWidget *tree_item,
gint position); gint position);
void gtk_tree_remove_items (GtkTree *tree, void gtk_tree_remove_items (GtkTree *tree,
GList *items); GList *items);
@ -95,9 +95,9 @@ void gtk_tree_select_item (GtkTree *tree,
void gtk_tree_unselect_item (GtkTree *tree, void gtk_tree_unselect_item (GtkTree *tree,
gint item); gint item);
void gtk_tree_select_child (GtkTree *tree, void gtk_tree_select_child (GtkTree *tree,
GtkWidget *child); GtkWidget *tree_item);
void gtk_tree_unselect_child (GtkTree *tree, void gtk_tree_unselect_child (GtkTree *tree,
GtkWidget *child); GtkWidget *tree_item);
gint gtk_tree_child_position (GtkTree *tree, gint gtk_tree_child_position (GtkTree *tree,
GtkWidget *child); GtkWidget *child);
void gtk_tree_set_selection_mode (GtkTree *tree, void gtk_tree_set_selection_mode (GtkTree *tree,

View File

@ -176,30 +176,37 @@ gtk_tree_item_subtree_button_click (GtkWidget *widget)
{ {
GtkTreeItem* item; GtkTreeItem* item;
item = (GtkTreeItem*) gtk_object_get_user_data(GTK_OBJECT(widget)); g_return_if_fail (widget != NULL);
if(!GTK_WIDGET_IS_SENSITIVE(item)) g_return_if_fail (GTK_IS_EVENT_BOX (widget));
item = (GtkTreeItem*) gtk_object_get_user_data (GTK_OBJECT (widget));
if (!GTK_WIDGET_IS_SENSITIVE (item))
return; return;
if(item->expanded) if (item->expanded)
gtk_tree_item_collapse(item); gtk_tree_item_collapse (item);
else else
gtk_tree_item_expand(item); gtk_tree_item_expand (item);
} }
/* callback for event box state changed */ /* callback for event box state changed */
static void static void
gtk_tree_item_subtree_button_changed_state(GtkWidget *w) gtk_tree_item_subtree_button_changed_state (GtkWidget *widget)
{ {
if(GTK_WIDGET_VISIBLE (w)) { g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_EVENT_BOX (widget));
if (w->state == GTK_STATE_NORMAL) if (GTK_WIDGET_VISIBLE (widget))
gdk_window_set_background (w->window, &w->style->base[w->state]); {
if (widget->state == GTK_STATE_NORMAL)
gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
else else
gdk_window_set_background (w->window, &w->style->bg[w->state]); gdk_window_set_background (widget->window, &widget->style->bg[widget->state]);
if (GTK_WIDGET_DRAWABLE(w)) if (GTK_WIDGET_DRAWABLE (widget))
gdk_window_clear_area (w->window, 0, 0, gdk_window_clear_area (widget->window, 0, 0,
w->allocation.width, w->allocation.height); widget->allocation.width, widget->allocation.height);
} }
} }
@ -208,6 +215,9 @@ gtk_tree_item_init (GtkTreeItem *tree_item)
{ {
GtkWidget *eventbox, *pixmapwid; GtkWidget *eventbox, *pixmapwid;
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
tree_item->expanded = FALSE; tree_item->expanded = FALSE;
tree_item->subtree = NULL; tree_item->subtree = NULL;
GTK_WIDGET_SET_FLAGS (tree_item, GTK_CAN_FOCUS); GTK_WIDGET_SET_FLAGS (tree_item, GTK_CAN_FOCUS);
@ -265,7 +275,6 @@ gtk_tree_item_new_with_label (gchar *label)
GtkWidget *tree_item; GtkWidget *tree_item;
GtkWidget *label_widget; GtkWidget *label_widget;
tree_item = gtk_tree_item_new (); tree_item = gtk_tree_item_new ();
label_widget = gtk_label_new (label); label_widget = gtk_label_new (label);
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
@ -283,6 +292,8 @@ gtk_tree_item_set_subtree (GtkTreeItem *tree_item,
{ {
g_return_if_fail (tree_item != NULL); g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
g_return_if_fail (subtree != NULL);
g_return_if_fail (GTK_IS_TREE (subtree));
if(tree_item->subtree) { if(tree_item->subtree) {
g_warning("there is already a subtree for this tree item\n"); g_warning("there is already a subtree for this tree item\n");
@ -326,33 +337,37 @@ gtk_tree_item_set_subtree (GtkTreeItem *tree_item,
void void
gtk_tree_item_select (GtkTreeItem *tree_item) gtk_tree_item_select (GtkTreeItem *tree_item)
{ {
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
gtk_item_select (GTK_ITEM (tree_item)); gtk_item_select (GTK_ITEM (tree_item));
} }
void void
gtk_tree_item_deselect (GtkTreeItem *tree_item) gtk_tree_item_deselect (GtkTreeItem *tree_item)
{ {
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
gtk_item_deselect (GTK_ITEM (tree_item)); gtk_item_deselect (GTK_ITEM (tree_item));
} }
void void
gtk_tree_item_expand (GtkTreeItem *tree_item) gtk_tree_item_expand (GtkTreeItem *tree_item)
{ {
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
gtk_signal_emit (GTK_OBJECT (tree_item), tree_item_signals[EXPAND_TREE], NULL); gtk_signal_emit (GTK_OBJECT (tree_item), tree_item_signals[EXPAND_TREE], NULL);
} }
void void
gtk_tree_item_collapse (GtkTreeItem *tree_item) gtk_tree_item_collapse (GtkTreeItem *tree_item)
{ {
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
gtk_signal_emit (GTK_OBJECT (tree_item), tree_item_signals[COLLAPSE_TREE], NULL); gtk_signal_emit (GTK_OBJECT (tree_item), tree_item_signals[COLLAPSE_TREE], NULL);
} }
static void static void
@ -362,6 +377,9 @@ gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item)
GdkColormap *colormap; GdkColormap *colormap;
GtkTreePixmaps *pixmap_node = NULL; GtkTreePixmaps *pixmap_node = NULL;
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
if (tree_item->pixmaps) if (tree_item->pixmaps)
return; return;
@ -418,6 +436,9 @@ gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item)
static void static void
gtk_tree_item_remove_pixmaps (GtkTreeItem *tree_item) gtk_tree_item_remove_pixmaps (GtkTreeItem *tree_item)
{ {
g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
if (tree_item->pixmaps) if (tree_item->pixmaps)
{ {
GtkTreePixmaps *pixmap_node = (GtkTreePixmaps *)tree_item->pixmaps->data; GtkTreePixmaps *pixmap_node = (GtkTreePixmaps *)tree_item->pixmaps->data;
@ -521,16 +542,6 @@ gtk_tree_item_size_allocate (GtkWidget *widget,
child_allocation.x = border_width + GTK_TREE(widget->parent)->current_indent; child_allocation.x = border_width + GTK_TREE(widget->parent)->current_indent;
child_allocation.y = GTK_CONTAINER (widget)->border_width; child_allocation.y = GTK_CONTAINER (widget)->border_width;
#if 0
child_allocation.height = allocation->height - child_allocation.y * 2;
child_allocation.width = item->pixmaps_box->requisition.width;
child_allocation.y += 1;
child_allocation.height -= 2;
gtk_widget_size_allocate (item->pixmaps_box, &child_allocation);
child_allocation.height += 2;
#else
child_allocation.width = item->pixmaps_box->requisition.width; child_allocation.width = item->pixmaps_box->requisition.width;
child_allocation.height = item->pixmaps_box->requisition.height; child_allocation.height = item->pixmaps_box->requisition.height;
@ -541,7 +552,6 @@ gtk_tree_item_size_allocate (GtkWidget *widget,
child_allocation.y = GTK_CONTAINER (widget)->border_width; child_allocation.y = GTK_CONTAINER (widget)->border_width;
child_allocation.height = allocation->height - child_allocation.y * 2; child_allocation.height = allocation->height - child_allocation.y * 2;
#endif
child_allocation.x += item->pixmaps_box->requisition.width+DEFAULT_DELTA; child_allocation.x += item->pixmaps_box->requisition.width+DEFAULT_DELTA;
child_allocation.width = child_allocation.width =
@ -549,7 +559,6 @@ gtk_tree_item_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (bin->child, &child_allocation); gtk_widget_size_allocate (bin->child, &child_allocation);
} }
} }
static void static void
@ -559,6 +568,9 @@ gtk_tree_item_draw_lines(GtkWidget *widget)
GtkTree* tree; GtkTree* tree;
guint lx1, ly1, lx2, ly2; guint lx1, ly1, lx2, ly2;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (widget));
item = GTK_TREE_ITEM(widget); item = GTK_TREE_ITEM(widget);
tree = GTK_TREE(widget->parent); tree = GTK_TREE(widget->parent);
@ -758,7 +770,6 @@ static gint
gtk_tree_item_focus_in (GtkWidget *widget, gtk_tree_item_focus_in (GtkWidget *widget,
GdkEventFocus *event) GdkEventFocus *event)
{ {
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE); g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE);
@ -774,7 +785,6 @@ static gint
gtk_tree_item_focus_out (GtkWidget *widget, gtk_tree_item_focus_out (GtkWidget *widget,
GdkEventFocus *event) GdkEventFocus *event)
{ {
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE); g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE);
@ -789,7 +799,6 @@ gtk_tree_item_focus_out (GtkWidget *widget,
static void static void
gtk_real_tree_item_select (GtkItem *item) gtk_real_tree_item_select (GtkItem *item)
{ {
g_return_if_fail (item != NULL); g_return_if_fail (item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (item)); g_return_if_fail (GTK_IS_TREE_ITEM (item));
@ -808,7 +817,6 @@ gtk_real_tree_item_select (GtkItem *item)
static void static void
gtk_real_tree_item_deselect (GtkItem *item) gtk_real_tree_item_deselect (GtkItem *item)
{ {
g_return_if_fail (item != NULL); g_return_if_fail (item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (item)); g_return_if_fail (GTK_IS_TREE_ITEM (item));
@ -829,7 +837,6 @@ gtk_real_tree_item_deselect (GtkItem *item)
static void static void
gtk_real_tree_item_toggle (GtkItem *item) gtk_real_tree_item_toggle (GtkItem *item)
{ {
g_return_if_fail (item != NULL); g_return_if_fail (item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (item)); g_return_if_fail (GTK_IS_TREE_ITEM (item));
@ -861,24 +868,24 @@ gtk_real_tree_item_expand (GtkTreeItem *tree_item)
g_return_if_fail (tree_item != NULL); g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
g_return_if_fail (tree_item->subtree != NULL);
if (tree_item->subtree && !tree_item->expanded)
if(!tree_item->expanded)
{ {
tree = GTK_TREE(GTK_WIDGET(tree_item)->parent); tree = GTK_TREE (GTK_WIDGET (tree_item)->parent);
/* hide subtree widget */ /* hide subtree widget */
gtk_widget_show(tree_item->subtree); gtk_widget_show (tree_item->subtree);
/* hide button '+' and show button '-' */ /* hide button '+' and show button '-' */
if(tree_item->pixmaps_box) { if (tree_item->pixmaps_box)
gtk_container_remove(GTK_CONTAINER(tree_item->pixmaps_box), {
gtk_container_remove (GTK_CONTAINER (tree_item->pixmaps_box),
tree_item->plus_pix_widget); tree_item->plus_pix_widget);
gtk_container_add(GTK_CONTAINER(tree_item->pixmaps_box), gtk_container_add (GTK_CONTAINER (tree_item->pixmaps_box),
tree_item->minus_pix_widget); tree_item->minus_pix_widget);
} }
if(tree->root_tree) gtk_widget_queue_resize(GTK_WIDGET(tree->root_tree)); if (tree->root_tree)
gtk_widget_queue_resize (GTK_WIDGET (tree->root_tree));
tree_item->expanded = TRUE; tree_item->expanded = TRUE;
} }
} }
@ -890,26 +897,26 @@ gtk_real_tree_item_collapse (GtkTreeItem *tree_item)
g_return_if_fail (tree_item != NULL); g_return_if_fail (tree_item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item));
g_return_if_fail (tree_item->subtree != NULL);
if(tree_item->expanded) if (tree_item->subtree && tree_item->expanded)
{ {
tree = GTK_TREE(GTK_WIDGET(tree_item)->parent); tree = GTK_TREE (GTK_WIDGET (tree_item)->parent);
/* hide subtree widget */ /* hide subtree widget */
gtk_widget_hide(tree_item->subtree); gtk_widget_hide (tree_item->subtree);
/* hide button '-' and show button '+' */ /* hide button '-' and show button '+' */
if(tree_item->pixmaps_box) { if (tree_item->pixmaps_box)
gtk_container_remove(GTK_CONTAINER(tree_item->pixmaps_box), {
gtk_container_remove (GTK_CONTAINER (tree_item->pixmaps_box),
tree_item->minus_pix_widget); tree_item->minus_pix_widget);
gtk_container_add(GTK_CONTAINER(tree_item->pixmaps_box), gtk_container_add (GTK_CONTAINER (tree_item->pixmaps_box),
tree_item->plus_pix_widget); tree_item->plus_pix_widget);
} }
if(tree->root_tree) gtk_widget_queue_resize(GTK_WIDGET(tree->root_tree)); if (tree->root_tree)
gtk_widget_queue_resize (GTK_WIDGET (tree->root_tree));
tree_item->expanded = FALSE; tree_item->expanded = FALSE;
} }
} }
static void static void
@ -928,7 +935,8 @@ gtk_tree_item_destroy (GtkObject *object)
item = GTK_TREE_ITEM(object); item = GTK_TREE_ITEM(object);
/* free sub tree if it exist */ /* free sub tree if it exist */
if((child = item->subtree)) child = item->subtree;
if (child)
{ {
gtk_widget_ref (child); gtk_widget_ref (child);
gtk_widget_unparent (child); gtk_widget_unparent (child);
@ -938,7 +946,8 @@ gtk_tree_item_destroy (GtkObject *object)
} }
/* free pixmaps box */ /* free pixmaps box */
if((child = item->pixmaps_box)) child = item->pixmaps_box;
if (child)
{ {
gtk_widget_ref (child); gtk_widget_ref (child);
gtk_widget_unparent (child); gtk_widget_unparent (child);
@ -969,8 +978,7 @@ gtk_tree_item_destroy (GtkObject *object)
*/ */
gtk_tree_item_remove_pixmaps (item); gtk_tree_item_remove_pixmaps (item);
if (GTK_OBJECT_CLASS (parent_class)->destroy) GTK_OBJECT_CLASS (parent_class)->destroy (object);
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
#ifdef TREE_DEBUG #ifdef TREE_DEBUG
g_print("- gtk_tree_item_destroy\n"); g_print("- gtk_tree_item_destroy\n");
@ -980,28 +988,29 @@ gtk_tree_item_destroy (GtkObject *object)
void void
gtk_tree_item_remove_subtree (GtkTreeItem* item) gtk_tree_item_remove_subtree (GtkTreeItem* item)
{ {
g_return_if_fail(item != NULL); g_return_if_fail (item != NULL);
g_return_if_fail(GTK_IS_TREE_ITEM(item)); g_return_if_fail (GTK_IS_TREE_ITEM(item));
g_return_if_fail(item->subtree); g_return_if_fail (item->subtree != NULL);
if(GTK_TREE(item->subtree)->children) if (GTK_TREE (item->subtree)->children)
gtk_tree_remove_items(GTK_TREE(item->subtree), gtk_tree_remove_items (GTK_TREE (item->subtree),
GTK_TREE(item->subtree)->children); GTK_TREE (item->subtree)->children);
if (GTK_WIDGET_MAPPED (item->subtree)) if (GTK_WIDGET_MAPPED (item->subtree))
gtk_widget_unmap (item->subtree); gtk_widget_unmap (item->subtree);
gtk_widget_unparent (item->subtree); gtk_widget_unparent (item->subtree);
if(item->pixmaps_box) if (item->pixmaps_box)
gtk_widget_hide(item->pixmaps_box); gtk_widget_hide (item->pixmaps_box);
item->subtree = NULL; item->subtree = NULL;
item->expanded = FALSE; item->expanded = FALSE;
if(item->pixmaps_box) { if (item->pixmaps_box)
gtk_container_remove(GTK_CONTAINER(item->pixmaps_box), {
gtk_container_remove (GTK_CONTAINER (item->pixmaps_box),
item->minus_pix_widget); item->minus_pix_widget);
gtk_container_add(GTK_CONTAINER(item->pixmaps_box), gtk_container_add (GTK_CONTAINER (item->pixmaps_box),
item->plus_pix_widget); item->plus_pix_widget);
} }
} }

View File

@ -1288,7 +1288,7 @@ create_tree_sample(guint selection_mode,
static void static void
cb_create_tree(GtkWidget* w) cb_create_tree(GtkWidget* w)
{ {
guint selection_mode; guint selection_mode = GTK_SELECTION_SINGLE;
guint view_line; guint view_line;
guint draw_line; guint draw_line;
guint no_root_item; guint no_root_item;

View File

@ -1288,7 +1288,7 @@ create_tree_sample(guint selection_mode,
static void static void
cb_create_tree(GtkWidget* w) cb_create_tree(GtkWidget* w)
{ {
guint selection_mode; guint selection_mode = GTK_SELECTION_SINGLE;
guint view_line; guint view_line;
guint draw_line; guint draw_line;
guint no_root_item; guint no_root_item;