]> Pileus Git - ~andy/gtk/blobdiff - gtk/testgtk.c
Adapt cast macros to standard.
[~andy/gtk] / gtk / testgtk.c
index 1aafdbc2c2f27a047d09b01ccc0292ffab109a6a..c8bc008999aabd08af42351d09ce2ffe31230c5e 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
 #undef G_LOG_DOMAIN
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <math.h>
 #include <time.h>
+#include <unistd.h>
 #include "gtk.h"
-#include "../gdk/gdk.h"
-#include "../gdk/gdkx.h"
-#include "../gdk/gdkkeysyms.h"
+#include "gdk/gdk.h"
+#include "gdk/gdkkeysyms.h"
+#include "gdkx.h"
 
 #include "circles.xbm"
 
@@ -99,7 +109,7 @@ build_option_menu (OptionMenuItem items[],
       group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
       gtk_menu_append (GTK_MENU (menu), menu_item);
       if (i == history)
-       gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
       gtk_widget_show (menu_item);
     }
 
@@ -150,7 +160,7 @@ create_buttons (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "GtkButton");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
@@ -158,7 +168,7 @@ create_buttons (void)
       table = gtk_table_new (3, 3, FALSE);
       gtk_table_set_row_spacings (GTK_TABLE (table), 5);
       gtk_table_set_col_spacings (GTK_TABLE (table), 5);
-      gtk_container_border_width (GTK_CONTAINER (table), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (table), 10);
       gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
 
       button[0] = gtk_button_new_with_label ("button1");
@@ -231,7 +241,7 @@ create_buttons (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button[9] = gtk_button_new_with_label ("close");
@@ -271,13 +281,13 @@ create_toggle_buttons (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "GtkToggleButton");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_toggle_button_new_with_label ("button1");
@@ -293,7 +303,7 @@ create_toggle_buttons (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -333,13 +343,13 @@ create_check_buttons (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "GtkCheckButton");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_check_button_new_with_label ("button1");
@@ -355,7 +365,7 @@ create_check_buttons (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -395,13 +405,13 @@ create_radio_buttons (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "radio buttons");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (NULL, "button1");
@@ -410,7 +420,7 @@ create_radio_buttons (void)
       button = gtk_radio_button_new_with_label (
                 gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
                 "button2");
-      gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
@@ -422,7 +432,7 @@ create_radio_buttons (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -463,7 +473,7 @@ create_bbox (gint  horizontal,
   else
     bbox = gtk_vbutton_box_new ();
 
-  gtk_container_border_width (GTK_CONTAINER (bbox), 5);
+  gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
   gtk_container_add (GTK_CONTAINER (frame), bbox);
 
   gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
@@ -501,7 +511,7 @@ create_button_box (void)
                        GTK_SIGNAL_FUNC(gtk_widget_destroyed),
                        &window);
     
-    gtk_container_border_width (GTK_CONTAINER (window), 10);
+    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
     main_vbox = gtk_vbox_new (FALSE, 0);
     gtk_container_add (GTK_CONTAINER (window), main_vbox);
@@ -510,7 +520,7 @@ create_button_box (void)
     gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
     
     vbox = gtk_vbox_new (FALSE, 0);
-    gtk_container_border_width (GTK_CONTAINER (vbox), 10);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
     gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
 
     gtk_box_pack_start (GTK_BOX (vbox), 
@@ -533,7 +543,7 @@ create_button_box (void)
     gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
     
     hbox = gtk_hbox_new (FALSE, 0);
-    gtk_container_border_width (GTK_CONTAINER (hbox), 10);
+    gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
     gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
 
     gtk_box_pack_start (GTK_BOX (hbox), 
@@ -615,6 +625,13 @@ set_toolbar_both (GtkWidget *widget,
   gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH);
 }
 
+static void
+set_toolbar_both_horiz (GtkWidget *widget,
+                       gpointer   data)
+{
+  gtk_toolbar_set_style (GTK_TOOLBAR (data), GTK_TOOLBAR_BOTH_HORIZ);
+}
+
 static void
 set_toolbar_small_space (GtkWidget *widget,
                         gpointer   data)
@@ -657,6 +674,20 @@ set_toolbar_borderless (GtkWidget *widget,
   gtk_toolbar_set_button_relief (GTK_TOOLBAR (data), GTK_RELIEF_NONE);
 }
 
+static void
+set_toolbar_space_style_empty (GtkWidget *widget,
+                              gpointer   data)
+{
+  gtk_toolbar_set_space_style (GTK_TOOLBAR (data), GTK_TOOLBAR_SPACE_EMPTY);
+}
+
+static void
+set_toolbar_space_style_line (GtkWidget *widget,
+                             gpointer   data)
+{
+  gtk_toolbar_set_space_style (GTK_TOOLBAR (data), GTK_TOOLBAR_SPACE_LINE);
+}
+
 static void
 create_toolbar (void)
 {
@@ -674,7 +705,7 @@ create_toolbar (void)
                          GTK_SIGNAL_FUNC (gtk_widget_destroyed),
                          &window);
 
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
       gtk_widget_realize (window);
 
       toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
@@ -703,7 +734,13 @@ create_toolbar (void)
                               "Both", "Show toolbar icons and text", "Toolbar/Both",
                               new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
                               (GtkSignalFunc) set_toolbar_both, toolbar);
-
+      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+                              "Both (horizontal)",
+                              "Show toolbar icons and text in a horizontal fashion",
+                              "Toolbar/BothHoriz",
+                              new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+                              (GtkSignalFunc) set_toolbar_both_horiz, toolbar);
+                              
       gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
 
       entry = gtk_entry_new ();
@@ -743,6 +780,17 @@ create_toolbar (void)
                               new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
                               (GtkSignalFunc) set_toolbar_borderless, toolbar);
 
+      gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+      
+      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+                              "Empty", "Empty spaces", NULL,
+                              new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+                              (GtkSignalFunc) set_toolbar_space_style_empty, toolbar);
+      gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
+                              "Lines", "Lines in spaces", NULL,
+                              new_pixmap ("test.xpm", window->window, &window->style->bg[GTK_STATE_NORMAL]),
+                              (GtkSignalFunc) set_toolbar_space_style_line, toolbar);
+
       gtk_container_add (GTK_CONTAINER (window), toolbar);
     }
 
@@ -930,13 +978,13 @@ create_statusbar (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "statusbar");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       statusbar = gtk_statusbar_new ();
@@ -985,7 +1033,7 @@ create_statusbar (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -1205,7 +1253,7 @@ create_tree_sample(guint selection_mode,
   /* create tree box */
   box2 = gtk_vbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(box1), box2, TRUE, TRUE, 0);
-  gtk_container_border_width(GTK_CONTAINER(box2), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
   gtk_widget_show(box2);
 
   /* create scrolled window */
@@ -1222,7 +1270,7 @@ create_tree_sample(guint selection_mode,
                     (GtkSignalFunc)cb_tree_changed,
                     (gpointer)NULL);
   gtk_object_set_user_data(GTK_OBJECT(root_tree), tree_buttons);
-  gtk_container_add(GTK_CONTAINER(scrolled_win), root_tree);
+  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win), root_tree);
   gtk_tree_set_selection_mode(GTK_TREE(root_tree), selection_mode);
   gtk_tree_set_view_lines(GTK_TREE(root_tree), draw_line);
   gtk_tree_set_view_mode(GTK_TREE(root_tree), !view_line);
@@ -1244,7 +1292,7 @@ create_tree_sample(guint selection_mode,
 
   box2 = gtk_vbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-  gtk_container_border_width(GTK_CONTAINER(box2), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
   gtk_widget_show(box2);
 
   button = gtk_button_new_with_label("Add Item");
@@ -1282,7 +1330,7 @@ create_tree_sample(guint selection_mode,
   /* create button box */
   box2 = gtk_vbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-  gtk_container_border_width(GTK_CONTAINER(box2), 5);
+  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
   gtk_widget_show(box2);
 
   button = gtk_button_new_with_label("Close");
@@ -1363,7 +1411,7 @@ create_tree_mode_window(void)
       /* create upper box - selection box */
       box2 = gtk_vbox_new(FALSE, 5);
       gtk_box_pack_start(GTK_BOX(box1), box2, TRUE, TRUE, 0);
-      gtk_container_border_width(GTK_CONTAINER(box2), 5);
+      gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
 
       box3 = gtk_hbox_new(FALSE, 5);
       gtk_box_pack_start(GTK_BOX(box2), box3, TRUE, TRUE, 0);
@@ -1374,7 +1422,7 @@ create_tree_mode_window(void)
 
       box4 = gtk_vbox_new(FALSE, 0);
       gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_border_width(GTK_CONTAINER(box4), 5);
+      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
 
       /* create radio button */  
       button = gtk_radio_button_new_with_label(NULL, "SINGLE");
@@ -1399,17 +1447,17 @@ create_tree_mode_window(void)
 
       box4 = gtk_vbox_new(FALSE, 0);
       gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_border_width(GTK_CONTAINER(box4), 5);
+      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
 
       /* create check button */
       button = gtk_check_button_new_with_label("Draw line");
       gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
       sTreeSampleSelection.draw_line_button = button;
   
       button = gtk_check_button_new_with_label("View Line mode");
       gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
       sTreeSampleSelection.view_line_button = button;
   
       button = gtk_check_button_new_with_label("Without Root item");
@@ -1422,7 +1470,7 @@ create_tree_mode_window(void)
 
       box4 = gtk_hbox_new(FALSE, 5);
       gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_border_width(GTK_CONTAINER(box4), 5);
+      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
 
       /* create number of item spin button */
       box5 = gtk_hbox_new(FALSE, 5);
@@ -1459,7 +1507,7 @@ create_tree_mode_window(void)
       /* create bottom button box */
       box2 = gtk_hbox_new(TRUE, 10);
       gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-      gtk_container_border_width(GTK_CONTAINER(box2), 5);
+      gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
 
       button = gtk_button_new_with_label("Create Tree");
       gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
@@ -1513,13 +1561,13 @@ create_handle_box (void)
     gtk_window_set_policy (GTK_WINDOW (window),
                           TRUE,
                           TRUE,
-                          FALSE);
+                          TRUE);
     
     gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        GTK_SIGNAL_FUNC(gtk_widget_destroyed),
                        &window);
     
-    gtk_container_border_width (GTK_CONTAINER (window), 20);
+    gtk_container_set_border_width (GTK_CONTAINER (window), 20);
 
     vbox = gtk_vbox_new (FALSE, 0);
     gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -1546,7 +1594,7 @@ create_handle_box (void)
     gtk_widget_show (label);
 
     handle_box = gtk_handle_box_new ();
-    gtk_container_add (GTK_CONTAINER (hbox), handle_box);
+    gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0);
     gtk_signal_connect (GTK_OBJECT (handle_box),
                        "child_attached",
                        GTK_SIGNAL_FUNC (handle_box_child_signal),
@@ -1563,7 +1611,7 @@ create_handle_box (void)
     gtk_widget_show (toolbar);
 
     handle_box = gtk_handle_box_new ();
-    gtk_container_add (GTK_CONTAINER (hbox), handle_box);
+    gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0);
     gtk_signal_connect (GTK_OBJECT (handle_box),
                        "child_attached",
                        GTK_SIGNAL_FUNC (handle_box_child_signal),
@@ -1597,6 +1645,96 @@ create_handle_box (void)
     gtk_widget_destroy (window);
 }
 
+/* 
+ * Label Demo
+ */
+void create_labels (void)
+{
+  static GtkWidget *window = NULL;
+  GtkWidget *hbox;
+  GtkWidget *vbox;
+  GtkWidget *frame;
+  GtkWidget *label;
+
+  if (!window)
+    {
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_signal_connect (GTK_OBJECT (window), "destroy",
+                         GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                         &window);
+
+      gtk_window_set_title (GTK_WINDOW (window), "Label");
+      vbox = gtk_vbox_new (FALSE, 5);
+      hbox = gtk_hbox_new (FALSE, 5);
+      gtk_container_add (GTK_CONTAINER (window), hbox);
+      gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 5);
+
+      frame = gtk_frame_new ("Normal Label");
+      label = gtk_label_new ("This is a Normal label");
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      frame = gtk_frame_new ("Multi-line Label");
+      label = gtk_label_new ("This is a Multi-line label.\nSecond line\nThird line");
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      frame = gtk_frame_new ("Left Justified Label");
+      label = gtk_label_new ("This is a Left-Justified\nMulti-line label.\nThird      line");
+      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      frame = gtk_frame_new ("Right Justified Label");
+      label = gtk_label_new ("This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)");
+      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      vbox = gtk_vbox_new (FALSE, 5);
+      gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+      frame = gtk_frame_new ("Line wrapped label");
+      label = gtk_label_new ("This is an example of a line-wrapped label.  It should not be taking "\
+                            "up the entire             "/* big space to test spacing */\
+                            "width allocated to it, but automatically wraps the words to fit.  "\
+                            "The time has come, for all good men, to come to the aid of their party.  "\
+                            "The sixth sheik's six sheep's sick.\n"\
+                            "     It supports multiple paragraphs correctly, and  correctly   adds "\
+                            "many          extra  spaces. ");
+
+      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      frame = gtk_frame_new ("Filled, wrapped label");
+      label = gtk_label_new ("This is an example of a line-wrapped, filled label.  It should be taking "\
+                            "up the entire              width allocated to it.  Here is a seneance to prove "\
+                            "my point.  Here is another sentence. "\
+                            "Here comes the sun, do de do de do.\n"\
+                            "    This is a new paragraph.\n"\
+                            "    This is another newer, longer, better paragraph.  It is coming to an end, "\
+                            "unfortunately.");
+      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL);
+      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+      frame = gtk_frame_new ("Underlined label");
+      label = gtk_label_new ("This label is underlined!\n"
+                            "This one is underlined in ÆüËܸì¤ÎÆþÍÑquite a funky fashion");
+      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+      gtk_label_set_pattern (GTK_LABEL (label), "_________________________ _ _________ _ _____ _ __ __  ___ ____ _____");
+      gtk_container_add (GTK_CONTAINER (frame), label);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+
+    }
+  if (!GTK_WIDGET_VISIBLE (window))
+    gtk_widget_show_all (window);
+  else
+    gtk_widget_destroy (window);
+}
+
 /*
  * Reparent demo
  */
@@ -1645,13 +1783,13 @@ create_reparent (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "reparent");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_hbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       label = gtk_label_new ("Hello World");
@@ -1660,7 +1798,7 @@ create_reparent (void)
       gtk_box_pack_start (GTK_BOX (box2), frame, TRUE, TRUE, 0);
 
       box3 = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box3), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box3), 5);
       gtk_container_add (GTK_CONTAINER (frame), box3);
 
       button = gtk_button_new_with_label ("switch");
@@ -1680,7 +1818,7 @@ create_reparent (void)
       gtk_box_pack_start (GTK_BOX (box2), frame, TRUE, TRUE, 0);
 
       box3 = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box3), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box3), 5);
       gtk_container_add (GTK_CONTAINER (frame), box3);
 
       button = gtk_button_new_with_label ("switch");
@@ -1694,7 +1832,7 @@ create_reparent (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -1730,9 +1868,9 @@ uposition_configure (GtkWidget *window)
 
   gdk_window_get_root_origin (window->window, &upositionx, &upositiony);
   sprintf (buffer, "%d", upositionx);
-  gtk_label_set (lx, buffer);
+  gtk_label_set_text (lx, buffer);
   sprintf (buffer, "%d", upositiony);
-  gtk_label_set (ly, buffer);
+  gtk_label_set_text (ly, buffer);
 
   return FALSE;
 }
@@ -1766,7 +1904,7 @@ create_saved_position (void)
                          &window);
 
       main_vbox = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (main_vbox), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 0);
       gtk_container_add (GTK_CONTAINER (window), main_vbox);
 
       vbox =
@@ -1779,7 +1917,7 @@ create_saved_position (void)
                        NULL);
 
       hbox = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
 
       label = gtk_label_new ("X Origin : ");
