[gimp] app: consolidate button creation code for the convolution matrix
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: consolidate button creation code for the convolution matrix
- Date: Mon, 6 Feb 2017 02:40:48 +0000 (UTC)
commit bed63c6bd98071bd2dbb84a3cd7467fec66df7e1
Author: Ell <ell_se yahoo com>
Date: Sun Feb 5 21:20:45 2017 -0500
app: consolidate button creation code for the convolution matrix
app/widgets/gimppropgui-constructors.c | 164 +++++++++++++++-----------------
1 files changed, 78 insertions(+), 86 deletions(-)
---
diff --git a/app/widgets/gimppropgui-constructors.c b/app/widgets/gimppropgui-constructors.c
index 439e60a..6df5468 100644
--- a/app/widgets/gimppropgui-constructors.c
+++ b/app/widgets/gimppropgui-constructors.c
@@ -566,12 +566,10 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *hbox;
- GtkWidget *button;
- GtkWidget *image;
GtkWidget *scale;
GtkWidget *vbox2;
const gchar *label;
- gint x, y;
+ gint x, y;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (param_specs != NULL, NULL);
@@ -584,6 +582,8 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
+ /* matrix */
+
table = gtk_table_new (5, 5, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
@@ -608,94 +608,84 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
}
}
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (button,
- _("Rotate matrix 90° counter-clockwise"));
- gtk_widget_set_can_focus (button, FALSE);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- image = gtk_image_new_from_icon_name (GIMP_STOCK_ROTATE_270,
- GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
-
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-rotate", GINT_TO_POINTER (1));
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-flip", GINT_TO_POINTER (0));
- g_signal_connect (button, "clicked",
- G_CALLBACK (convolution_matrix_rotate_flip),
- config);
-
- button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (button,
- _("Rotate matrix 90° clockwise"));
- gtk_widget_set_can_focus (button, FALSE);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- image = gtk_image_new_from_icon_name (GIMP_STOCK_ROTATE_90,
- GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
-
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-rotate", GINT_TO_POINTER (3));
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-flip", GINT_TO_POINTER (0));
- g_signal_connect (button, "clicked",
- G_CALLBACK (convolution_matrix_rotate_flip),
- config);
-
- button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (button,
- _("Flip matrix horizontally"));
- gtk_widget_set_can_focus (button, FALSE);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- image = gtk_image_new_from_icon_name (GIMP_STOCK_FLIP_HORIZONTAL,
- GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
-
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-rotate", GINT_TO_POINTER (0));
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-flip", GINT_TO_POINTER (1));
- g_signal_connect (button, "clicked",
- G_CALLBACK (convolution_matrix_rotate_flip),
- config);
-
- button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (button,
- _("Flip matrix vertically"));
- gtk_widget_set_can_focus (button, FALSE);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
- gtk_widget_show (button);
- image = gtk_image_new_from_icon_name (GIMP_STOCK_FLIP_VERTICAL,
- GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
-
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-rotate", GINT_TO_POINTER (2));
- g_object_set_data (G_OBJECT (button),
- "convolution-matrix-flip", GINT_TO_POINTER (1));
- g_signal_connect (button, "clicked",
- G_CALLBACK (convolution_matrix_rotate_flip),
- config);
+ /* rotate / flip buttons */
+ {
+ typedef struct
+ {
+ const gchar *tooltip;
+ const gchar *icon_name;
+ gint rotate;
+ gint flip;
+ } ButtonInfo;
+
+ gint i;
+ const ButtonInfo buttons[] = {
+ {
+ .tooltip = _("Rotate matrix 90° counter-clockwise"),
+ .icon_name = GIMP_STOCK_ROTATE_270,
+ .rotate = 1,
+ .flip = 0
+ },
+ {
+ .tooltip = _("Rotate matrix 90° clockwise"),
+ .icon_name = GIMP_STOCK_ROTATE_90,
+ .rotate = 3,
+ .flip = 0
+ },
+ {
+ .tooltip = _("Flip matrix horizontally"),
+ .icon_name = GIMP_STOCK_FLIP_HORIZONTAL,
+ .rotate = 0,
+ .flip = 1
+ },
+ {
+ .tooltip = _("Flip matrix vertically"),
+ .icon_name = GIMP_STOCK_FLIP_VERTICAL,
+ .rotate = 2,
+ .flip = 1
+ }};
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ for (i = 0; i < G_N_ELEMENTS (buttons); i++)
+ {
+ const ButtonInfo *info = &buttons[i];
+ GtkWidget *button;
+ GtkWidget *image;
+
+ button = gtk_button_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_widget_set_tooltip_text (button, info->tooltip);
+ gtk_widget_set_can_focus (button, FALSE);
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_widget_show (button);
+
+ image = gtk_image_new_from_icon_name (info->icon_name,
+ GTK_ICON_SIZE_BUTTON);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
+
+ g_object_set_data (G_OBJECT (button),
+ "convolution-matrix-rotate",
+ GINT_TO_POINTER (info->rotate));
+ g_object_set_data (G_OBJECT (button),
+ "convolution-matrix-flip",
+ GINT_TO_POINTER (info->flip));
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (convolution_matrix_rotate_flip),
+ config);
+ }
+ }
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
+ /* divisor / offset spin scales */
+
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
@@ -711,6 +701,8 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
gtk_widget_show (scale);
+ /* rest of the properties */
+
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]