[cheese] Replace all GtkBoxes by GtkGrids, bug 664428



commit 4317b88eea3e5f7537a97a5e2714caf252a9f9d6
Author: Lucas Baudin <xapantu gmail com>
Date:   Sat Nov 26 10:32:13 2011 +0100

    Replace all GtkBoxes by GtkGrids, bug 664428

 data/cheese-main-window.ui        |  107 +++++++++++++++++++------------------
 data/cheese-prefs.ui              |   36 ++++---------
 libcheese/cheese-avatar-chooser.c |   47 +++++++---------
 src/cheese-window.vala            |    4 +-
 4 files changed, 88 insertions(+), 106 deletions(-)
---
diff --git a/data/cheese-main-window.ui b/data/cheese-main-window.ui
index d82f163..a435114 100644
--- a/data/cheese-main-window.ui
+++ b/data/cheese-main-window.ui
@@ -1,47 +1,53 @@
 <?xml version="1.0"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
-  <object class="GtkBox" id="mainbox_normal">
+  <object class="GtkGrid" id="mainbox_normal">
     <property name="orientation">vertical</property>
-    <property name="homogeneous">False</property>
     <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <child>
       <object class="GtkMenuBar" id="main_menubar" constructor="menu_ui_man">
       </object>
       <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
       </packing>
     </child>
     <child>
-      <object class="GtkBox" id="content_area">
+      <object class="GtkGrid" id="content_area">
+        <property name="vexpand">True</property>
+        <property name="hexpand">True</property>
         <property name="orientation">horizontal</property>
         <child>
-          <object class="GtkBox" id="view_area">
-            <property name="orientation">vertical</property>
+          <object class="GtkGrid" id="view_area">
             <child>
               <object class="GtkClutterEmbed" id="viewport">
+                <property name="vexpand">True</property>
+                <property name="hexpand">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK</property>
                 <property name="height_request">450</property>
                 <property name="width_request">600</property>
               </object>
+
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkAlignment" id="action_area_alignment">
                 <property name="left_padding">24</property>
                 <property name="right_padding">24</property>
+                <property name="hexpand">True</property>
                 <child>
-                  <object class="GtkBox" id="buttons_area">
+                  <object class="GtkGrid" id="buttons_area">
                     <property name="orientation">horizontal</property>
                     <child>
-                      <object class="GtkBox" id="mode_toggle_buttons">
-                        <property name="orientation">horizontal</property>
-                        <property name="homogeneous">True</property>
-                        <property name="spacing">2</property>
+                      <object class="GtkGrid" id="mode_toggle_buttons">
+                        <property name="column-spacing">2</property>
                         <child>
                           <object class="GtkToggleButton" id="photo_toggle_button">
                             <property name="related-action">photo_mode</property>
@@ -80,39 +86,33 @@
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
                       </packing>
                     </child>
                     <child>
                       <object class="GtkAlignment" id="action_button_alignment">
                         <property name="xscale">0</property>
                         <property name="yscale">0</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">False</property>
                         <child>
                           <object class="GtkButton" id="take_action_button">
-                            <property name="related-action">take_photo</property>
                             <property name="tooltip_text" translatable="yes">Take a photo</property>
                             <child>
-                              <object class="GtkBox" id="take_action_button_internal_hbox">
+                              <object class="GtkGrid" id="take_action_button_internal_hbox">
                                 <property name="orientation">horizontal</property>
-                                <property name="spacing">2</property>
+                                <property name="column-spacing">2</property>
                                 <child>
                                   <object class="GtkImage" id="take_action_button_internal_image">
                                     <property name="icon_name">gtk-media-record</property>
                                   </object>
-                                  <packing>
-                                    <property name="padding">2</property>
-                                  </packing>
                                 </child>
                                 <child>
                                   <object class="GtkLabel" id="take_action_button_internal_label">
                                     <property name="label" translatable="yes">_Take a Photo</property>
                                     <property name="use-underline">True</property>
                                     <property name="use-markup">True</property>
