[gnome-panel/features/modernize-for-gnome-3-12: 1/11] panel: replace gtktable with gtkgrid in panel-ditem-editor.c



commit 387b53f0ffb3c9361b1bc1ca4cdf9840a818d244
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Nov 17 15:36:37 2013 +0200

    panel: replace gtktable with gtkgrid in panel-ditem-editor.c

 gnome-panel/panel-ditem-editor.c |  105 +++++++++++++-------------------------
 1 files changed, 35 insertions(+), 70 deletions(-)
---
diff --git a/gnome-panel/panel-ditem-editor.c b/gnome-panel/panel-ditem-editor.c
index c0db79d..5e5c60f 100644
--- a/gnome-panel/panel-ditem-editor.c
+++ b/gnome-panel/panel-ditem-editor.c
@@ -60,7 +60,7 @@ struct _PanelDItemEditorPrivate
        PanelDitemSaveUri save_uri;
        gpointer          save_uri_data;
 
-       GtkWidget *table;
+       GtkWidget *grid;
        GtkWidget *type_label;
        GtkWidget *type_combo;
        GtkWidget *name_label;
@@ -507,29 +507,16 @@ label_new_with_mnemonic (const char *text)
 }
 
 static inline void
-table_attach_label (GtkTable  *table,
-                   GtkWidget *label,
-                   int        left,
-                   int        right,
-                   int        top,
-                   int        bottom)
+grid_attach_label (GtkGrid *grid, GtkWidget *label, int left, int top, int width, int height)
 {
-       gtk_table_attach (table, label, left, right, top, bottom,
-                         GTK_FILL, GTK_FILL,
-                         0, 0);
+       gtk_grid_attach (grid, label, left, top, width, height);
 }
 
 static inline void
-table_attach_entry (GtkTable  *table,
-                   GtkWidget *entry,
-                   int        left,
-                   int        right,
-                   int        top,
-                   int        bottom)
+grid_attach_entry (GtkGrid *grid, GtkWidget *entry, int left, int top, int width, int height)
 {
-       gtk_table_attach (table, entry, left, right, top, bottom,
-                         GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL,
-                         0, 0);
+       gtk_widget_set_hexpand (entry, TRUE);
+       gtk_grid_attach (grid, entry, left, top, width, height);
 }
 
 static void
@@ -603,13 +590,12 @@ panel_ditem_editor_make_ui (PanelDItemEditor *dialog)
        dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
        gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
 
-       priv->table = gtk_table_new (4, 3, FALSE);
-       gtk_container_set_border_width (GTK_CONTAINER (priv->table), 5);
-       gtk_table_set_row_spacings (GTK_TABLE (priv->table), 6);
-       gtk_table_set_col_spacings (GTK_TABLE (priv->table), 12);
-       gtk_box_pack_start (GTK_BOX (dialog_vbox),
-                           priv->table, TRUE, TRUE, 0);
-       gtk_widget_show (priv->table);
+       priv->grid = gtk_grid_new ();
+       gtk_container_set_border_width (GTK_CONTAINER (priv->grid), 5);
+       gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6);
+       gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 12);
+       gtk_box_pack_start (GTK_BOX (dialog_vbox), priv->grid, TRUE, TRUE, 0);
+       gtk_widget_show (priv->grid);
 
        /* Type */
        priv->type_label = label_new_with_mnemonic (_("_Type:"));
@@ -629,9 +615,7 @@ panel_ditem_editor_make_ui (PanelDItemEditor *dialog)
        priv->icon_chooser = panel_icon_chooser_new (NULL);
        panel_icon_chooser_set_fallback_icon_name (PANEL_ICON_CHOOSER (priv->icon_chooser),
                                                   PANEL_ICON_LAUNCHER);
-       gtk_table_attach (GTK_TABLE (priv->table), priv->icon_chooser,
-                         0, 1, 0, 2,
-                         0, 0, 0, 0);
+       gtk_grid_attach (GTK_GRID (priv->grid), priv->icon_chooser, 0, 0, 1, 2);
        gtk_widget_show (priv->icon_chooser);
 
        /* Command */
