]> Pileus Git - ~andy/gtk/blobdiff - tests/testtreeflow.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testtreeflow.c
index 6f87df0cbac8eb3ac647d3c59b8a832e5711cf4c..efbb792f19f9b887ec572502b43e62c3e321d883 100644 (file)
@@ -1,8 +1,26 @@
-#include <config.h>
+/* testtreeflow.c
+ * Copyright (C) 2001 Red Hat, Inc
+ * Author: Jonathan Blandford
+ *
+ * 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
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
 #include <gtk/gtk.h>
 
 GtkTreeModel *model = NULL;
-static GRand *rand = NULL;
+static GRand *grand = NULL;
 GtkTreeSelection *selection = NULL;
 enum
 {
@@ -32,12 +50,12 @@ initialize_model (void)
   GtkTreeIter iter;
 
   model = (GtkTreeModel *) gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING);
-  rand = g_rand_new ();
+  grand = g_rand_new ();
   for (i = 0; i < NUM_ROWS; i++)
     {
       gtk_list_store_append (GTK_LIST_STORE (model), &iter);
       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-                         TEXT_COLUMN, words[g_rand_int_range (rand, 0, NUM_WORDS)],
+                         TEXT_COLUMN, words[g_rand_int_range (grand, 0, NUM_WORDS)],
                          -1);
     }
 }
@@ -50,7 +68,7 @@ futz_row (void)
   GtkTreeIter iter;
   GtkTreeIter iter2;
 
-  i = g_rand_int_range (rand, 0,
+  i = g_rand_int_range (grand, 0,
                        gtk_tree_model_iter_n_children (model, NULL));
   path = gtk_tree_path_new ();
   gtk_tree_path_append_index (path, i);
@@ -59,14 +77,14 @@ futz_row (void)
 
   if (gtk_tree_selection_iter_is_selected (selection, &iter))
     return;
-  switch (g_rand_int_range (rand, 0, 3))
+  switch (g_rand_int_range (grand, 0, 3))
     {
     case 0:
       /* insert */
             gtk_list_store_insert_after (GTK_LIST_STORE (model),
                                           &iter2, &iter);
             gtk_list_store_set (GTK_LIST_STORE (model), &iter2,
-                                 TEXT_COLUMN, words[g_rand_int_range (rand, 0, NUM_WORDS)],
+                                 TEXT_COLUMN, words[g_rand_int_range (grand, 0, NUM_WORDS)],
                                  -1);
       break;
     case 1:
@@ -81,7 +99,7 @@ futz_row (void)
       if (gtk_tree_model_iter_n_children (model, NULL) == 0)
        return;
       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-                         TEXT_COLUMN, words[g_rand_int_range (rand, 0, NUM_WORDS)],
+                         TEXT_COLUMN, words[g_rand_int_range (grand, 0, NUM_WORDS)],
                          -1);
       break;
     }
@@ -115,7 +133,7 @@ main (int argc, char *argv[])
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "Reflow test");
   g_signal_connect (window, "destroy", gtk_main_quit, NULL);
-  vbox = gtk_vbox_new (FALSE, 8);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
   gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Incremental Reflow Test"), FALSE, FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -139,16 +157,16 @@ main (int argc, char *argv[])
                                               "text", TEXT_COLUMN,
                                               NULL);
   gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
-  hbox = gtk_hbox_new (FALSE, FALSE);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
   button = gtk_button_new_with_mnemonic ("<b>_Futz!!</b>");
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-  gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (button)->child), TRUE);
+  gtk_label_set_use_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), TRUE);
   g_signal_connect (button, "clicked", G_CALLBACK (futz), NULL);
   g_signal_connect (button, "realize", G_CALLBACK (gtk_widget_grab_focus), NULL);
   gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
   gtk_widget_show_all (window);
-  g_timeout_add (1000, (GSourceFunc) futz, NULL);
+  gdk_threads_add_timeout (1000, (GSourceFunc) futz, NULL);
   gtk_main ();
   return 0;
 }