@@ -1791,7 +1929,7 @@ create_saved_position (void)
       gtk_object_set_data (GTK_OBJECT (window), "x", x_label);
 
       hbox = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
 
       label = gtk_label_new ("Y Origin : ");
@@ -1809,7 +1947,7 @@ create_saved_position (void)
       gtk_box_pack_start (GTK_BOX (main_vbox), any, FALSE, TRUE, 0);
 
       hbox = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
       gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("Close");
@@ -1843,7 +1981,6 @@ create_pixmap (void)
   GtkWidget *pixmapwid;
   GdkPixmap *pixmap;
   GdkBitmap *mask;
-  GtkStyle *style;
 
   if (!window)
     {
@@ -1854,23 +1991,20 @@ create_pixmap (void)
                           &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "GtkPixmap");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
       gtk_widget_realize(window);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_button_new ();
       gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
 
-      style = gtk_widget_get_style(button);
-
-      pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, 
-                                          &style->bg[GTK_STATE_NORMAL],
+      pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, NULL,
                                           "test.xpm");
       pixmapwid = gtk_pixmap_new (pixmap, mask);
       gdk_pixmap_unref (pixmap);
@@ -1878,7 +2012,7 @@ create_pixmap (void)
 
       label = gtk_label_new ("Pixmap\ntest");
       box3 = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (box3), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (box3), 2);
       gtk_container_add (GTK_CONTAINER (box3), pixmapwid);
       gtk_container_add (GTK_CONTAINER (box3), label);
       gtk_container_add (GTK_CONTAINER (button), box3);
@@ -1887,7 +2021,7 @@ create_pixmap (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -1914,7 +2048,7 @@ tips_query_widget_entered (GtkTipsQuery   *tips_query,
 {
   if (GTK_TOGGLE_BUTTON (toggle)->active)
     {
-      gtk_label_set (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
+      gtk_label_set_text (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
       /* don't let GtkTipsQuery reset it's label */
       gtk_signal_emit_stop_by_name (GTK_OBJECT (tips_query), "widget_entered");
     }
@@ -1973,7 +2107,7 @@ create_tooltips (void)
       gtk_container_add (GTK_CONTAINER (window), box1);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_toggle_button_new_with_label ("button1");
@@ -2041,7 +2175,7 @@ create_tooltips (void)
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -2135,7 +2269,7 @@ create_menus (void)
       gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
 
       gtk_window_set_title (GTK_WINDOW (window), "menus");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
       
       
       box1 = gtk_vbox_new (FALSE, 0);
@@ -2165,7 +2299,7 @@ create_menus (void)
       gtk_widget_show (menuitem);
       
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
       gtk_widget_show (box2);
       
@@ -2205,7 +2339,7 @@ create_menus (void)
                                  GDK_F3,
                                  0,
                                  GTK_ACCEL_VISIBLE);
-      gtk_widget_freeze_accelerators (menuitem);
+      gtk_widget_lock_accelerators (menuitem);
       
       optionmenu = gtk_option_menu_new ();
       gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
@@ -2218,7 +2352,7 @@ create_menus (void)
       gtk_widget_show (separator);
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -2248,7 +2382,7 @@ gtk_ifactory_cb (gpointer             callback_data,
 
 static GtkItemFactoryEntry menu_items[] =
 {
-  { "/_File",            NULL,         gtk_ifactory_cb,       0, "<Branch>" },
+  { "/_File",            NULL,         0,                     0, "<Branch>" },
   { "/File/tearoff1",    NULL,         gtk_ifactory_cb,       0, "<Tearoff>" },
   { "/File/_New",        "<control>N", gtk_ifactory_cb,       0 },
   { "/File/_Open",       "<control>O", gtk_ifactory_cb,       0 },
@@ -2257,17 +2391,17 @@ static GtkItemFactoryEntry menu_items[] =
   { "/File/sep1",        NULL,         gtk_ifactory_cb,       0, "<Separator>" },
   { "/File/_Quit",       "<control>Q", gtk_ifactory_cb,       0 },
 
-  { "/_Preferences",                   NULL, gtk_ifactory_cb, 0, "<Branch>" },
-  { "/_Preferences/_Color",            NULL, gtk_ifactory_cb, 0, "<Branch>" },
+  { "/_Preferences",                   NULL, 0,               0, "<Branch>" },
+  { "/_Preferences/_Color",            NULL, 0,               0, "<Branch>" },
   { "/_Preferences/Color/_Red",        NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
-  { "/_Preferences/Color/_Green",      NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
-  { "/_Preferences/Color/_Blue",        NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
-  { "/_Preferences/_Shape",            NULL, gtk_ifactory_cb, 0, "<Branch>" },
+  { "/_Preferences/Color/_Green",      NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
+  { "/_Preferences/Color/_Blue",        NULL, gtk_ifactory_cb, 0, "/Preferences/Color/Red" },
+  { "/_Preferences/_Shape",            NULL, 0,               0, "<Branch>" },
   { "/_Preferences/Shape/_Square",      NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
-  { "/_Preferences/Shape/_Rectangle",   NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
-  { "/_Preferences/Shape/_Oval",        NULL, gtk_ifactory_cb, 0, "<RadioItem>" },
+  { "/_Preferences/Shape/_Rectangle",   NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Square" },
+  { "/_Preferences/Shape/_Oval",        NULL, gtk_ifactory_cb, 0, "/Preferences/Shape/Rectangle" },
 
-  { "/_Help",            NULL,         gtk_ifactory_cb,       0, "<LastBranch>" },
+  { "/_Help",            NULL,         0,                     0, "<LastBranch>" },
   { "/Help/_About",      NULL,         gtk_ifactory_cb,       0 },
 };
 
@@ -2299,11 +2433,21 @@ create_item_factory (void)
       
       accel_group = gtk_accel_group_new ();
       item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
-      gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
+      gtk_object_set_data_full (GTK_OBJECT (window),
+                               "<main>",
+                               item_factory,
+                               (GtkDestroyNotify) gtk_object_unref);
       gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
       gtk_window_set_title (GTK_WINDOW (window), "Item Factory");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
-      
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
+      gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
+
+      /* preselect /Preferences/Shape/Oval over the other radios
+       */
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory,
+                                                                                     "/Preferences/Shape/Oval")),
+                                     TRUE);
+
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
       
@@ -2322,7 +2466,7 @@ create_item_factory (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
@@ -2379,7 +2523,7 @@ cmw_destroy_cb(GtkWidget *widget)
 }
 
 static void
-cmw_color (GtkWidget *widget)
+cmw_color (GtkWidget *widget, GtkWidget *parent)
 {
     GtkWidget *csd;
 
@@ -2387,6 +2531,9 @@ cmw_color (GtkWidget *widget)
 
     /* Set as modal */
     gtk_window_set_modal (GTK_WINDOW(csd),TRUE);
+
+    /* And mark it as a transient dialog */
+    gtk_window_set_transient_for (GTK_WINDOW (csd), GTK_WINDOW (parent));
     
     gtk_signal_connect (GTK_OBJECT(csd), "destroy",
                        GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
@@ -2404,7 +2551,7 @@ cmw_color (GtkWidget *widget)
 }
 
 static void
-cmw_file (GtkWidget *widget)
+cmw_file (GtkWidget *widget, GtkWidget *parent)
 {
     GtkWidget *fs;
 
@@ -2413,6 +2560,9 @@ cmw_file (GtkWidget *widget)
     /* Set as modal */
     gtk_window_set_modal (GTK_WINDOW(fs),TRUE);
 
+    /* And mark it as a transient dialog */
+    gtk_window_set_transient_for (GTK_WINDOW (fs), GTK_WINDOW (parent));
+
     gtk_signal_connect (GTK_OBJECT(fs), "destroy",
                         GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL);
 
@@ -2454,8 +2604,8 @@ create_modal_window (void)
      btnClose = gtk_button_new_with_label ("Close");
 
   /* Init widgets */
-  gtk_container_border_width (GTK_CONTAINER(box1),3);
-  gtk_container_border_width (GTK_CONTAINER(box2),3);
+  gtk_container_set_border_width (GTK_CONTAINER(box1),3);
+  gtk_container_set_border_width (GTK_CONTAINER(box2),3);
     
   /* Pack widgets */
   gtk_container_add (GTK_CONTAINER (window), box1);
@@ -2475,9 +2625,9 @@ create_modal_window (void)
                       GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL);
   
   gtk_signal_connect (GTK_OBJECT (btnColor), "clicked",
-                      GTK_SIGNAL_FUNC (cmw_color),NULL);
+                      GTK_SIGNAL_FUNC (cmw_color),window);
   gtk_signal_connect (GTK_OBJECT (btnFile), "clicked",
-                      GTK_SIGNAL_FUNC (cmw_file),NULL);
+                      GTK_SIGNAL_FUNC (cmw_file),window);
 
   /* Show widgets */
   gtk_widget_show_all (window);
@@ -2509,11 +2659,11 @@ create_scrolled_windows (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "dialog");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
 
       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-      gtk_container_border_width (GTK_CONTAINER (scrolled_window), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_AUTOMATIC);
@@ -2524,7 +2674,7 @@ create_scrolled_windows (void)
       table = gtk_table_new (20, 20, FALSE);
       gtk_table_set_row_spacings (GTK_TABLE (table), 10);
       gtk_table_set_col_spacings (GTK_TABLE (table), 10);
-      gtk_container_add (GTK_CONTAINER (scrolled_window), table);
+      gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), table);
       gtk_container_set_focus_hadjustment (GTK_CONTAINER (table),
                                           gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled_window)));
       gtk_container_set_focus_vadjustment (GTK_CONTAINER (table),
@@ -2562,6 +2712,7 @@ create_scrolled_windows (void)
       gtk_widget_grab_default (button);
       gtk_widget_show (button);
 
+      gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
@@ -2630,7 +2781,7 @@ create_entry (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "entry");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
 
       box1 = gtk_vbox_new (FALSE, 0);
@@ -2639,7 +2790,7 @@ create_entry (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -2661,21 +2812,21 @@ create_entry (void)
       gtk_box_pack_start (GTK_BOX (box2), editable_check, FALSE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT(editable_check), "toggled",
                          GTK_SIGNAL_FUNC(entry_toggle_editable), entry);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(editable_check), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(editable_check), TRUE);
       gtk_widget_show (editable_check);
 
       editable_check = gtk_check_button_new_with_label("Visible");
       gtk_box_pack_start (GTK_BOX (box2), editable_check, FALSE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT(editable_check), "toggled",
                          GTK_SIGNAL_FUNC(entry_toggle_visibility), entry);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(editable_check), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(editable_check), TRUE);
       gtk_widget_show (editable_check);
 
       sensitive_check = gtk_check_button_new_with_label("Sensitive");
       gtk_box_pack_start (GTK_BOX (box2), sensitive_check, FALSE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT(sensitive_check), "toggled",
                          GTK_SIGNAL_FUNC(entry_toggle_sensitive), entry);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sensitive_check), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sensitive_check), TRUE);
       gtk_widget_show (sensitive_check);
 
       separator = gtk_hseparator_new ();
@@ -2684,7 +2835,7 @@ create_entry (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -2744,7 +2895,105 @@ get_value (GtkWidget *widget, gpointer data)
   else
     sprintf (buf, "%0.*f", spin->digits,
             gtk_spin_button_get_value_as_float (spin));
-  gtk_label_set (label, buf);
+  gtk_label_set_text (label, buf);
+}
+
+static gint
+spin_button_time_output_func (GtkSpinButton *spin_button)
+{
+  static gchar buf[6];
+  gfloat hours;
+  gfloat minutes;
+
+  hours = spin_button->adjustment->value / 60.0;
+  minutes = (fabs(floor (hours) - hours) < 1e-5) ? 0.0 : 30;
+  sprintf (buf, "%02.0f:%02.0f", floor (hours), minutes);
+  if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
+    gtk_entry_set_text (GTK_ENTRY (spin_button), buf);
+  return TRUE;
+}
+
+static gint
+spin_button_month_input_func (GtkSpinButton *spin_button,
+                             gfloat        *new_val)
+{
+  gint i;
+  static gchar *month[12] = { "January", "February", "March", "April",
+                             "May", "June", "July", "August",
+                             "September", "October", "November", "December" };
+  gchar *tmp1, *tmp2;
+  gboolean found = FALSE;
+
+  for (i = 1; i <= 12; i++)
+    {
+      tmp1 = g_strdup (month[i-1]);
+      g_strup (tmp1);
+      tmp2 = g_strdup (gtk_entry_get_text (GTK_ENTRY (spin_button)));
+      g_strup (tmp2);
+      if (strstr (tmp1, tmp2) == tmp1)
+       found = TRUE;
+      g_free (tmp1);
+      g_free (tmp2);
+      if (found)
+       break;
+    }
+  if (!found)
+    {
+      *new_val = 0.0;
+      return INPUT_ERROR;
+    }
+  *new_val = (gfloat) i;
+  return TRUE;
+}
+
+static gint
+spin_button_month_output_func (GtkSpinButton *spin_button)
+{
+  gint i;
+  static gchar *month[12] = { "January", "February", "March", "April",
+                             "May", "June", "July", "August", "September",
+                             "October", "November", "December" };
+
+  for (i = 1; i <= 12; i++)
+    if (fabs (spin_button->adjustment->value - (double)i) < 1e-5)
+      {
+       if (strcmp (month[i-1], gtk_entry_get_text (GTK_ENTRY (spin_button))))
+         gtk_entry_set_text (GTK_ENTRY (spin_button), month[i-1]);
+      }
+  return TRUE;
+}
+
+static gint
+spin_button_hex_input_func (GtkSpinButton *spin_button,
+                           gfloat        *new_val)
+{
+  gchar *buf;
+  gchar *err;
+  gfloat res;
+
+  buf = gtk_entry_get_text (GTK_ENTRY (spin_button));
+  res = (gfloat)(strtol(buf, &err, 16));
+  *new_val = res;
+  if (*err)
+    return INPUT_ERROR;
+  else
+    return TRUE;
+}
+
+static gint
+spin_button_hex_output_func (GtkSpinButton *spin_button)
+{
+  static gchar buf[7];
+  gint val;
+
+  val = (gint) spin_button->adjustment->value;
+  if (fabs (val) < 1e-5)
+    sprintf (buf, "0x00");
+  else
+    sprintf (buf, "0x%.2X", val);
+  if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
+    gtk_entry_set_text (GTK_ENTRY (spin_button), buf);
+  return TRUE;
 }
 
 static void
@@ -2774,17 +3023,17 @@ create_spins (void)
       gtk_window_set_title (GTK_WINDOW (window), "GtkSpinButton");
       
       main_vbox = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (main_vbox), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);
       gtk_container_add (GTK_CONTAINER (window), main_vbox);
       
       frame = gtk_frame_new ("Not accelerated");
       gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
       
       vbox = gtk_vbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (vbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
       gtk_container_add (GTK_CONTAINER (frame), vbox);
       
-      /* Day, month, year spinners */
+      /* Time, month, hex spinners */
       
       hbox = gtk_hbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
@@ -2792,16 +3041,19 @@ create_spins (void)
       vbox2 = gtk_vbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
       
-      label = gtk_label_new ("Day :");
+      label = gtk_label_new ("Time :");
       gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
       gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
       
-      adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 31.0, 1.0,
-                                                 5.0, 0.0);
+      adj = (GtkAdjustment *) gtk_adjustment_new (0, 0, 1410, 30, 60, 0);
       spinner = gtk_spin_button_new (adj, 0, 0);
+      gtk_editable_set_editable (GTK_EDITABLE (spinner), FALSE);
+      gtk_signal_connect (GTK_OBJECT (spinner),
+                         "output",
+                         GTK_SIGNAL_FUNC (spin_button_time_output_func),
+                         NULL);
       gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE);
-      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
-                                      GTK_SHADOW_OUT);
+      gtk_widget_set_usize (spinner, 55, -1);
       gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
 
       vbox2 = gtk_vbox_new (FALSE, 0);