@@ -725,25 +709,17 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
                GtkTreeModel         *model;
                PanelDItemEditorType  buf_type;
 
-               table_attach_label (GTK_TABLE (priv->table), priv->type_label,
-                                   1, 2, 0, 1);
-               table_attach_entry (GTK_TABLE (priv->table), priv->type_combo,
-                                   2, 3, 0, 1);
+               grid_attach_label (GTK_GRID (priv->grid), priv->type_label, 1, 0, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->type_combo, 2, 0, 1, 1);
 
-               table_attach_label (GTK_TABLE (priv->table), priv->name_label,
-                                   1, 2, 1, 2);
-               table_attach_entry (GTK_TABLE (priv->table), priv->name_entry,
-                                   2, 3, 1, 2);
+               grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 1, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 1, 1, 1);
 
-               table_attach_label (GTK_TABLE (priv->table), priv->command_label,
-                                   1, 2, 2, 3);
-               table_attach_entry (GTK_TABLE (priv->table), priv->command_hbox,
-                                   2, 3, 2, 3);
+               grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 2, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 2, 1, 1);
 
-               table_attach_label (GTK_TABLE (priv->table), priv->comment_label,
-                                   1, 2, 3, 4);
-               table_attach_entry (GTK_TABLE (priv->table), priv->comment_entry,
-                                   2, 3, 3, 4);
+               grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 3, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 3, 1, 1);
 
                /* FIXME: hack hack hack */
                model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->type_combo));
@@ -759,30 +735,20 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
                        }
                } while (gtk_tree_model_iter_next (model, &iter));
        } else if (type == PANEL_DITEM_EDITOR_TYPE_DIRECTORY) {
-               table_attach_label (GTK_TABLE (priv->table), priv->name_label,
-                                   1, 2, 0, 1);
-               table_attach_entry (GTK_TABLE (priv->table), priv->name_entry,
-                                   2, 3, 0, 1);
-
-               table_attach_label (GTK_TABLE (priv->table), priv->comment_label,
-                                   1, 2, 1, 2);
-               table_attach_entry (GTK_TABLE (priv->table), priv->comment_entry,
-                                   2, 3, 1, 2);
+               grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 0, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 0, 1, 1);
+
+               grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 1, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 1, 1, 1);
        } else {
-               table_attach_label (GTK_TABLE (priv->table), priv->name_label,
-                                   1, 2, 0, 1);
-               table_attach_entry (GTK_TABLE (priv->table), priv->name_entry,
-                                   2, 3, 0, 1);
-
-               table_attach_label (GTK_TABLE (priv->table), priv->command_label,
-                                   1, 2, 1, 2);
-               table_attach_entry (GTK_TABLE (priv->table), priv->command_hbox,
-                                   2, 3, 1, 2);
-
-               table_attach_label (GTK_TABLE (priv->table), priv->comment_label,
-                                   1, 2, 2, 3);
-               table_attach_entry (GTK_TABLE (priv->table), priv->comment_entry,
-                                   2, 3, 2, 3);
+               grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 0, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 0, 1, 1);
+
+               grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 1, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 1, 1, 1);
+
+               grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 2, 1, 1);
+               grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 2, 1, 1);
        }
 
        type_combo_changed (dialog);
@@ -796,8 +762,7 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
        focus_chain = g_list_prepend (focus_chain, priv->command_hbox);
        focus_chain = g_list_prepend (focus_chain, priv->comment_entry);
        focus_chain = g_list_reverse (focus_chain);
-       gtk_container_set_focus_chain (GTK_CONTAINER (priv->table),
-                                      focus_chain);
+       gtk_container_set_focus_chain (GTK_CONTAINER (priv->grid), focus_chain);
        g_list_free (focus_chain);
 
        gtk_widget_grab_focus (priv->name_entry);


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