[gtk+] gtk-demo: Drop uses of GtkAlignment



commit c5cd4174c3010a1199bb6797610708b387a23034
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 1 13:27:14 2011 -0400

    gtk-demo: Drop uses of GtkAlignment

 demos/gtk-demo/assistant.c     |   17 +++++++----------
 demos/gtk-demo/images.c        |   37 ++++++++++++-------------------------
 demos/gtk-demo/stock_browser.c |   11 ++++-------
 demos/gtk-demo/textview.c      |    8 +++-----
 4 files changed, 26 insertions(+), 47 deletions(-)
---
diff --git a/demos/gtk-demo/assistant.c b/demos/gtk-demo/assistant.c
index c95fa02..5d7a460 100644
--- a/demos/gtk-demo/assistant.c
+++ b/demos/gtk-demo/assistant.c
@@ -147,22 +147,19 @@ create_page3 (GtkWidget *assistant)
 static void
 create_page4 (GtkWidget *assistant)
 {
-  GtkWidget *page;
-
-  page = gtk_alignment_new (0.5, 0.5, 0.5, 0.0);
-
   progress_bar = gtk_progress_bar_new ();
-  gtk_container_add (GTK_CONTAINER (page), progress_bar);
+  gtk_widget_set_halign (progress_bar, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (progress_bar, GTK_ALIGN_CENTER);
 
-  gtk_widget_show_all (page);
-  gtk_assistant_append_page (GTK_ASSISTANT (assistant), page);
-  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_PROGRESS);
-  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Applying changes");
+  gtk_widget_show (progress_bar);
+  gtk_assistant_append_page (GTK_ASSISTANT (assistant), progress_bar);
+  gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), progress_bar, GTK_ASSISTANT_PAGE_PROGRESS);
+  gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), progress_bar, "Applying changes");
 
   /* This prevents the assistant window from being
    * closed while we're "busy" applying changes.
    */
-  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, FALSE);
+  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), progress_bar, FALSE);
 }
 
 GtkWidget*
diff --git a/demos/gtk-demo/images.c b/demos/gtk-demo/images.c
index 203deae..228d04e 100644
--- a/demos/gtk-demo/images.c
+++ b/demos/gtk-demo/images.c
@@ -314,7 +314,6 @@ do_images (GtkWidget *do_widget)
   GtkWidget *vbox;
   GtkWidget *image;
   GtkWidget *label;
-  GtkWidget *align;
   GtkWidget *button;
   GdkPixbuf *pixbuf;
   GIcon     *gicon;
@@ -346,12 +345,9 @@ do_images (GtkWidget *do_widget)
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-      /* The alignment keeps the frame from growing when users resize
-       * the window
-       */
-      align = gtk_alignment_new (0.5, 0.5, 0, 0);
-      gtk_container_add (GTK_CONTAINER (align), frame);
-      gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
+      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
+      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       /* demo_find_file() looks in the current directory first,
        * so you can run gtk-demo without installing GTK, then looks
@@ -403,12 +399,9 @@ do_images (GtkWidget *do_widget)
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-      /* The alignment keeps the frame from growing when users resize
-       * the window
-       */
-      align = gtk_alignment_new (0.5, 0.5, 0, 0);
-      gtk_container_add (GTK_CONTAINER (align), frame);
-      gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
+      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
+      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       filename = demo_find_file ("floppybuddy.gif", NULL);
       image = gtk_image_new_from_file (filename);
@@ -425,12 +418,9 @@ do_images (GtkWidget *do_widget)
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-      /* The alignment keeps the frame from growing when users resize
-       * the window
-       */
-      align = gtk_alignment_new (0.5, 0.5, 0, 0);
-      gtk_container_add (GTK_CONTAINER (align), frame);
-      gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
+      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
+      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       gicon = g_themed_icon_new_with_default_fallbacks ("battery-caution-charging-symbolic");
       image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_DIALOG);
@@ -447,12 +437,9 @@ do_images (GtkWidget *do_widget)
 
       frame = gtk_frame_new (NULL);
       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-      /* The alignment keeps the frame from growing when users resize
-       * the window
-       */
-      align = gtk_alignment_new (0.5, 0.5, 0, 0);
-      gtk_container_add (GTK_CONTAINER (align), frame);
-      gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
+      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
+      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       /* Create an empty image for now; the progressive loader
        * will create the pixbuf and fill it in.
diff --git a/demos/gtk-demo/stock_browser.c b/demos/gtk-demo/stock_browser.c
index d0d3442..78bf1f9 100644
--- a/demos/gtk-demo/stock_browser.c
+++ b/demos/gtk-demo/stock_browser.c
@@ -393,7 +393,7 @@ label_set_func (GtkTreeViewColumn *tree_column,
 
 GtkWidget *
 do_stock_browser (GtkWidget *do_widget)
-{  
+{
   if (!window)
     {
       GtkWidget *frame;
@@ -401,7 +401,6 @@ do_stock_browser (GtkWidget *do_widget)
       GtkWidget *hbox;
       GtkWidget *sw;
       GtkWidget *treeview;
-      GtkWidget *align;
       GtkTreeModel *model;
       GtkCellRenderer *cell_renderer;
       StockItemDisplay *display;
@@ -479,12 +478,10 @@ do_stock_browser (GtkWidget *do_widget)
                                                   id_set_func,
                                                   NULL,
                                                   NULL);
-      
-      align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
-      gtk_box_pack_end (GTK_BOX (hbox), align, FALSE, FALSE, 0);
-      
+
       frame = gtk_frame_new ("Selected Item");
-      gtk_container_add (GTK_CONTAINER (align), frame);
+      gtk_widget_set_valign (frame, GTK_ALIGN_START);
+      gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
 
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
       gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index 21da68d..b942574 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -561,7 +561,6 @@ recursive_attach_view (int                 depth,
   GtkWidget *child_view;
   GtkWidget *event_box;
   GdkRGBA color;
-  GtkWidget *align;
 
   if (depth > 4)
     return;
@@ -573,11 +572,10 @@ recursive_attach_view (int                 depth,
   gdk_rgba_parse (&color, "black");
   gtk_widget_override_background_color (event_box, 0, &color);
 
-  align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-  gtk_container_set_border_width (GTK_CONTAINER (align), 1);
+  gtk_widget_set_halign (child_view, GTK_ALIGN_FILL);
+  gtk_widget_set_valign (child_view, GTK_ALIGN_FILL);
 
-  gtk_container_add (GTK_CONTAINER (event_box), align);
-  gtk_container_add (GTK_CONTAINER (align), child_view);
+  gtk_container_add (GTK_CONTAINER (event_box), child_view);
 
   gtk_text_view_add_child_at_anchor (view, event_box, anchor);
 



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