[gtk+] gtk-demo: Cosmetic changes



commit 609e04ddcf626e6295b11260269ab5d0492a65f6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 28 09:23:28 2015 -0400

    gtk-demo: Cosmetic changes
    
    Clean up the code of many examples in minor ways, fix some memory
    leaks, and avoid the use of dialogs where a regular toplevel works
    just as well.

 demos/gtk-demo/Makefile.am             |   79 +---------
 demos/gtk-demo/assistant.c             |    2 +-
 demos/gtk-demo/builder.c               |   24 ++--
 demos/gtk-demo/button_box.c            |   11 +-
 demos/gtk-demo/clipboard.c             |   21 +--
 demos/gtk-demo/colorsel.c              |   20 +--
 demos/gtk-demo/combobox.c              |   15 +--
 demos/gtk-demo/css_accordion.c         |    9 +-
 demos/gtk-demo/css_basics.c            |    9 +-
 demos/gtk-demo/css_multiplebgs.c       |    9 +-
 demos/gtk-demo/css_pixbufs.c           |   17 +--
 demos/gtk-demo/css_shadows.c           |   17 +--
 demos/gtk-demo/cursors.c               |    9 +-
 demos/gtk-demo/dialog.c                |   13 +-
 demos/gtk-demo/drawingarea.c           |    3 +-
 demos/gtk-demo/editable_cells.c        |   10 +-
 demos/gtk-demo/entry_buffer.c          |   74 ++++-----
 demos/gtk-demo/entry_completion.c      |   20 +--
 demos/gtk-demo/event_axes.c            |    5 +-
 demos/gtk-demo/expander.c              |    2 +
 demos/gtk-demo/flowbox.c               |   10 +-
 demos/gtk-demo/font-features.ui        |   49 +++---
 demos/gtk-demo/font_features.c         |   11 +-
 demos/gtk-demo/gestures.c              |    7 +-
 demos/gtk-demo/headerbar.c             |    9 +-
 demos/gtk-demo/hypertext.c             |   14 +-
 demos/gtk-demo/iconview.c              |    5 +-
 demos/gtk-demo/iconview_edit.c         |    9 +-
 demos/gtk-demo/images.c                |    9 +-
 demos/gtk-demo/infobar.c               |   14 +-
 demos/gtk-demo/links.c                 |   12 +-
 demos/gtk-demo/menus.c                 |    9 +-
 demos/gtk-demo/offscreen_window.c      |    9 +-
 demos/gtk-demo/offscreen_window2.c     |    9 +-
 demos/gtk-demo/overlay.c               |    9 +-
 demos/gtk-demo/pagesetup.c             |    5 +-
 demos/gtk-demo/panes.c                 |    9 +-
 demos/gtk-demo/pickers.c               |   12 +-
 demos/gtk-demo/pixbufs.c               |    6 +-
 demos/gtk-demo/popover.c               |    5 +-
 demos/gtk-demo/revealer.c              |   37 ++---
 demos/gtk-demo/revealer.ui             |  286 +++++++++++++------------------
 demos/gtk-demo/rotated_text.c          |   16 +-
 demos/gtk-demo/search_entry.c          |   26 +---
 demos/gtk-demo/search_entry2.c         |   16 +--
 demos/gtk-demo/sidebar.c               |    3 +-
 demos/gtk-demo/sizegroup.c             |   26 +--
 demos/gtk-demo/spinner.c               |    2 +-
 demos/gtk-demo/stack.c                 |   15 +-
 demos/gtk-demo/theming_style_classes.c |   18 +--
 demos/gtk-demo/transparent.c           |   12 +-
 demos/gtk-demo/tree_store.c            |    9 +-
 52 files changed, 358 insertions(+), 699 deletions(-)
---
diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am
index c6791ae..72ba875 100644
--- a/demos/gtk-demo/Makefile.am
+++ b/demos/gtk-demo/Makefile.am
@@ -98,7 +98,7 @@ EXTRA_DIST +=                                 \
        data/source.svg                 \
        data/symbolic-source.svg        \
        demo.gresource.xml              \
-       $(RESOURCES)                    \
+       $(resource_files)               \
        org.gtk.Demo.gschema.xml        \
        demos.h.win32
 
@@ -130,81 +130,10 @@ gtk3_demo_application_SOURCES = \
 
 gtk3_demo_application_LDADD = $(LDADDS)
 
-demo_resources.c: demo.gresource.xml $(RESOURCES)
-       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/demo.gresource.xml
-
-RESOURCES =                            \
-       $(demos)                        \
-       main.ui                         \
-       application.ui                  \
-       demo.ui                         \
-       menus.ui                        \
-       stack.ui                        \
-       revealer.ui                     \
-       theming.ui                      \
-       listbox.ui                      \
-       popover.ui                      \
-       alphatest.png                   \
-       apple-red.png                   \
-       brick.png                       \
-       brick2.png                      \
-       background.jpg                  \
-       floppybuddy.gif                 \
-       glarea-fragment.glsl            \
-       glarea-vertex.glsl              \
-       gnome-applets.png               \
-       gnome-calendar.png              \
-       gnome-foot.png                  \
-       gnome-fs-directory.png          \
-       gnome-fs-regular.png            \
-       gnome-gimp.png                  \
-       gnome-gmush.png                 \
-       gnome-gsame.png                 \
-       gnu-keys.png                    \
-       messages.txt                    \
-       css_accordion.css               \
-       css_basics.css                  \
-       css_multiplebgs.css             \
-       css_pixbufs.css                 \
-       css_shadows.css                 \
-       cssview.css                     \
-       reset.css                       \
-       alias_cursor.png                \
-       all_scroll_cursor.png           \
-       cell_cursor.png                 \
-       col_resize_cursor.png           \
-       copy_cursor.png                 \
-       crosshair_cursor.png            \
-       default_cursor.png              \
-       e_resize_cursor.png             \
-       ew_resize_cursor.png            \
-       grabbing_cursor.png             \
-       grab_cursor.png                 \
-       hand_cursor.png                 \
-       help_cursor.png                 \
-       move_cursor.png                 \
-       ne_resize_cursor.png            \
-       nesw_resize_cursor.png          \
-       none_cursor.png                 \
-       no_drop_cursor.png              \
-       not_allowed_cursor.png          \
-       n_resize_cursor.png             \
-       ns_resize_cursor.png            \
-       nw_resize_cursor.png            \
-       nwse_resize_cursor.png          \
-       pointer_cursor.png              \
-       progress_cursor.png             \
-       row_resize_cursor.png           \
-       se_resize_cursor.png            \
-       s_resize_cursor.png             \
-       sw_resize_cursor.png            \
-       text_cursor.png                 \
-       vertical_text_cursor.png        \
-       wait_cursor.png                 \
-       w_resize_cursor.png             \
-       zoom_in_cursor.png              \
-       zoom_out_cursor.png
+resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(builddir)/demo.gresource.xml)
 
