2013-05-30 22:33:30 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2014-05-27 08:11:51 +08:00
|
|
|
* gimppropgui.c
|
2017-07-03 06:37:55 +08:00
|
|
|
* Copyright (C) 2002-2017 Michael Natterer <mitch@gimp.org>
|
2013-05-30 22:33:30 +08:00
|
|
|
* Sven Neumann <sven@gimp.org>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2013-05-30 22:33:30 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gegl-paramspecs.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2017-07-03 18:29:41 +08:00
|
|
|
#include "propgui-types.h"
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2014-05-16 09:10:01 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
2017-07-09 23:59:29 +08:00
|
|
|
#include "operations/gimp-operation-config.h"
|
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2017-07-03 18:29:41 +08:00
|
|
|
#include "widgets/gimpcolorpanel.h"
|
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
#include "widgets/gimpspinscale.h"
|
|
|
|
#include "widgets/gimppropwidgets.h"
|
|
|
|
|
2014-05-27 08:11:51 +08:00
|
|
|
#include "gimppropgui.h"
|
2017-06-05 08:26:30 +08:00
|
|
|
#include "gimppropgui-channel-mixer.h"
|
2017-06-05 07:16:50 +08:00
|
|
|
#include "gimppropgui-color-balance.h"
|
2017-06-05 08:26:30 +08:00
|
|
|
#include "gimppropgui-color-rotate.h"
|
2017-10-16 23:47:43 +08:00
|
|
|
#include "gimppropgui-color-to-alpha.h"
|
2017-06-05 08:26:30 +08:00
|
|
|
#include "gimppropgui-convolution-matrix.h"
|
2017-10-16 01:26:57 +08:00
|
|
|
#include "gimppropgui-diffraction-patterns.h"
|
2017-05-01 04:07:38 +08:00
|
|
|
#include "gimppropgui-eval.h"
|
2017-06-05 18:05:39 +08:00
|
|
|
#include "gimppropgui-generic.h"
|
2017-06-06 00:29:07 +08:00
|
|
|
#include "gimppropgui-hue-saturation.h"
|
2019-01-04 21:36:10 +08:00
|
|
|
#include "gimppropgui-motion-blur-circular.h"
|
|
|
|
#include "gimppropgui-motion-blur-linear.h"
|
|
|
|
#include "gimppropgui-motion-blur-zoom.h"
|
2019-07-18 00:24:33 +08:00
|
|
|
#include "gimppropgui-newsprint.h"
|
2018-04-10 21:53:42 +08:00
|
|
|
#include "gimppropgui-panorama-projection.h"
|
2018-03-01 15:24:58 +08:00
|
|
|
#include "gimppropgui-recursive-transform.h"
|
2018-01-05 10:56:08 +08:00
|
|
|
#include "gimppropgui-shadows-highlights.h"
|
2017-07-03 18:45:59 +08:00
|
|
|
#include "gimppropgui-spiral.h"
|
|
|
|
#include "gimppropgui-supernova.h"
|
2017-07-17 02:14:18 +08:00
|
|
|
#include "gimppropgui-utils.h"
|
2013-05-30 22:33:30 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
|
|
|
|
|
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
static gboolean gimp_prop_string_to_boolean (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue *to_value,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gimp_prop_config_notify (GObject *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void gimp_prop_widget_show (GtkWidget *widget,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_free_label_ref (GWeakRef *label_ref);
|
2014-05-27 08:07:23 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GtkWidget *
|
2017-07-03 06:37:55 +08:00
|
|
|
gimp_prop_widget_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
GeglRectangle *area,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpCreatePickerFunc create_picker_func,
|
|
|
|
GimpCreateControllerFunc create_controller_func,
|
|
|
|
gpointer creator,
|
|
|
|
const gchar **label)
|
2014-06-03 02:27:59 +08:00
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
|
|
|
|
|
|
|
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
|
|
|
|
property_name);
|
|
|
|
|
2016-07-06 18:19:40 +08:00
|
|
|
return gimp_prop_widget_new_from_pspec (config, pspec, area, context,
|
2017-07-03 06:37:55 +08:00
|
|
|
create_picker_func,
|
|
|
|
create_controller_func,
|
|
|
|
creator,
|
2014-06-03 02:27:59 +08:00
|
|
|
label);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2017-07-03 06:37:55 +08:00
|
|
|
gimp_prop_widget_new_from_pspec (GObject *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GeglRectangle *area,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpCreatePickerFunc create_picker_func,
|
|
|
|
GimpCreateControllerFunc create_controller_func,
|
|
|
|
gpointer creator,
|
|
|
|
const gchar **label)
|
2013-05-30 22:33:30 +08:00
|
|
|
{
|
2014-05-27 08:07:23 +08:00
|
|
|
GtkWidget *widget = NULL;
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
2014-06-03 02:27:59 +08:00
|
|
|
g_return_val_if_fail (pspec != NULL, NULL);
|
2014-05-27 08:07:23 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
g_return_val_if_fail (label != NULL, NULL);
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
*label = NULL;
|
|
|
|
|
2014-05-27 16:47:41 +08:00
|
|
|
if (GEGL_IS_PARAM_SPEC_SEED (pspec))
|
|
|
|
{
|
2017-07-17 02:14:18 +08:00
|
|
|
widget = gimp_prop_random_seed_new (config, pspec->name);
|
2014-05-27 16:47:41 +08:00
|
|
|
|
|
|
|
*label = g_param_spec_get_nick (pspec);
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_INT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_UINT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_DOUBLE (pspec))
|
2013-05-30 22:33:30 +08:00
|
|
|
{
|
2014-05-27 08:07:23 +08:00
|
|
|
gdouble lower;
|
|
|
|
gdouble upper;
|
|
|
|
gdouble step;
|
|
|
|
gdouble page;
|
|
|
|
gint digits;
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
|
|
|
|
{
|
|
|
|
GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
lower = gspec->ui_minimum;
|
|
|
|
upper = gspec->ui_maximum;
|
|
|
|
step = gspec->ui_step_small;
|
|
|
|
page = gspec->ui_step_big;
|
|
|
|
digits = gspec->ui_digits;
|
|
|
|
}
|
|
|
|
else if (GEGL_IS_PARAM_SPEC_INT (pspec))
|
|
|
|
{
|
|
|
|
GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
|
|
|
|
|
|
|
|
lower = gspec->ui_minimum;
|
|
|
|
upper = gspec->ui_maximum;
|
|
|
|
step = gspec->ui_step_small;
|
|
|
|
page = gspec->ui_step_big;
|
|
|
|
digits = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdouble value;
|
|
|
|
|
2016-06-14 22:52:52 +08:00
|
|
|
/* Get the min and max for the given property. */
|
2014-05-27 08:07:23 +08:00
|
|
|
_gimp_prop_widgets_get_numeric_values (config, pspec,
|
|
|
|
&value, &lower, &upper,
|
|
|
|
G_STRFUNC);
|
|
|
|
|
|
|
|
if ((upper - lower <= 1.0) &&
|
|
|
|
(G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_DOUBLE (pspec)))
|
|
|
|
{
|
|
|
|
step = 0.01;
|
|
|
|
page = 0.1;
|
|
|
|
digits = 4;
|
|
|
|
}
|
|
|
|
else if ((upper - lower <= 10.0) &&
|
|
|
|
(G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_DOUBLE (pspec)))
|
|
|
|
{
|
|
|
|
step = 0.1;
|
|
|
|
page = 1.0;
|
|
|
|
digits = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
step = 1.0;
|
|
|
|
page = 10.0;
|
|
|
|
digits = (G_IS_PARAM_SPEC_FLOAT (pspec) ||
|
|
|
|
G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 02:27:59 +08:00
|
|
|
widget = gimp_prop_spin_scale_new (config, pspec->name, NULL,
|
2014-05-27 08:07:23 +08:00
|
|
|
step, page, digits);
|
|
|
|
|
|
|
|
if (HAS_KEY (pspec, "unit", "degree") &&
|
|
|
|
(upper - lower) == 360.0)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *dial;
|
|
|
|
|
|
|
|
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
|
|
|
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
dial = gimp_prop_angle_dial_new (config, pspec->name);
|
2018-07-24 14:01:13 +08:00
|
|
|
g_object_set (dial,
|
|
|
|
"clockwise-angles", HAS_KEY (pspec, "direction", "cw"),
|
|
|
|
NULL);
|
2014-05-27 08:07:23 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), dial, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (dial);
|
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
gimp_help_set_help_data (hbox, g_param_spec_get_blurb (pspec), NULL);
|
|
|
|
gimp_prop_gui_bind_label (hbox, widget);
|
|
|
|
|
2014-06-02 02:58:21 +08:00
|
|
|
widget = hbox;
|
|
|
|
}
|
|
|
|
else if (HAS_KEY (pspec, "unit", "kelvin"))
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
button = gimp_prop_kelvin_presets_new (config, pspec->name);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
gimp_help_set_help_data (hbox, g_param_spec_get_blurb (pspec), NULL);
|
|
|
|
gimp_prop_gui_bind_label (hbox, widget);
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
widget = hbox;
|
|
|
|
}
|
2017-05-01 04:07:38 +08:00
|
|
|
else
|
2016-07-06 18:19:40 +08:00
|
|
|
{
|
2017-05-01 04:07:38 +08:00
|
|
|
gimp_prop_gui_bind_label (widget, widget);
|
2016-07-06 18:19:40 +08:00
|
|
|
|
2019-01-04 05:19:48 +08:00
|
|
|
if (area &&
|
|
|
|
(HAS_KEY (pspec, "unit", "pixel-coordinate") ||
|
|
|
|
HAS_KEY (pspec, "unit", "pixel-distance")) &&
|
|
|
|
(HAS_KEY (pspec, "axis", "x") ||
|
|
|
|
HAS_KEY (pspec, "axis", "y")))
|
2017-05-01 04:07:38 +08:00
|
|
|
{
|
2019-01-04 05:19:48 +08:00
|
|
|
gdouble min = lower;
|
|
|
|
gdouble max = upper;
|
|
|
|
|
|
|
|
if (HAS_KEY (pspec, "unit", "pixel-coordinate"))
|
2016-07-06 18:19:40 +08:00
|
|
|
{
|
2019-01-04 05:19:48 +08:00
|
|
|
/* limit pixel coordinate scales to the actual area */
|
2017-07-03 07:50:08 +08:00
|
|
|
|
2019-01-04 05:19:48 +08:00
|
|
|
gint off_x = area->x;
|
|
|
|
gint off_y = area->y;
|
2017-07-03 07:50:08 +08:00
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
if (HAS_KEY (pspec, "axis", "x"))
|
|
|
|
{
|
2019-01-04 05:19:48 +08:00
|
|
|
min = MAX (lower, off_x);
|
|
|
|
max = MIN (upper, off_x + area->width);
|
2017-05-01 04:07:38 +08:00
|
|
|
}
|
|
|
|
else if (HAS_KEY (pspec, "axis","y"))
|
|
|
|
{
|
2019-01-04 05:19:48 +08:00
|
|
|
min = MAX (lower, off_y);
|
|
|
|
max = MIN (upper, off_y + area->height);
|
2017-05-01 04:07:38 +08:00
|
|
|
}
|
2016-07-06 18:19:40 +08:00
|
|
|
}
|
2019-01-04 05:19:48 +08:00
|
|
|
else if (HAS_KEY (pspec, "unit", "pixel-distance"))
|
|
|
|
{
|
|
|
|
/* limit pixel distance scales to the same value on the
|
|
|
|
* x and y axes, so linked values have the same range,
|
|
|
|
* we use MAX (width, height), see issue #2540
|
|
|
|
*/
|
|
|
|
|
|
|
|
max = MIN (upper, MAX (area->width, area->height));
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
|
|
|
|
min, max);
|
2016-07-06 18:19:40 +08:00
|
|
|
}
|
|
|
|
}
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
2014-05-27 08:07:23 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
2013-05-30 22:33:30 +08:00
|
|
|
{
|
2016-04-16 09:48:24 +08:00
|
|
|
*label = g_param_spec_get_nick (pspec);
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
|
|
|
|
{
|
2014-06-03 02:27:59 +08:00
|
|
|
widget =
|
|
|
|
gimp_prop_file_chooser_button_new (config, pspec->name,
|
|
|
|
g_param_spec_get_nick (pspec),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
2014-05-27 08:07:23 +08:00
|
|
|
}
|
2016-03-26 19:22:01 +08:00
|
|
|
else if (HAS_KEY (pspec, "multiline", "true"))
|
2014-05-27 08:07:23 +08:00
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkWidget *view;
|
|
|
|
|
|
|
|
buffer = gimp_prop_text_buffer_new (config, pspec->name, -1);
|
|
|
|
view = gtk_text_view_new_with_buffer (buffer);
|
2014-06-20 14:59:42 +08:00
|
|
|
g_object_unref (buffer);
|
2014-05-27 08:07:23 +08:00
|
|
|
|
|
|
|
widget = gtk_scrolled_window_new (NULL, NULL);
|
2016-04-17 00:51:32 +08:00
|
|
|
gtk_widget_set_size_request (widget, -1, 150);
|
2014-05-27 08:07:23 +08:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (widget), view);
|
|
|
|
gtk_widget_show (view);
|
|
|
|
}
|
2016-04-16 09:48:24 +08:00
|
|
|
else if (HAS_KEY (pspec, "error", "true"))
|
|
|
|
{
|
|
|
|
GtkWidget *l;
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
widget = gimp_message_box_new (GIMP_ICON_WILBER_EEK);
|
2016-04-16 09:48:24 +08:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (widget), "%s",
|
|
|
|
*label);
|
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_BOX (widget), "%s", "");
|
|
|
|
|
|
|
|
l = GIMP_MESSAGE_BOX (widget)->label[1];
|
|
|
|
|
|
|
|
g_object_bind_property (config, pspec->name,
|
|
|
|
l, "label",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
g_object_bind_property_full (config, pspec->name,
|
|
|
|
widget, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
gimp_prop_string_to_boolean,
|
|
|
|
NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
*label = NULL;
|
|
|
|
}
|
2014-05-27 08:07:23 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
widget = gimp_prop_entry_new (config, pspec->name, -1);
|
|
|
|
}
|
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
2014-05-27 08:07:23 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
|
|
|
|
{
|
|
|
|
widget = gimp_prop_check_button_new (config, pspec->name,
|
|
|
|
g_param_spec_get_nick (pspec));
|
2017-05-01 04:07:38 +08:00
|
|
|
|
|
|
|
gimp_prop_gui_bind_label (widget, widget);
|
2014-05-27 08:07:23 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
|
|
|
{
|
|
|
|
widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0);
|
|
|
|
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget),
|
|
|
|
g_param_spec_get_nick (pspec));
|
2017-05-01 04:07:38 +08:00
|
|
|
|
|
|
|
gimp_prop_gui_bind_label (widget, widget);
|
2014-05-27 08:07:23 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
|
|
|
|
{
|
2017-11-03 01:50:17 +08:00
|
|
|
gboolean has_alpha;
|
2014-05-27 08:07:23 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
|
2017-11-03 01:50:17 +08:00
|
|
|
has_alpha = gimp_param_spec_rgb_has_alpha (pspec);
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
|
|
|
|
|
|
|
button = gimp_prop_color_button_new (config, pspec->name,
|
|
|
|
g_param_spec_get_nick (pspec),
|
|
|
|
128, 24,
|
2017-11-03 01:50:17 +08:00
|
|
|
has_alpha ?
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT);
|
2014-05-27 08:07:23 +08:00
|
|
|
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
|
|
|
|
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
|
|
|
|
gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2018-03-09 04:22:31 +08:00
|
|
|
gimp_prop_gui_bind_tooltip (button, widget);
|
2017-05-01 04:07:38 +08:00
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
if (create_picker_func)
|
|
|
|
{
|
2017-07-03 06:37:55 +08:00
|
|
|
button = create_picker_func (creator,
|
2014-05-27 08:07:23 +08:00
|
|
|
pspec->name,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_COLOR_PICKER_GRAY,
|
2017-05-03 22:41:12 +08:00
|
|
|
_("Pick color from the image"),
|
2017-10-16 23:38:28 +08:00
|
|
|
/* pick_abyss = */ FALSE,
|
|
|
|
NULL, NULL);
|
2014-05-27 08:07:23 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
}
|
|
|
|
|
|
|
|
*label = g_param_spec_get_nick (pspec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name);
|
|
|
|
}
|
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
/* if we have any keys for dynamic properties, listen to config's notify
|
|
|
|
* signal, and update the properties accordingly.
|
|
|
|
*/
|
|
|
|
if (gegl_param_spec_get_property_key (pspec, "sensitive") ||
|
|
|
|
gegl_param_spec_get_property_key (pspec, "visible") ||
|
|
|
|
gegl_param_spec_get_property_key (pspec, "label") ||
|
|
|
|
gegl_param_spec_get_property_key (pspec, "description"))
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (widget), "gimp-prop-pspec", pspec);
|
|
|
|
|
|
|
|
g_signal_connect_object (config, "notify",
|
|
|
|
G_CALLBACK (gimp_prop_config_notify),
|
|
|
|
widget, 0);
|
|
|
|
|
|
|
|
if (gegl_param_spec_get_property_key (pspec, "visible"))
|
|
|
|
{
|
|
|
|
/* a bit of a hack: if we have a dynamic "visible" property key,
|
|
|
|
* connect to the widget's "show" signal, so that we can intercept
|
|
|
|
* our caller's gtk_widget_show() call, and keep the widget hidden if
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
g_signal_connect (widget, "show",
|
|
|
|
G_CALLBACK (gimp_prop_widget_show),
|
|
|
|
config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update all the properties now */
|
|
|
|
gimp_prop_config_notify (config, NULL, widget);
|
|
|
|
}
|
|
|
|
|
2019-09-26 02:24:06 +08:00
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
return widget;
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
|
|
|
|
2014-05-27 17:19:32 +08:00
|
|
|
|
2017-07-03 06:37:55 +08:00
|
|
|
typedef GtkWidget * (* GimpPropGuiNewFunc) (GObject *config,
|
|
|
|
GParamSpec **param_specs,
|
|
|
|
guint n_param_specs,
|
|
|
|
GeglRectangle *area,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpCreatePickerFunc create_picker_func,
|
|
|
|
GimpCreateControllerFunc create_controller_func,
|
|
|
|
gpointer creator);
|
2014-05-27 17:19:32 +08:00
|
|
|
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const gchar *config_type;
|
|
|
|
GimpPropGuiNewFunc gui_new_func;
|
|
|
|
}
|
|
|
|
gui_new_funcs[] =
|
|
|
|
{
|
2017-06-05 07:16:50 +08:00
|
|
|
{ "GimpColorBalanceConfig",
|
|
|
|
_gimp_prop_gui_new_color_balance },
|
2017-06-06 00:29:07 +08:00
|
|
|
{ "GimpHueSaturationConfig",
|
|
|
|
_gimp_prop_gui_new_hue_saturation },
|
2014-05-28 04:09:40 +08:00
|
|
|
{ "GimpGegl-gegl-color-rotate-config",
|
2014-05-28 07:00:50 +08:00
|
|
|
_gimp_prop_gui_new_color_rotate },
|
2018-02-15 21:55:33 +08:00
|
|
|
{ "GimpGegl-gegl-color-to-alpha-config",
|
2017-10-16 23:47:43 +08:00
|
|
|
_gimp_prop_gui_new_color_to_alpha },
|
2014-05-28 04:09:40 +08:00
|
|
|
{ "GimpGegl-gegl-convolution-matrix-config",
|
|
|
|
_gimp_prop_gui_new_convolution_matrix },
|
2014-12-08 01:25:11 +08:00
|
|
|
{ "GimpGegl-gegl-channel-mixer-config",
|
|
|
|
_gimp_prop_gui_new_channel_mixer },
|
2015-02-07 02:43:49 +08:00
|
|
|
{ "GimpGegl-gegl-diffraction-patterns-config",
|
|
|
|
_gimp_prop_gui_new_diffraction_patterns },
|
2019-01-04 21:36:10 +08:00
|
|
|
{ "GimpGegl-gegl-motion-blur-circular-config",
|
|
|
|
_gimp_prop_gui_new_motion_blur_circular },
|
|
|
|
{ "GimpGegl-gegl-motion-blur-linear-config",
|
|
|
|
_gimp_prop_gui_new_motion_blur_linear },
|
|
|
|
{ "GimpGegl-gegl-motion-blur-zoom-config",
|
|
|
|
_gimp_prop_gui_new_motion_blur_zoom },
|
2019-07-18 00:24:33 +08:00
|
|
|
{ "GimpGegl-gegl-newsprint-config",
|
|
|
|
_gimp_prop_gui_new_newsprint },
|
2018-04-10 21:53:42 +08:00
|
|
|
{ "GimpGegl-gegl-panorama-projection-config",
|
|
|
|
_gimp_prop_gui_new_panorama_projection },
|
2018-03-01 15:24:58 +08:00
|
|
|
{ "GimpGegl-gegl-recursive-transform-config",
|
|
|
|
_gimp_prop_gui_new_recursive_transform },
|
2018-01-05 10:56:08 +08:00
|
|
|
{ "GimpGegl-gegl-shadows-highlights-config",
|
|
|
|
_gimp_prop_gui_new_shadows_highlights },
|
2017-07-03 06:37:55 +08:00
|
|
|
{ "GimpGegl-gegl-spiral-config",
|
|
|
|
_gimp_prop_gui_new_spiral },
|
2017-07-03 18:45:59 +08:00
|
|
|
{ "GimpGegl-gegl-supernova-config",
|
|
|
|
_gimp_prop_gui_new_supernova },
|
2014-05-28 04:09:40 +08:00
|
|
|
{ NULL,
|
|
|
|
_gimp_prop_gui_new_generic }
|
2014-05-27 17:19:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
GtkWidget *
|
2017-07-03 06:37:55 +08:00
|
|
|
gimp_prop_gui_new (GObject *config,
|
|
|
|
GType owner_type,
|
|
|
|
GParamFlags flags,
|
|
|
|
GeglRectangle *area,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpCreatePickerFunc create_picker_func,
|
|
|
|
GimpCreateControllerFunc create_controller_func,
|
|
|
|
gpointer creator)
|
2013-05-30 22:33:30 +08:00
|
|
|
{
|
2014-05-27 17:19:32 +08:00
|
|
|
GtkWidget *gui = NULL;
|
|
|
|
GParamSpec **param_specs;
|
|
|
|
guint n_param_specs;
|
2013-05-30 22:33:30 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
2014-05-27 08:07:23 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2017-07-10 01:20:55 +08:00
|
|
|
param_specs = gimp_operation_config_list_properties (config,
|
2017-07-09 23:59:29 +08:00
|
|
|
owner_type, flags,
|
|
|
|
&n_param_specs);
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2017-07-09 23:59:29 +08:00
|
|
|
if (param_specs)
|
2014-05-27 17:19:32 +08:00
|
|
|
{
|
2014-06-06 05:14:00 +08:00
|
|
|
const gchar *config_type_name = G_OBJECT_TYPE_NAME (config);
|
2017-07-09 23:59:29 +08:00
|
|
|
gint i;
|
2014-06-06 05:14:00 +08:00
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (gui_new_funcs); i++)
|
2013-05-30 22:33:30 +08:00
|
|
|
{
|
2014-06-06 05:14:00 +08:00
|
|
|
if (! gui_new_funcs[i].config_type ||
|
|
|
|
! strcmp (gui_new_funcs[i].config_type, config_type_name))
|
|
|
|
{
|
|
|
|
g_printerr ("GUI new func match: %s\n",
|
|
|
|
gui_new_funcs[i].config_type ?
|
|
|
|
gui_new_funcs[i].config_type : "generic fallback");
|
|
|
|
|
|
|
|
gui = gui_new_funcs[i].gui_new_func (config,
|
|
|
|
param_specs, n_param_specs,
|
2016-07-06 18:19:40 +08:00
|
|
|
area,
|
2014-06-06 05:14:00 +08:00
|
|
|
context,
|
|
|
|
create_picker_func,
|
2017-07-03 06:37:55 +08:00
|
|
|
create_controller_func,
|
|
|
|
creator);
|
2014-06-06 05:14:00 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
2017-07-09 23:59:29 +08:00
|
|
|
|
|
|
|
g_free (param_specs);
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
2014-06-06 05:14:00 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gui = gtk_label_new (_("This operation has no editable properties"));
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (gui),
|
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
-1);
|
2018-04-29 07:51:36 +08:00
|
|
|
g_object_set (gui,
|
|
|
|
"margin-top", 4,
|
|
|
|
"margin-bottom", 4,
|
|
|
|
NULL);
|
2014-06-06 05:14:00 +08:00
|
|
|
}
|
2013-05-30 22:33:30 +08:00
|
|
|
|
2019-09-26 02:24:06 +08:00
|
|
|
gtk_widget_show (gui);
|
|
|
|
|
2014-05-27 17:19:32 +08:00
|
|
|
return gui;
|
2013-05-30 22:33:30 +08:00
|
|
|
}
|
2014-05-27 08:07:23 +08:00
|
|
|
|
2017-05-01 04:07:38 +08:00
|
|
|
void
|
|
|
|
gimp_prop_gui_bind_container (GtkWidget *source,
|
|
|
|
GtkWidget *target)
|
|
|
|
{
|
|
|
|
g_object_bind_property (source, "sensitive",
|
|
|
|
target, "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
g_object_bind_property (source, "visible",
|
|
|
|
target, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_prop_gui_bind_label (GtkWidget *source,
|
|
|
|
GtkWidget *target)
|
|
|
|
{
|
|
|
|
GWeakRef *label_ref;
|
|
|
|
const gchar *label;
|
|
|
|
|
|
|
|
/* we want to update "target"'s "label" property whenever the label
|
|
|
|
* expression associated with "source" is reevaluated, however, "source"
|
|
|
|
* might not itself have a "label" property we can bind to. just keep around
|
|
|
|
* a reference to "target", and update its label manually.
|
|
|
|
*/
|
|
|
|
g_return_if_fail (g_object_get_data (G_OBJECT (source),
|
|
|
|
"gimp-prop-label-ref") == NULL);
|
|
|
|
|
|
|
|
label_ref = g_slice_new (GWeakRef);
|
|
|
|
|
|
|
|
g_weak_ref_init (label_ref, target);
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (source),
|
|
|
|
"gimp-prop-label-ref", label_ref,
|
|
|
|
(GDestroyNotify) gimp_prop_free_label_ref);
|
|
|
|
|
|
|
|
label = g_object_get_data (G_OBJECT (source), "gimp-prop-label");
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
g_object_set (target, "label", label, NULL);
|
|
|
|
|
|
|
|
/* note that "source" might be its own label widget, in which case there's no
|
|
|
|
* need to bind the rest of the properties.
|
|
|
|
*/
|
|
|
|
if (source != target)
|
|
|
|
gimp_prop_gui_bind_tooltip (source, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_prop_gui_bind_tooltip (GtkWidget *source,
|
|
|
|
GtkWidget *target)
|
|
|
|
{
|
|
|
|
g_object_bind_property (source, "tooltip-text",
|
|
|
|
target, "tooltip-text",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
|
2014-05-27 08:07:23 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2016-04-16 09:48:24 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_prop_string_to_boolean (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue *to_value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
const gchar *string = g_value_get_string (from_value);
|
|
|
|
|
|
|
|
g_value_set_boolean (to_value, string && *string);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-05-01 04:07:38 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_config_notify (GObject *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GParamSpec *widget_pspec;
|
|
|
|
GWeakRef *label_ref;
|
|
|
|
GtkWidget *label_widget;
|
|
|
|
gboolean sensitive;
|
|
|
|
gboolean visible;
|
|
|
|
gchar *label;
|
|
|
|
gchar *description;
|
|
|
|
|
|
|
|
widget_pspec = g_object_get_data (G_OBJECT (widget), "gimp-prop-pspec");
|
|
|
|
label_ref = g_object_get_data (G_OBJECT (widget), "gimp-prop-label-ref");
|
|
|
|
|
|
|
|
if (label_ref)
|
|
|
|
label_widget = g_weak_ref_get (label_ref);
|
|
|
|
else
|
|
|
|
label_widget = NULL;
|
|
|
|
|
|
|
|
sensitive = gimp_prop_eval_boolean (config, widget_pspec, "sensitive", TRUE);
|
|
|
|
visible = gimp_prop_eval_boolean (config, widget_pspec, "visible", TRUE);
|
|
|
|
label = gimp_prop_eval_string (config, widget_pspec, "label",
|
|
|
|
g_param_spec_get_nick (widget_pspec));
|
|
|
|
description = gimp_prop_eval_string (config, widget_pspec, "description",
|
|
|
|
g_param_spec_get_blurb (widget_pspec));
|
|
|
|
|
|
|
|
/* we store the label in (and pass ownership over it to) the widget's
|
|
|
|
* "gimp-prop-label" key, so that we can use it to initialize the label
|
|
|
|
* widget's label in gimp_prop_gui_bind_label() upon binding.
|
|
|
|
*/
|
|
|
|
g_object_set_data_full (G_OBJECT (widget), "gimp-prop-label", label, g_free);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (widget,
|
|
|
|
gimp_prop_widget_show, config);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (widget, sensitive);
|
|
|
|
gtk_widget_set_visible (widget, visible);
|
|
|
|
if (label_widget) g_object_set (label_widget, "label", label, NULL);
|
|
|
|
gimp_help_set_help_data (widget, description, NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (widget,
|
|
|
|
gimp_prop_widget_show, config);
|
|
|
|
|
|
|
|
g_free (description);
|
|
|
|
|
|
|
|
if (label_widget)
|
|
|
|
g_object_unref (label_widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_widget_show (GtkWidget *widget,
|
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *widget_pspec;
|
|
|
|
gboolean visible;
|
|
|
|
|
|
|
|
widget_pspec = g_object_get_data (G_OBJECT (widget), "gimp-prop-pspec");
|
|
|
|
|
|
|
|
visible = gimp_prop_eval_boolean (config, widget_pspec, "visible", TRUE);
|
|
|
|
|
|
|
|
gtk_widget_set_visible (widget, visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_free_label_ref (GWeakRef *label_ref)
|
|
|
|
{
|
|
|
|
g_weak_ref_clear (label_ref);
|
|
|
|
|
|
|
|
g_slice_free (GWeakRef, label_ref);
|
|
|
|
}
|