[gimp/gimp-2-10] app: merge back gegl:recursive-transform-plus propgui to recursive-transform
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: merge back gegl:recursive-transform-plus propgui to recursive-transform
- Date: Sun, 17 Jun 2018 19:51:04 +0000 (UTC)
commit 313bb4bc2a23f67af70269eab40b8bfd0d03592f
Author: Ell <ell_se yahoo com>
Date: Sun Jun 17 15:44:51 2018 -0400
app: merge back gegl:recursive-transform-plus propgui to recursive-transform
... following GEGL commit 6be0a86583f9c10c7710c96c21c261e4227c4727.
gegl:recursive-transform now allows applying multiple
transforamtions simultaneously, using multiple transform-grid
widgets.
(cherry picked from commit 56d15e83e95d940e189134109cb8e04bf6605459)
app/propgui/Makefile.am | 2 -
app/propgui/gimppropgui-recursive-transform-plus.c | 334 ---------------------
app/propgui/gimppropgui-recursive-transform-plus.h | 35 ---
app/propgui/gimppropgui-recursive-transform.c | 230 ++++++++++++--
app/propgui/gimppropgui.c | 3 -
po/POTFILES.in | 1 -
6 files changed, 210 insertions(+), 395 deletions(-)
---
diff --git a/app/propgui/Makefile.am b/app/propgui/Makefile.am
index 1a9b5d19a5..a15c04b1e3 100644
--- a/app/propgui/Makefile.am
+++ b/app/propgui/Makefile.am
@@ -41,8 +41,6 @@ libapppropgui_a_SOURCES = \
gimppropgui-panorama-projection.h \
gimppropgui-recursive-transform.c \
gimppropgui-recursive-transform.h \
- gimppropgui-recursive-transform-plus.c \
- gimppropgui-recursive-transform-plus.h \
gimppropgui-shadows-highlights.c \
gimppropgui-shadows-highlights.h \
gimppropgui-spiral.c \
diff --git a/app/propgui/gimppropgui-recursive-transform.c b/app/propgui/gimppropgui-recursive-transform.c
index aa31b14a3e..eda4fd2542 100644
--- a/app/propgui/gimppropgui-recursive-transform.c
+++ b/app/propgui/gimppropgui-recursive-transform.c
@@ -1,7 +1,7 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
- * gimppropgui-recursive-transform.c
+ * gimppropgui-recursive-transform-plus.c
* Copyright (C) 2018 Ell
*
* This program is free software: you can redistribute it and/or modify
@@ -37,18 +37,112 @@
#include "gimp-intl.h"
+#define MAX_N_TRANSFORMS 10
+
+
static void
-transform_grid_callback (GObject *config,
- GeglRectangle *area,
- const GimpMatrix3 *transform)
+add_transform (GtkButton *button,
+ GObject *config)
{
- gchar *transform_str;
+ gchar *transform;
+ gchar *new_transform;
+
+ g_object_get (config,
+ "transform", &transform,
+ NULL);
+
+ new_transform = g_strdup_printf ("%s;matrix (1, 0, 0, 0, 1, 0, 0, 0, 1)",
+ transform);
+
+ g_object_set (config,
+ "transform", new_transform,
+ NULL);
+
+ g_free (transform);
+ g_free (new_transform);
+}
+
+static void
+duplicate_transform (GtkButton *button,
+ GObject *config)
+{
+ gchar *transform;
+ gchar *new_transform;
+ gchar *delim;
+
+ g_object_get (config,
+ "transform", &transform,
+ NULL);
+
+ delim = strrchr (transform, ';');
+
+ if (! delim)
+ delim = transform;
+ else
+ delim++;
+
+ new_transform = g_strdup_printf ("%s;%s", transform, delim);
+
+ g_object_set (config,
+ "transform", new_transform,
+ NULL);
+
+ g_free (transform);
+ g_free (new_transform);
+}
+
+static void
+remove_transform (GtkButton *button,
+ GObject *config)
+{
+ gchar *transform;
+ gchar *delim;
+
+ g_object_get (config,
+ "transform", &transform,
+ NULL);
+
+ delim = strrchr (transform, ';');
+
+ if (delim)
+ {
+ *delim = '\0';
+
+ g_object_set (config,
+ "transform", transform,
+ NULL);
+ }
+
+ g_free (transform);
+}
+
+static void
+transform_grids_callback (GObject *config,
+ GeglRectangle *area,
+ const GimpMatrix3 *transforms,
+ gint n_transforms)
+{
+ GString *transforms_str = g_string_new (NULL);
+ gchar *transform_str;
+ gint i;
g_object_set_data_full (G_OBJECT (config), "area",
g_memdup (area, sizeof (GeglRectangle)),
(GDestroyNotify) g_free);
- transform_str = gegl_matrix3_to_string ((GeglMatrix3 *) transform);
+ for (i = 0; i < n_transforms; i++)
+ {
+ if (i > 0)
+ g_string_append (transforms_str, ";");
+
+ transform_str = gegl_matrix3_to_string ((GeglMatrix3 *) &transforms[i]);
+
+ g_string_append (transforms_str, transform_str);
+
+ g_free (transform_str);
+ }
+
+ transform_str = g_string_free (transforms_str, FALSE);
g_object_set (config,
"transform", transform_str,
@@ -62,23 +156,49 @@ config_notify (GObject *config,
const GParamSpec *pspec,
gpointer set_data)
{
- GimpControllerTransformGridCallback set_func;
- GeglRectangle *area;
- gchar *transform_str;
- GimpMatrix3 transform;
+ GtkWidget *add_button;
+ GtkWidget *duplicate_button;
+ GtkWidget *remove_button;
+ GimpControllerTransformGridsCallback set_func;
+ GeglRectangle *area;
+ gchar *transform_str;
+ gchar **transform_strs;
+ GimpMatrix3 *transforms;
+ gint n_transforms;
+ gint i;
- set_func = g_object_get_data (G_OBJECT (config), "set-func");
- area = g_object_get_data (G_OBJECT (config), "area");
+ add_button = g_object_get_data (G_OBJECT (config), "add-transform-button");
+ duplicate_button = g_object_get_data (G_OBJECT (config), "duplicate-transform-button");
+ remove_button = g_object_get_data (G_OBJECT (config), "remove-transform-button");
+ set_func = g_object_get_data (G_OBJECT (config), "set-func");
+ area = g_object_get_data (G_OBJECT (config), "area");
g_object_get (config,
"transform", &transform_str,
NULL);
- gegl_matrix3_parse_string ((GeglMatrix3 *) &transform, transform_str);
-
- set_func (set_data, area, &transform);
+ transform_strs = g_strsplit (transform_str, ";", -1);
g_free (transform_str);
+
+ for (n_transforms = 0; transform_strs[n_transforms]; n_transforms++);
+
+ transforms = g_new (GimpMatrix3, n_transforms);
+
+ for (i = 0; i < n_transforms; i++)
+ {
+ gegl_matrix3_parse_string ((GeglMatrix3 *) &transforms[i],
+ transform_strs[i]);
+ }
+
+ set_func (set_data, area, transforms, n_transforms);
+
+ g_strfreev (transform_strs);
+ g_free (transforms);
+
+ gtk_widget_set_sensitive (add_button, n_transforms < MAX_N_TRANSFORMS);
+ gtk_widget_set_sensitive (duplicate_button, n_transforms < MAX_N_TRANSFORMS);
+ gtk_widget_set_sensitive (remove_button, n_transforms > 1);
}
GtkWidget *
@@ -114,16 +234,86 @@ _gimp_prop_gui_new_recursive_transform (GObject *config,
create_controller_func,
creator);
-
if (create_controller_func)
{
- GCallback set_func;
- gpointer set_data;
+ GtkWidget *outer_vbox;
+ GtkWidget *hbox;
+ GtkWidget *button;
+ GtkWidget *image;
+ GCallback set_func;
+ gpointer set_data;
+
+ outer_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL,
+ gtk_box_get_spacing (GTK_BOX (vbox)));
+
+ gtk_box_pack_start (GTK_BOX (outer_vbox), vbox, FALSE, FALSE, 0);
+ gtk_widget_show (vbox);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+ gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
+ gtk_box_pack_start (GTK_BOX (outer_vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show (hbox);
+
+ button = gtk_button_new ();
+ gimp_help_set_help_data (button,
+ _("Add transform"),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ image = gtk_image_new_from_icon_name (GIMP_ICON_LIST_ADD,
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (add_transform),
+ config);
+
+ g_object_set_data (config, "add-transform-button", button);
+
+ button = gtk_button_new ();
+ gimp_help_set_help_data (button,
+ _("Duplicate transform"),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ image = gtk_image_new_from_icon_name (GIMP_ICON_OBJECT_DUPLICATE,
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (duplicate_transform),
+ config);
+
+ g_object_set_data (config, "duplicate-transform-button", button);
+
+ button = gtk_button_new ();
+ gimp_help_set_help_data (button,
+ _("Remove transform"),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show (button);
+
+ image = gtk_image_new_from_icon_name (GIMP_ICON_LIST_REMOVE,
+ GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (remove_transform),
+ config);
+
+ g_object_set_data (config, "remove-transform-button", button);
+
+ vbox = outer_vbox;
set_func = create_controller_func (creator,
- GIMP_CONTROLLER_TYPE_TRANSFORM_GRID,
+ GIMP_CONTROLLER_TYPE_TRANSFORM_GRIDS,
_("Recursive Transform: "),
- (GCallback) transform_grid_callback,
+ (GCallback) transform_grids_callback,
config,
&set_data);
diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c
index cf79c51a66..5f63fc7868 100644
--- a/app/propgui/gimppropgui.c
+++ b/app/propgui/gimppropgui.c
@@ -56,7 +56,6 @@
#include "gimppropgui-hue-saturation.h"
#include "gimppropgui-panorama-projection.h"
#include "gimppropgui-recursive-transform.h"
-#include "gimppropgui-recursive-transform-plus.h"
#include "gimppropgui-shadows-highlights.h"
#include "gimppropgui-spiral.h"
#include "gimppropgui-supernova.h"
@@ -457,8 +456,6 @@ gui_new_funcs[] =
_gimp_prop_gui_new_panorama_projection },
{ "GimpGegl-gegl-recursive-transform-config",
_gimp_prop_gui_new_recursive_transform },
- { "GimpGegl-gegl-recursive-transform-plus-config",
- _gimp_prop_gui_new_recursive_transform_plus },
{ "GimpGegl-gegl-shadows-highlights-config",
_gimp_prop_gui_new_shadows_highlights },
{ "GimpGegl-gegl-spiral-config",
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 21f74ad6ab..8a1e2e9afc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -390,7 +390,6 @@ app/propgui/gimppropgui-generic.c
app/propgui/gimppropgui-hue-saturation.c
app/propgui/gimppropgui-panorama-projection.c
app/propgui/gimppropgui-recursive-transform.c
-app/propgui/gimppropgui-recursive-transform-plus.c
app/propgui/gimppropgui-shadows-highlights.c
app/propgui/gimppropgui-spiral.c
app/propgui/gimppropgui-supernova.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]