+                                    <property name="margin-left">15</property>
                                   </object>
-                                  <packing>
-                                    <property name="padding">15</property>
-                                  </packing>
                                 </child>
                               </object>
                             </child>
@@ -121,9 +121,9 @@
                       </object>
                     </child>
                     <child>
-                      <object class="GtkBox" id="effects_actions_pack">
+                      <object class="GtkGrid" id="effects_actions_pack">
                         <property name="orientation">horizontal</property>
-                        <property name="spacing">0</property>
+                        <property name="column-spacing">0</property>
                         <child>
                           <object class="GtkButton" id="effects_prev_page_button">
                             <property name="related-action">effects_page_prev</property>
@@ -139,13 +139,15 @@
                         </child>
                         <child>
                           <object class="GtkToggleButton" id="effects_toggle_button">
+                            <property name="vexpand">False</property>
+                            <property name="hexpand">False</property>
                             <property name="related-action">effects_toggle</property>
                             <property name="tooltip_text" translatable="yes">Effects</property>
                             <child>
-                              <object class="GtkBox" id="effects_toggle_button_internal_hbox">
+                              <object class="GtkGrid" id="effects_toggle_button_internal_hbox">
                                 <property name="orientation">horizontal</property>
                                 <property name="visible">True</property>
-                                <property name="spacing">2</property>
+                                <property name="column-spacing">2</property>
                                 <child>
                                   <object class="GtkImage" id="effects_toggle_button_internal_image">
                                     <property name="icon_name">browse-webcam-effects</property>
@@ -160,10 +162,6 @@
                               </object>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkButton" id="effects_next_page_button">
@@ -179,25 +177,22 @@
                           </object>
                         </child>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                      </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="leave_fullscreen_button_bin">
+                      <object class="GtkGrid" id="leave_fullscreen_button_bin">
                         <property name="orientation">horizontal</property>
                         <property name="visible">False</property>
                         <property name="no-show-all">True</property>
+                        <property name="hexpand">False</property>
                         <child>
                           <object class="GtkButton" id="leave_fullscreen_button">
                             <property name="use-action-appearance">False</property>
                             <property name="related-action">fullscreen</property>
                             <property name="tooltip_text" translatable="yes">Leave fullscreen</property>
                             <child>
-                              <object class="GtkBox" id="fullscreen_button_internal_hbox">
+                              <object class="GtkGrid" id="fullscreen_button_internal_hbox">
                                 <property name="orientation">horizontal</property>
-                                <property name="spacing">2</property>
+                                <property name="column-spacing">2</property>
                                 <child>
                                   <object class="GtkImage" id="fullscreen_button_internal_image">
                                     <property name="stock">gtk-leave-fullscreen</property>
@@ -214,44 +209,50 @@
                           </object>
                         </child>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                      </packing>
                     </child>
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">4</property>
-              </packing>
+      <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+      </packing>
             </child>
           </object>
         </child>
         <child>
           <object class="GtkAlignment" id="thumbnails_right">
             <property name="visible">False</property>
+            <property name="vexpand">False</property>
             <child>
               <placeholder/>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-          </packing>
         </child>
       </object>
+
+      <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+      </packing>
     </child>
     <child>
       <object class="GtkAlignment" id="thumbnails_bottom">
         <property name="visible">False</property>
+        <property name="vexpand">False</property>
         <child>
           <placeholder/>
         </child>
       </object>
       <packing>
-        <property name="expand">False</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
       </packing>
     </child>
   </object>
diff --git a/data/cheese-prefs.ui b/data/cheese-prefs.ui
index abcef56..d5df3cd 100644
--- a/data/cheese-prefs.ui
+++ b/data/cheese-prefs.ui
@@ -322,12 +322,11 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="box1">
+              <object class="GtkGrid" id="box1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="border_width">12</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">18</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">12</property>
                 <child>
                   <object class="GtkGrid" id="grid4">
                     <property name="visible">True</property>
