[gimp/gtk3-port: 309/440] dialogs: get rid of GtkTable



commit a5afa7a9da2c75716b96bcbd2f97f7317c0dac60
Author: Simon Budig <simon budig de>
Date:   Thu May 3 00:44:54 2018 +0200

    dialogs: get rid of GtkTable

 app/dialogs/module-dialog.c               |   23 +++++------
 app/dialogs/palette-import-dialog.c       |   61 +++++++++++++---------------
 app/dialogs/print-size-dialog.c           |   29 +++++--------
 app/dialogs/resolution-calibrate-dialog.c |   22 ++++------
 4 files changed, 58 insertions(+), 77 deletions(-)
---
diff --git a/app/dialogs/module-dialog.c b/app/dialogs/module-dialog.c
index e18ea55..4d5ae5b 100644
--- a/app/dialogs/module-dialog.c
+++ b/app/dialogs/module-dialog.c
@@ -70,7 +70,7 @@ struct _ModuleDialog
   GtkListStore *list;
 
   GtkWidget    *hint;
-  GtkWidget    *table;
+  GtkWidget    *grid;
   GtkWidget    *label[N_INFOS];
   GtkWidget    *error_box;
   GtkWidget    *error_label;
@@ -101,7 +101,7 @@ static void   dialog_info_update      (GimpModuleDB          *db,
                                        GimpModule            *module,
                                        ModuleDialog          *private);
 static void   dialog_info_init        (ModuleDialog          *private,
-                                       GtkWidget             *table);
+                                       GtkWidget             *grid);
 
 
 /*  public functions  */
@@ -199,10 +199,10 @@ module_dialog_new (Gimp *gimp)
   gtk_container_add (GTK_CONTAINER (sw), view);
   gtk_widget_show (view);
 
-  private->table = gtk_table_new (2, N_INFOS, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (private->table), 6);
-  gtk_box_pack_start (GTK_BOX (vbox), private->table, FALSE, FALSE, 0);
-  gtk_widget_show (private->table);
+  private->grid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (private->grid), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), private->grid, FALSE, FALSE, 0);
+  gtk_widget_show (private->grid);
 
   private->error_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_box_pack_start (GTK_BOX (vbox), private->error_box, FALSE, FALSE, 0);
@@ -218,7 +218,7 @@ module_dialog_new (Gimp *gimp)
                       private->error_label, TRUE, TRUE, 0);
   gtk_widget_show (private->error_label);
 
-  dialog_info_init (private, private->table);
+  dialog_info_init (private, private->grid);
 
   dialog_info_update (gimp->module_db, private->selected, private);
 
@@ -492,7 +492,7 @@ dialog_info_update (GimpModuleDB *db,
 
 static void
 dialog_info_init (ModuleDialog *private,
-                  GtkWidget    *table)
+                  GtkWidget    *grid)
 {
   GtkWidget *label;
   gint       i;
@@ -510,17 +510,14 @@ dialog_info_init (ModuleDialog *private,
     {
       label = gtk_label_new (gettext (text[i]));
       gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-      gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1,
-                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
+      gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1);
       gtk_widget_show (label);
 
       private->label[i] = gtk_label_new ("");
       gtk_label_set_xalign (GTK_LABEL (private->label[i]), 0.0);
       gtk_label_set_ellipsize (GTK_LABEL (private->label[i]),
                                PANGO_ELLIPSIZE_END);
-      gtk_table_attach (GTK_TABLE (private->table), private->label[i],
-                        1, 2, i, i + 1,
-                        GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 2);
+      gtk_grid_attach (GTK_GRID (grid), private->label[i], 1, i, 1, 1);
       gtk_widget_show (private->label[i]);
     }
 }