@@ -2814,24 +3066,39 @@ create_spins (void)
       adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 12.0, 1.0,
                                                  5.0, 0.0);
       spinner = gtk_spin_button_new (adj, 0, 0);
+      gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spinner),
+                                        GTK_UPDATE_IF_VALID);
+      gtk_signal_connect (GTK_OBJECT (spinner),
+                         "input",
+                         GTK_SIGNAL_FUNC (spin_button_month_input_func),
+                         NULL);
+      gtk_signal_connect (GTK_OBJECT (spinner),
+                         "output",
+                         GTK_SIGNAL_FUNC (spin_button_month_output_func),
+                         NULL);
       gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE);
-      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
-                                      GTK_SHADOW_ETCHED_IN);
+      gtk_widget_set_usize (spinner, 85, -1);
       gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
       
       vbox2 = gtk_vbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
 
-      label = gtk_label_new ("Year :");
+      label = gtk_label_new ("Hex :");
       gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
       gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
 
-      adj = (GtkAdjustment *) gtk_adjustment_new (1998.0, 0.0, 2100.0, 
-                                                 1.0, 100.0, 0.0);
+      adj = (GtkAdjustment *) gtk_adjustment_new (0, 0, 255, 1, 16, 0);
       spinner = gtk_spin_button_new (adj, 0, 0);
+      gtk_editable_set_editable (GTK_EDITABLE (spinner), TRUE);
+      gtk_signal_connect (GTK_OBJECT (spinner),
+                         "input",
+                         GTK_SIGNAL_FUNC (spin_button_hex_input_func),
+                         NULL);
+      gtk_signal_connect (GTK_OBJECT (spinner),
+                         "output",
+                         GTK_SIGNAL_FUNC (spin_button_hex_output_func),
+                         NULL);
       gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE);
-      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
-                                      GTK_SHADOW_IN);
       gtk_widget_set_usize (spinner, 55, 0);
       gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
 
@@ -2839,7 +3106,7 @@ create_spins (void)
       gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
   
       vbox = gtk_vbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (vbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
       gtk_container_add (GTK_CONTAINER (frame), vbox);
       
       hbox = gtk_hbox_new (FALSE, 0);
@@ -2868,7 +3135,6 @@ create_spins (void)
 
       adj = (GtkAdjustment *) gtk_adjustment_new (2, 1, 5, 1, 1, 0);
       spinner2 = gtk_spin_button_new (adj, 0.0, 0);
-      gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner2), TRUE);
       gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
                          GTK_SIGNAL_FUNC (change_digits),
                          (gpointer) spinner2);
@@ -2882,14 +3148,14 @@ create_spins (void)
                          GTK_SIGNAL_FUNC (toggle_snap),
                          spinner1);
       gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
 
       button = gtk_check_button_new_with_label ("Numeric only input mode");
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (toggle_numeric),
                          spinner1);
       gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
 
       val_label = gtk_label_new ("");
 
@@ -2911,7 +3177,7 @@ create_spins (void)
       gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
 
       gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
-      gtk_label_set (GTK_LABEL (val_label), "0");
+      gtk_label_set_text (GTK_LABEL (val_label), "0");
 
       hbox = gtk_hbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
@@ -2929,6 +3195,7 @@ create_spins (void)
     gtk_widget_destroy (window);
 }
 
+
 /*
  * Cursors
  */
@@ -2998,9 +3265,9 @@ set_cursor (GtkWidget *spinner,
   while (vals && vals->value != c)
     vals++;
   if (vals)
-    gtk_label_set (GTK_LABEL (label), vals->value_nick);
+    gtk_label_set_text (GTK_LABEL (label), vals->value_nick);
   else
-    gtk_label_set (GTK_LABEL (label), "<unknown>");
+    gtk_label_set_text (GTK_LABEL (label), "<unknown>");
 
   cursor = gdk_cursor_new (c);
   gdk_window_set_cursor (widget->window, cursor);
@@ -3050,7 +3317,7 @@ create_cursors (void)
       gtk_window_set_title (GTK_WINDOW (window), "Cursors");
       
       main_vbox = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (main_vbox), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 0);
       gtk_container_add (GTK_CONTAINER (window), main_vbox);
 
       vbox =
@@ -3063,7 +3330,7 @@ create_cursors (void)
                        NULL);
 
       hbox = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
       
       label = gtk_label_new ("Cursor Value : ");
@@ -3122,7 +3389,7 @@ create_cursors (void)
       gtk_box_pack_start (GTK_BOX (main_vbox), any, FALSE, TRUE, 0);
   
       hbox = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
       gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("Close");
@@ -3163,25 +3430,45 @@ list_add (GtkWidget *widget,
 
 static void
 list_remove (GtkWidget *widget,
-            GtkWidget *list)
+            GtkList   *list)
 {
-  GList *tmp_list;
-  GList *clear_list;
-
-  tmp_list = GTK_LIST (list)->selection;
-  clear_list = NULL;
+  GList *clear_list = NULL;
+  GList *sel_row = NULL;
+  GList *work = NULL;
 
-  while (tmp_list)
+  if (list->selection_mode == GTK_SELECTION_EXTENDED)
     {
-      clear_list = g_list_prepend (clear_list, tmp_list->data);
-      tmp_list = tmp_list->next;
+      GtkWidget *item;
+
+      item = GTK_CONTAINER (list)->focus_child;
+      if (!item && list->selection)
+       item = list->selection->data;
+
+      if (item)
+       {
+         work = g_list_find (list->children, item);
+         for (sel_row = work; sel_row; sel_row = sel_row->next)
+           if (GTK_WIDGET (sel_row->data)->state != GTK_STATE_SELECTED)
+             break;
+
+         if (!sel_row)
+           {
+             for (sel_row = work; sel_row; sel_row = sel_row->prev)
+               if (GTK_WIDGET (sel_row->data)->state != GTK_STATE_SELECTED)
+                 break;
+           }
+       }
     }
 
-  clear_list = g_list_reverse (clear_list);
+  for (work = list->selection; work; work = work->next)
+    clear_list = g_list_prepend (clear_list, work->data);
 
+  clear_list = g_list_reverse (clear_list);
   gtk_list_remove_items (GTK_LIST (list), clear_list);
-
   g_list_free (clear_list);
+
+  if (list->selection_mode == GTK_SELECTION_EXTENDED && sel_row)
+    gtk_list_select_child (list, GTK_WIDGET(sel_row->data));
 }
 
 static void
@@ -3191,13 +3478,6 @@ list_clear (GtkWidget *widget,
   gtk_list_clear_items (GTK_LIST (list), 0, -1);
 }
 
-static void
-list_undo_selection (GtkWidget *widget,
-                    GtkWidget *list)
-{
-  gtk_list_undo_selection (GTK_LIST (list));
-}
-
 #define RADIOMENUTOGGLED(_rmi_, __i) { \
   GSList * __g; \
   __i = 0; \
@@ -3228,21 +3508,27 @@ static void
 create_list (void)
 {
   static GtkWidget *window = NULL;
-  GtkWidget *box1;
-  GtkWidget *box2;
-  GtkWidget *hbox;
-  GtkWidget *label;
-  GtkWidget *scrolled_win;
-  GtkWidget *list;
-  GtkWidget *button;
-  GtkWidget *separator;
-  GtkWidget *menu;
-  GtkWidget *menu_item;
-  GSList *group;
-  FILE *infile;
+
+  static OptionMenuItem items[] =
+  {
+    { "Single",   list_toggle_sel_mode },
+    { "Browse",   list_toggle_sel_mode },
+    { "Multiple", list_toggle_sel_mode },
+    { "Extended", list_toggle_sel_mode }
+  };
 
   if (!window)
     {
+      GtkWidget *cbox;
+      GtkWidget *vbox;
+      GtkWidget *hbox;
+      GtkWidget *label;
+      GtkWidget *scrolled_win;
+      GtkWidget *list;
+      GtkWidget *button;
+      GtkWidget *separator;
+      FILE *infile;
+
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
@@ -3250,25 +3536,23 @@ create_list (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "list");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
-
-      box1 = gtk_vbox_new (FALSE, 0);
-      gtk_container_add (GTK_CONTAINER (window), box1);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
-      box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
+      vbox = gtk_vbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
 
       scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+      gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 5);
+      gtk_widget_set_usize (scrolled_win, -1, 300);
+      gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_AUTOMATIC);
-      gtk_box_pack_start (GTK_BOX (box2), scrolled_win, TRUE, TRUE, 0);
-      gtk_widget_set_usize (scrolled_win, -1, 300);
 
       list = gtk_list_new ();
       gtk_list_set_selection_mode (GTK_LIST (list), GTK_SELECTION_EXTENDED);
-      gtk_container_add (GTK_CONTAINER (scrolled_win), list);
+      gtk_scrolled_window_add_with_viewport
+       (GTK_SCROLLED_WINDOW (scrolled_win), list);
       gtk_container_set_focus_vadjustment
        (GTK_CONTAINER (list),
         gtk_scrolled_window_get_vadjustment
@@ -3295,93 +3579,54 @@ create_list (void)
          fclose (infile);
        }
 
-      hbox = gtk_hbox_new (TRUE, 10);
-      gtk_box_pack_start (GTK_BOX (box2), hbox, FALSE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Undo Selection");
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC(list_undo_selection),
-                         list);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+      hbox = gtk_hbox_new (TRUE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Remove Selection");
+      button = gtk_button_new_with_label ("Insert Row");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC (list_remove),
+                         GTK_SIGNAL_FUNC (list_add),
                          list);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
       button = gtk_button_new_with_label ("Clear List");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (list_clear),
                          list);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
-      hbox = gtk_hbox_new (FALSE, 10);
-      gtk_box_pack_start (GTK_BOX (box2), hbox, FALSE, TRUE, 0);
-
-      button = gtk_button_new_with_label ("Insert Row");
+      button = gtk_button_new_with_label ("Remove Selection");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC (list_add),
+                         GTK_SIGNAL_FUNC (list_remove),
                          list);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+
+      cbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, TRUE, 0);
+
+      hbox = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_box_pack_start (GTK_BOX (cbox), hbox, TRUE, FALSE, 0);
 
       label = gtk_label_new ("Selection Mode :");
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC(list_remove),
-                         list);
       gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
 
-      list_omenu = gtk_option_menu_new ();
-      menu = gtk_menu_new ();
-      group = NULL;
-      
-      menu_item = gtk_radio_menu_item_new_with_label (group, "Single");
-      gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
-                         GTK_SIGNAL_FUNC (list_toggle_sel_mode), list);
-      group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
-      gtk_menu_append (GTK_MENU (menu), menu_item);
-      gtk_widget_show (menu_item);
-      
-      menu_item = gtk_radio_menu_item_new_with_label (group, "Browse");
-      gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
-                         GTK_SIGNAL_FUNC (list_toggle_sel_mode), list);
-      group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
-      gtk_menu_append (GTK_MENU (menu), menu_item);
-      gtk_widget_show (menu_item);
-      
-      menu_item = gtk_radio_menu_item_new_with_label (group, "Multiple");
-      gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
-                      GTK_SIGNAL_FUNC (list_toggle_sel_mode), list);
-      group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
-      gtk_menu_append (GTK_MENU (menu), menu_item);
-      gtk_widget_show (menu_item);
-      
-      menu_item = gtk_radio_menu_item_new_with_label (group, "Extended");
-      gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
-                         GTK_SIGNAL_FUNC (list_toggle_sel_mode), list);
-      group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menu_item));
-      gtk_menu_append (GTK_MENU (menu), menu_item);
-      gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
-      gtk_widget_show (menu_item);
-      
-      gtk_option_menu_set_menu (GTK_OPTION_MENU (list_omenu), menu);
+      list_omenu = build_option_menu (items, 4, 3, list);
       gtk_box_pack_start (GTK_BOX (hbox), list_omenu, FALSE, TRUE, 0);
-      
-      gtk_option_menu_set_history (GTK_OPTION_MENU (list_omenu), 3);
 
       separator = gtk_hseparator_new ();
-      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
-
+      gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
 
-      box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
+      cbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
+      gtk_container_set_border_width (GTK_CONTAINER (button), 10);
+      gtk_box_pack_start (GTK_BOX (cbox), button, TRUE, TRUE, 0);
       gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                                 GTK_SIGNAL_FUNC(gtk_widget_destroy),
                                 GTK_OBJECT (window));
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
       gtk_widget_grab_default (button);
@@ -3508,7 +3753,7 @@ static char * gtk_mini_xpm[] = {
 "     >%$$      ",
 "      >=       "};
 
-#define TESTGTK_CLIST_COLUMNS 20
+#define TESTGTK_CLIST_COLUMNS 12
 static gint clist_rows = 0;
 static GtkWidget *clist_omenu;
 
@@ -3585,190 +3830,87 @@ clear_clist (GtkWidget *widget, gpointer data)
   clist_rows = 0;
 }
 
-void
-remove_row_clist (GtkWidget *widget, gpointer data)
+void clist_remove_selection (GtkWidget *widget, GtkCList *clist)
 {
-  gtk_clist_remove (GTK_CLIST (data), GTK_CLIST (data)->focus_row);
-  clist_rows--;
+  gtk_clist_freeze (clist);
+
+  while (clist->selection)
+    {
+      gint row;
+
+      clist_rows--;
+      row = GPOINTER_TO_INT (clist->selection->data);
+
+      gtk_clist_remove (clist, row);
+
+      if (clist->selection_mode == GTK_SELECTION_BROWSE)
+       break;
+    }
+
+  if (clist->selection_mode == GTK_SELECTION_EXTENDED && !clist->selection &&
+      clist->focus_row >= 0)
+    gtk_clist_select_row (clist, clist->focus_row, -1);
+
+  gtk_clist_thaw (clist);
 }
 
-void
-show_titles_clist (GtkWidget *widget, gpointer data)
+void toggle_title_buttons (GtkWidget *widget, GtkCList *clist)
 {
-  gtk_clist_column_titles_show (GTK_CLIST (data));
+  if (GTK_TOGGLE_BUTTON (widget)->active)
+    gtk_clist_column_titles_show (clist);
+  else
+    gtk_clist_column_titles_hide (clist);
 }
 
-void
-hide_titles_clist (GtkWidget *widget, gpointer data)
+void toggle_reorderable (GtkWidget *widget, GtkCList *clist)
 {
-  gtk_clist_column_titles_hide (GTK_CLIST (data));
+  gtk_clist_set_reorderable (clist, GTK_TOGGLE_BUTTON (widget)->active);
 }
 
-void
-select_clist (GtkWidget *widget,
-             gint row, 
-             gint column, 
-             GdkEventButton * bevent,
-             GtkWidget *button)
+static void
+insert_row_clist (GtkWidget *widget, gpointer data)
 {
-  gint i;
-  guint8 spacing;
-  gchar *text;
-  GdkPixmap *pixmap;
-  GdkBitmap *mask;
-  GList *list;
+  static char *text[] =
+  {
+    "This", "is an", "inserted", "row.",
+    "This", "is an", "inserted", "row.",
+    "This", "is an", "inserted", "row."
+  };
 
-  g_print ("GtkCList Selection: row %d column %d button %d\n", 
-          row, column, bevent ? bevent->button : 0);
+  static GtkStyle *style1 = NULL;
+  static GtkStyle *style2 = NULL;
+  static GtkStyle *style3 = NULL;
+  gint row;
+  
+  if (GTK_CLIST (data)->focus_row >= 0)
+    row = gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row,
+                           text);
+  else
+    row = gtk_clist_prepend (GTK_CLIST (data), text);
 
