summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Janik <timj@gimp.org>1998-03-11 04:05:15 +0000
committerTim Janik <timj@src.gnome.org>1998-03-11 04:05:15 +0000
commit309d7377e7ed7450adebac3ec42f02ebe678b927 (patch)
tree40c367bfa0981270508a0cb2a02cb8d268864a0c
parent2ff460a6c84c9e64a833bb335d0c843c89166625 (diff)
downloadgdk-pixbuf-309d7377e7ed7450adebac3ec42f02ebe678b927.tar.gz
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.
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLog.pre-2-010
-rw-r--r--ChangeLog.pre-2-1010
-rw-r--r--ChangeLog.pre-2-210
-rw-r--r--ChangeLog.pre-2-410
-rw-r--r--ChangeLog.pre-2-610
-rw-r--r--ChangeLog.pre-2-810
-rw-r--r--gdk/gdkvisual.c2
-rw-r--r--gdk/x11/gdkvisual-x11.c2
-rw-r--r--gtk/gtkbutton.h6
-rw-r--r--gtk/gtkcontainer.c10
-rw-r--r--gtk/gtkentry.c7
-rw-r--r--gtk/gtklist.c5
-rw-r--r--gtk/gtktext.c6
-rw-r--r--gtk/gtktree.c114
-rw-r--r--gtk/gtktree.h10
-rw-r--r--gtk/gtktreeitem.c211
-rw-r--r--gtk/testgtk.c2
-rw-r--r--tests/testgtk.c2
19 files changed, 284 insertions, 163 deletions
diff --git a/ChangeLog b/ChangeLog
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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>
* gtk/gtktooltips.h:
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index d58f78595..ceb7e4e01 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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>
* gtk/gtktooltips.h:
diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c
index c6365de9c..e2f1448eb 100644
--- a/gdk/gdkvisual.c
+++ b/gdk/gdkvisual.c
@@ -40,7 +40,7 @@ static gint navailable_depths;
static GdkVisualType available_types[6];
static gint navailable_types;
-static char* visual_names[] =
+static gchar* visual_names[] =
{
"static gray",
"grayscale",
diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c
index c6365de9c..e2f1448eb 100644
--- a/gdk/x11/gdkvisual-x11.c
+++ b/gdk/x11/gdkvisual-x11.c
@@ -40,7 +40,7 @@ static gint navailable_depths;
static GdkVisualType available_types[6];
static gint navailable_types;
-static char* visual_names[] =
+static gchar* visual_names[] =
{
"static gray",
"grayscale",
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index ec72c99f7..e184dd3ce 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -28,9 +28,9 @@ extern "C" {
#endif /* __cplusplus */
-#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_IS_BUTTON(obj) GTK_CHECK_TYPE (obj, gtk_button_get_type ())
+#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_IS_BUTTON(obj) (GTK_CHECK_TYPE ((obj), gtk_button_get_type ()))
typedef struct _GtkButton GtkButton;
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index d7c6dec86..d00d17fb0 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -308,6 +308,11 @@ void
gtk_container_add (GtkContainer *container,
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);
}
@@ -317,7 +322,10 @@ gtk_container_remove (GtkContainer *container,
{
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));
+ g_return_if_fail (GTK_CONTAINER (widget->parent) == container);
+
if (container->focus_child == widget)
container->focus_child = NULL;
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index e825afa81..d0202ee03 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -1832,10 +1832,3 @@ gtk_entry_select_region (GtkEntry *entry,
{
gtk_editable_select_region (GTK_EDITABLE(entry), start, end);
}
-
-void
-gtk_entry_set_max_length (GtkEntry *entry,
- guint16 max)
-{
- entry->text_max_length = max;
-}
diff --git a/gtk/gtklist.c b/gtk/gtklist.c
index 67fc1fa56..2a44474e6 100644
--- a/gtk/gtklist.c
+++ b/gtk/gtklist.c
@@ -398,8 +398,8 @@ gtk_list_clear_items (GtkList *list,
GList *start_list;
GList *end_list;
GList *tmp_list;
- gint nchildren;
- gint selection_changed;
+ guint nchildren;
+ gboolean selection_changed;
g_return_if_fail (list != NULL);
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 (GTK_IS_LIST (container));
g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_LIST_ITEM (widget));
list = GTK_LIST (container);
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index ba709e40b..d8a42abf3 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -822,9 +822,9 @@ gtk_text_forward_delete (GtkText *text,
}
static gchar *
-gtk_text_get_chars (GtkEditable *editable,
- gint start_pos,
- gint end_pos)
+gtk_text_get_chars (GtkEditable *editable,
+ gint start_pos,
+ gint end_pos)
{
GtkText *text;
diff --git a/gtk/gtktree.c b/gtk/gtktree.c
index d9be758b7..28b93dda7 100644
--- a/gtk/gtktree.c
+++ b/gtk/gtktree.c
@@ -181,48 +181,52 @@ gtk_tree_new ()
void
gtk_tree_append (GtkTree *tree,
- GtkWidget *child)
+ GtkWidget *tree_item)
{
-
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
gtk_tree_prepend (GtkTree *tree,
- GtkWidget *child)
+ GtkWidget *tree_item)
{
g_return_if_fail (tree != NULL);
- g_return_if_fail (GTK_IS_TREE_ITEM (child));
-
- gtk_tree_insert(tree, child, 0);
+ 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, tree_item, 0);
}
void
gtk_tree_insert (GtkTree *tree,
- GtkWidget *child,
+ GtkWidget *tree_item,
gint position)
{
gint nchildren;
- g_return_if_fail (tree != NULL || child != NULL);
- g_return_if_fail (GTK_IS_TREE_ITEM(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));
/* 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) &&
- !GTK_WIDGET_REALIZED (child))
- gtk_widget_realize (child);
+ if (GTK_WIDGET_REALIZED (tree_item->parent) &&
+ !GTK_WIDGET_REALIZED (tree_item))
+ gtk_widget_realize (tree_item);
- if (GTK_WIDGET_MAPPED (child->parent) &&
- !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
+ if (GTK_WIDGET_MAPPED (tree_item->parent) &&
+ !GTK_WIDGET_MAPPED (tree_item))
+ gtk_widget_map (tree_item);
}
nchildren = g_list_length (tree->children);
@@ -232,11 +236,11 @@ gtk_tree_insert (GtkTree *tree,
if (position == nchildren)
{
- tree->children = g_list_append(tree->children, child);
+ tree->children = g_list_append(tree->children, tree_item);
}
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))
@@ -253,6 +257,7 @@ gtk_tree_add (GtkContainer *container,
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_TREE (container));
g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_TREE_ITEM (widget));
tree = GTK_TREE (container);
@@ -363,9 +368,39 @@ gtk_tree_clear_items (GtkTree *tree,
gint start,
gint end)
{
+ GtkWidget *widget;
+ GList *clear_list;
+ GList *tmp_list;
+ guint nchildren;
+ guint index;
+
g_return_if_fail (tree != NULL);
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
@@ -616,7 +651,6 @@ gtk_tree_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (widget->window,
&widget->style->base[GTK_STATE_NORMAL]);
-
}
void
@@ -630,8 +664,7 @@ gtk_tree_remove_item (GtkTree *container,
g_return_if_fail (widget != NULL);
g_return_if_fail (container == GTK_TREE (widget->parent));
- item_list = g_list_alloc ();
- item_list->data = widget;
+ item_list = g_list_append (NULL, widget);
gtk_tree_remove_items (GTK_TREE (container), item_list);
@@ -679,8 +712,10 @@ gtk_tree_remove_items (GtkTree *tree,
#ifdef TREE_DEBUG
g_print("* sort list by depth\n");
#endif /* TREE_DEBUG */
- while(tmp_list)
+
+ while (tmp_list)
{
+
#ifdef TREE_DEBUG
g_print("* item [%#x] depth [%d]\n",
(int)tmp_list->data,
@@ -709,6 +744,7 @@ gtk_tree_remove_items (GtkTree *tree,
#ifdef TREE_DEBUG
g_print("* scan sorted list\n");
#endif /* TREE_DEBUG */
+
tmp_list = sorted_list;
while (tmp_list)
{
@@ -835,20 +871,22 @@ gtk_tree_remove_items (GtkTree *tree,
void
gtk_tree_select_child (GtkTree *tree,
- GtkWidget *child)
+ GtkWidget *tree_item)
{
-
- gtk_signal_emit (GTK_OBJECT (tree), tree_signals[SELECT_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[SELECT_CHILD], tree_item);
}
void
gtk_tree_select_item (GtkTree *tree,
- gint item)
+ gint item)
{
GList *tmp_list;
-
g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree));
@@ -979,9 +1017,14 @@ gtk_tree_unmap (GtkWidget *widget)
void
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
@@ -990,7 +1033,6 @@ gtk_tree_unselect_item (GtkTree *tree,
{
GList *tmp_list;
-
g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree));
@@ -1008,7 +1050,6 @@ gtk_real_tree_select_child (GtkTree *tree,
GList *tmp_list;
GtkWidget *tmp_item;
-
g_return_if_fail (tree != NULL);
g_return_if_fail (GTK_IS_TREE (tree));
g_return_if_fail (child != NULL);
@@ -1129,7 +1170,6 @@ 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);
diff --git a/gtk/gtktree.h b/gtk/gtktree.h
index 94c849b46..5b287e310 100644
--- a/gtk/gtktree.h
+++ b/gtk/gtktree.h
@@ -79,11 +79,11 @@ struct _GtkTreeClass
guint gtk_tree_get_type (void);
GtkWidget* gtk_tree_new (void);
void gtk_tree_append (GtkTree *tree,
- GtkWidget *child);
+ GtkWidget *tree_item);
void gtk_tree_prepend (GtkTree *tree,
- GtkWidget *child);
+ GtkWidget *tree_item);
void gtk_tree_insert (GtkTree *tree,
- GtkWidget *child,
+ GtkWidget *tree_item,
gint position);
void gtk_tree_remove_items (GtkTree *tree,
GList *items);
@@ -95,9 +95,9 @@ void gtk_tree_select_item (GtkTree *tree,
void gtk_tree_unselect_item (GtkTree *tree,
gint item);
void gtk_tree_select_child (GtkTree *tree,
- GtkWidget *child);
+ GtkWidget *tree_item);
void gtk_tree_unselect_child (GtkTree *tree,
- GtkWidget *child);
+ GtkWidget *tree_item);
gint gtk_tree_child_position (GtkTree *tree,
GtkWidget *child);
void gtk_tree_set_selection_mode (GtkTree *tree,
diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c
index fcb039f60..f2241b6e4 100644
--- a/gtk/gtktreeitem.c
+++ b/gtk/gtktreeitem.c
@@ -175,32 +175,39 @@ static void
gtk_tree_item_subtree_button_click (GtkWidget *widget)
{
GtkTreeItem* item;
-
- item = (GtkTreeItem*) gtk_object_get_user_data(GTK_OBJECT(widget));
- if(!GTK_WIDGET_IS_SENSITIVE(item))
+
+ g_return_if_fail (widget != NULL);
+ 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;
-
- if(item->expanded)
- gtk_tree_item_collapse(item);
+
+ if (item->expanded)
+ gtk_tree_item_collapse (item);
else
- gtk_tree_item_expand(item);
+ gtk_tree_item_expand (item);
}
/* callback for event box state changed */
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)) {
-
- if (w->state == GTK_STATE_NORMAL)
- gdk_window_set_background (w->window, &w->style->base[w->state]);
- else
- gdk_window_set_background (w->window, &w->style->bg[w->state]);
-
- if (GTK_WIDGET_DRAWABLE(w))
- gdk_window_clear_area (w->window, 0, 0,
- w->allocation.width, w->allocation.height);
- }
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_EVENT_BOX (widget));
+
+ if (GTK_WIDGET_VISIBLE (widget))
+ {
+
+ if (widget->state == GTK_STATE_NORMAL)
+ gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
+ else
+ gdk_window_set_background (widget->window, &widget->style->bg[widget->state]);
+
+ if (GTK_WIDGET_DRAWABLE (widget))
+ gdk_window_clear_area (widget->window, 0, 0,
+ widget->allocation.width, widget->allocation.height);
+ }
}
static void
@@ -208,6 +215,9 @@ gtk_tree_item_init (GtkTreeItem *tree_item)
{
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->subtree = NULL;
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 *label_widget;
-
tree_item = gtk_tree_item_new ();
label_widget = gtk_label_new (label);
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 (GTK_IS_TREE_ITEM (tree_item));
+ g_return_if_fail (subtree != NULL);
+ g_return_if_fail (GTK_IS_TREE (subtree));
if(tree_item->subtree) {
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
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));
-
}
void
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));
-
}
void
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);
-
}
void
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);
-
}
static void
@@ -362,6 +377,9 @@ gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item)
GdkColormap *colormap;
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)
return;
@@ -418,6 +436,9 @@ gtk_tree_item_add_pixmaps (GtkTreeItem *tree_item)
static void
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)
{
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.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.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.height = allocation->height - child_allocation.y * 2;
-#endif
child_allocation.x += item->pixmaps_box->requisition.width+DEFAULT_DELTA;
child_allocation.width =
@@ -549,7 +559,6 @@ gtk_tree_item_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (bin->child, &child_allocation);
}
-
}
static void
@@ -559,6 +568,9 @@ gtk_tree_item_draw_lines(GtkWidget *widget)
GtkTree* tree;
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);
tree = GTK_TREE(widget->parent);
@@ -758,7 +770,6 @@ static gint
gtk_tree_item_focus_in (GtkWidget *widget,
GdkEventFocus *event)
{
-
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -774,7 +785,6 @@ static gint
gtk_tree_item_focus_out (GtkWidget *widget,
GdkEventFocus *event)
{
-
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TREE_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -788,8 +798,7 @@ gtk_tree_item_focus_out (GtkWidget *widget,
static void
gtk_real_tree_item_select (GtkItem *item)
-{
-
+{
g_return_if_fail (item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (item));
@@ -808,7 +817,6 @@ gtk_real_tree_item_select (GtkItem *item)
static void
gtk_real_tree_item_deselect (GtkItem *item)
{
-
g_return_if_fail (item != NULL);
g_return_if_fail (GTK_IS_TREE_ITEM (item));
@@ -829,7 +837,6 @@ gtk_real_tree_item_deselect (GtkItem *item)
static void
gtk_real_tree_item_toggle (GtkItem *item)
{
-
g_return_if_fail (item != NULL);
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 (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 */
- gtk_widget_show(tree_item->subtree);
-
+ gtk_widget_show (tree_item->subtree);
+
/* hide button '+' and show button '-' */
- if(tree_item->pixmaps_box) {
- gtk_container_remove(GTK_CONTAINER(tree_item->pixmaps_box),
- tree_item->plus_pix_widget);
- gtk_container_add(GTK_CONTAINER(tree_item->pixmaps_box),
- tree_item->minus_pix_widget);
- }
- if(tree->root_tree) gtk_widget_queue_resize(GTK_WIDGET(tree->root_tree));
+ if (tree_item->pixmaps_box)
+ {
+ gtk_container_remove (GTK_CONTAINER (tree_item->pixmaps_box),
+ tree_item->plus_pix_widget);
+ gtk_container_add (GTK_CONTAINER (tree_item->pixmaps_box),
+ tree_item->minus_pix_widget);
+ }
+ if (tree->root_tree)
+ gtk_widget_queue_resize (GTK_WIDGET (tree->root_tree));
tree_item->expanded = TRUE;
}
}
@@ -887,29 +894,29 @@ static void
gtk_real_tree_item_collapse (GtkTreeItem *tree_item)
{
GtkTree* tree;
-
+
g_return_if_fail (tree_item != NULL);
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 */
- gtk_widget_hide(tree_item->subtree);
-
+ gtk_widget_hide (tree_item->subtree);
+
/* hide button '-' and show button '+' */
- if(tree_item->pixmaps_box) {
- gtk_container_remove(GTK_CONTAINER(tree_item->pixmaps_box),
- tree_item->minus_pix_widget);
- gtk_container_add(GTK_CONTAINER(tree_item->pixmaps_box),
- tree_item->plus_pix_widget);
- }
- if(tree->root_tree) gtk_widget_queue_resize(GTK_WIDGET(tree->root_tree));
+ if (tree_item->pixmaps_box)
+ {
+ gtk_container_remove (GTK_CONTAINER (tree_item->pixmaps_box),
+ tree_item->minus_pix_widget);
+ gtk_container_add (GTK_CONTAINER (tree_item->pixmaps_box),
+ tree_item->plus_pix_widget);
+ }
+ if (tree->root_tree)
+ gtk_widget_queue_resize (GTK_WIDGET (tree->root_tree));
tree_item->expanded = FALSE;
}
-
}
static void
@@ -928,7 +935,8 @@ gtk_tree_item_destroy (GtkObject *object)
item = GTK_TREE_ITEM(object);
/* free sub tree if it exist */
- if((child = item->subtree))
+ child = item->subtree;
+ if (child)
{
gtk_widget_ref (child);
gtk_widget_unparent (child);
@@ -936,9 +944,10 @@ gtk_tree_item_destroy (GtkObject *object)
gtk_widget_unref (child);
item->subtree = NULL;
}
-
+
/* free pixmaps box */
- if((child = item->pixmaps_box))
+ child = item->pixmaps_box;
+ if (child)
{
gtk_widget_ref (child);
gtk_widget_unparent (child);
@@ -946,8 +955,8 @@ gtk_tree_item_destroy (GtkObject *object)
gtk_widget_unref (child);
item->pixmaps_box = NULL;
}
-
-
+
+
/* destroy plus pixmap */
if (item->plus_pix_widget)
{
@@ -955,7 +964,7 @@ gtk_tree_item_destroy (GtkObject *object)
gtk_widget_unref (item->plus_pix_widget);
item->plus_pix_widget = NULL;
}
-
+
/* destroy minus pixmap */
if (item->minus_pix_widget)
{
@@ -963,15 +972,14 @@ gtk_tree_item_destroy (GtkObject *object)
gtk_widget_unref (item->minus_pix_widget);
item->minus_pix_widget = NULL;
}
-
+
/* By removing the pixmaps here, and not in unrealize, we depend on
* the fact that a widget can never change colormap or visual.
*/
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
g_print("- gtk_tree_item_destroy\n");
#endif /* TREE_DEBUG */
@@ -980,30 +988,31 @@ gtk_tree_item_destroy (GtkObject *object)
void
gtk_tree_item_remove_subtree (GtkTreeItem* item)
{
- g_return_if_fail(item != NULL);
- g_return_if_fail(GTK_IS_TREE_ITEM(item));
- g_return_if_fail(item->subtree);
-
- if(GTK_TREE(item->subtree)->children)
- gtk_tree_remove_items(GTK_TREE(item->subtree),
- GTK_TREE(item->subtree)->children);
-
+ g_return_if_fail (item != NULL);
+ g_return_if_fail (GTK_IS_TREE_ITEM(item));
+ g_return_if_fail (item->subtree != NULL);
+
+ if (GTK_TREE (item->subtree)->children)
+ gtk_tree_remove_items (GTK_TREE (item->subtree),
+ GTK_TREE (item->subtree)->children);
+
if (GTK_WIDGET_MAPPED (item->subtree))
gtk_widget_unmap (item->subtree);
gtk_widget_unparent (item->subtree);
-
- if(item->pixmaps_box)
- gtk_widget_hide(item->pixmaps_box);
-
+
+ if (item->pixmaps_box)
+ gtk_widget_hide (item->pixmaps_box);
+
item->subtree = NULL;
item->expanded = FALSE;
- if(item->pixmaps_box) {
- gtk_container_remove(GTK_CONTAINER(item->pixmaps_box),
- item->minus_pix_widget);
- gtk_container_add(GTK_CONTAINER(item->pixmaps_box),
- item->plus_pix_widget);
- }
+ if (item->pixmaps_box)
+ {
+ gtk_container_remove (GTK_CONTAINER (item->pixmaps_box),
+ item->minus_pix_widget);
+ gtk_container_add (GTK_CONTAINER (item->pixmaps_box),
+ item->plus_pix_widget);
+ }
}
static void
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 9ceb305a6..1722553e8 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -1288,7 +1288,7 @@ create_tree_sample(guint selection_mode,
static void
cb_create_tree(GtkWidget* w)
{
- guint selection_mode;
+ guint selection_mode = GTK_SELECTION_SINGLE;
guint view_line;
guint draw_line;
guint no_root_item;
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 9ceb305a6..1722553e8 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1288,7 +1288,7 @@ create_tree_sample(guint selection_mode,
static void
cb_create_tree(GtkWidget* w)
{
- guint selection_mode;
+ guint selection_mode = GTK_SELECTION_SINGLE;
guint view_line;
guint draw_line;
guint no_root_item;