diff --git a/app/dialogs/palette-import-dialog.c b/app/dialogs/palette-import-dialog.c
index 6e2cb96..7cb7239 100644
--- a/app/dialogs/palette-import-dialog.c
+++ b/app/dialogs/palette-import-dialog.c
@@ -138,7 +138,7 @@ palette_import_dialog_new (GimpContext *context)
   GtkWidget    *main_hbox;
   GtkWidget    *frame;
   GtkWidget    *vbox;
-  GtkWidget    *table;
+  GtkWidget    *grid;
   GtkSizeGroup *size_group;
   GSList       *group = NULL;
 
@@ -201,17 +201,16 @@ palette_import_dialog_new (GimpContext *context)
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  table = gtk_table_new (5, 2, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-  gtk_container_add (GTK_CONTAINER (frame), table);
-  gtk_widget_show (table);
+  grid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_container_add (GTK_CONTAINER (frame), grid);
+  gtk_widget_show (grid);
 
   private->gradient_radio =
     gtk_radio_button_new_with_mnemonic (group, _("_Gradient"));
   group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (private->gradient_radio));
-  gtk_table_attach (GTK_TABLE (table), private->gradient_radio,
-                    0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), private->gradient_radio, 0, 0, 1, 1);
   gtk_widget_show (private->gradient_radio);
 
   g_signal_connect (private->gradient_radio, "toggled",
@@ -221,8 +220,7 @@ palette_import_dialog_new (GimpContext *context)
   private->image_radio =
     gtk_radio_button_new_with_mnemonic (group, _("I_mage"));
   group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (private->image_radio));
-  gtk_table_attach (GTK_TABLE (table), private->image_radio,
-                    0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), private->image_radio, 0, 1, 1, 1);
   gtk_widget_show (private->image_radio);
 
   g_signal_connect (private->image_radio, "toggled",
@@ -236,8 +234,7 @@ palette_import_dialog_new (GimpContext *context)
     gtk_check_button_new_with_mnemonic (_("Sample _Merged"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (private->sample_merged_toggle),
                                 TRUE);
-  gtk_table_attach (GTK_TABLE (table), private->sample_merged_toggle,
-                    1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), private->sample_merged_toggle, 1, 2, 1, 1);
   gtk_widget_show (private->sample_merged_toggle);
 
   g_signal_connect_swapped (private->sample_merged_toggle, "toggled",
@@ -248,8 +245,7 @@ palette_import_dialog_new (GimpContext *context)
     gtk_check_button_new_with_mnemonic (_("_Selected Pixels only"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (private->selection_only_toggle),
                                 FALSE);
-  gtk_table_attach (GTK_TABLE (table), private->selection_only_toggle,
-                    1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), private->selection_only_toggle, 1, 3, 1, 1);
   gtk_widget_show (private->selection_only_toggle);
 
   g_signal_connect_swapped (private->selection_only_toggle, "toggled",
@@ -259,8 +255,7 @@ palette_import_dialog_new (GimpContext *context)
   private->file_radio =
     gtk_radio_button_new_with_mnemonic (group, _("Palette _file"));
   group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (private->image_radio));
-  gtk_table_attach (GTK_TABLE (table), private->file_radio,
-                    0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), private->file_radio, 0, 4, 1, 1);
   gtk_widget_show (private->file_radio);
 
   g_signal_connect (private->file_radio, "toggled",
@@ -273,23 +268,23 @@ palette_import_dialog_new (GimpContext *context)
   private->gradient_combo =
     gimp_container_combo_box_new (gimp_data_factory_get_container (context->gimp->gradient_factory),
                                   private->context, 24, 1);
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
-                             NULL, 0.0, 0.5, private->gradient_combo, 1, FALSE);
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
+                            NULL, 0.0, 0.5, private->gradient_combo, 1);
   gtk_size_group_add_widget (size_group, private->gradient_combo);
 
   /*  The image menu  */
   private->image_combo =
     gimp_container_combo_box_new (context->gimp->images, private->context,
                                   24, 1);
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
-                             NULL, 0.0, 0.5, private->image_combo, 1, FALSE);
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
+                            NULL, 0.0, 0.5, private->image_combo, 1);
   gtk_size_group_add_widget (size_group, private->image_combo);
 
   /*  Palette file name entry  */
   private->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"),
                                                       GTK_FILE_CHOOSER_ACTION_OPEN);
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
-                             NULL, 0.0, 0.5, private->file_chooser, 1, FALSE);
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 4,
+                            NULL, 0.0, 0.5, private->file_chooser, 1);
   gtk_size_group_add_widget (size_group, private->file_chooser);
 
   g_object_unref (size_group);