-  for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
+  if (!style1)
     {
-      switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
-       {
-       case GTK_CELL_TEXT:
-         g_print ("CELL %d GTK_CELL_TEXT\n", i);
-         gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
-         g_print ("TEXT: %s\n", text);
-         break;
+      GdkColor col1;
+      GdkColor col2;
 
-       case GTK_CELL_PIXMAP:
-         g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
-         gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
-         g_print ("PIXMAP: %p\n", pixmap);
-         g_print ("MASK: %p\n", mask);
-         break;
+      col1.red   = 0;
+      col1.green = 56000;
+      col1.blue  = 0;
+      col2.red   = 32000;
+      col2.green = 0;
+      col2.blue  = 56000;
 
-       case GTK_CELL_PIXTEXT:
-         g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
-         gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
-         g_print ("TEXT: %s\n", text);
-         g_print ("SPACING: %d\n", spacing);
-         g_print ("PIXMAP: %p\n", pixmap);
-         g_print ("MASK: %p\n", mask);
-         break;
-
-       default:
-         break;
-       }
-    }
-
-  /* print selections list */
-  g_print ("\nSelected Rows:");
-  list = GTK_CLIST (widget)->selection;
-  while (list)
-    {
-      g_print (" %d ", GPOINTER_TO_INT (list->data));
-      list = list->next;
-    }
-
-  g_print ("\n\n\n");
-}
-
-void
-unselect_clist (GtkWidget *widget,
-               gint row, 
-               gint column, 
-               GdkEventButton * bevent,
-               GtkWidget *button)
-{
-  gint i;
-  guint8 spacing;
-  gchar *text;
-  GdkPixmap *pixmap;
-  GdkBitmap *mask;
-  GList *list;
-
-  g_print ("GtkCList Unselection: row %d column %d button %d\n", 
-          row, column, bevent ? bevent->button : 0);
-
-  for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
-    {
-      switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
-       {
-       case GTK_CELL_TEXT:
-         g_print ("CELL %d GTK_CELL_TEXT\n", i);
-         gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
-         g_print ("TEXT: %s\n", text);
-         break;
-
-       case GTK_CELL_PIXMAP:
-         g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
-         gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
-         g_print ("PIXMAP: %p\n", pixmap);
-         g_print ("MASK: %p\n", mask);
-         break;
-
-       case GTK_CELL_PIXTEXT:
-         g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
-         gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
-         g_print ("TEXT: %s\n", text);
-         g_print ("SPACING: %d\n", spacing);
-         g_print ("PIXMAP: %p\n", pixmap);
-         g_print ("MASK: %p\n", mask);
-         break;
-
-       default:
-         break;
-       }
-    }
-
-  /* print selections list */
-  g_print ("\nSelected Rows:");
-  list = GTK_CLIST (widget)->selection;
-  while (list)
-    {
-      g_print (" %d ", GPOINTER_TO_INT (list->data));
-      list = list->next;
-    }
-
-  g_print ("\n\n\n");
-}
-
-static void
-insert_row_clist (GtkWidget *widget, gpointer data)
-{
-  static char *text[] =
-  {
-    "This", "is", "a", "inserted", "row.",
-    "This", "is", "a", "inserted", "row.",
-    "This", "is", "a", "inserted", "row.",
-    "This", "is", "a", "inserted", "row."
-  };
-
-  static GtkStyle *style1 = NULL;
-  static GtkStyle *style2 = NULL;
-  static GtkStyle *style3 = NULL;
-  gint row;
-  
-  if (GTK_CLIST (data)->focus_row >= 0)
-    row = gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row,
-                           text);
-  else
-    row = gtk_clist_prepend (GTK_CLIST (data), text);
-
-  if (!style1)
-    {
-      GdkColor col1;
-      GdkColor col2;
-
-      col1.red   = 0;
-      col1.green = 56000;
-      col1.blue  = 0;
-      col2.red   = 32000;
-      col2.green = 0;
-      col2.blue  = 56000;
-
-      style1 = gtk_style_copy (GTK_WIDGET (data)->style);
-      style1->bg[GTK_STATE_PRELIGHT] = col1;
-      style1->bg[GTK_STATE_SELECTED] = col2;
+      style1 = gtk_style_copy (GTK_WIDGET (data)->style);
+      style1->base[GTK_STATE_NORMAL] = col1;
+      style1->base[GTK_STATE_SELECTED] = col2;
 
       style2 = gtk_style_copy (GTK_WIDGET (data)->style);
-      style2->fg[GTK_STATE_PRELIGHT] = col1;
+      style2->fg[GTK_STATE_NORMAL] = col1;
       style2->fg[GTK_STATE_SELECTED] = col2;
 
       style3 = gtk_style_copy (GTK_WIDGET (data)->style);
-      style3->fg[GTK_STATE_PRELIGHT] = col1;
-      style3->bg[GTK_STATE_PRELIGHT] = col2;
+      style3->fg[GTK_STATE_NORMAL] = col1;
+      style3->base[GTK_STATE_NORMAL] = col2;
       gdk_font_unref (style3->font);
       style3->font =
        gdk_font_load ("-*-courier-medium-*-*-*-*-120-*-*-*-*-*-*");
@@ -3855,9 +3997,7 @@ create_clist (void)
   {
     "auto resize", "not resizeable", "max width 100", "min width 50",
     "hide column", "Title 5", "Title 6", "Title 7",
-    "Title 8",  "Title 9",  "Title 10", "Title 11", "Title 12",
-    "Title 13", "Title 14", "Title 15", "Title 16", "Title 17",
-    "Title 18", "Title 19"
+    "Title 8",  "Title 9",  "Title 10", "Title 11"
   };
 
   static OptionMenuItem items[] =
@@ -3871,12 +4011,13 @@ create_clist (void)
   char text[TESTGTK_CLIST_COLUMNS][50];
   char *texts[TESTGTK_CLIST_COLUMNS];
 
-  GtkWidget *box1;
-  GtkWidget *box2;
+  GtkWidget *vbox;
+  GtkWidget *hbox;
   GtkWidget *clist;
   GtkWidget *button;
   GtkWidget *separator;
   GtkWidget *scrolled_win;
+  GtkWidget *check;
 
   GtkWidget *undo_button;
   GtkWidget *label;
@@ -3894,124 +4035,101 @@ create_clist (void)
                          GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "clist");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
-
-      box1 = gtk_vbox_new (FALSE, 0);
-      gtk_container_add (GTK_CONTAINER (window), box1);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
-      box2 = gtk_hbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
+      vbox = gtk_vbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
 
-      /* create GtkCList here so we have a pointer to throw at the 
-       * button callbacks -- more is done with it later */
-      clist = gtk_clist_new_with_titles (TESTGTK_CLIST_COLUMNS, titles);
-      gtk_widget_show (clist);
       scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+      gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 5);
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                      GTK_POLICY_AUTOMATIC, 
                                      GTK_POLICY_AUTOMATIC);
-      gtk_container_add (GTK_CONTAINER (scrolled_win), clist);
-      /*clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS);*/
 
+      /* create GtkCList here so we have a pointer to throw at the 
+       * button callbacks -- more is done with it later */
+      clist = gtk_clist_new_with_titles (TESTGTK_CLIST_COLUMNS, titles);
+      gtk_container_add (GTK_CONTAINER (scrolled_win), clist);
       gtk_signal_connect (GTK_OBJECT (clist), "click_column",
                          (GtkSignalFunc) clist_click_column, NULL);
 
       /* control buttons */
-      button = gtk_button_new_with_label ("Add 1,000 Rows With Pixmaps");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      hbox = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
+      button = gtk_button_new_with_label ("Insert Row");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+      gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                          (GtkSignalFunc) insert_row_clist, (gpointer) clist);
+
+      button = gtk_button_new_with_label ("Add 1,000 Rows With Pixmaps");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                           (GtkSignalFunc) add1000_clist, (gpointer) clist);
 
       button = gtk_button_new_with_label ("Add 10,000 Rows");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                           (GtkSignalFunc) add10000_clist, (gpointer) clist);
 
-      button = gtk_button_new_with_label ("Clear List");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                          (GtkSignalFunc) clear_clist, (gpointer) clist);
-
-      button = gtk_button_new_with_label ("Remove Row");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                          (GtkSignalFunc) remove_row_clist, (gpointer) clist);
-
       /* second layer of buttons */
-      box2 = gtk_hbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
-
-      button = gtk_button_new_with_label ("Insert Row");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      hbox = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
+      button = gtk_button_new_with_label ("Clear List");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                          (GtkSignalFunc) insert_row_clist, (gpointer) clist);
-
-      button = gtk_button_new_with_label ("Show Title Buttons");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+                          (GtkSignalFunc) clear_clist, (gpointer) clist);
 
+      button = gtk_button_new_with_label ("Remove Selection");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                          (GtkSignalFunc) show_titles_clist, (gpointer) clist);
-
-      button = gtk_button_new_with_label ("Hide Title Buttons");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+                          (GtkSignalFunc) clist_remove_selection,
+                         (gpointer) clist);
 
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                          (GtkSignalFunc) hide_titles_clist, (gpointer) clist);
+      undo_button = gtk_button_new_with_label ("Undo Selection");
+      gtk_box_pack_start (GTK_BOX (hbox), undo_button, TRUE, TRUE, 0);
+      gtk_signal_connect (GTK_OBJECT (undo_button), "clicked",
+                          (GtkSignalFunc) undo_selection, (gpointer) clist);
 
       button = gtk_button_new_with_label ("Warning Test");
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                           (GtkSignalFunc) clist_warning_test,(gpointer) clist);
 
-      box2 = gtk_hbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
+      /* third layer of buttons */
+      hbox = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
-      undo_button = gtk_button_new_with_label ("Undo last selection");
-      gtk_box_pack_start (GTK_BOX (box2), undo_button, TRUE, TRUE, 0);
-      gtk_signal_connect (GTK_OBJECT (undo_button), "clicked",
-                          (GtkSignalFunc) undo_selection, (gpointer) clist);
+      check = gtk_check_button_new_with_label ("Show Title Buttons");
+      gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
+      gtk_signal_connect (GTK_OBJECT (check), "clicked",
+                         GTK_SIGNAL_FUNC (toggle_title_buttons), clist);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
+
+      check = gtk_check_button_new_with_label ("Reorderable");
+      gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
+      gtk_signal_connect (GTK_OBJECT (check), "clicked",
+                         GTK_SIGNAL_FUNC (toggle_reorderable), clist);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
 
       label = gtk_label_new ("Selection Mode :");
-      gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
 
       clist_omenu = build_option_menu (items, 4, 3, clist);
-      gtk_box_pack_start (GTK_BOX (box2), clist_omenu, FALSE, TRUE, 0);
-
-      /* vbox for the list itself */
-      box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (hbox), clist_omenu, FALSE, TRUE, 0);
 
       /* 
        * the rest of the clist configuration
        */
 
-      /*
-      gtk_signal_connect (GTK_OBJECT (clist), 
-                         "select_row",
-                         (GtkSignalFunc) select_clist, 
-                         undo_button);
-
-      gtk_signal_connect (GTK_OBJECT (clist), 
-                         "unselect_row",
-                         (GtkSignalFunc) unselect_clist, 
-                         undo_button);
-      */
-
+      gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
       gtk_clist_set_row_height (GTK_CLIST (clist), 18);
       gtk_widget_set_usize (clist, -1, 300);
 
-      gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
-
       for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++)
        gtk_clist_set_column_width (GTK_CLIST (clist), i, 80);
 
@@ -4019,9 +4137,7 @@ create_clist (void)
       gtk_clist_set_column_resizeable (GTK_CLIST (clist), 1, FALSE);
       gtk_clist_set_column_max_width (GTK_CLIST (clist), 2, 100);
       gtk_clist_set_column_min_width (GTK_CLIST (clist), 3, 50);
-
       gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_EXTENDED);
-
       gtk_clist_set_column_justification (GTK_CLIST (clist), 1,
                                          GTK_JUSTIFY_RIGHT);
       gtk_clist_set_column_justification (GTK_CLIST (clist), 2,
@@ -4044,8 +4160,8 @@ create_clist (void)
       col2.blue  = 32000;
 
       style = gtk_style_new ();
-      style->fg[GTK_STATE_PRELIGHT] = col1;
-      style->bg[GTK_STATE_PRELIGHT] = col2;
+      style->fg[GTK_STATE_NORMAL] = col1;
+      style->base[GTK_STATE_NORMAL] = col2;
       
       gdk_font_unref (style->font);
       style->font =
@@ -4067,22 +4183,19 @@ create_clist (void)
            }
        }
 
-      gtk_container_border_width (GTK_CONTAINER (scrolled_win), 5);
-      gtk_box_pack_start (GTK_BOX (box2), scrolled_win, TRUE, TRUE, 0);
-
       separator = gtk_hseparator_new ();
-      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
 
-      box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
-      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
 
       button = gtk_button_new_with_label ("close");
+      gtk_container_set_border_width (GTK_CONTAINER (button), 10);
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                                 GTK_SIGNAL_FUNC(gtk_widget_destroy),
                                 GTK_OBJECT (window));
 
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
       GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
       gtk_widget_grab_default (button);
     }
@@ -4128,16 +4241,16 @@ void after_press (GtkCTree *ctree, gpointer data)
   char buf[80];
 
   sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->selection));
-  gtk_label_set (GTK_LABEL (sel_label), buf);
+  gtk_label_set_text (GTK_LABEL (sel_label), buf);
 
   sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->row_list));
-  gtk_label_set (GTK_LABEL (vis_label), buf);
+  gtk_label_set_text (GTK_LABEL (vis_label), buf);
 
   sprintf (buf, "%d", books);
-  gtk_label_set (GTK_LABEL (book_label), buf);
+  gtk_label_set_text (GTK_LABEL (book_label), buf);
 
   sprintf (buf, "%d", pages);
-  gtk_label_set (GTK_LABEL (page_label), buf);
+  gtk_label_set_text (GTK_LABEL (page_label), buf);
 }
 
 void after_move (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent, 
@@ -4160,74 +4273,6 @@ void after_move (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent,
           (parent) ? target1 : "nil", (sibling) ? target2 : "nil");
 }
 
-gint button_press (GtkCTree *ctree, GdkEventButton *event, gpointer data)
-{
-  gint row;
-  gint column;
-  GtkCTreeNode *work;
-  gint res;
-  
-  res = gtk_clist_get_selection_info (GTK_CLIST (ctree), event->x, event->y, 
-                                     &row, &column);
-  if (!res && event->button != 3)
-    return FALSE;
-
-  work = GTK_CTREE_NODE (g_list_nth (GTK_CLIST (ctree)->row_list, row));
-
-  switch (event->button)
-    {
-    case 1:
-      if (GTK_CLIST (ctree)->selection_mode == GTK_SELECTION_MULTIPLE &&
-         event->state & GDK_SHIFT_MASK)
-       gtk_signal_emit_stop_by_name (GTK_OBJECT (ctree),"button_press_event");
-      break;
-    case  2:
-      if (GTK_CTREE_ROW (work)->children && 
-         gtk_ctree_is_hot_spot (ctree, event->x, event->y))
-       {
-         if (GTK_CTREE_ROW (work)->expanded)
-           gtk_ctree_collapse_recursive (ctree, work);
-         else
-           gtk_ctree_expand_recursive (ctree, work);
-         after_press (ctree, NULL);
-         gtk_signal_emit_stop_by_name (GTK_OBJECT (ctree),
-                                       "button_press_event");
-       }
-      break;
-    default:
-      break;
-    }
-  return FALSE;
-}
-
-gint button_release (GtkCTree *ctree, GdkEventButton *event, gpointer data)
-{
-  gint row;
-  gint column;
-  GtkCTreeNode *work;
-  gint res;
-  
-  res = gtk_clist_get_selection_info (GTK_CLIST (ctree), event->x, event->y, 
-                                     &row, &column);
-  if (!res || event->button != 1)
-    return FALSE;
-
-  work = GTK_CTREE_NODE (g_list_nth (GTK_CLIST (ctree)->row_list, row));
-
-  if (GTK_CLIST (ctree)->selection_mode == GTK_SELECTION_MULTIPLE &&
-      event->state & GDK_SHIFT_MASK)
-    {
-      if (GTK_CTREE_ROW (work)->row.state == GTK_STATE_SELECTED) 
-           gtk_ctree_unselect_recursive (ctree, work);
-      else
-       gtk_ctree_select_recursive (ctree, work);
-      after_press (ctree, NULL);
-      gtk_signal_emit_stop_by_name (GTK_OBJECT (ctree), 
-                                   "button_release_event");
-    }
-  return FALSE;
-}
-
 void count_items (GtkCTree *ctree, GtkCTreeNode *list)
 {
   if (GTK_CTREE_ROW (list)->is_leaf)
@@ -4282,13 +4327,13 @@ void change_style (GtkWidget *widget, GtkCTree *ctree)
       col2.blue  = 56000;
 
       style1 = gtk_style_new ();
-      style1->bg[GTK_STATE_PRELIGHT] = col1;
+      style1->base[GTK_STATE_NORMAL] = col1;
       style1->fg[GTK_STATE_SELECTED] = col2;
 
       style2 = gtk_style_new ();
-      style2->bg[GTK_STATE_SELECTED] = col2;
-      style2->fg[GTK_STATE_PRELIGHT] = col1;
-      style2->bg[GTK_STATE_PRELIGHT] = col2;
+      style2->base[GTK_STATE_SELECTED] = col2;
+      style2->fg[GTK_STATE_NORMAL] = col1;
+      style2->base[GTK_STATE_NORMAL] = col2;
       gdk_font_unref (style2->font);
       style2->font =
        gdk_font_load ("-*-courier-medium-*-*-*-*-300-*-*-*-*-*-*");
@@ -4300,7 +4345,6 @@ void change_style (GtkWidget *widget, GtkCTree *ctree)
   if (GTK_CTREE_ROW (node)->children)
     gtk_ctree_node_set_row_style (ctree, GTK_CTREE_ROW (node)->children,
                                  style2);
-  
 }
 
 void unselect_all (GtkWidget *widget, GtkCTree *ctree)