+demo_resources.c: demo.gresource.xml $(resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
$(srcdir)/demo.gresource.xml
 
 iconthemedir = $(datadir)/icons/hicolor
 
diff --git a/demos/gtk-demo/assistant.c b/demos/gtk-demo/assistant.c
index b461171..6b8a036 100644
--- a/demos/gtk-demo/assistant.c
+++ b/demos/gtk-demo/assistant.c
@@ -168,7 +168,7 @@ do_assistant (GtkWidget *do_widget)
     {
       assistant = gtk_assistant_new ();
 
-         gtk_window_set_default_size (GTK_WINDOW (assistant), -1, 300);
+      gtk_window_set_default_size (GTK_WINDOW (assistant), -1, 300);
 
       gtk_window_set_screen (GTK_WINDOW (assistant),
                              gtk_widget_get_screen (do_widget));
diff --git a/demos/gtk-demo/builder.c b/demos/gtk-demo/builder.c
index 33c86ac..83399f2 100644
--- a/demos/gtk-demo/builder.c
+++ b/demos/gtk-demo/builder.c
@@ -5,16 +5,13 @@
 
 #include <gtk/gtk.h>
 
-static GtkBuilder *builder;
-
 static void
 quit_activate (GSimpleAction *action,
                GVariant      *parameter,
                gpointer       user_data)
 {
-  GtkWidget *window;
+  GtkWidget *window = user_data;
 
-  window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
   gtk_widget_destroy (window);
 }
 
@@ -23,8 +20,11 @@ about_activate (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
 {
+  GtkWidget *window = user_data;
+  GtkBuilder *builder;
   GtkWidget *about_dlg;
 
+  builder = g_object_get_data (G_OBJECT (window), "builder");
   about_dlg = GTK_WIDGET (gtk_builder_get_object (builder, "aboutdialog1"));
   gtk_dialog_run (GTK_DIALOG (about_dlg));
   gtk_widget_hide (about_dlg);
@@ -55,6 +55,8 @@ do_builder (GtkWidget *do_widget)
 
   if (!window)
     {
+      GtkBuilder *builder;
+
       builder = gtk_builder_new_from_resource ("/builder/demo.ui");
 
       gtk_builder_connect_signals (builder, NULL);
@@ -69,7 +71,7 @@ do_builder (GtkWidget *do_widget)
       actions = (GActionGroup*)g_simple_action_group_new ();
       g_action_map_add_action_entries (G_ACTION_MAP (actions),
                                        win_entries, G_N_ELEMENTS (win_entries),
-                                       NULL);
+                                       window);
       gtk_widget_insert_action_group (window, "win", actions);
       accel_group = gtk_accel_group_new ();
       gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
@@ -109,18 +111,14 @@ do_builder (GtkWidget *do_widget)
       item = (GtkWidget*)gtk_builder_get_object (builder, "about_item");
       gtk_widget_add_accelerator (item, "activate", accel_group,
                                   GDK_KEY_F7, 0, GTK_ACCEL_VISIBLE);
+
+      g_object_set_data_full (G_OBJECT(window), "builder", builder, g_object_unref);
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
-
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/button_box.c b/demos/gtk-demo/button_box.c
index c99bbb7..7d383d3 100644
--- a/demos/gtk-demo/button_box.c
+++ b/demos/gtk-demo/button_box.c
@@ -56,7 +56,7 @@ do_button_box (GtkWidget *do_widget)
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
     gtk_window_set_screen (GTK_WINDOW (window),
                            gtk_widget_get_screen (do_widget));
-    gtk_window_set_title (GTK_WINDOW (window), "Button Boxes demo");
+    gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
 
     g_signal_connect (window, "destroy",
                       G_CALLBACK (gtk_widget_destroyed),
@@ -129,14 +129,9 @@ do_button_box (GtkWidget *do_widget)
   }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index e4b882e..f04a203 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -13,8 +13,6 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-static GtkWidget *window = NULL;
-
 void
 copy_button_clicked (GtkWidget *button,
                      gpointer   user_data)
@@ -107,12 +105,12 @@ drag_begin (GtkWidget      *widget,
 }
 
 void
-drag_data_get  (GtkWidget        *widget,
-                GdkDragContext   *context,
-                GtkSelectionData *selection_data,
-                guint             info,
-                guint             time,
-                gpointer          data)
+drag_data_get (GtkWidget        *widget,
+               GdkDragContext   *context,
+               GtkSelectionData *selection_data,
+               guint             info,
+               guint             time,
+               gpointer          data)
 {
   GdkPixbuf *pixbuf;
 
@@ -202,6 +200,8 @@ button_press (GtkWidget      *widget,
 GtkWidget *
 do_clipboard (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *vbox, *hbox;
@@ -325,10 +325,7 @@ do_clipboard (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/colorsel.c b/demos/gtk-demo/colorsel.c
index 8f0cc18..c00d503 100644
--- a/demos/gtk-demo/colorsel.c
+++ b/demos/gtk-demo/colorsel.c
@@ -32,9 +32,7 @@ response_cb (GtkDialog *dialog,
              gpointer   user_data)
 {
   if (response_id == GTK_RESPONSE_OK)
-    {
-      gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
-    }
+    gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
 
   gtk_widget_destroy (GTK_WIDGET (dialog));
 }
@@ -49,10 +47,8 @@ change_color_callback (GtkWidget *button,
   gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
   gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
 
-  g_signal_connect (dialog,
-                    "response",
-                    G_CALLBACK (response_cb),
-                    NULL);
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (response_cb), NULL);
 
   gtk_widget_show_all (dialog);
 }
@@ -88,7 +84,6 @@ do_colorsel (GtkWidget *do_widget)
        * Create the color swatch area
        */
 
-
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
       gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
@@ -113,14 +108,9 @@ do_colorsel (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c
index dec9a06..5bdaf02 100644
--- a/demos/gtk-demo/combobox.c
+++ b/demos/gtk-demo/combobox.c
@@ -321,8 +321,7 @@ do_combobox (GtkWidget *do_widget)
     gtk_window_set_title (GTK_WINDOW (window), "Combo Boxes");
 
     g_signal_connect (window, "destroy",
-                      G_CALLBACK (gtk_widget_destroyed),
-                      &window);
+                      G_CALLBACK (gtk_widget_destroyed), &window);
 
     gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
@@ -400,8 +399,7 @@ do_combobox (GtkWidget *do_widget)
     gtk_tree_path_free (path);
     gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
 
-    /* A GtkComboBoxEntry with validation.
-     */
+    /* A GtkComboBoxEntry with validation */
     frame = gtk_frame_new ("Editable");
     gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
@@ -441,14 +439,9 @@ do_combobox (GtkWidget *do_widget)
   }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/css_accordion.c b/demos/gtk-demo/css_accordion.c
index 8c3dae7..2afa6b5 100644
--- a/demos/gtk-demo/css_accordion.c
+++ b/demos/gtk-demo/css_accordion.c
@@ -6,8 +6,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 apply_css (GtkWidget *widget, GtkStyleProvider *provider)
 {
@@ -19,6 +17,8 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
 GtkWidget *
 do_css_accordion (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *container, *child;
@@ -63,10 +63,7 @@ do_css_accordion (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/css_basics.c b/demos/gtk-demo/css_basics.c
index 6bc245f..1016aba 100644
--- a/demos/gtk-demo/css_basics.c
+++ b/demos/gtk-demo/css_basics.c
@@ -7,8 +7,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 show_parsing_error (GtkCssProvider *provider,
                     GtkCssSection  *section,
@@ -64,6 +62,8 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
 GtkWidget *
 do_css_basics (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *container, *child;
@@ -112,10 +112,7 @@ do_css_basics (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/css_multiplebgs.c b/demos/gtk-demo/css_multiplebgs.c
index c10a5ca..a5d2e0f 100644
--- a/demos/gtk-demo/css_multiplebgs.c
+++ b/demos/gtk-demo/css_multiplebgs.c
@@ -7,8 +7,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 show_parsing_error (GtkCssProvider *provider,
                     GtkCssSection  *section,
@@ -82,6 +80,8 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
 GtkWidget *
 do_css_multiplebgs (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *paned, *container, *child;
@@ -163,10 +163,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/css_pixbufs.c b/demos/gtk-demo/css_pixbufs.c
index 360c0d5..45dee45 100644
--- a/demos/gtk-demo/css_pixbufs.c
+++ b/demos/gtk-demo/css_pixbufs.c
@@ -6,8 +6,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 show_parsing_error (GtkCssProvider *provider,
                     GtkCssSection  *section,
@@ -63,6 +61,8 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
 GtkWidget *
 do_css_pixbufs (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *paned, *container, *child;
@@ -95,15 +95,13 @@ do_css_pixbufs (GtkWidget *do_widget)
                                   NULL);
 
       provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
-      
+
       container = gtk_scrolled_window_new (NULL, NULL);
       gtk_container_add (GTK_CONTAINER (paned), container);
       child = gtk_text_view_new_with_buffer (text);
       gtk_container_add (GTK_CONTAINER (container), child);
-      g_signal_connect (text,
-                        "changed",
-                        G_CALLBACK (css_text_changed),
-                        provider);
+      g_signal_connect (text, "changed",
+                        G_CALLBACK (css_text_changed), provider);
 
       bytes = g_resources_lookup_data ("/css_pixbufs/gtk.css", 0, NULL);
       gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
@@ -120,10 +118,7 @@ do_css_pixbufs (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/css_shadows.c b/demos/gtk-demo/css_shadows.c
index a4b5497..ae2392e 100644
--- a/demos/gtk-demo/css_shadows.c
+++ b/demos/gtk-demo/css_shadows.c
@@ -5,8 +5,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 show_parsing_error (GtkCssProvider *provider,
                     GtkCssSection  *section,
@@ -86,6 +84,8 @@ create_toolbar (void)
 GtkWidget *
 do_css_shadows (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *paned, *container, *child;
@@ -117,15 +117,13 @@ do_css_shadows (GtkWidget *do_widget)
                                   NULL);
 
       provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
-      
+
       container = gtk_scrolled_window_new (NULL, NULL);
       gtk_container_add (GTK_CONTAINER (paned), container);
       child = gtk_text_view_new_with_buffer (text);
       gtk_container_add (GTK_CONTAINER (container), child);
-      g_signal_connect (text,
-                        "changed",
-                        G_CALLBACK (css_text_changed),
-                        provider);
+      g_signal_connect (text, "changed",
+                        G_CALLBACK (css_text_changed), provider);
 
       bytes = g_resources_lookup_data ("/css_shadows/gtk.css", 0, NULL);
       gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
@@ -142,10 +140,7 @@ do_css_shadows (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/cursors.c b/demos/gtk-demo/cursors.c
index 1ccb580..eb922a3 100644
--- a/demos/gtk-demo/cursors.c
+++ b/demos/gtk-demo/cursors.c
@@ -152,14 +152,9 @@ do_cursors (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
 
   return window;
diff --git a/demos/gtk-demo/dialog.c b/demos/gtk-demo/dialog.c
index 081bbe3..0eb1c62 100644
--- a/demos/gtk-demo/dialog.c
+++ b/demos/gtk-demo/dialog.c
@@ -111,7 +111,9 @@ do_dialog (GtkWidget *do_widget)
                              gtk_widget_get_screen (do_widget));
       gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
 
-      g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+      g_signal_connect (window, "destroy",
+                        G_CALLBACK (gtk_widget_destroyed), &window);
+
       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
 
       frame = gtk_frame_new ("Dialogs");
@@ -163,14 +165,9 @@ do_dialog (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index c7bbcae..3b7da92 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -212,7 +212,8 @@ do_drawingarea (GtkWidget *do_widget)
                              gtk_widget_get_screen (do_widget));
       gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
 
-      g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
+      g_signal_connect (window, "destroy",
+                        G_CALLBACK (close_window), NULL);
 
       gtk_container_set_border_width (GTK_CONTAINER (window), 8);
 
diff --git a/demos/gtk-demo/editable_cells.c b/demos/gtk-demo/editable_cells.c
index dd8a970..f57ae5c 100644
--- a/demos/gtk-demo/editable_cells.c
+++ b/demos/gtk-demo/editable_cells.c
@@ -14,8 +14,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-static GtkWidget *window = NULL;
-
 typedef struct
 {
   gint   number;
@@ -335,6 +333,8 @@ add_columns (GtkTreeView  *treeview,
 GtkWidget *
 do_editable_cells (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *vbox;
@@ -345,7 +345,6 @@ do_editable_cells (GtkWidget *do_widget)
       GtkTreeModel *items_model;
       GtkTreeModel *numbers_model;
 
-      /* create window, etc */
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_screen (GTK_WINDOW (window),
                              gtk_widget_get_screen (do_widget));
@@ -406,10 +405,7 @@ do_editable_cells (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/entry_buffer.c b/demos/gtk-demo/entry_buffer.c
index 7774467..d4863e3 100644
--- a/demos/gtk-demo/entry_buffer.c
+++ b/demos/gtk-demo/entry_buffer.c
@@ -8,56 +8,48 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 GtkWidget *
 do_entry_buffer (GtkWidget *do_widget)
 {
-  GtkWidget *content_area;
+  static GtkWidget *window = NULL;
   GtkWidget *vbox;
   GtkWidget *label;
   GtkWidget *entry;
   GtkEntryBuffer *buffer;
 
   if (!window)
-  {
-    window = gtk_dialog_new_with_buttons ("Entry Buffer",
-                                          GTK_WINDOW (do_widget),
-                                          0,
-                                          _("_Close"),
-                                          GTK_RESPONSE_NONE,
-                                          NULL);
-    gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
-    g_signal_connect (window, "response",
-                      G_CALLBACK (gtk_widget_destroy), NULL);
-    g_signal_connect (window, "destroy",
-                      G_CALLBACK (gtk_widget_destroyed), &window);
-
-    content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
-
-    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-    gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-
-    label = gtk_label_new (NULL);
-    gtk_label_set_markup (GTK_LABEL (label), "Entries share a buffer. Typing in one is reflected in the 
other.");
-    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
-    /* Create a buffer */
-    buffer = gtk_entry_buffer_new (NULL, 0);
-
-    /* Create our first entry */
-    entry = gtk_entry_new_with_buffer (buffer);
-    gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
-
-    /* Create the second entry */
-    entry = gtk_entry_new_with_buffer (buffer);
-    gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
-    gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
-
-    g_object_unref (buffer);
-  }
+    {
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_screen (GTK_WINDOW (window),
+                             gtk_widget_get_screen (do_widget));
+      gtk_window_set_title (GTK_WINDOW (window), "Entry Buffer");
+      gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+      g_signal_connect (window, "destroy",
+                        G_CALLBACK (gtk_widget_destroyed), &window);
+
+      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
+      gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+      label = gtk_label_new (NULL);
+      gtk_label_set_markup (GTK_LABEL (label),
+                            "Entries share a buffer. Typing in one is reflected in the other.");
+      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+      /* Create a buffer */
+      buffer = gtk_entry_buffer_new (NULL, 0);
+
+      /* Create our first entry */
+      entry = gtk_entry_new_with_buffer (buffer);
+      gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+      /* Create the second entry */
+      entry = gtk_entry_new_with_buffer (buffer);
+      gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+      gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+      g_object_unref (buffer);
+    }
 
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
diff --git a/demos/gtk-demo/entry_completion.c b/demos/gtk-demo/entry_completion.c
index 301f5d7..cb82235 100644
--- a/demos/gtk-demo/entry_completion.c
+++ b/demos/gtk-demo/entry_completion.c
@@ -8,8 +8,6 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 /* Creates a tree model containing the completions */
 GtkTreeModel *
 create_completion_model (void)
@@ -38,7 +36,7 @@ create_completion_model (void)
 GtkWidget *
 do_entry_completion (GtkWidget *do_widget)
 {
-  GtkWidget *content_area;
+  static GtkWidget *window = NULL;
   GtkWidget *vbox;
   GtkWidget *label;
   GtkWidget *entry;
@@ -47,23 +45,17 @@ do_entry_completion (GtkWidget *do_widget)
 
   if (!window)
     {
-      window = gtk_dialog_new_with_buttons ("Entry Completion",
-                                            GTK_WINDOW (do_widget),
-                                            0,
-                                            _("_Close"),
-                                            GTK_RESPONSE_NONE,
-                                            NULL);
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_screen (GTK_WINDOW (window),
+                             gtk_widget_get_screen (do_widget));
+      gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
 
-      g_signal_connect (window, "response",
-                        G_CALLBACK (gtk_widget_destroy), NULL);
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
 
-      content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
-
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-      gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
       gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
       label = gtk_label_new (NULL);
diff --git a/demos/gtk-demo/event_axes.c b/demos/gtk-demo/event_axes.c
index 7c77d18..bc31f53 100644
--- a/demos/gtk-demo/event_axes.c
+++ b/demos/gtk-demo/event_axes.c
@@ -412,10 +412,7 @@ do_event_axes (GtkWidget *toplevel)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/expander.c b/demos/gtk-demo/expander.c
index bc40b54..2a2dff8 100644
--- a/demos/gtk-demo/expander.c
+++ b/demos/gtk-demo/expander.c
@@ -3,6 +3,8 @@
  * GtkExpander allows to provide additional content that is initially hidden.
  * This is also known as "disclosure triangle".
  *
+ * This example also shows how to make the window resizable only if the expander
+ * is expanded.
  */
 
 #include <glib/gi18n.h>
diff --git a/demos/gtk-demo/flowbox.c b/demos/gtk-demo/flowbox.c
index 38ce3c0..863838d 100644
--- a/demos/gtk-demo/flowbox.c
+++ b/demos/gtk-demo/flowbox.c
@@ -10,8 +10,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-static GtkWidget *window = NULL;
-
 static gboolean
 draw_color (GtkWidget  *drawingarea,
             cairo_t    *cr,
@@ -46,6 +44,7 @@ color_swatch_new (const gchar *color)
 GtkWidget *
 do_flowbox (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *scrolled, *flowbox;
   const gchar *colors[] = {
     "AliceBlue",
@@ -726,8 +725,7 @@ do_flowbox (GtkWidget *do_widget)
       gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
 
       g_signal_connect (window, "destroy",
-                        G_CALLBACK (gtk_widget_destroyed),
-                        &window);
+                        G_CALLBACK (gtk_widget_destroyed), &window);
 
       scrolled = gtk_scrolled_window_new (NULL, NULL);
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, 
GTK_POLICY_AUTOMATIC);
@@ -740,9 +738,7 @@ do_flowbox (GtkWidget *do_widget)
       gtk_container_add (GTK_CONTAINER (window), scrolled);
 
       for (i = 0; colors[i]; i++)
-        {
-          gtk_container_add (GTK_CONTAINER (flowbox), color_swatch_new (colors[i]));
-        }
+        gtk_container_add (GTK_CONTAINER (flowbox), color_swatch_new (colors[i]));
 
       gtk_widget_show_all (scrolled);
     }
diff --git a/demos/gtk-demo/font-features.ui b/demos/gtk-demo/font-features.ui
index b378a10..d271515 100644
--- a/demos/gtk-demo/font-features.ui
+++ b/demos/gtk-demo/font-features.ui
@@ -49,10 +49,7 @@
                   <object class="GtkBox" id="box2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="margin_left">10</property>
-                    <property name="margin_right">10</property>
-                    <property name="margin_top">10</property>
-                    <property name="margin_bottom">10</property>
+                    <property name="margin">10</property>
                     <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
@@ -77,8 +74,8 @@
                           <object class="GtkBox" id="box13">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -148,8 +145,8 @@
                           <object class="GtkBox" id="box3">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -348,8 +345,8 @@
                           <object class="GtkBox" id="box4">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -462,8 +459,8 @@
                           <object class="GtkBox" id="box5">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -543,8 +540,8 @@
                           <object class="GtkBox" id="box6">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -624,8 +621,8 @@
                           <object class="GtkBox" id="box7">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -705,8 +702,8 @@
                           <object class="GtkBox" id="box8">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -819,8 +816,8 @@
                           <object class="GtkBox" id="box9">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -1019,8 +1016,8 @@
                           <object class="GtkBox" id="box10">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="margin_left">20</property>
-                            <property name="margin_right">20</property>
+                            <property name="margin_start">20</property>
+                            <property name="margin_end">20</property>
                             <property name="margin_top">10</property>
                             <property name="orientation">vertical</property>
                             <child>
@@ -1276,8 +1273,8 @@
             <child>
               <object class="GtkStack" id="stack">
                 <property name="visible">True</property>
-                <property name="margin_left">20</property>
-                <property name="margin_right">20</property>
+                <property name="margin_start">20</property>
+                <property name="margin_end">20</property>
                 <property name="margin_top">20</property>
                 <property name="margin_bottom">20</property>
                 <child>
@@ -1322,8 +1319,8 @@
               <object class="GtkLabel" id="settings">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="margin_left">20</property>
-                <property name="margin_right">20</property>
+                <property name="margin_start">20</property>
+                <property name="margin_end">20</property>
                 <property name="margin_bottom">20</property>
                 <property name="xalign">0</property>
               </object>
diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c
index 4d4a53b..ac1492e 100644
--- a/demos/gtk-demo/font_features.c
+++ b/demos/gtk-demo/font_features.c
@@ -189,17 +189,14 @@ do_font_features (GtkWidget *do_widget)
 
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
+
+      g_object_unref (builder);
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_window_present (GTK_WINDOW (window));
-    }
+    gtk_window_present (GTK_WINDOW (window));
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c
index 55d1ae0..b5a2958 100644
--- a/demos/gtk-demo/gestures.c
+++ b/demos/gtk-demo/gestures.c
@@ -7,7 +7,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
 static GtkGesture *rotate = NULL;
 static GtkGesture *zoom = NULL;
 static gdouble swipe_x = 0;
@@ -132,6 +131,7 @@ drawing_area_draw (GtkWidget *widget,
 GtkWidget *
 do_gestures (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *drawing_area;
   GtkGesture *gesture;
 
@@ -190,10 +190,7 @@ do_gestures (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/headerbar.c b/demos/gtk-demo/headerbar.c
index 64356c8..2bf99a2 100644
--- a/demos/gtk-demo/headerbar.c
+++ b/demos/gtk-demo/headerbar.c
@@ -58,14 +58,9 @@ do_headerbar (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index 7b541ea..28d605a 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -258,15 +258,14 @@ do_hypertext (GtkWidget *do_widget)
       regular_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_XTERM);
 
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
       gtk_window_set_screen (GTK_WINDOW (window),
                              gtk_widget_get_screen (do_widget));
-      gtk_window_set_default_size (GTK_WINDOW (window),
-                                   450, 450);
+      gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
 
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
 
-      gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
       gtk_container_set_border_width (GTK_CONTAINER (window), 0);
 
       view = gtk_text_view_new ();
@@ -293,14 +292,9 @@ do_hypertext (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c
index 199a343..67cdabb 100644
--- a/demos/gtk-demo/iconview.c
+++ b/demos/gtk-demo/iconview.c
@@ -328,10 +328,7 @@ do_iconview (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/iconview_edit.c b/demos/gtk-demo/iconview_edit.c
index 25bc80f..3d626fd 100644
--- a/demos/gtk-demo/iconview_edit.c
+++ b/demos/gtk-demo/iconview_edit.c
@@ -8,8 +8,6 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-static GtkWidget *window = NULL;
-
 enum
 {
   COL_TEXT,
@@ -100,6 +98,8 @@ edited (GtkCellRendererText *cell,
 GtkWidget *
 do_iconview_edit (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *icon_view;
@@ -152,10 +152,7 @@ do_iconview_edit (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/images.c b/demos/gtk-demo/images.c
index a36c8df..2561c7d 100644
--- a/demos/gtk-demo/images.c
+++ b/demos/gtk-demo/images.c
@@ -436,14 +436,9 @@ do_images (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/infobar.c b/demos/gtk-demo/infobar.c
index 7b0b575..b16ed1b 100644
--- a/demos/gtk-demo/infobar.c
+++ b/demos/gtk-demo/infobar.c
@@ -6,14 +6,13 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 static void
 on_bar_response (GtkInfoBar *info_bar,
                  gint        response_id,
                  gpointer    user_data)
 {
   GtkWidget *dialog;
+  GtkWidget *window;
 
   if (response_id == GTK_RESPONSE_CLOSE)
     {
@@ -21,6 +20,7 @@ on_bar_response (GtkInfoBar *info_bar,
       return;
     }
 
+  window = gtk_widget_get_toplevel (GTK_WIDGET (info_bar));
   dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                    GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                    GTK_MESSAGE_INFO,
@@ -40,6 +40,7 @@ on_bar_response (GtkInfoBar *info_bar,
 GtkWidget *
 do_infobar (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *frame;
   GtkWidget *bar;
   GtkWidget *vbox;
@@ -131,14 +132,9 @@ do_infobar (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/links.c b/demos/gtk-demo/links.c
index fa3075d..5a39a1a 100644
--- a/demos/gtk-demo/links.c
+++ b/demos/gtk-demo/links.c
@@ -44,11 +44,10 @@ activate_link (GtkWidget   *label,
   return FALSE;
 }
 
-static GtkWidget *window = NULL;
-
 GtkWidget *
 do_links (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *label;
 
   if (!window)
@@ -78,14 +77,9 @@ do_links (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/menus.c b/demos/gtk-demo/menus.c
index 9e69afa..86c435e 100644
--- a/demos/gtk-demo/menus.c
+++ b/demos/gtk-demo/menus.c
@@ -158,14 +158,9 @@ do_menus (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c
index 7c72194..433cad1 100644
--- a/demos/gtk-demo/offscreen_window.c
+++ b/demos/gtk-demo/offscreen_window.c
@@ -565,11 +565,11 @@ scale_changed (GtkRange      *range,
   gtk_rotated_bin_set_angle (bin, gtk_range_get_value (range));
 }
 
-static GtkWidget *window = NULL;
-
 GtkWidget *
 do_offscreen_window (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *bin, *vbox, *scale, *button;
@@ -603,10 +603,7 @@ do_offscreen_window (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c
index b327f71..50f77a2 100644
--- a/demos/gtk-demo/offscreen_window2.c
+++ b/demos/gtk-demo/offscreen_window2.c
@@ -468,11 +468,11 @@ gtk_mirror_bin_draw (GtkWidget *widget,
 
 /*** ***/
 
-static GtkWidget *window = NULL;
-
 GtkWidget *
 do_offscreen_window2 (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *bin, *vbox;
@@ -516,10 +516,7 @@ do_offscreen_window2 (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/overlay.c b/demos/gtk-demo/overlay.c
index f06da40..f6d67ed 100644
--- a/demos/gtk-demo/overlay.c
+++ b/demos/gtk-demo/overlay.c
@@ -77,14 +77,9 @@ do_overlay (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/pagesetup.c b/demos/gtk-demo/pagesetup.c
index 59709ab..f169bae 100644
--- a/demos/gtk-demo/pagesetup.c
+++ b/demos/gtk-demo/pagesetup.c
@@ -29,10 +29,7 @@ do_pagesetup (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c
index 97c7237..98cf8bc 100644
--- a/demos/gtk-demo/panes.c
+++ b/demos/gtk-demo/panes.c
@@ -192,14 +192,9 @@ do_panes (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/pickers.c b/demos/gtk-demo/pickers.c
index 46826b5..db8ee77 100644
--- a/demos/gtk-demo/pickers.c
+++ b/demos/gtk-demo/pickers.c
@@ -20,8 +20,7 @@ do_pickers (GtkWidget *do_widget)
     gtk_window_set_title (GTK_WINDOW (window), "Pickers");
 
     g_signal_connect (window, "destroy",
-                      G_CALLBACK (gtk_widget_destroyed),
-                      &window);
+                      G_CALLBACK (gtk_widget_destroyed), &window);
 
     gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
@@ -76,14 +75,9 @@ do_pickers (GtkWidget *do_widget)
   }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/pixbufs.c b/demos/gtk-demo/pixbufs.c
index d220b75..e4faae4 100644
--- a/demos/gtk-demo/pixbufs.c
+++ b/demos/gtk-demo/pixbufs.c
@@ -183,7 +183,6 @@ do_pixbufs (GtkWidget *do_widget)
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
 
-
       error = NULL;
       if (!load_pixbufs (&error))
         {
@@ -221,13 +220,10 @@ do_pixbufs (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
     {
       gtk_widget_destroy (window);
-      window = NULL;
       g_object_unref (frame);
     }
 
diff --git a/demos/gtk-demo/popover.c b/demos/gtk-demo/popover.c
index cb2c6b9..94c376b 100644
--- a/demos/gtk-demo/popover.c
+++ b/demos/gtk-demo/popover.c
@@ -176,10 +176,7 @@ do_popover (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/revealer.c b/demos/gtk-demo/revealer.c
index 703223a..23092d0 100644
--- a/demos/gtk-demo/revealer.c
+++ b/demos/gtk-demo/revealer.c
@@ -6,8 +6,8 @@
 
 #include <gtk/gtk.h>
 
-static GtkBuilder *builder;
 static gint count = 0;
+static guint timeout = 0;
 
 static void
 change_direction (GtkRevealer *revealer)
@@ -18,14 +18,15 @@ change_direction (GtkRevealer *revealer)
   gtk_revealer_set_reveal_child (revealer, !revealed);
 }
 
-static guint timeout = 0;
-
 static gboolean
 reveal_one (gpointer data)
 {
+  GtkWidget *window = data;
+  GtkBuilder *builder;
   gchar *name;
   GtkRevealer *revealer;
 
+  builder = GTK_BUILDER (g_object_get_data (G_OBJECT (window), "builder"));
   name = g_strdup_printf ("revealer%d", count);
   revealer = (GtkRevealer *)gtk_builder_get_object (builder, name);
 
@@ -44,53 +45,45 @@ reveal_one (gpointer data)
     return TRUE;
 }
 
+static GtkWidget *window = NULL;
+
 static void
-response_cb (GtkWidget *dialog,
-             gint       response_id,
-             gpointer   data)
+on_destroy (gpointer data)
 {
+  window = NULL;
   if (timeout != 0)
     {
       g_source_remove (timeout);
       timeout = 0;
     }
-  gtk_widget_destroy (dialog);
 }
 
 GtkWidget *
 do_revealer (GtkWidget *do_widget)
 {
-  static GtkWidget *window = NULL;
-  GError *err = NULL;
-
   if (!window)
     {
-      builder = gtk_builder_new ();
-      gtk_builder_add_from_resource (builder, "/revealer/revealer.ui", &err);
-      if (err)
-        {
-          g_error ("ERROR: %s\n", err->message);
-          return NULL;
-        }
+      GtkBuilder *builder;
+
+      builder = gtk_builder_new_from_resource ("/revealer/revealer.ui");
       gtk_builder_connect_signals (builder, NULL);
-      window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog1"));
+      window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
       gtk_window_set_screen (GTK_WINDOW (window),
                              gtk_widget_get_screen (do_widget));
       g_signal_connect (window, "destroy",
-                        G_CALLBACK (gtk_widget_destroyed), &window);
-      g_signal_connect (window, "response", G_CALLBACK (response_cb), NULL);
+                        G_CALLBACK (on_destroy), NULL);
+      g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
     }
 
   if (!gtk_widget_get_visible (window))
     {
       count = 0;
-      timeout = g_timeout_add (690, reveal_one, NULL);
+      timeout = g_timeout_add (690, reveal_one, window);
       gtk_widget_show_all (window);
     }
   else
     {
       gtk_widget_destroy (window);
-      window = NULL;
     }
 
 
diff --git a/demos/gtk-demo/revealer.ui b/demos/gtk-demo/revealer.ui
index f1cbac0..356b260 100644
--- a/demos/gtk-demo/revealer.ui
+++ b/demos/gtk-demo/revealer.ui
@@ -1,223 +1,177 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.6 -->
-  <object class="GtkDialog" id="dialog1">
-    <property name="can_focus">False</property>
+  <object class="GtkWindow" id="window">
     <property name="border_width">5</property>
-    <property name="type_hint">dialog</property>
     <property name="default_width">300</property>
     <property name="default_height">300</property>
     <property name="title">Revealer</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
+    <child>
+      <object class="GtkGrid">
+        <property name="visible">True</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <child>
+          <object class="GtkRevealer" id="revealer0">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">crossfade</property>
             <child>
-              <object class="GtkButton" id="button1">
-                <property name="label" translatable="yes">_Close</property>
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
+            <property name="left-attach">2</property>
+            <property name="top-attach">2</property>
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid1">
+          <object class="GtkRevealer" id="revealer1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="halign">center</property>
-            <property name="valign">center</property>
-            <child>
-              <object class="GtkRevealer" id="revealer0">
-                <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">crossfade</property>
-                <child>
-                  <object class="GtkImage" id="image0">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">2</property>
-              </packing>
-            </child>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-up</property>
             <child>
-              <object class="GtkRevealer" id="revealer1">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-up</property>
-                <child>
-                  <object class="GtkImage" id="image1">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">1</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer2">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-right</property>
             <child>
-              <object class="GtkRevealer" id="revealer2">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-right</property>
-                <child>
-                  <object class="GtkImage" id="image2">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">3</property>
-                <property name="top-attach">2</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">3</property>
+            <property name="top-attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer3">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
             <child>
-              <object class="GtkRevealer" id="revealer3">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-down</property>
-                <child>
-                  <object class="GtkImage" id="image3">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">3</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer4">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-left</property>
             <child>
-              <object class="GtkRevealer" id="revealer4">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-left</property>
-                <child>
-                  <object class="GtkImage" id="image4">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">2</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="top-attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer5">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-up</property>
             <child>
-              <object class="GtkRevealer" id="revealer5">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-up</property>
-                <child>
-                  <object class="GtkImage" id="image5">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">0</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer6">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-right</property>
             <child>
-              <object class="GtkRevealer" id="revealer6">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-right</property>
-                <child>
-                  <object class="GtkImage" id="image6">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">4</property>
-                <property name="top-attach">2</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">4</property>
+            <property name="top-attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer7">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
             <child>
-              <object class="GtkRevealer" id="revealer7">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-down</property>
-                <child>
-                  <object class="GtkImage" id="image7">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">4</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="revealer8">
+            <property name="visible">True</property>
+            <property name="transition-duration">2000</property>
+            <property name="transition-type">slide-left</property>
             <child>
-              <object class="GtkRevealer" id="revealer8">
+              <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="transition-duration">2000</property>
-                <property name="transition-type">slide-left</property>
-                <child>
-                  <object class="GtkImage" id="image8">
-                    <property name="visible">True</property>
-                    <property name="icon-name">face-cool-symbolic</property>
-                    <property name="icon-size">6</property>
-                  </object>
-                </child>
+                <property name="icon-name">face-cool-symbolic</property>
+                <property name="icon-size">6</property>
               </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">2</property>
-              </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="left-attach">0</property>
+            <property name="top-attach">2</property>
           </packing>
         </child>
       </object>
     </child>
-    <action-widgets>
-      <action-widget response="0">button1</action-widget>
-    </action-widgets>
   </object>
 </interface>
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index 8b4ecb2..6afe6ca 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -11,8 +11,6 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-static GtkWidget *window = NULL;
-
 #define HEART "♥"
 const char text[] = "I ♥ GTK+";
 
@@ -173,6 +171,8 @@ rotated_text_draw (GtkWidget *widget,
 GtkWidget *
 do_rotated_text (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *box;
@@ -186,7 +186,8 @@ do_rotated_text (GtkWidget *do_widget)
                              gtk_widget_get_screen (do_widget));
       gtk_window_set_title (GTK_WINDOW (window), "Rotated Text");
       gtk_window_set_default_size (GTK_WINDOW (window), 4 * RADIUS, 2 * RADIUS);
-      g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
+      g_signal_connect (window, "destroy",
+                        G_CALLBACK (gtk_widget_destroyed), &window);
 
       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
       gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
@@ -218,14 +219,9 @@ do_rotated_text (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c
index 5594118..3e61e2d 100644
--- a/demos/gtk-demo/search_entry.c
+++ b/demos/gtk-demo/search_entry.c
@@ -167,7 +167,7 @@ activate_cb (GtkEntry  *entry,
 }
 
 static void
-search_entry_destroyed (GtkWidget  *widget)
+search_entry_destroyed (GtkWidget *widget)
 {
   if (finish_search_id != 0)
     g_source_remove (finish_search_id);
@@ -210,34 +210,24 @@ entry_populate_popup (GtkEntry *entry,
 GtkWidget *
 do_search_entry (GtkWidget *do_widget)
 {
-  GtkWidget *content_area;
   GtkWidget *vbox;
   GtkWidget *hbox;
   GtkWidget *label;
   GtkWidget *entry;
-  GtkWidget *button;
   GtkWidget *find_button;
   GtkWidget *cancel_button;
 
   if (!window)
     {
-      window = gtk_dialog_new_with_buttons ("Search Entry",
-                                            GTK_WINDOW (do_widget),
-                                            0,
-                                            _("_Close"),
-                                            GTK_RESPONSE_NONE,
-                                            NULL);
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget));
+      gtk_window_set_title (GTK_WINDOW (window), "Search Entry");
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
-      g_signal_connect (window, "response",
-                        G_CALLBACK (gtk_widget_destroy), NULL);
       g_signal_connect (window, "destroy",
                         G_CALLBACK (search_entry_destroyed), &window);
 
-      content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
-
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-      gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
       gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
       label = gtk_label_new (NULL);
@@ -284,12 +274,9 @@ do_search_entry (GtkWidget *do_widget)
       gtk_menu_attach_to_widget (GTK_MENU (menu), entry, NULL);
 
       /* add accessible alternatives for icon functionality */
+      g_object_set (entry, "populate-all", TRUE, NULL);
       g_signal_connect (entry, "populate-popup",
                         G_CALLBACK (entry_populate_popup), NULL);
-
-      /* Give the focus to the close button */
-      button = gtk_dialog_get_widget_for_response (GTK_DIALOG (window), GTK_RESPONSE_NONE);
-      gtk_widget_grab_focus (button);
     }
 
   if (!gtk_widget_get_visible (window))
@@ -298,7 +285,6 @@ do_search_entry (GtkWidget *do_widget)
     {
       gtk_widget_destroy (menu);
       gtk_widget_destroy (window);
-      window = NULL;
     }
 
   return window;
diff --git a/demos/gtk-demo/search_entry2.c b/demos/gtk-demo/search_entry2.c
index 988eaac..b20cb13 100644
--- a/demos/gtk-demo/search_entry2.c
+++ b/demos/gtk-demo/search_entry2.c
@@ -8,14 +8,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
-static void
-search_entry_destroyed (GtkWidget  *widget)
-{
-  window = NULL;
-}
-
 static void
 search_changed_cb (GtkSearchEntry *entry,
                    GtkLabel       *result_label)
@@ -73,6 +65,7 @@ stop_search (GtkSearchEntry *entry,
 GtkWidget *
 do_search_entry2 (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *vbox;
   GtkWidget *hbox;
   GtkWidget *label;
@@ -90,7 +83,7 @@ do_search_entry2 (GtkWidget *do_widget)
       gtk_widget_set_size_request (window, 200, -1);
 
       g_signal_connect (window, "destroy",
-                        G_CALLBACK (search_entry_destroyed), &window);
+                        G_CALLBACK (gtk_widget_destroyed), &window);
 
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
       gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -164,10 +157,7 @@ do_search_entry2 (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/sidebar.c b/demos/gtk-demo/sidebar.c
index 61f4dcf..6830acc 100644
--- a/demos/gtk-demo/sidebar.c
+++ b/demos/gtk-demo/sidebar.c
@@ -9,11 +9,10 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 GtkWidget *
 do_sidebar (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *sidebar;
   GtkWidget *stack;
   GtkWidget *box;
diff --git a/demos/gtk-demo/sizegroup.c b/demos/gtk-demo/sizegroup.c
index d99cc8a..1a63924 100644
--- a/demos/gtk-demo/sizegroup.c
+++ b/demos/gtk-demo/sizegroup.c
@@ -16,8 +16,6 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 /* Convenience function to create a combo box holding a number of strings
  */
 GtkWidget *
@@ -48,12 +46,14 @@ add_row (GtkGrid      *table,
 
   label = gtk_label_new_with_mnemonic (label_text);
   gtk_widget_set_halign (label, GTK_ALIGN_START);
-  gtk_widget_set_valign (label, GTK_ALIGN_END);
+  gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
   gtk_widget_set_hexpand (label, TRUE);
   gtk_grid_attach (table, label, 0, row, 1, 1);
 
   combo_box = create_combo_box (options);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
+  gtk_widget_set_halign (combo_box, GTK_ALIGN_END);
+  gtk_widget_set_valign (combo_box, GTK_ALIGN_BASELINE);
   gtk_size_group_add_widget (size_group, combo_box);
   gtk_grid_attach (table, combo_box, 1, row, 1, 1);
 }
@@ -79,7 +79,7 @@ toggle_grouping (GtkToggleButton *check_button,
 GtkWidget *
 do_sizegroup (GtkWidget *do_widget)
 {
-  GtkWidget *content_area;
+  static GtkWidget *window = NULL;
   GtkWidget *table;
   GtkWidget *frame;
   GtkWidget *vbox;
@@ -95,28 +95,20 @@ do_sizegroup (GtkWidget *do_widget)
   };
 
   static const char *end_options[] = {
-    "Square", "Round", "Arrow", NULL
+    "Square", "Round", "Double Arrow", NULL
   };
 
   if (!window)
     {
-      window = gtk_dialog_new_with_buttons ("Size Groups",
-                                            GTK_WINDOW (do_widget),
-                                            0,
-                                            _("_Close"),
-                                            GTK_RESPONSE_NONE,
-                                            NULL);
+      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+      gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget));
+      gtk_window_set_title (GTK_WINDOW (window), "Size Groups");
       gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
-
-      g_signal_connect (window, "response",
-                        G_CALLBACK (gtk_widget_destroy), NULL);
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
 
-      content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
-
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-      gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+      gtk_container_add (GTK_CONTAINER (window), vbox);
       gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
 
       size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
diff --git a/demos/gtk-demo/spinner.c b/demos/gtk-demo/spinner.c
index c0690a6..c368c20 100644
--- a/demos/gtk-demo/spinner.c
+++ b/demos/gtk-demo/spinner.c
@@ -7,7 +7,6 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
 static GtkWidget *spinner_sensitive = NULL;
 static GtkWidget *spinner_unsensitive = NULL;
 
@@ -28,6 +27,7 @@ on_stop_clicked (GtkButton *button, gpointer user_data)
 GtkWidget *
 do_spinner (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
   GtkWidget *content_area;
   GtkWidget *vbox;
   GtkWidget *hbox;
diff --git a/demos/gtk-demo/stack.c b/demos/gtk-demo/stack.c
index d536187..6a82cb7 100644
--- a/demos/gtk-demo/stack.c
+++ b/demos/gtk-demo/stack.c
@@ -8,8 +8,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkBuilder *builder;
-
 GtkWidget *
 do_stack (GtkWidget *do_widget)
 {
@@ -17,6 +15,8 @@ do_stack (GtkWidget *do_widget)
 
   if (!window)
     {
+      GtkBuilder *builder;
+
       builder = gtk_builder_new_from_resource ("/stack/stack.ui");
       gtk_builder_connect_signals (builder, NULL);
       window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
@@ -24,17 +24,14 @@ do_stack (GtkWidget *do_widget)
                              gtk_widget_get_screen (do_widget));
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
+
+      g_object_unref (builder);
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show_all (window);
-    }
+    gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
 
   return window;
diff --git a/demos/gtk-demo/theming_style_classes.c b/demos/gtk-demo/theming_style_classes.c
index fa9cded..ad8db28 100644
--- a/demos/gtk-demo/theming_style_classes.c
+++ b/demos/gtk-demo/theming_style_classes.c
@@ -17,7 +17,6 @@ do_theming_style_classes (GtkWidget *do_widget)
 {
   GtkWidget *grid;
   GtkBuilder *builder;
-  GError *err = NULL;
 
   if (!window)
     {
@@ -29,13 +28,7 @@ do_theming_style_classes (GtkWidget *do_widget)
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
 
-      builder = gtk_builder_new ();
-      gtk_builder_add_from_resource (builder, "/theming_style_classes/theming.ui", NULL);
-      if (err)
-        {
-          g_error ("ERROR: %s\n", err->message);
-          return NULL;
-        }
+      builder = gtk_builder_new_from_resource ("/theming_style_classes/theming.ui");
 
       grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
       gtk_widget_show_all (grid);
@@ -44,14 +37,9 @@ do_theming_style_classes (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/transparent.c b/demos/gtk-demo/transparent.c
index ea685a1..f156ff2 100644
--- a/demos/gtk-demo/transparent.c
+++ b/demos/gtk-demo/transparent.c
@@ -196,8 +196,7 @@ do_transparent (GtkWidget *do_widget)
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_screen (GTK_WINDOW (window),
                              gtk_widget_get_screen (do_widget));
-      gtk_window_set_default_size (GTK_WINDOW (window),
-                                   450, 450);
+      gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
 
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
@@ -235,14 +234,9 @@ do_transparent (GtkWidget *do_widget)
     }
 
   if (!gtk_widget_get_visible (window))
-    {
-      gtk_widget_show (window);
-    }
+    gtk_widget_show (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }
diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c
index 3706e4d..228b21d 100644
--- a/demos/gtk-demo/tree_store.c
+++ b/demos/gtk-demo/tree_store.c
@@ -10,8 +10,6 @@
 
 #include <gtk/gtk.h>
 
-static GtkWidget *window = NULL;
-
 /* TreeItem structure */
 typedef struct _TreeItem TreeItem;
 struct _TreeItem
@@ -387,6 +385,8 @@ add_columns (GtkTreeView *treeview)
 GtkWidget *
 do_tree_store (GtkWidget *do_widget)
 {
+  static GtkWidget *window = NULL;
+
   if (!window)
     {
       GtkWidget *vbox;
@@ -440,10 +440,7 @@ do_tree_store (GtkWidget *do_widget)
   if (!gtk_widget_get_visible (window))
     gtk_widget_show_all (window);
   else
-    {
-      gtk_widget_destroy (window);
-      window = NULL;
-    }
+    gtk_widget_destroy (window);
 
   return window;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]