[gnome-panel/features/layout-using-gtkgrid: 1/2] panel: replace gtktable with gtkgrid in panel-toplevel.c



commit 4591243c81b079d7bddab17656fcc817ce798c65
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Nov 18 23:31:18 2013 +0200

    panel: replace gtktable with gtkgrid in panel-toplevel.c

 gnome-panel/panel-toplevel.c |   56 ++++++++++++-----------------------------
 1 files changed, 17 insertions(+), 39 deletions(-)
---
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index 16599cb..569b312 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -147,7 +147,7 @@ struct _PanelToplevelPrivate {
 
        PanelWidget            *panel_widget;
        PanelFrame             *inner_frame;
-       GtkWidget              *table;
+       GtkWidget              *grid;
        GtkWidget              *hide_button_top;
        GtkWidget              *hide_button_bottom;
        GtkWidget              *hide_button_left;
@@ -1257,10 +1257,8 @@ panel_toplevel_hide_button_clicked (PanelToplevel *toplevel,
 static GtkWidget *
 panel_toplevel_add_hide_button (PanelToplevel *toplevel,
                                GtkArrowType   arrow_type,
-                               int            left_attach,
-                               int            right_attach,
-                               int            top_attach,
-                               int            bottom_attach)
+                               int            left,
+                               int            top)
 {
        GtkWidget *button;
        AtkObject *obj;
@@ -1309,17 +1307,8 @@ panel_toplevel_add_hide_button (PanelToplevel *toplevel,
                                  G_CALLBACK (panel_toplevel_hide_button_event), toplevel);
        g_signal_connect_swapped (button, "button_release_event",
                                  G_CALLBACK (panel_toplevel_hide_button_event), toplevel);
-                                 
-       gtk_table_attach (GTK_TABLE (toplevel->priv->table),
-                         button,
-                         left_attach,
-                         right_attach,
-                         top_attach,
-                         bottom_attach,
-                         GTK_FILL,
-                         GTK_FILL,
-                         0,
-                         0);
+
+       gtk_grid_attach (GTK_GRID (toplevel->priv->grid), button, left, top, 1, 1);
 
        return button;
 }
@@ -4193,19 +4182,12 @@ panel_toplevel_setup_widgets (PanelToplevel *toplevel)
 {
        GtkWidget *container;
 
-       toplevel->priv->table = gtk_table_new (3, 3, FALSE);
-
-       toplevel->priv->hide_button_top =
-               panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP,    1, 2, 0, 1);
-
-       toplevel->priv->hide_button_bottom =
-               panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN,  1, 2, 2, 3);
+       toplevel->priv->grid = gtk_grid_new ();
 
-       toplevel->priv->hide_button_left =
-               panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT,  0, 1, 1, 2);
-
-       toplevel->priv->hide_button_right =
-               panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 3, 1, 2);
+       toplevel->priv->hide_button_top    = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP,    1, 0);
+       toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN,  1, 2);
+       toplevel->priv->hide_button_left   = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT,  0, 1);
+       toplevel->priv->hide_button_right  = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
 
        if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
                gtk_widget_show (toplevel->priv->hide_button_left);
@@ -4217,13 +4199,10 @@ panel_toplevel_setup_widgets (PanelToplevel *toplevel)
 
        toplevel->priv->inner_frame = g_object_new (PANEL_TYPE_FRAME, NULL);
 
-       gtk_table_attach (GTK_TABLE (toplevel->priv->table),
-                         GTK_WIDGET (toplevel->priv->inner_frame),
-                         1, 2,
-                         1, 2,
-                         GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-                         GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-                         0, 0);
+       gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame), TRUE);
+       gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame), TRUE);
+
+       gtk_grid_attach (GTK_GRID (toplevel->priv->grid), GTK_WIDGET (toplevel->priv->inner_frame), 1, 1, 1, 
1);
        gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame));
 
        container = panel_widget_new (toplevel,
@@ -4238,9 +4217,8 @@ panel_toplevel_setup_widgets (PanelToplevel *toplevel)
        gtk_container_add (GTK_CONTAINER (toplevel->priv->inner_frame), container);
        gtk_widget_show (container);
 
-       gtk_container_add (GTK_CONTAINER (toplevel), toplevel->priv->table);
-       gtk_widget_show (toplevel->priv->table);
-
+       gtk_container_add (GTK_CONTAINER (toplevel), toplevel->priv->grid);
+       gtk_widget_show (toplevel->priv->grid);
 }
 
 static void
@@ -4307,7 +4285,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
 
        toplevel->priv->panel_widget       = NULL;
        toplevel->priv->inner_frame        = NULL;
-       toplevel->priv->table              = NULL;
+       toplevel->priv->grid               = NULL;
        toplevel->priv->hide_button_top    = NULL;
        toplevel->priv->hide_button_bottom = NULL;
        toplevel->priv->hide_button_left   = NULL;


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