@@ -391,26 +390,12 @@
                         <property name="height">1</property>
                       </packing>
                     </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -511,9 +496,10 @@
                     </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">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
                   </packing>
                 </child>
               </object>
diff --git a/libcheese/cheese-avatar-chooser.c b/libcheese/cheese-avatar-chooser.c
index 2cc900a..99e26d5 100644
--- a/libcheese/cheese-avatar-chooser.c
+++ b/libcheese/cheese-avatar-chooser.c
@@ -217,37 +217,32 @@ create_page (GtkWidget *child,
              GtkWidget *button,
              GtkWidget *extra)
 {
-  GtkWidget *vbox, *hbox, *align;
-
-  vbox = gtk_vbox_new (FALSE, 8);
-  gtk_box_pack_start (GTK_BOX (vbox),
-                      child,
-                      TRUE,
-                      TRUE,
-                      0);
+  GtkWidget *vgrid, *hgrid, *align;
+
+  vgrid = gtk_grid_new ();
+  gtk_grid_attach (GTK_GRID (vgrid),
+                   child, 0, 0, 1, 1);
+  gtk_widget_set_hexpand (child, TRUE);
+  gtk_widget_set_vexpand (child, TRUE);
   align = gtk_alignment_new (0.5, 0, 0, 0);
-  gtk_box_pack_start (GTK_BOX (vbox),
-                      align,
-                      FALSE,
-                      TRUE,
-                      0);
-  hbox = gtk_hbox_new (FALSE, 8);
-  gtk_container_add(GTK_CONTAINER(align), hbox);
-  gtk_box_pack_start (GTK_BOX (hbox),
-                      button,
-                      FALSE,
-                      TRUE,
-                      0);
+  gtk_widget_set_valign (align, GTK_ALIGN_END);
+  gtk_grid_attach (GTK_GRID (vgrid),
+                   align, 0, 1, 1, 1);
+  hgrid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (hgrid), 8);
+  gtk_container_add(GTK_CONTAINER(align), hgrid);
+  gtk_grid_attach (GTK_GRID (hgrid),
+                   button, 0, 0, 1, 1);
+  gtk_widget_set_halign (button, GTK_ALIGN_START);
   if (extra != NULL)
   {
-    gtk_box_pack_start (GTK_BOX (hbox),
-                        extra,
-                        TRUE,
-                        TRUE,
-                        0);
+    gtk_grid_attach (GTK_GRID (hgrid),
+                     extra, 1, 0, 1, 1);
+    gtk_widget_set_hexpand (extra, TRUE);
+    gtk_widget_set_vexpand (extra, TRUE);
   }
 
-  return vbox;
+  return vgrid;
 }
 
 static void
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index f9ea127..415d945 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -43,7 +43,7 @@ public class Cheese.MainWindow : Gtk.Window
 
   private Gtk.Widget       thumbnails;
   private GtkClutter.Embed viewport_widget;
-  private Gtk.Box          main_vbox;
+  private Gtk.Grid          main_vbox;
   private Eog.ThumbNav     thumb_nav;
   private Cheese.ThumbView thumb_view;
   private Gtk.Alignment    thumbnails_right;
@@ -1351,7 +1351,7 @@ public class Cheese.MainWindow : Gtk.Window
       error ("Error: %s", err.message);
     }
 
-    main_vbox                         = gtk_builder.get_object ("mainbox_normal") as Gtk.Box;
+    main_vbox                         = gtk_builder.get_object ("mainbox_normal") as Gtk.Grid;
     thumbnails                        = gtk_builder.get_object ("thumbnails") as Gtk.Widget;
     viewport_widget                   = gtk_builder.get_object ("viewport") as GtkClutter.Embed;
     viewport                          = viewport_widget.get_stage () as Clutter.Stage;



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