@@ -4311,49 +4355,39 @@ void unselect_all (GtkWidget *widget, GtkCTree *ctree)
 
 void remove_selection (GtkWidget *widget, GtkCTree *ctree)
 {
-  GtkCTreeNode *work;
-  GtkCTreeNode *new_sel;
-  GList *selection;
+  GtkCList *clist;
+  GtkCTreeNode *node;
 
-  selection = GTK_CLIST (ctree)->selection;
-  new_sel = NULL;
+  clist = GTK_CLIST (ctree);
 
-  gtk_clist_freeze (GTK_CLIST (ctree));
+  gtk_clist_freeze (clist);
 
-  while (selection)
+  while (clist->selection)
     {
-      work = selection->data;
-      if (GTK_CTREE_ROW (work)->is_leaf)
+      node = clist->selection->data;
+
+      if (GTK_CTREE_ROW (node)->is_leaf)
        pages--;
       else
-       gtk_ctree_post_recursive (ctree, work, 
+       gtk_ctree_post_recursive (ctree, node,
                                  (GtkCTreeFunc) count_items, NULL);
 
-      if (GTK_CLIST (ctree)->selection_mode == GTK_SELECTION_BROWSE)
-       {
-         if (GTK_CTREE_ROW (work)->children)
-           {
-             new_sel = GTK_CTREE_ROW (work)->sibling;
-             if (!new_sel)
-               new_sel = GTK_CTREE_NODE_NEXT (work);
-           }
-         else
-           {
-             if (GTK_CTREE_NODE_NEXT (work))
-               new_sel = GTK_CTREE_NODE_NEXT (work);
-             else
-               new_sel = GTK_CTREE_NODE_PREV (work);
-           }
-       }
+      gtk_ctree_remove_node (ctree, node);
 
-      gtk_ctree_remove_node (ctree, work);
-      selection = GTK_CLIST (ctree)->selection;
+      if (clist->selection_mode == GTK_SELECTION_BROWSE)
+       break;
     }
 
-  if (new_sel)
-    gtk_ctree_select (ctree, new_sel);
+  if (clist->selection_mode == GTK_SELECTION_EXTENDED && !clist->selection &&
+      clist->focus_row >= 0)
+    {
+      node = gtk_ctree_node_nth (ctree, clist->focus_row);
 
-  gtk_clist_thaw (GTK_CLIST (ctree));
+      if (node)
+       gtk_ctree_select (ctree, node);
+    }
+    
+  gtk_clist_thaw (clist);
   after_press (ctree, NULL);
 }
 
@@ -4447,7 +4481,7 @@ void export_ctree (GtkWidget *widget, GtkCTree *ctree)
                          &export_window);
 
       gtk_window_set_title (GTK_WINDOW (export_window), "exported ctree");
-      gtk_container_border_width (GTK_CONTAINER (export_window), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (export_window), 5);
 
       vbox = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (export_window), vbox);
@@ -4514,11 +4548,6 @@ void change_row_height (GtkWidget *widget, GtkCList *clist)
   gtk_clist_set_row_height (clist, GTK_ADJUSTMENT (widget)->value);
 }
 
-void toggle_reorderable (GtkWidget *widget, GtkCTree *ctree)
-{
-  gtk_ctree_set_reorderable (ctree, GTK_TOGGLE_BUTTON (widget)->active);
-}
-
 void set_background (GtkCTree *ctree, GtkCTreeNode *node, gpointer data)
 {
   GtkStyle *style = NULL;
@@ -4638,23 +4667,23 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
                                       pixmap1, mask1, pixmap2, mask2,
                                       FALSE, FALSE);
 
-      style = gtk_style_new();
+      style = gtk_style_new ();
       switch (cur_depth % 3)
        {
        case 0:
-         style->bg[GTK_STATE_PRELIGHT].red   = 10000 * (cur_depth % 6);
-         style->bg[GTK_STATE_PRELIGHT].green = 0;
-         style->bg[GTK_STATE_PRELIGHT].blue  = 65535 - ((i * 10000) % 65535);
+         style->base[GTK_STATE_NORMAL].red   = 10000 * (cur_depth % 6);
+         style->base[GTK_STATE_NORMAL].green = 0;
+         style->base[GTK_STATE_NORMAL].blue  = 65535 - ((i * 10000) % 65535);
          break;
        case 1:
-         style->bg[GTK_STATE_PRELIGHT].red   = 10000 * (cur_depth % 6);
-         style->bg[GTK_STATE_PRELIGHT].green = 65535 - ((i * 10000) % 65535);
-         style->bg[GTK_STATE_PRELIGHT].blue  = 0;
+         style->base[GTK_STATE_NORMAL].red   = 10000 * (cur_depth % 6);
+         style->base[GTK_STATE_NORMAL].green = 65535 - ((i * 10000) % 65535);
+         style->base[GTK_STATE_NORMAL].blue  = 0;
          break;
        default:
-         style->bg[GTK_STATE_PRELIGHT].red   = 65535 - ((i * 10000) % 65535);
-         style->bg[GTK_STATE_PRELIGHT].green = 0;
-         style->bg[GTK_STATE_PRELIGHT].blue  = 10000 * (cur_depth % 6);
+         style->base[GTK_STATE_NORMAL].red   = 65535 - ((i * 10000) % 65535);
+         style->base[GTK_STATE_NORMAL].green = 0;
+         style->base[GTK_STATE_NORMAL].blue  = 10000 * (cur_depth % 6);
          break;
        }
       gtk_ctree_node_set_row_data_full (ctree, sibling, style,
@@ -4702,9 +4731,9 @@ void rebuild_tree (GtkWidget *widget, GtkCTree *ctree)
                                  mask1, pixmap2, mask2, FALSE, TRUE);
 
   style = gtk_style_new ();
-  style->bg[GTK_STATE_PRELIGHT].red   = 0;
-  style->bg[GTK_STATE_PRELIGHT].green = 45000;
-  style->bg[GTK_STATE_PRELIGHT].blue  = 55000;
+  style->base[GTK_STATE_NORMAL].red   = 0;
+  style->base[GTK_STATE_NORMAL].green = 45000;
+  style->base[GTK_STATE_NORMAL].blue  = 55000;
   gtk_ctree_node_set_row_data_full (ctree, parent, style,
                                    (GtkDestroyNotify) gtk_style_unref);
 
@@ -4753,7 +4782,7 @@ void create_ctree (void)
   GtkWidget *check;
   GtkAdjustment *adj;
   GtkWidget *spinner;
-  GdkColor transparent;
+  GdkColor transparent = { 0 };
 
   char *title[] = { "Tree" , "Info" };
   char buf[80];
@@ -4797,7 +4826,7 @@ void create_ctree (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "GtkCTree");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       tooltips = gtk_tooltips_new ();
       gtk_object_ref (GTK_OBJECT (tooltips));
@@ -4810,7 +4839,7 @@ void create_ctree (void)
       gtk_container_add (GTK_CONTAINER (window), vbox);
 
       hbox = gtk_hbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
       
       label = gtk_label_new ("Depth :");
@@ -4841,26 +4870,32 @@ void create_ctree (void)
                                 (GtkSignalFunc) gtk_widget_destroy,
                                 GTK_OBJECT(window));
 
-      button = gtk_button_new_with_label ("Rebuild tree");
+      button = gtk_button_new_with_label ("Rebuild Tree");
       gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
+      scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+      gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 5);
+      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                     GTK_POLICY_AUTOMATIC,
+                                     GTK_POLICY_ALWAYS);
+      gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
+
       ctree = GTK_CTREE (gtk_ctree_new_with_titles (2, 0, title));
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC (rebuild_tree), ctree);
-      
+      gtk_container_add (GTK_CONTAINER (scrolled_win), GTK_WIDGET (ctree));
+
+      gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE);
+      gtk_clist_set_column_width (GTK_CLIST (ctree), 1, 200);
+      gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_EXTENDED);
       gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
       line_style = GTK_CTREE_LINES_DOTTED;
 
-      gtk_ctree_set_reorderable (ctree, TRUE);
+      gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                         GTK_SIGNAL_FUNC (rebuild_tree), ctree);
       gtk_signal_connect (GTK_OBJECT (ctree), "click_column",
-                         (GtkSignalFunc) ctree_click_column,
-                         NULL);
-      gtk_signal_connect (GTK_OBJECT (ctree), "button_press_event",
-                         GTK_SIGNAL_FUNC (button_press), NULL);
+                         (GtkSignalFunc) ctree_click_column, NULL);
+
       gtk_signal_connect_after (GTK_OBJECT (ctree), "button_press_event",
                                GTK_SIGNAL_FUNC (after_press), NULL);
-      gtk_signal_connect (GTK_OBJECT (ctree), "button_release_event",
-                         GTK_SIGNAL_FUNC (button_release), NULL);
       gtk_signal_connect_after (GTK_OBJECT (ctree), "button_release_event",
                                GTK_SIGNAL_FUNC (after_press), NULL);
       gtk_signal_connect_after (GTK_OBJECT (ctree), "tree_move",
@@ -4875,26 +4910,15 @@ void create_ctree (void)
                                GTK_SIGNAL_FUNC (after_press), NULL);
       gtk_signal_connect_after (GTK_OBJECT (ctree), "scroll_vertical",
                                GTK_SIGNAL_FUNC (after_press), NULL);
-      
-      scrolled_win = gtk_scrolled_window_new (NULL, NULL);
-      gtk_container_add (GTK_CONTAINER (scrolled_win), GTK_WIDGET (ctree));
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
-                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-      gtk_container_border_width (GTK_CONTAINER (scrolled_win), 5);
-      gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
-      gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_EXTENDED);
-      gtk_clist_set_column_min_width (GTK_CLIST (ctree), 0, 50);
-      gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE);
-      gtk_clist_set_column_width (GTK_CLIST (ctree), 1, 200);
 
       bbox = gtk_hbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (bbox), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
       gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0);
 
       mbox = gtk_vbox_new (TRUE, 5);
       gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
 
-      label = gtk_label_new ("Row height :");
+      label = gtk_label_new ("Row Height :");
       gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
 
       label = gtk_label_new ("Indent :");
@@ -4908,26 +4932,26 @@ void create_ctree (void)
 
       adj = (GtkAdjustment *) gtk_adjustment_new (20, 12, 100, 1, 10, 0);
       spinner = gtk_spin_button_new (adj, 0, 0);
+      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
       gtk_tooltips_set_tip (tooltips, spinner,
                            "Row height of list items", NULL);
       gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
                          GTK_SIGNAL_FUNC (change_row_height), ctree);
-      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
       gtk_clist_set_row_height ( GTK_CLIST (ctree), adj->value);
 
       adj = (GtkAdjustment *) gtk_adjustment_new (20, 0, 60, 1, 10, 0);
       spinner = gtk_spin_button_new (adj, 0, 0);
-      gtk_tooltips_set_tip (tooltips, spinner, "Tree indentation.", NULL);
+      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+      gtk_tooltips_set_tip (tooltips, spinner, "Tree Indentation.", NULL);
       gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
                          GTK_SIGNAL_FUNC (change_indent), ctree);
-      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
 
       adj = (GtkAdjustment *) gtk_adjustment_new (5, 0, 60, 1, 10, 0);
       spinner = gtk_spin_button_new (adj, 0, 0);
-      gtk_tooltips_set_tip (tooltips, spinner, "Tree spacing.", NULL);
+      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+      gtk_tooltips_set_tip (tooltips, spinner, "Tree Spacing.", NULL);
       gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
                          GTK_SIGNAL_FUNC (change_spacing), ctree);
-      gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
 
       mbox = gtk_vbox_new (TRUE, 5);
       gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
@@ -4935,150 +4959,150 @@ void create_ctree (void)
       hbox = gtk_hbox_new (FALSE, 5);
       gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
 
-      button = gtk_button_new_with_label ("Expand all");
+      button = gtk_button_new_with_label ("Expand All");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (expand_all), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Collapse all");
+      button = gtk_button_new_with_label ("Collapse All");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (collapse_all), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
       button = gtk_button_new_with_label ("Change Style");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (change_style), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Export tree");
+      button = gtk_button_new_with_label ("Export Tree");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (export_ctree), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
       hbox = gtk_hbox_new (FALSE, 5);
       gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
 
-      button = gtk_button_new_with_label ("Select all");
+      button = gtk_button_new_with_label ("Select All");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (select_all), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Unselect all");
+      button = gtk_button_new_with_label ("Unselect All");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (unselect_all), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
-      button = gtk_button_new_with_label ("Remove selection");
+      button = gtk_button_new_with_label ("Remove Selection");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
                          GTK_SIGNAL_FUNC (remove_selection), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
       check = gtk_check_button_new_with_label ("Reorderable");
+      gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
       gtk_tooltips_set_tip (tooltips, check,
                            "Tree items can be reordered by dragging.", NULL);
       gtk_signal_connect (GTK_OBJECT (check), "clicked",
                          GTK_SIGNAL_FUNC (toggle_reorderable), ctree);
-      gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
-      gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (check), TRUE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
 
       hbox = gtk_hbox_new (TRUE, 5);
       gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
-      
+
       omenu1 = build_option_menu (items1, 4, 2, ctree);
-      gtk_tooltips_set_tip (tooltips, omenu1, "The tree's line style.", NULL);
       gtk_box_pack_start (GTK_BOX (hbox), omenu1, FALSE, TRUE, 0);
-      
+      gtk_tooltips_set_tip (tooltips, omenu1, "The tree's line style.", NULL);
+
       omenu2 = build_option_menu (items2, 4, 1, ctree);
+      gtk_box_pack_start (GTK_BOX (hbox), omenu2, FALSE, TRUE, 0);
       gtk_tooltips_set_tip (tooltips, omenu2, "The tree's expander style.",
                            NULL);
-      gtk_box_pack_start (GTK_BOX (hbox), omenu2, FALSE, TRUE, 0);
 
       omenu3 = build_option_menu (items3, 2, 0, ctree);
+      gtk_box_pack_start (GTK_BOX (hbox), omenu3, FALSE, TRUE, 0);
       gtk_tooltips_set_tip (tooltips, omenu3, "The tree's justification.",
                            NULL);
-      gtk_box_pack_start (GTK_BOX (hbox), omenu3, FALSE, TRUE, 0);
-      
+
       omenu4 = build_option_menu (items4, 4, 3, ctree);
