[gimp] app: add dedicated source files for gimp_prop_table_new()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add dedicated source files for gimp_prop_table_new()
- Date: Thu, 30 May 2013 14:37:48 +0000 (UTC)
commit 73d7c28f760a768ea5195b90a7142ef3c60356f8
Author: Michael Natterer <mitch gimp org>
Date: Thu May 30 16:33:30 2013 +0200
app: add dedicated source files for gimp_prop_table_new()
app/tools/gimpoperationtool.c | 2 +-
app/widgets/Makefile.am | 2 +
app/widgets/gimpproptable.c | 338 ++++++++++++++++++++++++++++++++++++
app/widgets/gimpproptable.h | 39 +++++
app/widgets/gimppropwidgets.c | 379 +++++------------------------------------
app/widgets/gimppropwidgets.h | 20 +--
po/POTFILES.in | 1 +
7 files changed, 431 insertions(+), 350 deletions(-)
---
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index f60f6ba..3b91eab 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -41,7 +41,7 @@
#include "core/gimpsettings.h"
#include "widgets/gimphelp-ids.h"
-#include "widgets/gimppropwidgets.h"
+#include "widgets/gimpproptable.h"
#include "display/gimpdisplay.h"
diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am
index 9e2ff60..c0485b6 100644
--- a/app/widgets/Makefile.am
+++ b/app/widgets/Makefile.am
@@ -271,6 +271,8 @@ libappwidgets_a_sources = \
gimpprogressbox.h \
gimpprogressdialog.c \
gimpprogressdialog.h \
+ gimpproptable.c \
+ gimpproptable.h \
gimppropwidgets.c \
gimppropwidgets.h \
gimpradioaction.c \
diff --git a/app/widgets/gimpproptable.c b/app/widgets/gimpproptable.c
new file mode 100644
index 0000000..f229583
--- /dev/null
+++ b/app/widgets/gimpproptable.c
@@ -0,0 +1,338 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
+ *
+ * gimppropwidgets.c
+ * Copyright (C) 2002-2004 Michael Natterer <mitch gimp org>
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <gegl.h>
+#include <gegl-paramspecs.h>
+#include <gtk/gtk.h>
+
+#include "libgimpcolor/gimpcolor.h"
+#include "libgimpbase/gimpbase.h"
+#include "libgimpconfig/gimpconfig.h"
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "widgets-types.h"
+
+#include "core/gimpcontext.h"
+
+#include "gimpcolorpanel.h"
+#include "gimpspinscale.h"
+#include "gimpproptable.h"
+#include "gimppropwidgets.h"
+
+#include "gimp-intl.h"
+
+
+static void
+gimp_prop_table_chain_toggled (GimpChainButton *chain,
+ GtkAdjustment *x_adj)
+{
+ GtkAdjustment *y_adj;
+
+ y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
+
+ if (gimp_chain_button_get_active (chain))
+ {
+ GBinding *binding;
+
+ binding = g_object_bind_property (x_adj, "value",
+ y_adj, "value",
+ G_BINDING_BIDIRECTIONAL);
+
+ g_object_set_data (G_OBJECT (chain), "binding", binding);
+ }
+ else
+ {
+ GBinding *binding;
+
+ binding = g_object_get_data (G_OBJECT (chain), "binding");
+
+ g_object_unref (binding);
+ g_object_set_data (G_OBJECT (chain), "binding", NULL);
+ }
+}
+
+static void
+gimp_prop_table_new_seed_clicked (GtkButton *button,
+ GtkAdjustment *adj)
+{
+ guint32 value = g_random_int_range (gtk_adjustment_get_lower (adj),
+ gtk_adjustment_get_upper (adj));
+
+ gtk_adjustment_set_value (adj, value);
+}
+
+GtkWidget *
+gimp_prop_table_new (GObject *config,
+ GType owner_type,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker_func,
+ gpointer picker_creator)
+{
+ GtkWidget *table;
+ GtkSizeGroup *size_group;
+ GParamSpec **param_specs;
+ guint n_param_specs;
+ gint i;
+ gint row = 0;
+ GtkAdjustment *last_x_adj = NULL;
+ gint last_x_row = 0;
+
+ g_return_val_if_fail (G_IS_OBJECT (config), NULL);
+ g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
+
+ param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
+ &n_param_specs);
+
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ table = gtk_table_new (3, 1, FALSE);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 4);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 2);
+
+ for (i = 0; i < n_param_specs; i++)
+ {
+ GParamSpec *pspec = param_specs[i];
+ GtkWidget *widget = NULL;
+ const gchar *label = NULL;
+
+ /* ignore properties of parent classes of owner_type */
+ if (! g_type_is_a (pspec->owner_type, owner_type))
+ continue;
+
+ if (G_IS_PARAM_SPEC_STRING (pspec))
+ {
+ static GQuark multiline_quark = 0;
+
+ if (! multiline_quark)
+ multiline_quark = g_quark_from_static_string ("multiline");
+
+ if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
+ {
+ widget = gimp_prop_file_chooser_button_new (config,
+ pspec->name,
+ g_param_spec_get_nick (pspec),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ }
+ else if (g_param_spec_get_qdata (pspec, multiline_quark))
+ {
+ GtkTextBuffer *buffer;
+ GtkWidget *view;
+
+ buffer = gimp_prop_text_buffer_new (config, pspec->name, -1);
+ view = gtk_text_view_new_with_buffer (buffer);
+
+ widget = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
+ GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (widget), view);
+ gtk_widget_show (view);
+ }
+ else
+ {
+ widget = gimp_prop_entry_new (config, pspec->name, -1);
+ }
+
+ label = g_param_spec_get_nick (pspec);
+ }
+ else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
+ {
+ widget = gimp_prop_check_button_new (config, pspec->name,
+ g_param_spec_get_nick (pspec));
+ }
+ else if (G_IS_PARAM_SPEC_ENUM (pspec))
+ {
+ widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0);
+ label = g_param_spec_get_nick (pspec);
+ }
+ else if (GEGL_IS_PARAM_SPEC_SEED (pspec))
+ {
+ GtkAdjustment *adj;
+ GtkWidget *scale;
+ GtkWidget *button;
+
+ widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+
+ scale = gimp_prop_spin_scale_new (config, pspec->name,
+ g_param_spec_get_nick (pspec),
+ 1.0, 10.0, 0);
+ gtk_box_pack_start (GTK_BOX (widget), scale, TRUE, TRUE, 0);
+ gtk_widget_show (scale);
+
+ button = gtk_button_new_with_label (_("New Seed"));
+ gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (scale));
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (gimp_prop_table_new_seed_clicked),
+ adj);
+ }
+ 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))
+ {
+ GtkAdjustment *adj;
+ gdouble value;
+ gdouble lower;
+ gdouble upper;
+ gdouble step = 1.0;
+ gdouble page = 10.0;
+ gint digits = (G_IS_PARAM_SPEC_FLOAT (pspec) ||
+ G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0;
+
+ if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
+ {
+ GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
+
+ lower = gspec->ui_minimum;
+ upper = gspec->ui_maximum;
+ }
+ else if (GEGL_IS_PARAM_SPEC_INT (pspec))
+ {
+ GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
+
+ lower = gspec->ui_minimum;
+ upper = gspec->ui_maximum;
+ }
+ else
+ {
+ _gimp_prop_widgets_get_numeric_values (config, pspec,
+ &value, &lower, &upper,
+ G_STRFUNC);
+ }
+
+ 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;
+ }
+
+ widget = gimp_prop_spin_scale_new (config, pspec->name,
+ g_param_spec_get_nick (pspec),
+ step, page, digits);
+
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
+
+ if (g_str_has_suffix (pspec->name, "x") ||
+ g_str_has_suffix (pspec->name, "width"))
+ {
+ last_x_adj = adj;
+ last_x_row = row;
+ }
+ else if ((g_str_has_suffix (pspec->name, "y") ||
+ g_str_has_suffix (pspec->name, "height")) &&
+ last_x_adj != NULL &&
+ last_x_row == row - 1)
+ {
+ GtkWidget *chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
+
+ gtk_table_attach (GTK_TABLE (table), chain,
+ 3, 4, last_x_row, row + 1,
+ GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL,
+ 0, 0);
+ gtk_widget_show (chain);
+
+ if (gtk_adjustment_get_value (last_x_adj) ==
+ gtk_adjustment_get_value (adj))
+ {
+ GBinding *binding;
+
+ gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), TRUE);
+
+ binding = g_object_bind_property (last_x_adj, "value",
+ adj, "value",
+ G_BINDING_BIDIRECTIONAL);
+
+ g_object_set_data (G_OBJECT (chain), "binding", binding);
+ }
+
+ g_signal_connect (chain, "toggled",
+ G_CALLBACK (gimp_prop_table_chain_toggled),
+ last_x_adj);
+
+ g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj);
+ }
+ }
+ else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
+ {
+ GtkWidget *button;
+
+ 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,
+ GIMP_COLOR_AREA_SMALL_CHECKS);
+ 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);
+
+ button = create_picker_func (picker_creator,
+ pspec->name,
+ GIMP_STOCK_COLOR_PICKER_GRAY,
+ _("Pick color from image"));
+ 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);
+ }
+
+ if (widget)
+ {
+ if (label)
+ {
+ gimp_table_attach_aligned (GTK_TABLE (table), 0, row,
+ label, 0.0, 0.5,
+ widget, 2, FALSE);
+ }
+ else
+ {
+ gtk_table_attach_defaults (GTK_TABLE (table), widget,
+ 0, 3, row, row + 1);
+ gtk_widget_show (widget);
+ }
+
+ row++;
+ }
+ }
+
+ g_object_unref (size_group);
+
+ g_free (param_specs);
+
+ return table;
+}
diff --git a/app/widgets/gimpproptable.h b/app/widgets/gimpproptable.h
new file mode 100644
index 0000000..73244c8
--- /dev/null
+++ b/app/widgets/gimpproptable.h
@@ -0,0 +1,39 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
+ *
+ * gimpproptable.h
+ * Copyright (C) 2002-2013 Michael Natterer <mitch 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_PROP_TABLE_H__
+#define __GIMP_PROP_TABLE_H__
+
+
+/* A view on all of an object's properties */
+
+typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
+ const gchar *property_name,
+ const gchar *stock_id,
+ const gchar *help_id);
+
+GtkWidget * gimp_prop_table_new (GObject *config,
+ GType owner_type,
+ GimpContext *context,
+ GimpCreatePickerFunc create_picker_fnc,
+ gpointer picker_creator);
+
+
+#endif /* __GIMP_PROP_TABLE_H__ */
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index 05b4f38..f97b564 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -73,13 +73,6 @@ static GParamSpec * check_param_spec_w (GObject *object,
GType type,
const gchar *strloc);
-static gboolean get_numeric_values (GObject *object,
- GParamSpec *param_spec,
- gdouble *value,
- gdouble *lower,
- gdouble *upper,
- const gchar *strloc);
-
static void connect_notify (GObject *config,
const gchar *property_name,
GCallback callback,
@@ -494,8 +487,9 @@ gimp_prop_spin_scale_new (GObject *config,
if (! param_spec)
return NULL;
- if (! get_numeric_values (config,
- param_spec, &value, &lower, &upper, G_STRFUNC))
+ if (! _gimp_prop_widgets_get_numeric_values (config, param_spec,
+ &value, &lower, &upper,
+ G_STRFUNC))
return NULL;
if (! G_IS_PARAM_SPEC_DOUBLE (param_spec))
@@ -1439,299 +1433,59 @@ gimp_prop_icon_picker_notify (GObject *config,
}
-/***********/
-/* table */
-/***********/
+/******************************/
+/* public utility functions */
+/******************************/
-static void
-gimp_prop_table_chain_toggled (GimpChainButton *chain,
- GtkAdjustment *x_adj)
+gboolean
+_gimp_prop_widgets_get_numeric_values (GObject *object,
+ GParamSpec *param_spec,
+ gdouble *value,
+ gdouble *lower,
+ gdouble *upper,
+ const gchar *strloc)
{
- GtkAdjustment *y_adj;
-
- y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");
-
- if (gimp_chain_button_get_active (chain))
+ if (G_IS_PARAM_SPEC_INT (param_spec))
{
- GBinding *binding;
+ GParamSpecInt *int_spec = G_PARAM_SPEC_INT (param_spec);
+ gint int_value;
- binding = g_object_bind_property (x_adj, "value",
- y_adj, "value",
- G_BINDING_BIDIRECTIONAL);
+ g_object_get (object, param_spec->name, &int_value, NULL);
- g_object_set_data (G_OBJECT (chain), "binding", binding);
+ *value = int_value;
+ *lower = int_spec->minimum;
+ *upper = int_spec->maximum;
}
- else
+ else if (G_IS_PARAM_SPEC_UINT (param_spec))
{
- GBinding *binding;
+ GParamSpecUInt *uint_spec = G_PARAM_SPEC_UINT (param_spec);
+ guint uint_value;
- binding = g_object_get_data (G_OBJECT (chain), "binding");
+ g_object_get (object, param_spec->name, &uint_value, NULL);
- g_object_unref (binding);
- g_object_set_data (G_OBJECT (chain), "binding", NULL);
+ *value = uint_value;
+ *lower = uint_spec->minimum;
+ *upper = uint_spec->maximum;
}
-}
-
-static void
-gimp_prop_table_new_seed_clicked (GtkButton *button,
- GtkAdjustment *adj)
-{
- guint32 value = g_random_int_range (gtk_adjustment_get_lower (adj),
- gtk_adjustment_get_upper (adj));
-
- gtk_adjustment_set_value (adj, value);
-}
-
-GtkWidget *
-gimp_prop_table_new (GObject *config,
- GType owner_type,
- GimpContext *context,
- GimpCreatePickerFunc create_picker_func,
- gpointer picker_creator)
-{
- GtkWidget *table;
- GtkSizeGroup *size_group;
- GParamSpec **param_specs;
- guint n_param_specs;
- gint i;
- gint row = 0;
- GtkAdjustment *last_x_adj = NULL;
- gint last_x_row = 0;
-
- g_return_val_if_fail (G_IS_OBJECT (config), NULL);
- g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
-
- param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
- &n_param_specs);
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
+ {
+ GParamSpecDouble *double_spec = G_PARAM_SPEC_DOUBLE (param_spec);
- table = gtk_table_new (3, 1, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 4);
- gtk_table_set_row_spacings (GTK_TABLE (table), 2);
+ g_object_get (object, param_spec->name, value, NULL);
- for (i = 0; i < n_param_specs; i++)
+ *lower = double_spec->minimum;
+ *upper = double_spec->maximum;
+ }
+ else
{
- GParamSpec *pspec = param_specs[i];
- GtkWidget *widget = NULL;
- const gchar *label = NULL;
-
- /* ignore properties of parent classes of owner_type */
- if (! g_type_is_a (pspec->owner_type, owner_type))
- continue;
-
- if (G_IS_PARAM_SPEC_STRING (pspec))
- {
- static GQuark multiline_quark = 0;
-
- if (! multiline_quark)
- multiline_quark = g_quark_from_static_string ("multiline");
-
- if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
- {
- widget = gimp_prop_file_chooser_button_new (config,
- pspec->name,
- g_param_spec_get_nick (pspec),
- GTK_FILE_CHOOSER_ACTION_OPEN);
- }
- else if (g_param_spec_get_qdata (pspec, multiline_quark))
- {
- GtkTextBuffer *buffer;
- GtkWidget *view;
-
- buffer = gimp_prop_text_buffer_new (config, pspec->name, -1);
- view = gtk_text_view_new_with_buffer (buffer);
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
- GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (widget), view);
- gtk_widget_show (view);
- }
- else
- {
- widget = gimp_prop_entry_new (config, pspec->name, -1);
- }
-
- label = g_param_spec_get_nick (pspec);
- }
- else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
- {
- widget = gimp_prop_check_button_new (config, pspec->name,
- g_param_spec_get_nick (pspec));
- }
- else if (G_IS_PARAM_SPEC_ENUM (pspec))
- {
- widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0);
- label = g_param_spec_get_nick (pspec);
- }
- else if (GEGL_IS_PARAM_SPEC_SEED (pspec))
- {
- GtkAdjustment *adj;
- GtkWidget *scale;
- GtkWidget *button;
-
- widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
-
- scale = gimp_prop_spin_scale_new (config, pspec->name,
- g_param_spec_get_nick (pspec),
- 1.0, 10.0, 0);
- gtk_box_pack_start (GTK_BOX (widget), scale, TRUE, TRUE, 0);
- gtk_widget_show (scale);
-
- button = gtk_button_new_with_label (_("New Seed"));
- gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (scale));
-
- g_signal_connect (button, "clicked",
- G_CALLBACK (gimp_prop_table_new_seed_clicked),
- adj);
- }
- 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))
- {
- GtkAdjustment *adj;
- gdouble value;
- gdouble lower;
- gdouble upper;
- gdouble step = 1.0;
- gdouble page = 10.0;
- gint digits = (G_IS_PARAM_SPEC_FLOAT (pspec) ||
- G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0;
-
- if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec))
- {
- GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec);
-
- lower = gspec->ui_minimum;
- upper = gspec->ui_maximum;
- }
- else if (GEGL_IS_PARAM_SPEC_INT (pspec))
- {
- GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec);
-
- lower = gspec->ui_minimum;
- upper = gspec->ui_maximum;
- }
- else
- {
- get_numeric_values (config, pspec,
- &value, &lower, &upper, G_STRFUNC);
- }
-
- 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;
- }
-
- widget = gimp_prop_spin_scale_new (config, pspec->name,
- g_param_spec_get_nick (pspec),
- step, page, digits);
-
- adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
-
- if (g_str_has_suffix (pspec->name, "x") ||
- g_str_has_suffix (pspec->name, "width"))
- {
- last_x_adj = adj;
- last_x_row = row;
- }
- else if ((g_str_has_suffix (pspec->name, "y") ||
- g_str_has_suffix (pspec->name, "height")) &&
- last_x_adj != NULL &&
- last_x_row == row - 1)
- {
- GtkWidget *chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
-
- gtk_table_attach (GTK_TABLE (table), chain,
- 3, 4, last_x_row, row + 1,
- GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL,
- 0, 0);
- gtk_widget_show (chain);
-
- if (gtk_adjustment_get_value (last_x_adj) ==
- gtk_adjustment_get_value (adj))
- {
- GBinding *binding;
-
- gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), TRUE);
-
- binding = g_object_bind_property (last_x_adj, "value",
- adj, "value",
- G_BINDING_BIDIRECTIONAL);
-
- g_object_set_data (G_OBJECT (chain), "binding", binding);
- }
-
- g_signal_connect (chain, "toggled",
- G_CALLBACK (gimp_prop_table_chain_toggled),
- last_x_adj);
-
- g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj);
- }
- }
- else if (GIMP_IS_PARAM_SPEC_RGB (pspec))
- {
- GtkWidget *button;
-
- 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,
- GIMP_COLOR_AREA_SMALL_CHECKS);
- 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);
-
- button = create_picker_func (picker_creator,
- pspec->name,
- GIMP_STOCK_COLOR_PICKER_GRAY,
- _("Pick color from image"));
- 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);
- }
-
- if (widget)
- {
- if (label)
- {
- gimp_table_attach_aligned (GTK_TABLE (table), 0, row,
- label, 0.0, 0.5,
- widget, 2, FALSE);
- }
- else
- {
- gtk_table_attach_defaults (GTK_TABLE (table), widget,
- 0, 3, row, row + 1);
- gtk_widget_show (widget);
- }
-
- row++;
- }
+ g_warning ("%s: property '%s' of %s is not numeric",
+ strloc,
+ param_spec->name,
+ g_type_name (G_TYPE_FROM_INSTANCE (object)));
+ return FALSE;
}
- g_object_unref (size_group);
-
- g_free (param_specs);
-
- return table;
+ return TRUE;
}
@@ -1844,57 +1598,6 @@ check_param_spec_w (GObject *object,
return param_spec;
}
-static gboolean
-get_numeric_values (GObject *object,
- GParamSpec *param_spec,
- gdouble *value,
- gdouble *lower,
- gdouble *upper,
- const gchar *strloc)
-{
- if (G_IS_PARAM_SPEC_INT (param_spec))
- {
- GParamSpecInt *int_spec = G_PARAM_SPEC_INT (param_spec);
- gint int_value;
-
- g_object_get (object, param_spec->name, &int_value, NULL);
-
- *value = int_value;
- *lower = int_spec->minimum;
- *upper = int_spec->maximum;
- }
- else if (G_IS_PARAM_SPEC_UINT (param_spec))
- {
- GParamSpecUInt *uint_spec = G_PARAM_SPEC_UINT (param_spec);
- guint uint_value;
-
- g_object_get (object, param_spec->name, &uint_value, NULL);
-
- *value = uint_value;
- *lower = uint_spec->minimum;
- *upper = uint_spec->maximum;
- }
- else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
- {
- GParamSpecDouble *double_spec = G_PARAM_SPEC_DOUBLE (param_spec);
-
- g_object_get (object, param_spec->name, value, NULL);
-
- *lower = double_spec->minimum;
- *upper = double_spec->maximum;
- }
- else
- {
- g_warning ("%s: property '%s' of %s is not numeric",
- strloc,
- param_spec->name,
- g_type_name (G_TYPE_FROM_INSTANCE (object)));
- return FALSE;
- }
-
- return TRUE;
-}
-
static void
connect_notify (GObject *config,
const gchar *property_name,
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index d13249d..f1efe21 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -88,6 +88,7 @@ GtkWidget * gimp_prop_number_pair_entry_new
gdouble min_valid_value,
gdouble max_valid_value);
+
/* GParamString */
GtkWidget * gimp_prop_language_combo_box_new (GObject *config,
@@ -98,18 +99,15 @@ GtkWidget * gimp_prop_language_entry_new (GObject *config,
GtkWidget * gimp_prop_icon_picker_new (GimpViewable *viewable,
Gimp *gimp);
-/* A view on all of an object's properties */
-typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
- const gchar *property_name,
- const gchar *stock_id,
- const gchar *help_id);
-
-GtkWidget * gimp_prop_table_new (GObject *config,
- GType owner_type,
- GimpContext *context,
- GimpCreatePickerFunc create_picker_fnc,
- gpointer picker_creator);
+/* Utility functions */
+
+gboolean _gimp_prop_widgets_get_numeric_values (GObject *object,
+ GParamSpec *param_spec,
+ gdouble *value,
+ gdouble *lower,
+ gdouble *upper,
+ const gchar *strloc);
#endif /* __GIMP_APP_PROP_WIDGETS_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4c540f8..bccc91c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -467,6 +467,7 @@ app/widgets/gimppanedbox.c
app/widgets/gimppdbdialog.c
app/widgets/gimpprofilechooserdialog.c
app/widgets/gimpprogressdialog.c
+app/widgets/gimpproptable.c
app/widgets/gimppropwidgets.c
app/widgets/gimpselectiondata.c
app/widgets/gimpselectioneditor.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]