X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=tests%2Fstresstest-toolbar.c;h=d115974cc72e55fa8ed53b997ebaab993a501b94;hb=af00c68dd07140a52f65596358be1ffb0fb0605a;hp=370acc1bd25ee298fe7712395f1605758ae7a6ea;hpb=eaab3748ed20740f09ec64fd3e814da8e5e25962;p=~andy%2Fgtk diff --git a/tests/stresstest-toolbar.c b/tests/stresstest-toolbar.c index 370acc1bd..d115974cc 100644 --- a/tests/stresstest-toolbar.c +++ b/tests/stresstest-toolbar.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ -#undef GTK_DISABLE_DEPRECATED +#include "config.h" #include typedef struct _Info Info; @@ -31,36 +31,43 @@ struct _Info static void add_random (GtkToolbar *toolbar, gint n) { + gint n_items; gint position; gchar *label = g_strdup_printf ("Button %d", n); - GtkWidget *widget = gtk_button_new_with_label (label); + GtkToolItem *toolitem = gtk_tool_button_new (NULL, label); + gtk_tool_item_set_tooltip_text (toolitem, "Bar"); g_free (label); - gtk_widget_show_all (widget); + gtk_widget_show_all (GTK_WIDGET (toolitem)); - if (g_list_length (toolbar->children) == 0) + n_items = gtk_toolbar_get_n_items (toolbar); + if (n_items == 0) position = 0; else - position = g_random_int_range (0, g_list_length (toolbar->children)); + position = g_random_int_range (0, n_items); - gtk_toolbar_insert_widget (toolbar, widget, "Bar", "Baz", position); + gtk_toolbar_insert (toolbar, toolitem, position); } static void remove_random (GtkToolbar *toolbar) { - GtkToolbarChild *child; + GtkToolItem *tool_item; + gint n_items; gint position; - if (!toolbar->children) + n_items = gtk_toolbar_get_n_items (toolbar); + + if (n_items == 0) return; - position = g_random_int_range (0, g_list_length (toolbar->children)); + position = g_random_int_range (0, n_items); - child = g_list_nth_data (toolbar->children, position); - - gtk_container_remove (GTK_CONTAINER (toolbar), child->widget); + tool_item = gtk_toolbar_get_nth_item (toolbar, position); + + gtk_container_remove (GTK_CONTAINER (toolbar), + GTK_WIDGET (tool_item)); } static gboolean @@ -74,7 +81,8 @@ stress_test_old_api (gpointer data) Info *info = data; Action action; - + gint n_items; + if (info->counter++ == 200) { gtk_main_quit (); @@ -89,12 +97,13 @@ stress_test_old_api (gpointer data) gtk_widget_show (GTK_WIDGET (info->toolbar)); } - if (!info->toolbar->children) + n_items = gtk_toolbar_get_n_items (info->toolbar); + if (n_items == 0) { add_random (info->toolbar, info->counter); return TRUE; } - else if (g_list_length (info->toolbar->children) > 50) + else if (n_items > 50) { int i; for (i = 0; i < 25; i++) @@ -136,7 +145,7 @@ main (gint argc, gchar **argv) gtk_widget_show (GTK_WIDGET (info.window)); - g_idle_add (stress_test_old_api, &info); + gdk_threads_add_idle (stress_test_old_api, &info); gtk_widget_show_all (GTK_WIDGET (info.window));