+      gtk_box_pack_start (GTK_BOX (hbox), omenu4, FALSE, TRUE, 0);
       gtk_tooltips_set_tip (tooltips, omenu4, "The list's selection mode.",
                            NULL);
-      gtk_box_pack_start (GTK_BOX (hbox), omenu4, FALSE, TRUE, 0);
-      
+
       gtk_widget_realize (window);
-      
+
       pixmap1 = gdk_pixmap_create_from_xpm_d (window->window, &mask1, 
                                              &transparent, book_closed_xpm);
       pixmap2 = gdk_pixmap_create_from_xpm_d (window->window, &mask2, 
                                              &transparent, book_open_xpm);
       pixmap3 = gdk_pixmap_create_from_xpm_d (window->window, &mask3,
                                              &transparent, mini_page_xpm);
-      
+
       gtk_widget_set_usize (GTK_WIDGET (ctree), 0, 300);
-      
+
       frame = gtk_frame_new (NULL);
-      gtk_container_border_width (GTK_CONTAINER (frame), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (frame), 0);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
       gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
-      
+
       hbox = gtk_hbox_new (TRUE, 2);
-      gtk_container_border_width (GTK_CONTAINER (hbox), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
       gtk_container_add (GTK_CONTAINER (frame), hbox);
-      
+
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
       gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
-      
+
       hbox2 = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox2), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox2), 2);
       gtk_container_add (GTK_CONTAINER (frame), hbox2);
-      
+
       label = gtk_label_new ("Books :");
       gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-      
+
       sprintf (buf, "%d", books);
       book_label = gtk_label_new (buf);
       gtk_box_pack_end (GTK_BOX (hbox2), book_label, FALSE, TRUE, 5);
-      
+
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
       gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
-      
+
       hbox2 = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox2), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox2), 2);
       gtk_container_add (GTK_CONTAINER (frame), hbox2);
-      
+
       label = gtk_label_new ("Pages :");
       gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-      
+
       sprintf (buf, "%d", pages);
       page_label = gtk_label_new (buf);
       gtk_box_pack_end (GTK_BOX (hbox2), page_label, FALSE, TRUE, 5);
-      
+
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
       gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
-      
+
       hbox2 = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox2), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox2), 2);
       gtk_container_add (GTK_CONTAINER (frame), hbox2);
-      
+
       label = gtk_label_new ("Selected :");
       gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-      
+
       sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->selection));
       sel_label = gtk_label_new (buf);
       gtk_box_pack_end (GTK_BOX (hbox2), sel_label, FALSE, TRUE, 5);
-      
+
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
       gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
-      
+
       hbox2 = gtk_hbox_new (FALSE, 0);
-      gtk_container_border_width (GTK_CONTAINER (hbox2), 2);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox2), 2);
       gtk_container_add (GTK_CONTAINER (frame), hbox2);
-      
+
       label = gtk_label_new ("Visible :");
       gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-      
+
       sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->row_list));
       vis_label = gtk_label_new (buf);
       gtk_box_pack_end (GTK_BOX (hbox2), vis_label, FALSE, TRUE, 5);
@@ -5137,7 +5161,7 @@ create_color_selection (void)
         GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
        GTK_UPDATE_CONTINUOUS);
 
-      gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
+      gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
 
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
                           GTK_SIGNAL_FUNC(gtk_widget_destroyed),
@@ -5199,7 +5223,7 @@ create_file_selection (void)
 
       gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (window));
 
-      gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
+      gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
 
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
                          GTK_SIGNAL_FUNC(gtk_widget_destroyed),
@@ -5243,7 +5267,10 @@ void
 font_selection_ok (GtkWidget              *w,
                   GtkFontSelectionDialog *fs)
 {
-  g_print ("%s\n", gtk_font_selection_dialog_get_font_name (fs));
+  gchar *s = gtk_font_selection_dialog_get_font_name (fs);
+
+  g_print ("%s\n", s);
+  g_free (s);
   gtk_widget_destroy (GTK_WIDGET (fs));
 }
 
@@ -5256,7 +5283,7 @@ create_font_selection (void)
     {
       window = gtk_font_selection_dialog_new ("Font Selection Dialog");
 
-      gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
+      gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
 
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
                          GTK_SIGNAL_FUNC(gtk_widget_destroyed),
@@ -5282,7 +5309,7 @@ create_font_selection (void)
 
 static GtkWidget *dialog_window = NULL;
 
-void
+static void
 label_toggle (GtkWidget  *widget,
              GtkWidget **label)
 {
@@ -5299,13 +5326,106 @@ label_toggle (GtkWidget  *widget,
       gtk_widget_show (*label);
     }
   else
-    gtk_widget_destroy (*label);
+    gtk_widget_destroy (*label);
+}
+
+static void
+create_dialog (void)
+{
+  static GtkWidget *label;
+  GtkWidget *button;
+
+  if (!dialog_window)
+    {
+      dialog_window = gtk_dialog_new ();
+
+      gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
+                         GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                         &dialog_window);
+
+      gtk_window_set_title (GTK_WINDOW (dialog_window), "GtkDialog");
+      gtk_container_set_border_width (GTK_CONTAINER (dialog_window), 0);
+      gtk_widget_set_usize (dialog_window, 200, 110);
+
+      button = gtk_button_new_with_label ("OK");
+      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area), 
+                         button, TRUE, TRUE, 0);
+      gtk_widget_grab_default (button);
+      gtk_widget_show (button);
+
+      button = gtk_button_new_with_label ("Toggle");
+      gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                         GTK_SIGNAL_FUNC (label_toggle),
+                         &label);
+      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area),
+                         button, TRUE, TRUE, 0);
+      gtk_widget_show (button);
+
+      label = NULL;
+    }
+
+  if (!GTK_WIDGET_VISIBLE (dialog_window))
+    gtk_widget_show (dialog_window);
+  else
+    gtk_widget_destroy (dialog_window);
+}
+
+/* Event Watcher
+ */
+static gboolean event_watcher_enter_id = 0;
+static gboolean event_watcher_leave_id = 0;
+
+static gboolean
+event_watcher (GtkObject      *object,
+              guint           signal_id,
+              guint           n_params,
+              GtkArg         *params,
+              gpointer        data)
+{
+  g_print ("Watch: \"%s\" emitted for %s\n",
+          gtk_signal_name (signal_id),
+          gtk_type_name (GTK_OBJECT_TYPE (object)));
+
+  return TRUE;
+}
+
+static void
+event_watcher_down (void)
+{
+  if (event_watcher_enter_id)
+    {
+      guint signal_id;
+
+      signal_id = gtk_signal_lookup ("enter_notify_event", GTK_TYPE_WIDGET);
+      gtk_signal_remove_emission_hook (signal_id, event_watcher_enter_id);
+      event_watcher_enter_id = 0;
+      signal_id = gtk_signal_lookup ("leave_notify_event", GTK_TYPE_WIDGET);
+      gtk_signal_remove_emission_hook (signal_id, event_watcher_leave_id);
+      event_watcher_leave_id = 0;
+    }
+}
+
+static void
+event_watcher_toggle (void)
+{
+  if (event_watcher_enter_id)
+    event_watcher_down ();
+  else
+    {
+      guint signal_id;
+
+      signal_id = gtk_signal_lookup ("enter_notify_event", GTK_TYPE_WIDGET);
+      event_watcher_enter_id = gtk_signal_add_emission_hook (signal_id, event_watcher, NULL);
+      signal_id = gtk_signal_lookup ("leave_notify_event", GTK_TYPE_WIDGET);
+      event_watcher_leave_id = gtk_signal_add_emission_hook (signal_id, event_watcher, NULL);
+    }
 }
 
-void
-create_dialog (void)
+static void
+create_event_watcher (void)
 {
-  static GtkWidget *label;
   GtkWidget *button;
 
   if (!dialog_window)
@@ -5313,30 +5433,35 @@ create_dialog (void)
       dialog_window = gtk_dialog_new ();
 
       gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
-                         GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                         GTK_SIGNAL_FUNC (gtk_widget_destroyed),
                          &dialog_window);
+      gtk_signal_connect (GTK_OBJECT (dialog_window),
+                         "destroy",
+                         GTK_SIGNAL_FUNC (event_watcher_down),
+                         NULL);
 
-      gtk_window_set_title (GTK_WINDOW (dialog_window), "GtkDialog");
-      gtk_container_border_width (GTK_CONTAINER (dialog_window), 0);
+      gtk_window_set_title (GTK_WINDOW (dialog_window), "Event Watcher");
+      gtk_container_set_border_width (GTK_CONTAINER (dialog_window), 0);
       gtk_widget_set_usize (dialog_window, 200, 110);
 
-      button = gtk_button_new_with_label ("OK");
-      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area), 
+      button = gtk_toggle_button_new_with_label ("Activate Watch");
+      gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                         GTK_SIGNAL_FUNC (event_watcher_toggle),
+                         NULL);
+      gtk_container_set_border_width (GTK_CONTAINER (button), 10);
+      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->vbox), 
                          button, TRUE, TRUE, 0);
-      gtk_widget_grab_default (button);
       gtk_widget_show (button);
 
-      button = gtk_button_new_with_label ("Toggle");
-      gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC (label_toggle),
-                         &label);
+      button = gtk_button_new_with_label ("Close");
+      gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                                GTK_SIGNAL_FUNC (gtk_widget_destroy),
+                                (GtkObject*) dialog_window);
       GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area),
                          button, TRUE, TRUE, 0);
+      gtk_widget_grab_default (button);
       gtk_widget_show (button);
-
-      label = NULL;
     }
 
   if (!GTK_WIDGET_VISIBLE (dialog_window))
@@ -5349,7 +5474,7 @@ create_dialog (void)
  * GtkRange
  */
 
-void
+static void
 create_range_controls (void)
 {
   static GtkWidget *window = NULL;
@@ -5370,7 +5495,7 @@ create_range_controls (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "range controls");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
 
       box1 = gtk_vbox_new (FALSE, 0);
@@ -5379,7 +5504,7 @@ create_range_controls (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -5407,7 +5532,7 @@ create_range_controls (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -5453,7 +5578,7 @@ create_rulers (void)
       gtk_widget_set_events (window, 
                             GDK_POINTER_MOTION_MASK 
                             | GDK_POINTER_MOTION_HINT_MASK);
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       table = gtk_table_new (2, 2, FALSE);
       gtk_container_add (GTK_CONTAINER (window), table);
@@ -5555,9 +5680,7 @@ create_text (void)
   GtkWidget *button;
   GtkWidget *check;
   GtkWidget *separator;
-  GtkWidget *table;
-  GtkWidget *hscrollbar;
-  GtkWidget *vscrollbar;
+  GtkWidget *scrolled_window;
   GtkWidget *text;
   GdkFont *font;
 
@@ -5575,7 +5698,7 @@ create_text (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "test");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
 
       box1 = gtk_vbox_new (FALSE, 0);
@@ -5584,34 +5707,24 @@ create_text (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
       gtk_widget_show (box2);
 
 
-      table = gtk_table_new (2, 2, FALSE);
-      gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
-      gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
-      gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0);
-      gtk_widget_show (table);
+      scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+      gtk_box_pack_start (GTK_BOX (box2), scrolled_window, TRUE, TRUE, 0);
+      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                     GTK_POLICY_NEVER,
+                                     GTK_POLICY_ALWAYS);
+      gtk_widget_show (scrolled_window);
 
       text = gtk_text_new (NULL, NULL);
       gtk_text_set_editable (GTK_TEXT (text), TRUE);
-      gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
-                       GTK_EXPAND | GTK_SHRINK | GTK_FILL,
-                       GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
+      gtk_container_add (GTK_CONTAINER (scrolled_window), text);
       gtk_widget_grab_focus (text);
       gtk_widget_show (text);
 
-      hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj);
-      gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 1, 2,
-                       GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
-      gtk_widget_show (hscrollbar);
-
-      vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
-      gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
-                       GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
-      gtk_widget_show (vscrollbar);
 
       gtk_text_freeze (GTK_TEXT (text));
 
@@ -5641,19 +5754,29 @@ create_text (void)
       
       if (infile)
        {
-         char buffer[1024];
-         int nchars;
+         char *buffer;
+         int nbytes_read, nbytes_alloc;
          
+         nbytes_read = 0;
+         nbytes_alloc = 1024;
+         buffer = g_new (char, nbytes_alloc);
          while (1)
            {
-             nchars = fread(buffer, 1, 1024, infile);
-             gtk_text_insert (GTK_TEXT (text), NULL, NULL,
-                              NULL, buffer, nchars);
-             
-             if (nchars < 1024)
+             int len;
+             if (nbytes_alloc < nbytes_read + 1024)
+               {
+                 nbytes_alloc *= 2;
+                 buffer = g_realloc (buffer, nbytes_alloc);
+               }
+             len = fread (buffer + nbytes_read, 1, 1024, infile);
+             nbytes_read += len;
+             if (len < 1024)
                break;
            }
          
+         gtk_text_insert (GTK_TEXT (text), NULL, NULL,
+                          NULL, buffer, nbytes_read);
+         g_free(buffer);
          fclose (infile);
        }
       
@@ -5667,14 +5790,14 @@ create_text (void)
       gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0);
       gtk_signal_connect (GTK_OBJECT(check), "toggled",
                          GTK_SIGNAL_FUNC(text_toggle_editable), text);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(check), TRUE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
       gtk_widget_show (check);
 
       check = gtk_check_button_new_with_label("Wrap Words");
       gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
       gtk_signal_connect (GTK_OBJECT(check), "toggled",
                          GTK_SIGNAL_FUNC(text_toggle_word_wrap), text);
-      gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(check), FALSE);
+      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE);
       gtk_widget_show (check);
 
       separator = gtk_hseparator_new ();
@@ -5683,7 +5806,7 @@ create_text (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -5719,6 +5842,7 @@ GdkPixmap *book_open;
 GdkPixmap *book_closed;
 GdkBitmap *book_open_mask;
 GdkBitmap *book_closed_mask;
+GtkWidget *sample_notebook;
 
 static void
 page_switch (GtkWidget *widget, GtkNotebookPage *page, gint page_num)
@@ -5730,33 +5854,71 @@ page_switch (GtkWidget *widget, GtkNotebookPage *page, gint page_num)
 
   if (page == oldpage)
     return;
-
-  pixwid = ((GtkBoxChild*)(GTK_BOX (page->tab_label)->children->data))->widget;
+  pixwid = ((GtkBoxChild*)
+           (GTK_BOX (page->tab_label)->children->data))->widget;
   gtk_pixmap_set (GTK_PIXMAP (pixwid), book_open, book_open_mask);
-  pixwid = ((GtkBoxChild*) (GTK_BOX (page->menu_label)->children->data))->widget;
+  pixwid = ((GtkBoxChild*)
+           (GTK_BOX (page->menu_label)->children->data))->widget;
   gtk_pixmap_set (GTK_PIXMAP (pixwid), book_open, book_open_mask);
 
   if (oldpage)
     {
-      pixwid = ((GtkBoxChild*) (GTK_BOX 
-                               (oldpage->tab_label)->children->data))->widget;
+      pixwid = ((GtkBoxChild*)
+               (GTK_BOX (oldpage->tab_label)->children->data))->widget;
       gtk_pixmap_set (GTK_PIXMAP (pixwid), book_closed, book_closed_mask);
-      pixwid = ((GtkBoxChild*) (GTK_BOX (oldpage->menu_label)->children->data))->widget;
+      pixwid = ((GtkBoxChild*)
+               (GTK_BOX (oldpage->menu_label)->children->data))->widget;
       gtk_pixmap_set (GTK_PIXMAP (pixwid), book_closed, book_closed_mask);
     }
 }
 
