From fb9787630278dd23a6900cfc28c84be5761bc885 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 10 Feb 2017 16:11:45 +0100 Subject: colorsel: port to GtkGrid --- libmate-desktop/mate-colorsel.c | 61 +++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/libmate-desktop/mate-colorsel.c b/libmate-desktop/mate-colorsel.c index 7ae2455..8e77ce2 100644 --- a/libmate-desktop/mate-colorsel.c +++ b/libmate-desktop/mate-colorsel.c @@ -181,13 +181,13 @@ static void color_sample_new (MateColorSelection *colors static void make_label_spinbutton (MateColorSelection *colorsel, GtkWidget **spinbutton, gchar *text, - GtkWidget *table, + GtkWidget *grid, gint i, gint j, gint channel_type, const gchar *tooltip); static void make_palette_frame (MateColorSelection *colorsel, - GtkWidget *table, + GtkWidget *grid, gint i, gint j); static void set_selected_palette (MateColorSelection *colorsel, @@ -328,7 +328,7 @@ mate_color_selection_init (MateColorSelection *colorsel) { GtkWidget *top_hbox; GtkWidget *top_right_vbox; - GtkWidget *table, *label, *hbox, *frame, *vbox, *button; + GtkWidget *grid, *label, *hbox, *frame, *vbox, *button; GtkAdjustment *adjust; GtkWidget *picker_image; gint i, j; @@ -382,25 +382,25 @@ mate_color_selection_init (MateColorSelection *colorsel) top_right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (top_hbox), top_right_vbox, FALSE, FALSE, 0); - table = gtk_table_new (8, 6, FALSE); - gtk_box_pack_start (GTK_BOX (top_right_vbox), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); + grid = gtk_grid_new (); + gtk_box_pack_start (GTK_BOX (top_right_vbox), grid, FALSE, FALSE, 0); + gtk_grid_set_row_spacing (GTK_GRID (grid), 6); + gtk_grid_set_column_spacing (GTK_GRID (grid), 12); - make_label_spinbutton (colorsel, &priv->hue_spinbutton, _("_Hue:"), table, 0, 0, COLORSEL_HUE, + make_label_spinbutton (colorsel, &priv->hue_spinbutton, _("_Hue:"), grid, 0, 0, COLORSEL_HUE, _("Position on the color wheel.")); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (priv->hue_spinbutton), TRUE); - make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("_Saturation:"), table, 0, 1, COLORSEL_SATURATION, + make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("_Saturation:"), grid, 0, 1, COLORSEL_SATURATION, _("\"Deepness\" of the color.")); - make_label_spinbutton (colorsel, &priv->val_spinbutton, _("_Value:"), table, 0, 2, COLORSEL_VALUE, + make_label_spinbutton (colorsel, &priv->val_spinbutton, _("_Value:"), grid, 0, 2, COLORSEL_VALUE, _("Brightness of the color.")); - make_label_spinbutton (colorsel, &priv->red_spinbutton, _("_Red:"), table, 6, 0, COLORSEL_RED, + make_label_spinbutton (colorsel, &priv->red_spinbutton, _("_Red:"), grid, 6, 0, COLORSEL_RED, _("Amount of red light in the color.")); - make_label_spinbutton (colorsel, &priv->green_spinbutton, _("_Green:"), table, 6, 1, COLORSEL_GREEN, + make_label_spinbutton (colorsel, &priv->green_spinbutton, _("_Green:"), grid, 6, 1, COLORSEL_GREEN, _("Amount of green light in the color.")); - make_label_spinbutton (colorsel, &priv->blue_spinbutton, _("_Blue:"), table, 6, 2, COLORSEL_BLUE, + make_label_spinbutton (colorsel, &priv->blue_spinbutton, _("_Blue:"), grid, 6, 2, COLORSEL_BLUE, _("Amount of blue light in the color.")); - gtk_table_attach_defaults (GTK_TABLE (table), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, 8, 3, 4); + gtk_grid_attach (GTK_GRID (grid), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, 3, 8, 1); priv->opacity_label = gtk_label_new_with_mnemonic (_("Op_acity:")); #if GTK_CHECK_VERSION (3, 16, 0) @@ -408,7 +408,7 @@ mate_color_selection_init (MateColorSelection *colorsel) #else gtk_misc_set_alignment (GTK_MISC (priv->opacity_label), 0.0, 0.5); #endif - gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_label, 0, 1, 4, 5); + gtk_grid_attach (GTK_GRID (grid), priv->opacity_label, 0, 4, 1, 1); adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 1.0, 0.0)); g_object_set_data (G_OBJECT (adjust), "COLORSEL", colorsel); priv->opacity_slider = gtk_hscale_new (adjust); @@ -420,7 +420,7 @@ mate_color_selection_init (MateColorSelection *colorsel) g_signal_connect (adjust, "value-changed", G_CALLBACK (adjustment_changed), GINT_TO_POINTER (COLORSEL_OPACITY)); - gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_slider, 1, 7, 4, 5); + gtk_grid_attach (GTK_GRID (grid), priv->opacity_slider, 1, 4, 6, 1); priv->opacity_entry = gtk_entry_new (); gtk_widget_set_tooltip_text (priv->opacity_entry, _("Transparency of the color.")); @@ -428,10 +428,10 @@ mate_color_selection_init (MateColorSelection *colorsel) g_signal_connect (priv->opacity_entry, "activate", G_CALLBACK (opacity_entry_changed), colorsel); - gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_entry, 7, 8, 4, 5); + gtk_grid_attach (GTK_GRID (grid), priv->opacity_entry, 7, 4, 1, 1); label = gtk_label_new_with_mnemonic (_("Color _name:")); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6); + gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (label), 0.0); #else @@ -451,7 +451,7 @@ mate_color_selection_init (MateColorSelection *colorsel) _("You can enter an HTML-style hexadecimal color value, or simply a color name such as 'orange' in this entry.")); gtk_entry_set_width_chars (GTK_ENTRY (priv->hex_entry), 7); - gtk_table_attach_defaults (GTK_TABLE (table), priv->hex_entry, 1, 5, 5, 6); + gtk_grid_attach (GTK_GRID (grid), priv->hex_entry, 1, 5, 4, 1); focus_chain = g_list_append (focus_chain, priv->hue_spinbutton); focus_chain = g_list_append (focus_chain, priv->sat_spinbutton); @@ -462,18 +462,18 @@ mate_color_selection_init (MateColorSelection *colorsel) focus_chain = g_list_append (focus_chain, priv->opacity_slider); focus_chain = g_list_append (focus_chain, priv->opacity_entry); focus_chain = g_list_append (focus_chain, priv->hex_entry); - gtk_container_set_focus_chain (GTK_CONTAINER (table), focus_chain); + gtk_container_set_focus_chain (GTK_CONTAINER (grid), focus_chain); g_list_free (focus_chain); /* Set up the palette */ - table = gtk_table_new (GTK_CUSTOM_PALETTE_HEIGHT, GTK_CUSTOM_PALETTE_WIDTH, TRUE); - gtk_table_set_row_spacings (GTK_TABLE (table), 1); - gtk_table_set_col_spacings (GTK_TABLE (table), 1); + grid = gtk_grid_new (); + gtk_grid_set_row_spacing (GTK_GRID (grid), 1); + gtk_grid_set_column_spacing (GTK_GRID (grid), 1); for (i = 0; i < GTK_CUSTOM_PALETTE_WIDTH; i++) { for (j = 0; j < GTK_CUSTOM_PALETTE_HEIGHT; j++) { - make_palette_frame (colorsel, table, i, j); + make_palette_frame (colorsel, grid, i, j); } } set_selected_palette (colorsel, 0, 0); @@ -490,7 +490,7 @@ mate_color_selection_init (MateColorSelection *colorsel) priv->custom_palette[0][0]); gtk_box_pack_end (GTK_BOX (top_right_vbox), priv->palette_frame, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (priv->palette_frame), table, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->palette_frame), grid, FALSE, FALSE, 0); gtk_widget_show_all (top_hbox); @@ -2047,7 +2047,7 @@ static void make_label_spinbutton (MateColorSelection *colorsel, GtkWidget **spinbutton, gchar *text, - GtkWidget *table, + GtkWidget *grid, gint i, gint j, gint channel_type, @@ -2085,13 +2085,13 @@ make_label_spinbutton (MateColorSelection *colorsel, #else gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif - gtk_table_attach_defaults (GTK_TABLE (table), label, i, i+1, j, j+1); - gtk_table_attach_defaults (GTK_TABLE (table), *spinbutton, i+1, i+2, j, j+1); + gtk_grid_attach (GTK_GRID (grid), label, i, j, 1, 1); + gtk_grid_attach (GTK_GRID (grid), *spinbutton, i+1, j, 1, 1); } static void make_palette_frame (MateColorSelection *colorsel, - GtkWidget *table, + GtkWidget *grid, gint i, gint j) { @@ -2104,7 +2104,8 @@ make_palette_frame (MateColorSelection *colorsel, priv->custom_palette[i][j] = palette_new (colorsel); gtk_widget_set_size_request (priv->custom_palette[i][j], CUSTOM_PALETTE_ENTRY_WIDTH, CUSTOM_PALETTE_ENTRY_HEIGHT); gtk_container_add (GTK_CONTAINER (frame), priv->custom_palette[i][j]); - gtk_table_attach_defaults (GTK_TABLE (table), frame, i, i+1, j, j+1); + gtk_widget_set_hexpand (frame, TRUE); + gtk_grid_attach (GTK_GRID (grid), frame, i, j, 1, 1); } /* Set the palette entry [x][y] to be the currently selected one. */ -- cgit v1.2.1