@@ -301,23 +296,23 @@ palette_import_dialog_new (GimpContext *context)
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  table = gtk_table_new (4, 3, FALSE);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-  gtk_container_add (GTK_CONTAINER (frame), table);
-  gtk_widget_show (table);
+  grid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_container_add (GTK_CONTAINER (frame), grid);
+  gtk_widget_show (grid);
 
   /*  The source's name  */
   private->entry = gtk_entry_new ();
   gtk_entry_set_text (GTK_ENTRY (private->entry),
                       gradient ?
                       gimp_object_get_name (gradient) : _("New import"));
-  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
-                             _("Palette _name:"), 0.0, 0.5,
-                             private->entry, 2, FALSE);
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
+                            _("Palette _name:"), 0.0, 0.5,
+                            private->entry, 2);
 
   /*  The # of colors  */
-  private->num_colors = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
+  private->num_colors = gimp_scale_entry_new_grid (GTK_GRID (grid), 0, 1,
                                               _("N_umber of colors:"), -1, 5,
                                               256, 2, 10000, 1, 10, 0,
                                               TRUE, 0.0, 0.0,
@@ -330,7 +325,7 @@ palette_import_dialog_new (GimpContext *context)
                             private);
 
   /*  The columns  */
-  private->columns = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
+  private->columns = gimp_scale_entry_new_grid (GTK_GRID (grid), 0, 2,
                                            _("C_olumns:"), -1, 5,
                                            16, 0, 64, 1, 8, 0,
                                            TRUE, 0.0, 0.0,
@@ -341,7 +336,7 @@ palette_import_dialog_new (GimpContext *context)
                     private);
 
   /*  The interval  */
-  private->threshold = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
+  private->threshold = gimp_scale_entry_new_grid (GTK_GRID (grid), 0, 3,
                                              _("I_nterval:"), -1, 5,
                                              1, 1, 128, 1, 8, 0,
                                              TRUE, 0.0, 0.0,
diff --git a/app/dialogs/print-size-dialog.c b/app/dialogs/print-size-dialog.c
index e21d382..4c26633 100644
--- a/app/dialogs/print-size-dialog.c
+++ b/app/dialogs/print-size-dialog.c
@@ -92,7 +92,7 @@ print_size_dialog_new (GimpImage              *image,
   PrintSizeDialog *private;
   GtkWidget       *dialog;
   GtkWidget       *frame;
-  GtkWidget       *table;
+  GtkWidget       *grid;
   GtkWidget       *entry;
   GtkWidget       *label;
   GtkWidget       *width;
@@ -147,13 +147,10 @@ print_size_dialog_new (GimpImage              *image,
                       frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  table = gtk_table_new (4, 3, FALSE);
-  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 6);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 12);
-  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
-  gtk_table_set_row_spacing (GTK_TABLE (table), 2, 2);
-  gtk_container_add (GTK_CONTAINER (frame), table);
-  gtk_widget_show (table);
+  grid = gtk_grid_new ();
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
+  gtk_container_add (GTK_CONTAINER (frame), grid);
+  gtk_widget_show (grid);
 
   /*  the print size entry  */
 
@@ -175,19 +172,17 @@ print_size_dialog_new (GimpImage              *image,
   label = gtk_label_new_with_mnemonic (_("_Width:"));
   gtk_label_set_xalign (GTK_LABEL (label), 0.0);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), width);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
