1 /* stresstest-toolbar.c
3 * Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 typedef struct _Info Info;
32 add_random (GtkToolbar *toolbar, gint n)
36 gchar *label = g_strdup_printf ("Button %d", n);
38 GtkToolItem *toolitem = gtk_tool_button_new (NULL, label);
39 gtk_tool_item_set_tooltip_text (toolitem, "Bar");
42 gtk_widget_show_all (GTK_WIDGET (toolitem));
44 n_items = gtk_toolbar_get_n_items (toolbar);
48 position = g_random_int_range (0, n_items);
50 gtk_toolbar_insert (toolbar, toolitem, position);
54 remove_random (GtkToolbar *toolbar)
56 GtkToolItem *tool_item;
60 n_items = gtk_toolbar_get_n_items (toolbar);
65 position = g_random_int_range (0, n_items);
67 tool_item = gtk_toolbar_get_nth_item (toolbar, position);
69 gtk_container_remove (GTK_CONTAINER (toolbar),
70 GTK_WIDGET (tool_item));
74 stress_test_old_api (gpointer data)
86 if (info->counter++ == 200)
94 info->toolbar = GTK_TOOLBAR (gtk_toolbar_new ());
95 gtk_container_add (GTK_CONTAINER (info->window),
96 GTK_WIDGET (info->toolbar));
97 gtk_widget_show (GTK_WIDGET (info->toolbar));
100 n_items = gtk_toolbar_get_n_items (info->toolbar);
103 add_random (info->toolbar, info->counter);
106 else if (n_items > 50)
109 for (i = 0; i < 25; i++)
110 remove_random (info->toolbar);
114 action = g_random_int_range (0, LAST_ACTION);
119 add_random (info->toolbar, info->counter);
123 remove_random (info->toolbar);
127 g_assert_not_reached();
136 main (gint argc, gchar **argv)
140 gtk_init (&argc, &argv);
144 info.window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
146 gtk_widget_show (GTK_WIDGET (info.window));
148 gdk_threads_add_idle (stress_test_old_api, &info);
150 gtk_widget_show_all (GTK_WIDGET (info.window));
154 gtk_widget_destroy (GTK_WIDGET (info.window));