[latexila/gnome-3] GtkGrid migration: side panel



commit ff4f27dabc891aedc6e976ba951e266aa3f7e983
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Sat Oct 22 03:10:49 2011 +0200

    GtkGrid migration: side panel

 src/file_browser.vala |   25 +++++++++++++++----------
 src/side_panel.vala   |   28 ++++++++++++++++------------
 src/structure.vala    |   34 +++++++++++++++++++---------------
 src/symbols.vala      |   11 +++++++----
 4 files changed, 57 insertions(+), 41 deletions(-)
---
diff --git a/src/file_browser.vala b/src/file_browser.vala
index 6ec58c1..50791b5 100644
--- a/src/file_browser.vala
+++ b/src/file_browser.vala
@@ -19,7 +19,7 @@
 
 using Gtk;
 
-public class FileBrowser : VBox
+public class FileBrowser : Grid
 {
     private enum ParentDirColumn
     {
@@ -52,7 +52,9 @@ public class FileBrowser : VBox
 
     public FileBrowser (MainWindow main_window)
     {
-        GLib.Object (spacing: 3);
+//        GLib.Object (spacing: 3);
+        row_spacing = 3;
+        orientation = Orientation.VERTICAL;
         this.main_window = main_window;
         this.build_view = main_window.get_build_view ();
 
@@ -94,8 +96,10 @@ public class FileBrowser : VBox
 
     private void init_toolbar ()
     {
-        HBox hbox = new HBox (true, 0);
-        pack_start (hbox, false, false);
+        Grid grid = new Grid ();
+        grid.set_orientation (Orientation.HORIZONTAL);
+        grid.column_homogeneous = true;
+        add (grid);
 
         Button home_button = Utils.get_toolbar_button (Stock.HOME);
         parent_button = Utils.get_toolbar_button (Stock.GO_UP);
@@ -107,10 +111,10 @@ public class FileBrowser : VBox
         jump_button.tooltip_text = _("Go to the active document directory");
         refresh_button.tooltip_text = _("Refresh");
 
-        hbox.pack_start (home_button);
-        hbox.pack_start (parent_button);
-        hbox.pack_start (jump_button);
-        hbox.pack_start (refresh_button);
+        grid.add (home_button);
+        grid.add (parent_button);
+        grid.add (jump_button);
+        grid.add (refresh_button);
 
         home_button.clicked.connect (() =>
         {
@@ -167,7 +171,7 @@ public class FileBrowser : VBox
             typeof (File));
 
         combo_box = new ComboBox.with_model (parent_dir_store);
-        pack_start (combo_box, false, false);
+        add (combo_box);
 
         // indentation
         CellRendererText text_renderer = new CellRendererText ();
@@ -233,7 +237,8 @@ public class FileBrowser : VBox
 
         // with a scrollbar
         Widget sw = Utils.add_scrollbar (_list_view);
-        pack_start (sw);
+        sw.expand = true;
+        add (sw);
 
         _list_view.row_activated.connect ((path) =>
         {
diff --git a/src/side_panel.vala b/src/side_panel.vala
index 27608a3..a71c981 100644
--- a/src/side_panel.vala
+++ b/src/side_panel.vala
@@ -19,34 +19,38 @@
 
 using Gtk;
 
-public class SidePanel : VBox
+public class SidePanel : Grid
 {
     private unowned MainWindow main_window;
     private unowned ToggleAction action_view_side_panel;
 
-    private VBox[] components;
+    private Grid[] components;
     private ComboBox combo_box;
     private ListStore list_store;
 
     public SidePanel (MainWindow main_window, ToggleAction action_view_side_panel)
     {
+        orientation = Orientation.VERTICAL;
         this.main_window = main_window;
         this.action_view_side_panel = action_view_side_panel;
 
-        HBox hbox = new HBox (false, 3);
-        hbox.border_width = 3;
-        pack_start (hbox, false, false, 3);
+        Grid grid = new Grid ();
+        grid.set_orientation (Orientation.HORIZONTAL);
+        grid.column_spacing = 3;
+        grid.border_width = 3;
+        add (grid);
 
         combo_box = get_combo_box ();
-        hbox.pack_start (combo_box);
-        hbox.pack_start (get_close_button (), false, false);
+        combo_box.set_hexpand (true);
+        grid.add (combo_box);
+        grid.add (get_close_button ());
         show_all ();
 
         show.connect (show_active_component);
         hide.connect (hide_all_components);
     }
 
-    public void add_component (string name, string stock_id, VBox component)
+    public void add_component (string name, string stock_id, Grid component)
     {
         TreeIter iter;
         list_store.append (out iter);
@@ -55,7 +59,7 @@ public class SidePanel : VBox
             SidePanelColumn.NAME, name,
             -1);
 
-        pack_start (component);
+        add (component);
         components += component;
     }
 
@@ -118,7 +122,7 @@ public class SidePanel : VBox
 
     private void hide_all_components ()
     {
-        foreach (VBox component in components)
+        foreach (Grid component in components)
             component.hide ();
     }
 
@@ -126,7 +130,7 @@ public class SidePanel : VBox
     {
         hide_all_components ();
 
-        int i = get_active_component ();
-            components[i].show ();
+        int active = get_active_component ();
+            components[active].show ();
     }
 }
diff --git a/src/structure.vala b/src/structure.vala
index 378b9b0..760c232 100644
--- a/src/structure.vala
+++ b/src/structure.vala
@@ -55,7 +55,7 @@ public enum StructAction
     NB_ACTIONS
 }
 
-public class Structure : VBox
+public class Structure : Grid
 {
     private unowned MainWindow _main_window;
     private Menu _popup_menu;
@@ -89,7 +89,9 @@ public class Structure : VBox
 
     public Structure (MainWindow main_window, UIManager ui_manager)
     {
-        GLib.Object (spacing: 3);
+//        GLib.Object (spacing: 3);
+        orientation = Orientation.VERTICAL;
+        row_spacing = 3;
         _main_window = main_window;
 
         _popup_menu = (Menu) ui_manager.get_widget ("/StructurePopup");
@@ -120,13 +122,14 @@ public class Structure : VBox
 
     private void init_toolbar ()
     {
-        HBox hbox = new HBox (false, 0);
-        pack_start (hbox, false, false);
+        Grid grid = new Grid ();
+        grid.set_orientation (Orientation.HORIZONTAL);
+        add (grid);
 
         // refresh button
         Button refresh_button = Utils.get_toolbar_button (Stock.REFRESH);
         refresh_button.tooltip_text = _("Refresh");
-        hbox.pack_start (refresh_button);
+        grid.add (refresh_button);
 
         refresh_button.clicked.connect (() =>
         {
@@ -135,46 +138,46 @@ public class Structure : VBox
 
         // separator
         SeparatorToolItem sep = new SeparatorToolItem ();
-        hbox.pack_start (sep, false);
+        grid.add (sep);
 
         // expand all button
         Button expand_button = Utils.get_toolbar_button (Stock.ZOOM_IN);
         expand_button.tooltip_text = _("Expand All");
-        hbox.pack_start (expand_button);
+        grid.add (expand_button);
 
         expand_button.clicked.connect (() => _tree_view.expand_all ());
 
         // collapse all button
         Button collapse_button = Utils.get_toolbar_button (Stock.ZOOM_OUT);
         collapse_button.tooltip_text = _("Collapse All");
-        hbox.pack_start (collapse_button);
+        grid.add (collapse_button);
 
         collapse_button.clicked.connect (() => _tree_view.collapse_all ());
 
         // separator
         sep = new SeparatorToolItem ();
-        hbox.pack_start (sep, false);
+        grid.add (sep);
 
         // simple list buttons
         ToggleButton toggle_button = create_simple_list_button ({ StructType.LABEL },
             _("Show labels"));
-        hbox.pack_start (toggle_button);
+        grid.add (toggle_button);
 
         toggle_button = create_simple_list_button ({ StructType.INCLUDE },
             _("Show files included"));
-        hbox.pack_start (toggle_button);
+        grid.add (toggle_button);
 
         toggle_button = create_simple_list_button ({ StructType.TABLE },
             _("Show tables"));
-        hbox.pack_start (toggle_button);
+        grid.add (toggle_button);
 
         toggle_button = create_simple_list_button (
             { StructType.FIGURE, StructType.IMAGE }, _("Show figures and images"));
-        hbox.pack_start (toggle_button);
+        grid.add (toggle_button);
 
         toggle_button = create_simple_list_button ({ StructType.TODO, StructType.FIXME },
             _("Show TODOs and FIXMEs"));
-        hbox.pack_start (toggle_button);
+        grid.add (toggle_button);
     }
 
     // Only one button can be activated at the same time.
@@ -250,7 +253,8 @@ public class Structure : VBox
     private void init_vpaned ()
     {
         _vpaned = new VPaned ();
-        pack_start (_vpaned);
+        _vpaned.expand = true;
+        add (_vpaned);
 
         GLib.Settings settings = new GLib.Settings ("org.gnome.latexila.state.window");
         _vpaned.set_position (settings.get_int ("structure-paned-position"));
diff --git a/src/symbols.vala b/src/symbols.vala
index f76717d..314372f 100644
--- a/src/symbols.vala
+++ b/src/symbols.vala
@@ -19,7 +19,7 @@
 
 using Gtk;
 
-public class Symbols : VBox
+public class Symbols : Grid
 {
     private const CategoryInfo[] categories =
     {
@@ -765,6 +765,7 @@ public class Symbols : VBox
             stores_initialized = true;
         }
 
+        orientation = Orientation.VERTICAL;
         this.main_window = main_window;
         create_icon_views ();
     }
@@ -781,7 +782,7 @@ public class Symbols : VBox
         categories_view.row_spacing = 0;
         categories_view.column_spacing = 0;
 
-        pack_start (categories_view, false, false, 0);
+        add (categories_view);
         categories_view.show ();
 
         /* show the symbols */
@@ -794,12 +795,14 @@ public class Symbols : VBox
         symbol_view.column_spacing = 0;
 
         Widget sw = Utils.add_scrollbar (symbol_view);
-        pack_start (sw);
+        sw.expand = true;
+        add (sw);
         sw.show_all ();
 
         /* clear button (for most used symbols) */
         Button button = new Button.from_stock (Stock.CLEAR);
-        pack_start (button, false, false, 2);
+        button.margin = 2;
+        add (button);
 
         /* signals */
         button.clicked.connect (() =>



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