+static void
+tab_fill (GtkToggleButton *button, GtkWidget *child)
+{
+  gboolean expand;
+  GtkPackType pack_type;
+
+  gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                       &expand, NULL, &pack_type);
+  gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                     expand, button->active, pack_type);
+}
+
+static void
+tab_expand (GtkToggleButton *button, GtkWidget *child)
+{
+  gboolean fill;
+  GtkPackType pack_type;
+
+  gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                       NULL, &fill, &pack_type);
+  gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                     button->active, fill, pack_type);
+}
+
+static void
+tab_pack (GtkToggleButton *button, GtkWidget *child)
+         
+{ 
+  gboolean expand;
+  gboolean fill;
+
+  gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                       &expand, &fill, NULL);
+  gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (sample_notebook), child,
+                                     expand, fill, button->active);
+}
+
 static void
 create_pages (GtkNotebook *notebook, gint start, gint end)
 {
   GtkWidget *child = NULL;
+  GtkWidget *button;
   GtkWidget *label;
-  GtkWidget *entry;
-  GtkWidget *box;
   GtkWidget *hbox;
+  GtkWidget *vbox;
   GtkWidget *label_box;
   GtkWidget *menu_box;
-  GtkWidget *button;
   GtkWidget *pixwid;
   gint i;
   char buffer[32];
@@ -5764,47 +5926,38 @@ create_pages (GtkNotebook *notebook, gint start, gint end)
   for (i = start; i <= end; i++)
     {
       sprintf (buffer, "Page %d", i);
-     
-      switch (i % 4)
-       {
-       case 3:
-         child = gtk_button_new_with_label (buffer);
-         gtk_container_border_width (GTK_CONTAINER(child), 10);
-         break;
-       case 2:
-         child = gtk_label_new (buffer);
-         break;
-       case 1:
-         child = gtk_frame_new (buffer);
-         gtk_container_border_width (GTK_CONTAINER (child), 10);
-      
-         box = gtk_vbox_new (TRUE,0);
-         gtk_container_border_width (GTK_CONTAINER (box), 10);
-         gtk_container_add (GTK_CONTAINER (child), box);
 
-         label = gtk_label_new (buffer);
-         gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 5);
+      child = gtk_frame_new (buffer);
+      gtk_container_set_border_width (GTK_CONTAINER (child), 10);
 
-         entry = gtk_entry_new ();
-         gtk_box_pack_start (GTK_BOX(box), entry, TRUE, TRUE, 5);
-      
-         hbox = gtk_hbox_new (TRUE,0);
-         gtk_box_pack_start (GTK_BOX(box), hbox, TRUE, TRUE, 5);
+      vbox = gtk_vbox_new (TRUE,0);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
+      gtk_container_add (GTK_CONTAINER (child), vbox);
 
-         button = gtk_button_new_with_label ("Ok");
-         gtk_box_pack_start (GTK_BOX(hbox), button, TRUE, TRUE, 5);
+      hbox = gtk_hbox_new (TRUE,0);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
 
-         button = gtk_button_new_with_label ("Cancel");
-         gtk_box_pack_start (GTK_BOX(hbox), button, TRUE, TRUE, 5);
-         break;
-       case 0:
-         child = gtk_frame_new (buffer);
-         gtk_container_border_width (GTK_CONTAINER (child), 10);
+      button = gtk_check_button_new_with_label ("Fill Tab");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_signal_connect (GTK_OBJECT (button), "toggled",
+                         GTK_SIGNAL_FUNC (tab_fill), child);
 
-         label = gtk_label_new (buffer);
-         gtk_container_add (GTK_CONTAINER (child), label);
-         break;
-       }
+      button = gtk_check_button_new_with_label ("Expand Tab");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+      gtk_signal_connect (GTK_OBJECT (button), "toggled",
+      GTK_SIGNAL_FUNC (tab_expand), child);
+
+      button = gtk_check_button_new_with_label ("Pack end");
+      gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+      gtk_signal_connect (GTK_OBJECT (button), "toggled",
+                         GTK_SIGNAL_FUNC (tab_pack), child);
+
+      button = gtk_button_new_with_label ("Hide Page");
+      gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 5);
+      gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                                GTK_SIGNAL_FUNC (gtk_widget_hide),
+                                GTK_OBJECT (child));
 
       gtk_widget_show_all (child);
 
@@ -5815,7 +5968,7 @@ create_pages (GtkNotebook *notebook, gint start, gint end)
       label = gtk_label_new (buffer);
       gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, TRUE, 0);
       gtk_widget_show_all (label_box);
-      
+
       menu_box = gtk_hbox_new (FALSE, 0);
       pixwid = gtk_pixmap_new (book_closed, book_closed_mask);
       gtk_box_pack_start (GTK_BOX (menu_box), pixwid, FALSE, TRUE, 0);
@@ -5823,7 +5976,6 @@ create_pages (GtkNotebook *notebook, gint start, gint end)
       label = gtk_label_new (buffer);
       gtk_box_pack_start (GTK_BOX (menu_box), label, FALSE, TRUE, 0);
       gtk_widget_show_all (menu_box);
-
       gtk_notebook_append_page_menu (notebook, child, label_box, menu_box);
     }
 }
@@ -5835,9 +5987,17 @@ rotate_notebook (GtkButton   *button,
   gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos + 1) % 4);
 }
 
+static void
+show_all_pages (GtkButton   *button,
+               GtkNotebook *notebook)
+{  
+  gtk_container_foreach (GTK_CONTAINER (notebook),
+                        (GtkCallback) gtk_widget_show, NULL);
+}
+
 static void
 standard_notebook (GtkButton   *button,
-                  GtkNotebook *notebook)
+                   GtkNotebook *notebook)
 {
   gint i;
 
@@ -5850,7 +6010,7 @@ standard_notebook (GtkButton   *button,
 
 static void
 notabs_notebook (GtkButton   *button,
-                GtkNotebook *notebook)
+                 GtkNotebook *notebook)
 {
   gint i;
 
@@ -5862,7 +6022,7 @@ notabs_notebook (GtkButton   *button,
 
 static void
 scrollable_notebook (GtkButton   *button,
-                    GtkNotebook *notebook)
+                     GtkNotebook *notebook)
 {
   gtk_notebook_set_show_tabs (notebook, TRUE);
   gtk_notebook_set_scrollable (notebook, TRUE);
@@ -5880,6 +6040,13 @@ notebook_popup (GtkToggleButton *button,
     gtk_notebook_popup_disable (notebook);
 }
 
+static void
+notebook_homogeneous (GtkToggleButton *button,
+                     GtkNotebook     *notebook)
+{
+  gtk_notebook_set_homogeneous_tabs (notebook, button->active);
+}
+
 static void
 create_notebook (void)
 {
@@ -5888,9 +6055,9 @@ create_notebook (void)
   GtkWidget *box2;
   GtkWidget *button;
   GtkWidget *separator;
-  GtkWidget *notebook;
   GtkWidget *omenu;
   GdkColor *transparent = NULL;
+  GtkWidget *label;
 
   static OptionMenuItem items[] =
   {
@@ -5908,77 +6075,96 @@ create_notebook (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "notebook");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
 
-      notebook = gtk_notebook_new ();
-      gtk_signal_connect (GTK_OBJECT (notebook), "switch_page",
+      sample_notebook = gtk_notebook_new ();
+      gtk_signal_connect (GTK_OBJECT (sample_notebook), "switch_page",
                          GTK_SIGNAL_FUNC (page_switch), NULL);
-      gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
-      gtk_box_pack_start (GTK_BOX (box1), notebook, TRUE, TRUE, 0);
-      gtk_container_border_width (GTK_CONTAINER (notebook), 10);
+      gtk_notebook_set_tab_pos (GTK_NOTEBOOK (sample_notebook), GTK_POS_TOP);
+      gtk_box_pack_start (GTK_BOX (box1), sample_notebook, TRUE, TRUE, 0);
+      gtk_container_set_border_width (GTK_CONTAINER (sample_notebook), 10);
 
-      gtk_widget_realize (notebook);
-      book_open = gdk_pixmap_create_from_xpm_d (notebook->window,
+      gtk_widget_realize (sample_notebook);
+      book_open = gdk_pixmap_create_from_xpm_d (sample_notebook->window,
                                                &book_open_mask, 
                                                transparent, 
                                                book_open_xpm);
-      book_closed = gdk_pixmap_create_from_xpm_d (notebook->window,
+      book_closed = gdk_pixmap_create_from_xpm_d (sample_notebook->window,
                                                  &book_closed_mask,
                                                  transparent, 
                                                  book_closed_xpm);
 
-      create_pages (GTK_NOTEBOOK (notebook), 1, 5);
+      create_pages (GTK_NOTEBOOK (sample_notebook), 1, 5);
 
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 10);
       
-      box2 = gtk_hbox_new (TRUE, 5);
+      box2 = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
-      
-      omenu = build_option_menu (items, 3, 0, notebook);
-      gtk_box_pack_start (GTK_BOX (box2), omenu, FALSE, FALSE, 0);
 
-      button = gtk_check_button_new_with_label ("enable popup menu");
-      gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
+      button = gtk_check_button_new_with_label ("popup menu");
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, FALSE, 0);
       gtk_signal_connect (GTK_OBJECT(button), "clicked",
                          GTK_SIGNAL_FUNC (notebook_popup),
-                         GTK_OBJECT (notebook));
-      
+                         GTK_OBJECT (sample_notebook));
+
+      button = gtk_check_button_new_with_label ("homogeneous tabs");
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, FALSE, 0);
+      gtk_signal_connect (GTK_OBJECT(button), "clicked",
+                         GTK_SIGNAL_FUNC (notebook_homogeneous),
+                         GTK_OBJECT (sample_notebook));
+
+      box2 = gtk_hbox_new (FALSE, 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
+      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
+
+      label = gtk_label_new ("Notebook Style :");
+      gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
+
+      omenu = build_option_menu (items, 3, 0, sample_notebook);
+      gtk_box_pack_start (GTK_BOX (box2), omenu, FALSE, TRUE, 0);
+
+      button = gtk_button_new_with_label ("Show all Pages");
+      gtk_box_pack_start (GTK_BOX (box2), button, FALSE, TRUE, 0);
+      gtk_signal_connect (GTK_OBJECT (button), "clicked",
+                         GTK_SIGNAL_FUNC (show_all_pages), sample_notebook);
+
       box2 = gtk_hbox_new (TRUE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
-      
-      button = gtk_button_new_with_label ("close");
+
+      button = gtk_button_new_with_label ("prev");
       gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
-                                GTK_SIGNAL_FUNC (gtk_widget_destroy),
-                                GTK_OBJECT (window));
+                                GTK_SIGNAL_FUNC (gtk_notebook_prev_page),
+                                GTK_OBJECT (sample_notebook));
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-      gtk_widget_grab_default (button);
 
       button = gtk_button_new_with_label ("next");
       gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                                 GTK_SIGNAL_FUNC (gtk_notebook_next_page),
-                                GTK_OBJECT (notebook));
-      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-
-      button = gtk_button_new_with_label ("prev");
-      gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
-                                GTK_SIGNAL_FUNC (gtk_notebook_prev_page),
-                                GTK_OBJECT (notebook));
+                                GTK_OBJECT (sample_notebook));
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
-      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
 
       button = gtk_button_new_with_label ("rotate");
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
-                         GTK_SIGNAL_FUNC (rotate_notebook),
-                         notebook);
+                         GTK_SIGNAL_FUNC (rotate_notebook), sample_notebook);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+
+      separator = gtk_hseparator_new ();
+      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
+
+      button = gtk_button_new_with_label ("close");
+      gtk_container_set_border_width (GTK_CONTAINER (button), 5);
+      gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+                                GTK_SIGNAL_FUNC (gtk_widget_destroy),
+                                GTK_OBJECT (window));
+      gtk_box_pack_start (GTK_BOX (box1), button, FALSE, FALSE, 0);
       GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+      gtk_widget_grab_default (button);
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
@@ -5991,6 +6177,106 @@ create_notebook (void)
  * GtkPanes
  */
 
+void
+toggle_resize (GtkWidget *widget, GtkWidget *child)
+{
+  GtkPaned *paned = GTK_PANED (child->parent);
+  gboolean is_child1 = (child == paned->child1);
+  gboolean resize, shrink;
+
+  resize = is_child1 ? paned->child1_resize : paned->child2_resize;
+  shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+
+  gtk_widget_ref (child);
+  gtk_container_remove (GTK_CONTAINER (child->parent), child);
+  if (is_child1)
+    gtk_paned_pack1 (paned, child, !resize, shrink);
+  else
+    gtk_paned_pack2 (paned, child, !resize, shrink);
+  gtk_widget_unref (child);
+}
+
+void
+toggle_shrink (GtkWidget *widget, GtkWidget *child)
+{
+  GtkPaned *paned = GTK_PANED (child->parent);
+  gboolean is_child1 = (child == paned->child1);
+  gboolean resize, shrink;
+
+  resize = is_child1 ? paned->child1_resize : paned->child2_resize;
+  shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+
+  gtk_widget_ref (child);
+  gtk_container_remove (GTK_CONTAINER (child->parent), child);
+  if (is_child1)
+    gtk_paned_pack1 (paned, child, resize, !shrink);
+  else
+    gtk_paned_pack2 (paned, child, resize, !shrink);
+  gtk_widget_unref (child);
+}
+
+GtkWidget *
+create_pane_options (GtkPaned *paned,
+                    const gchar *frame_label,
+                    const gchar *label1,
+                    const gchar *label2)
+{
+  GtkWidget *frame;
+  GtkWidget *table;
+  GtkWidget *label;
+  GtkWidget *check_button;
+  
+  frame = gtk_frame_new (frame_label);
+  gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
+  
+  table = gtk_table_new (3, 2, 4);
+  gtk_container_add (GTK_CONTAINER (frame), table);
+  
+  label = gtk_label_new (label1);
+  gtk_table_attach_defaults (GTK_TABLE (table), label,
+                            0, 1, 0, 1);
+  
+  check_button = gtk_check_button_new_with_label ("Resize");
+  gtk_table_attach_defaults (GTK_TABLE (table), check_button,
+                            0, 1, 1, 2);
+  gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
+                     GTK_SIGNAL_FUNC (toggle_resize),
+                     paned->child1);
+  
+  check_button = gtk_check_button_new_with_label ("Shrink");
+  gtk_table_attach_defaults (GTK_TABLE (table), check_button,
+                            0, 1, 2, 3);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
+                              TRUE);
+  gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
+                     GTK_SIGNAL_FUNC (toggle_shrink),
+                     paned->child1);
+  
+  label = gtk_label_new (label2);
+  gtk_table_attach_defaults (GTK_TABLE (table), label,
+                            1, 2, 0, 1);
+  
+  check_button = gtk_check_button_new_with_label ("Resize");
+  gtk_table_attach_defaults (GTK_TABLE (table), check_button,
+                            1, 2, 1, 2);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
+                              TRUE);
+  gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
+                     GTK_SIGNAL_FUNC (toggle_resize),
+                     paned->child2);
+  
+  check_button = gtk_check_button_new_with_label ("Shrink");
+  gtk_table_attach_defaults (GTK_TABLE (table), check_button,
+                            1, 2, 2, 3);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
+                              TRUE);
+  gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
+                     GTK_SIGNAL_FUNC (toggle_shrink),
+                     paned->child2);
+
+  return frame;
+}
+
 void
 create_panes (void)
 {
@@ -5999,6 +6285,7 @@ create_panes (void)
   GtkWidget *hpaned;
   GtkWidget *vpaned;
   GtkWidget *button;
+  GtkWidget *vbox;
 
   if (!window)
     {
@@ -6009,12 +6296,14 @@ create_panes (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Panes");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
+      vbox = gtk_vbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
+      
       vpaned = gtk_vpaned_new ();
-      gtk_container_add (GTK_CONTAINER (window), vpaned);
-      gtk_container_border_width (GTK_CONTAINER(vpaned), 5);
-      gtk_widget_show (vpaned);
+      gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);
+      gtk_container_set_border_width (GTK_CONTAINER(vpaned), 5);
 
       hpaned = gtk_hpaned_new ();
       gtk_paned_add1 (GTK_PANED (vpaned), hpaned);
@@ -6023,25 +6312,37 @@ create_panes (void)
       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
       gtk_widget_set_usize (frame, 60, 60);
       gtk_paned_add1 (GTK_PANED (hpaned), frame);
-      gtk_widget_show (frame);
       
       button = gtk_button_new_with_label ("Hi there");
       gtk_container_add (GTK_CONTAINER(frame), button);
-      gtk_widget_show (button);
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
       gtk_widget_set_usize (frame, 80, 60);
       gtk_paned_add2 (GTK_PANED (hpaned), frame);
-      gtk_widget_show (frame);
-
-      gtk_widget_show (hpaned);
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
       gtk_widget_set_usize (frame, 60, 80);
       gtk_paned_add2 (GTK_PANED (vpaned), frame);
-      gtk_widget_show (frame);
+
+      /* Now create toggle buttons to control sizing */
+
+      gtk_box_pack_start (GTK_BOX (vbox),
+                         create_pane_options (GTK_PANED (hpaned),
+                                              "Horizontal",
+                                              "Left",
+                                              "Right"),
+                         FALSE, FALSE, 0);
+
+      gtk_box_pack_start (GTK_BOX (vbox),
+                         create_pane_options (GTK_PANED (vpaned),
+                                              "Vertical",
+                                              "Top",
+                                              "Bottom"),
+                         FALSE, FALSE, 0);
+
+      gtk_widget_show_all (vbox);
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
@@ -6082,7 +6383,7 @@ dnd_drop (GtkWidget *button, GdkEvent *event)
     return;
 
   window = gtk_window_new(GTK_WINDOW_DIALOG);
-  gtk_container_border_width (GTK_CONTAINER(window), 10);
+  gtk_container_set_border_width (GTK_CONTAINER(window), 10);
 
   gtk_signal_connect (GTK_OBJECT (window), "destroy",
                      GTK_SIGNAL_FUNC(dnd_drop_destroy_popup),
@@ -6185,14 +6486,14 @@ create_dnd (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Drag -N- Drop");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       box1 = gtk_vbox_new (FALSE, 0);
       gtk_container_add (GTK_CONTAINER (window), box1);
       gtk_widget_show (box1);
 
       box2 = gtk_hbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -6201,7 +6502,7 @@ create_dnd (void)
       gtk_widget_show (frame);
 
       box3 = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box3), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box3), 5);
       gtk_container_add (GTK_CONTAINER (frame), box3);
       gtk_widget_show (box3);
 
@@ -6230,7 +6531,7 @@ create_dnd (void)
       gtk_widget_show (frame);
 
       box3 = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (box3), 5);