-                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
   gtk_widget_show (label);
 
   label = gtk_label_new_with_mnemonic (_("H_eight:"));
   gtk_label_set_xalign (GTK_LABEL (label), 0.0);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), height);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
-                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
   gtk_widget_show (label);
 
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
+  gtk_grid_attach (GTK_GRID (grid), hbox, 1, 0, 1, 2);
   gtk_widget_show (hbox);
 
   gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
@@ -233,19 +228,17 @@ print_size_dialog_new (GimpImage              *image,
   label = gtk_label_new_with_mnemonic (_("_X resolution:"));
   gtk_label_set_xalign (GTK_LABEL (label), 0.0);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), width);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
-                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
   gtk_widget_show (label);
 
   label = gtk_label_new_with_mnemonic (_("_Y resolution:"));
   gtk_label_set_xalign (GTK_LABEL (label), 0.0);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), height);
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
-                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
   gtk_widget_show (label);
 
   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 2, 4);
+  gtk_grid_attach (GTK_GRID (grid), hbox, 1, 2, 1, 2);
   gtk_widget_show (hbox);
 
   entry = gimp_size_entry_new (0, gimp_image_get_unit (image), _("pixels/%a"),
diff --git a/app/dialogs/resolution-calibrate-dialog.c b/app/dialogs/resolution-calibrate-dialog.c
index dcf7055..e9c8c88 100644
--- a/app/dialogs/resolution-calibrate-dialog.c
+++ b/app/dialogs/resolution-calibrate-dialog.c
@@ -50,7 +50,7 @@ resolution_calibrate_dialog (GtkWidget   *resolution_entry,
                              const gchar *icon_name)
 {
   GtkWidget    *dialog;
-  GtkWidget    *table;
+  GtkWidget    *grid;
   GtkWidget    *vbox;
   GtkWidget    *hbox;
   GtkWidget    *ruler;
@@ -90,39 +90,35 @@ resolution_calibrate_dialog (GtkWidget   *resolution_entry,
   ruler_width  = rect.width  - 300 - (rect.width  % 100);
   ruler_height = rect.height - 300 - (rect.height % 100);
 
-  table = gtk_table_new (4, 4, FALSE);
-  gtk_container_set_border_width (GTK_CONTAINER (table), 12);
+  grid = gtk_grid_new ();
+  gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
   gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
-                      table, TRUE, TRUE, 0);
-  gtk_widget_show (table);
+                      grid, TRUE, TRUE, 0);
+  gtk_widget_show (grid);
 
   if (icon_name)
     {
       GtkWidget *image = gtk_image_new_from_icon_name (icon_name,
                                                        GTK_ICON_SIZE_DIALOG);
 
-      gtk_table_attach (GTK_TABLE (table), image, 0, 1, 0, 1,
-                        GTK_SHRINK, GTK_SHRINK, 4, 4);
+      gtk_grid_attach (GTK_GRID (grid), image, 0, 0, 1, 1);
       gtk_widget_show (image);
     }
 
   ruler = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_widget_set_size_request (ruler, ruler_width, 32);
   gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_width, ruler_width);
-  gtk_table_attach (GTK_TABLE (table), ruler, 1, 3, 0, 1,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), ruler, 1, 0, 2, 1);
   gtk_widget_show (ruler);
 
   ruler = gimp_ruler_new (GTK_ORIENTATION_VERTICAL);
   gtk_widget_set_size_request (ruler, 32, ruler_height);
   gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_height, ruler_height);
-  gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 3,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), ruler, 0, 1, 1, 2);
   gtk_widget_show (ruler);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
-  gtk_table_attach (GTK_TABLE (table), vbox, 1, 2, 1, 2,
-                    GTK_SHRINK, GTK_SHRINK, 0, 0);
+  gtk_grid_attach (GTK_GRID (grid), vbox, 1, 1, 1, 1);
   gtk_widget_show (vbox);
 
   label =


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