+      gtk_container_set_border_width (GTK_CONTAINER (box3), 5);
       gtk_container_add (GTK_CONTAINER (frame), box3);
       gtk_widget_show (box3);
 
@@ -6257,7 +6558,7 @@ create_dnd (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -6285,8 +6586,6 @@ create_dnd (void)
  * Shaped Windows
  */
 
-static GdkWindow *root_win = NULL;
-
 typedef struct _cursoroffset {gint x,y;} CursorOffset;
 
 static void
@@ -6331,7 +6630,7 @@ shape_motion (GtkWidget      *widget,
    * Can't use event->x / event->y here 
    * because I need absolute coordinates.
    */
-  gdk_window_get_pointer (root_win, &xp, &yp, &mask);
+  gdk_window_get_pointer (NULL, &xp, &yp, &mask);
   gtk_widget_set_uposition (widget, xp  - p->x, yp  - p->y);
 }
 
@@ -6407,8 +6706,6 @@ create_shapes (void)
   static GtkWidget *sheets = NULL;
   static GtkWidget *rings = NULL;
 
-  root_win = gdk_window_foreign_new (GDK_ROOT_WINDOW ());
-
   if (!modeller)
     {
       modeller = shape_create_icon ("Modeller.xpm",
@@ -6472,7 +6769,7 @@ create_wmhints (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "WM Hints");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       gtk_widget_realize (window);
       
@@ -6504,7 +6801,7 @@ create_wmhints (void)
 
 
       box2 = gtk_vbox_new (FALSE, 10);
-      gtk_container_border_width (GTK_CONTAINER (box2), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
       gtk_widget_show (box2);
 
@@ -6633,7 +6930,7 @@ progress_value_changed (GtkAdjustment *adj, ProgressData *pdata)
   else
     sprintf (buf, "%.0f%%", 100 *
             gtk_progress_get_current_percentage (GTK_PROGRESS (pdata->pbar)));
-  gtk_label_set (GTK_LABEL (pdata->label), buf);
+  gtk_label_set_text (GTK_LABEL (pdata->label), buf);
 }
 
 static void
@@ -6732,10 +7029,10 @@ create_progress_bar (void)
       pdata->timer = 0;
 
       gtk_window_set_title (GTK_WINDOW (pdata->window), "GtkProgressBar");
-      gtk_container_border_width (GTK_CONTAINER (pdata->window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (pdata->window), 0);
 
       vbox = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (vbox), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pdata->window)->vbox), 
                          vbox, FALSE, TRUE, 0);
 
@@ -6991,7 +7288,7 @@ create_color_preview (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "test");
-      gtk_container_border_width (GTK_CONTAINER (window), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
       preview = gtk_preview_new (GTK_PREVIEW_COLOR);
       gtk_preview_size (GTK_PREVIEW (preview), 256, 256);
@@ -7074,7 +7371,7 @@ create_gray_preview (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "test");
-      gtk_container_border_width (GTK_CONTAINER (window), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
       preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
       gtk_preview_size (GTK_PREVIEW (preview), 256, 256);
@@ -7183,12 +7480,12 @@ create_selection_test (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Selection Test");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       /* Create the list */
 
       vbox = gtk_vbox_new (FALSE, 5);
-      gtk_container_border_width (GTK_CONTAINER (vbox), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox,
                          TRUE, TRUE, 0);
 
@@ -7203,7 +7500,7 @@ create_selection_test (void)
       gtk_widget_set_usize (scrolled_win, 100, 200);
 
       list = gtk_list_new ();
-      gtk_container_add (GTK_CONTAINER (scrolled_win), list);
+      gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win), list);
 
       gtk_signal_connect (GTK_OBJECT(list), "selection_received",
                          GTK_SIGNAL_FUNC (selection_test_received), NULL);
@@ -7248,7 +7545,7 @@ create_gamma_curve (void)
     {
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_title (GTK_WINDOW (window), "test");
-      gtk_container_border_width (GTK_CONTAINER (window), 10);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
                          GTK_SIGNAL_FUNC(gtk_widget_destroyed),
@@ -7408,6 +7705,8 @@ create_scroll_test (void)
   GtkWidget *scrollbar;
   GtkWidget *button;
   GtkAdjustment *adj;
+  GdkGeometry geometry;
+  GdkWindowHints geometry_mask;
   
   if (!window)
     {
@@ -7418,7 +7717,7 @@ create_scroll_test (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Scroll Test");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       hbox = gtk_hbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), hbox,
@@ -7459,6 +7758,22 @@ create_scroll_test (void)
                                 GTK_SIGNAL_FUNC (gtk_widget_destroy),
                                 GTK_OBJECT (window));
       gtk_widget_show (button);
+
+      /* Set up gridded geometry */
+
+      geometry_mask = GDK_HINT_MIN_SIZE | 
+                      GDK_HINT_BASE_SIZE | 
+                      GDK_HINT_RESIZE_INC;
+
+      geometry.min_width = 20;
+      geometry.min_height = 20;
+      geometry.base_width = 0;
+      geometry.base_height = 0;
+      geometry.width_inc = 10;
+      geometry.height_inc = 10;
+      
+      gtk_window_set_geometry_hints (GTK_WINDOW (window),
+                              drawing_area, &geometry, geometry_mask);
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
@@ -7480,7 +7795,7 @@ timeout_test (GtkWidget *label)
   static char buffer[32];
 
   sprintf (buffer, "count: %d", ++count);
-  gtk_label_set (GTK_LABEL (label), buffer);
+  gtk_label_set_text (GTK_LABEL (label), buffer);
 
   return TRUE;
 }
@@ -7531,7 +7846,7 @@ create_timeout_test (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Timeout Test");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       label = gtk_label_new ("count: 0");
       gtk_misc_set_padding (GTK_MISC (label), 10, 10);
@@ -7578,7 +7893,7 @@ create_timeout_test (void)
  * Idle Test
  */
 
-static int idle = 0;
+static int idle_id = 0;
 
 static gint
 idle_test (GtkWidget *label)
@@ -7587,7 +7902,7 @@ idle_test (GtkWidget *label)
   static char buffer[32];
 
   sprintf (buffer, "count: %d", ++count);
-  gtk_label_set (GTK_LABEL (label), buffer);
+  gtk_label_set_text (GTK_LABEL (label), buffer);
 
   return TRUE;
 }
@@ -7596,9 +7911,9 @@ static void
 start_idle_test (GtkWidget *widget,
                 GtkWidget *label)
 {
-  if (!idle)
+  if (!idle_id)
     {
-      idle = gtk_idle_add ((GtkFunction) idle_test, label);
+      idle_id = gtk_idle_add ((GtkFunction) idle_test, label);
     }
 }
 
@@ -7606,10 +7921,10 @@ static void
 stop_idle_test (GtkWidget *widget,
                gpointer   data)
 {
-  if (idle)
+  if (idle_id)
     {
-      gtk_idle_remove (idle);
-      idle = 0;
+      gtk_idle_remove (idle_id);
+      idle_id = 0;
     }
 }
 
@@ -7626,7 +7941,7 @@ static void
 toggle_idle_container (GtkObject *button,
                       GtkContainer *container)
 {
-  gtk_container_set_resize_mode (container, (guint) gtk_object_get_user_data (button));
+  gtk_container_set_resize_mode (container, GPOINTER_TO_INT (gtk_object_get_user_data (button)));
 }
 
 static void
@@ -7649,7 +7964,7 @@ create_idle_test (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Idle Test");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       label = gtk_label_new ("count: 0");
       gtk_misc_set_padding (GTK_MISC (label), 10, 10);
@@ -7801,7 +8116,7 @@ create_rc_file (void)
                          &window);
 
       gtk_window_set_title (GTK_WINDOW (window), "Reload Rc file");
-      gtk_container_border_width (GTK_CONTAINER (window), 0);
+      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       button = gtk_button_new_with_label ("Reload");
       gtk_signal_connect (GTK_OBJECT (button), "clicked",
@@ -7898,6 +8213,110 @@ create_mainloop (void)
     gtk_widget_destroy (window);
 }
 
+gint
+layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
+{
+  GtkLayout *layout;
+
+  gint i,j;
+  gint imin, imax, jmin, jmax;
+  
+  layout = GTK_LAYOUT (widget);
+
+  imin = (layout->xoffset + event->area.x) / 10;
+  imax = (layout->xoffset + event->area.x + event->area.width + 9) / 10;
+
+  jmin = (layout->yoffset + event->area.y) / 10;
+  jmax = (layout->yoffset + event->area.y + event->area.height + 9) / 10;
+
+  gdk_window_clear_area (widget->window,
+                        event->area.x, event->area.y,
+                        event->area.width, event->area.height);
+
+  for (i=imin; i<imax; i++)
+    for (j=jmin; j<jmax; j++)
+      if ((i+j) % 2)
+       gdk_draw_rectangle (layout->bin_window,
+                           widget->style->black_gc,
+                           TRUE,
+                           10*i - layout->xoffset, 10*j - layout->yoffset, 
+                           1+i%10, 1+j%10);
+  
+  return TRUE;
+}
+
+void create_layout (void)
+{
+  static GtkWidget *window = NULL;
+  GtkWidget *layout;
+  GtkWidget *scrolledwindow;
+  GtkWidget *button;
+
+  if (!window)
+    {
+      gchar buf[16];
+
+      gint i, j;
+      
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_signal_connect (GTK_OBJECT (window), "destroy",
+                         GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+                         &window);
+
+      gtk_window_set_title (GTK_WINDOW (window), "Layout");
+      gtk_widget_set_usize (window, 200, 200);
+
+      scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+
+      gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
+      
+      layout = gtk_layout_new (NULL, NULL);
+      gtk_container_add (GTK_CONTAINER (scrolledwindow), layout);
+
+      /* We set step sizes here since GtkLayout does not set
+       * them itself.
+       */
+      GTK_LAYOUT (layout)->hadjustment->step_increment = 10.0;
+      GTK_LAYOUT (layout)->vadjustment->step_increment = 10.0;
+      
+      gtk_widget_set_events (layout, GDK_EXPOSURE_MASK);
+      gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
+                         GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
+      
+      gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 128000);
+      
+      for (i=0 ; i < 16 ; i++)
+       for (j=0 ; j < 16 ; j++)
+         {
+           sprintf(buf, "Button %d, %d", i, j);
+           if ((i + j) % 2)
+             button = gtk_button_new_with_label (buf);
+           else
+             button = gtk_label_new (buf);
+
+           gtk_layout_put (GTK_LAYOUT (layout), button,
+                           j*100, i*100);
+         }
+
+      for (i=16; i < 1280; i++)
+       {
+         sprintf(buf, "Button %d, %d", i, 0);
+         if (i % 2)
+           button = gtk_button_new_with_label (buf);
+         else
+           button = gtk_label_new (buf);
+
+         gtk_layout_put (GTK_LAYOUT (layout), button,
+                         0, i*100);
+       }
+    }
+
+  if (!GTK_WIDGET_VISIBLE (window))
+    gtk_widget_show_all (window);
+  else
+    gtk_widget_destroy (window);
+}
+
 /*
  * Main Window and Exit
  */
@@ -7927,11 +8346,14 @@ create_main_window (void)
       { "dialog", create_dialog },
       /*      { "dnd", create_dnd }, */
       { "entry", create_entry },
+      { "event watcher", create_event_watcher },
       { "file selection", create_file_selection },
       { "font selection", create_font_selection },
       { "gamma curve", create_gamma_curve },
       { "handle box", create_handle_box },
       { "item factory", create_item_factory },
+      { "labels", create_labels },
+      { "layout", create_layout },
       { "list", create_list },
       { "menus", create_menus },
       { "modal window", create_modal_window },
@@ -8006,15 +8428,15 @@ create_main_window (void)
   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
 
   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-  gtk_container_border_width (GTK_CONTAINER (scrolled_window), 10);
+  gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                  GTK_POLICY_AUTOMATIC, 
                                   GTK_POLICY_AUTOMATIC);
   gtk_box_pack_start (GTK_BOX (box1), scrolled_window, TRUE, TRUE, 0);
 
   box2 = gtk_vbox_new (FALSE, 0);
-  gtk_container_border_width (GTK_CONTAINER (box2), 10);
-  gtk_container_add (GTK_CONTAINER (scrolled_window), box2);
+  gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
+  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), box2);
   gtk_container_set_focus_vadjustment (GTK_CONTAINER (box2),
                                       gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window)));
   gtk_widget_show (box2);
@@ -8036,7 +8458,7 @@ create_main_window (void)
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
   box2 = gtk_vbox_new (FALSE, 10);
-  gtk_container_border_width (GTK_CONTAINER (box2), 10);
+  gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
   gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
 
   button = gtk_button_new_with_label ("close");
@@ -8054,11 +8476,24 @@ int
 main (int argc, char *argv[])
 {
   GtkBindingSet *binding_set;
+  struct stat statbuf;
 
   srand (time (NULL));
 
   gtk_set_locale ();
 
+  /* Check to see if we are being run from the correct
+   * directory.
+   */
+  if (stat("./testgtkrc", &statbuf) < 0)
+    {
+      fprintf (stderr, "*** The testgtk program must be run from within the\n"
+                      "*** gtk/ subdirectory of the GTK+ distribution.\n");
+      exit (1);
+    }
+
+  gtk_rc_add_default_file ("testgtkrc");
+
   gtk_init (&argc, &argv);
 
   gdk_rgb_init ();
@@ -8072,8 +8507,6 @@ main (int argc, char *argv[])
                                1,
                                GTK_TYPE_STRING, "GtkWidgetClass <ctrl><release>9 test");
 
-  gtk_rc_parse ("testgtkrc");
-
   create_main_window ();
 
   gtk_main ();