[gimp/soc-2011-gimpunitentry] libgimpwidgets: port "new image" dialog to GimpUnitEntry
- From: Enrico SchrÃder <eschroeder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-gimpunitentry] libgimpwidgets: port "new image" dialog to GimpUnitEntry
- Date: Sun, 19 Jun 2011 16:05:40 +0000 (UTC)
commit dff0e067f90478dfed736941dc67cf99ef53b6f5
Author: Enrico SchroÌder <enni schroeder gmail com>
Date: Sun Jun 19 18:03:09 2011 +0200
libgimpwidgets: port "new image" dialog to GimpUnitEntry
Uses GimpUnitEntry instead of GimpSizeEntry for the "new image" dialog. Therefore gimppropwidgets.c has partially been ported, but the old GimpSizeEntry functions still exist to avoid breaking anything.
app/dialogs/image-new-dialog.c | 4 +-
app/widgets/gimptemplateeditor.c | 141 +++++----------
app/widgets/gimptemplateeditor.h | 2 +-
libgimpwidgets/gimppropwidgets.c | 389 ++++++++++++++++++++++++++++++++++++++
libgimpwidgets/gimppropwidgets.h | 9 +
5 files changed, 445 insertions(+), 100 deletions(-)
---
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 6a0816d..6487519 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -154,9 +154,9 @@ image_new_dialog_new (GimpContext *context)
gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
gtk_widget_show (dialog->editor);
- entry = GIMP_SIZE_ENTRY (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (dialog->editor)));
+ /*entry = GIMP_SIZE_ENTRY (gimp_template_editor_get_size_se (GIMP_TEMPLATE_EDITOR (dialog->editor)));
gimp_size_entry_set_activates_default (entry, TRUE);
- gimp_size_entry_grab_focus (entry);
+ gimp_size_entry_grab_focus (entry);*/
image_new_template_changed (dialog->context,
gimp_context_get_template (dialog->context),
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index c4f7b56..caa9982 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -58,11 +58,11 @@ struct _GimpTemplateEditorPrivate
gboolean block_aspect;
GtkWidget *expander;
- GtkWidget *size_se;
+ GimpUnitEntryTable *size_se;
GtkWidget *memsize_label;
GtkWidget *pixel_label;
GtkWidget *more_label;
- GtkWidget *resolution_se;
+ GimpUnitEntryTable *resolution_se;
};
#define GET_PRIVATE(editor) \
@@ -176,56 +176,33 @@ gimp_template_editor_constructed (GObject *object)
1, 2);
gtk_entry_set_width_chars (GTK_ENTRY (height), SB_WIDTH);
- /* the image size labels */
- label = gtk_label_new_with_mnemonic (_("_Width:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), width);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
- GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
- gtk_widget_show (label);
-
- label = gtk_label_new_with_mnemonic (_("H_eight:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), height);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
- GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
- gtk_widget_show (label);
-
/* create the sizeentry which keeps it all together */
hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
+ //gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
gtk_widget_show (hbox);
- private->size_se = gimp_size_entry_new (0,
- gimp_template_get_unit (template),
- _("%p"),
- TRUE, FALSE, FALSE, SB_WIDTH,
- GIMP_SIZE_ENTRY_UPDATE_SIZE);
+ private->size_se = GIMP_UNIT_ENTRY_TABLE (gimp_unit_entry_table_new ());
+
+ gtk_table_attach_defaults (GTK_TABLE (table), private->size_se->table, 0, 2, 0, 2);
gtk_table_set_row_spacing (GTK_TABLE (private->size_se), 0, 2);
gtk_table_set_col_spacing (GTK_TABLE (private->size_se), 1, 6);
- gtk_box_pack_start (GTK_BOX (hbox), private->size_se, FALSE, FALSE, 0);
- gtk_widget_show (private->size_se);
-
- gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
- GTK_SPIN_BUTTON (height), NULL);
- gtk_table_attach_defaults (GTK_TABLE (private->size_se), height, 0, 1, 1, 2);
- gtk_widget_show (height);
+ gimp_unit_entry_table_add_entry (private->size_se,
+ "width",
+ _("Width:"));
+ gimp_unit_entry_table_add_entry (private->size_se,
+ "heigth",
+ _("Height:"));
- gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
- GTK_SPIN_BUTTON (width), NULL);
- gtk_table_attach_defaults (GTK_TABLE (private->size_se), width, 0, 1, 0, 1);
- gtk_widget_show (width);
-
- gimp_prop_coordinates_connect (G_OBJECT (template),
+ gimp_prop_coordinates_connect2 (G_OBJECT (template),
"width", "height", "unit",
- private->size_se, NULL,
+ G_OBJECT (private->size_se), NULL,
gimp_template_get_resolution_x (template),
gimp_template_get_resolution_y (template));
hbox = gtk_hbox_new (FALSE, 12);
- gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 3, 2, 3);
+ gtk_table_attach_defaults (GTK_TABLE (table), hbox, 0, 3, 2, 3);
gtk_widget_show (hbox);
vbox = gtk_vbox_new (0, FALSE);
@@ -305,69 +282,41 @@ gimp_template_editor_constructed (GObject *object)
1, 2);
gtk_entry_set_width_chars (GTK_ENTRY (yres), SB_WIDTH);
- /* the resolution labels */
- label = gtk_label_new_with_mnemonic (_("_X resolution:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), xres);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
- GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
- gtk_widget_show (label);
-
- label = gtk_label_new_with_mnemonic (_("_Y resolution:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), yres);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
- GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
- gtk_widget_show (label);
-
/* the resolution sizeentry */
hbox = gtk_hbox_new (FALSE, 0);
- gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 2);
+ gtk_table_attach_defaults (GTK_TABLE (table), hbox, 0, 2, 0, 2);
gtk_widget_show (hbox);
- private->resolution_se =
- gimp_size_entry_new (0,
- gimp_template_get_resolution_unit (template),
- _("pixels/%s"),
- FALSE, FALSE, FALSE, SB_WIDTH,
- GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
+ private->resolution_se = GIMP_UNIT_ENTRY_TABLE (gimp_unit_entry_table_new ());
+
+ gimp_unit_entry_table_add_entry (private->resolution_se,
+ "xres",
+ _("X resolution:"));
+ gimp_unit_entry_table_add_entry (private->resolution_se,
+ "yres",
+ _("Y resolution:"));
+ gimp_unit_entry_table_set_res_mode (private->resolution_se, TRUE);
gtk_table_set_row_spacing (GTK_TABLE (private->resolution_se), 0, 2);
gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 1, 2);
gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 2, 2);
- gtk_box_pack_start (GTK_BOX (hbox), private->resolution_se, FALSE, FALSE, 0);
- gtk_widget_show (private->resolution_se);
-
- gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->resolution_se),
- GTK_SPIN_BUTTON (yres), NULL);
- gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), yres,
- 0, 1, 1, 2);
- gtk_widget_show (yres);
+ gtk_box_pack_start (GTK_BOX (hbox), private->resolution_se->table, TRUE, TRUE, 0);
+ gtk_widget_show (private->resolution_se->table);
- gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->resolution_se),
- GTK_SPIN_BUTTON (xres), NULL);
- gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), xres,
- 0, 1, 0, 1);
- gtk_widget_show (xres);
-
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
- gimp_template_get_resolution_x (template),
- FALSE);
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
- gimp_template_get_resolution_y (template),
- FALSE);
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 0),
+ gimp_template_get_resolution_x (template));
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 1),
+ gimp_template_get_resolution_y (template));
/* the resolution chainbutton */
- chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
- gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), chainbutton,
- 1, 2, 0, 2);
- gtk_widget_show (chainbutton);
+ chainbutton = gimp_unit_entry_table_add_chainbutton (private->resolution_se,
+ "xres", "yres");
- gimp_prop_coordinates_connect (G_OBJECT (template),
+ gimp_prop_coordinates_connect2 (G_OBJECT (template),
"xresolution", "yresolution",
"resolution-unit",
- private->resolution_se, chainbutton,
+ G_OBJECT (private->resolution_se), chainbutton,
1.0, 1.0);
focus_chain = g_list_prepend (focus_chain,
@@ -544,7 +493,7 @@ gimp_template_editor_show_advanced (GimpTemplateEditor *editor,
gtk_expander_set_expanded (GTK_EXPANDER (private->expander), expanded);
}
-GtkWidget *
+GimpUnitEntryTable *
gimp_template_editor_get_size_se (GimpTemplateEditor *editor)
{
g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
@@ -599,10 +548,10 @@ gimp_template_editor_aspect_callback (GtkWidget *widget,
gimp_template_editor_template_notify,
editor);
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
- yresolution, FALSE);
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
- xresolution, FALSE);
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 0),
+ yresolution);
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 1),
+ xresolution);
g_object_set (template,
"width", height,
@@ -637,15 +586,13 @@ gimp_template_editor_template_notify (GimpTemplate *template,
{
if (! strcmp (param_spec->name, "xresolution"))
{
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
- gimp_template_get_resolution_x (template),
- FALSE);
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 0),
+ gimp_template_get_resolution_x (template));
}
else if (! strcmp (param_spec->name, "yresolution"))
{
- gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
- gimp_template_get_resolution_y (template),
- FALSE);
+ gimp_unit_entry_set_resolution (gimp_unit_entry_table_get_nth_entry (private->size_se, 1),
+ gimp_template_get_resolution_y (template));
}
}
diff --git a/app/widgets/gimptemplateeditor.h b/app/widgets/gimptemplateeditor.h
index 0c47833..a804f70 100644
--- a/app/widgets/gimptemplateeditor.h
+++ b/app/widgets/gimptemplateeditor.h
@@ -53,7 +53,7 @@ GimpTemplate * gimp_template_editor_get_template (GimpTemplateEditor *editor);
void gimp_template_editor_show_advanced (GimpTemplateEditor *editor,
gboolean expanded);
-GtkWidget * gimp_template_editor_get_size_se (GimpTemplateEditor *editor);
+GimpUnitEntryTable * gimp_template_editor_get_size_se (GimpTemplateEditor *editor);
#endif /* __GIMP_TEMPLATE_EDITOR_H__ */
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index a8d2e23..9c73ebf 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -2807,15 +2807,27 @@ gimp_prop_size_entry_num_chars (gdouble lower,
static void gimp_prop_coordinates_callback (GimpSizeEntry *entry,
GObject *config);
+static void gimp_prop_coordinates_callback2 (GimpUnitEntryTable *entry,
+ GimpUnitEntry *e,
+ GObject *config);
static void gimp_prop_coordinates_notify_x (GObject *config,
GParamSpec *param_spec,
GimpSizeEntry *entry);
static void gimp_prop_coordinates_notify_y (GObject *config,
GParamSpec *param_spec,
GimpSizeEntry *entry);
+static void gimp_prop_coordinates_notify_x2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entry);
+static void gimp_prop_coordinates_notify_y2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entry);
static void gimp_prop_coordinates_notify_unit (GObject *config,
GParamSpec *param_spec,
GimpSizeEntry *entry);
+static void gimp_prop_coordinates_notify_unit2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entry);
/**
@@ -3040,6 +3052,154 @@ gimp_prop_coordinates_connect (GObject *config,
return TRUE;
}
+gboolean gimp_prop_coordinates_connect2 (GObject *config,
+ const gchar *x_property_name,
+ const gchar *y_property_name,
+ const gchar *unit_property_name,
+ GObject *sizeentry,
+ GtkWidget *chainbutton,
+ gdouble xresolution,
+ gdouble yresolution)
+{
+ GParamSpec *x_param_spec;
+ GParamSpec *y_param_spec;
+ GParamSpec *unit_param_spec;
+ gdouble x_value, x_lower, x_upper;
+ gdouble y_value, y_lower, y_upper;
+ GimpUnit unit_value;
+ gdouble *old_x_value;
+ gdouble *old_y_value;
+ GimpUnit *old_unit_value;
+ gboolean chain_checked;
+ GimpUnitEntry *entry1, *entry2;
+ GimpUnitEntryTable *entry;
+
+ g_return_val_if_fail (GIMP_IS_UNIT_ENTRY_TABLE (sizeentry), FALSE);
+ entry = GIMP_UNIT_ENTRY_TABLE (sizeentry);
+ g_return_val_if_fail (gimp_unit_entry_table_get_entry_count(entry) == 2, FALSE);
+ g_return_val_if_fail (chainbutton == NULL ||
+ GIMP_IS_CHAIN_BUTTON (chainbutton), FALSE);
+
+ x_param_spec = find_param_spec (config, x_property_name, G_STRFUNC);
+ if (! x_param_spec)
+ return FALSE;
+
+ y_param_spec = find_param_spec (config, y_property_name, G_STRFUNC);
+ if (! y_param_spec)
+ return FALSE;
+
+ if (! get_numeric_values (config, x_param_spec,
+ &x_value, &x_lower, &x_upper, G_STRFUNC) ||
+ ! get_numeric_values (config, y_param_spec,
+ &y_value, &y_lower, &y_upper, G_STRFUNC))
+ return FALSE;
+
+ if (unit_property_name)
+ {
+ unit_param_spec = check_param_spec_w (config, unit_property_name,
+ GIMP_TYPE_PARAM_UNIT, G_STRFUNC);
+ if (! unit_param_spec)
+ return FALSE;
+
+ g_object_get (config,
+ unit_property_name, &unit_value,
+ NULL);
+ }
+ else
+ {
+ unit_param_spec = NULL;
+ unit_value = GIMP_UNIT_INCH;
+ }
+
+ entry1 = gimp_unit_entry_table_get_nth_entry (entry, 0);
+ entry2 = gimp_unit_entry_table_get_nth_entry (entry, 1);
+
+ set_param_spec (NULL,
+ GTK_WIDGET (entry1),
+ x_param_spec);
+ set_param_spec (NULL,
+ GTK_WIDGET (entry2),
+ y_param_spec);
+
+ gimp_unit_entry_table_set_unit (entry, unit_value);
+
+ gimp_unit_entry_set_resolution (entry1, xresolution);
+ gimp_unit_entry_set_resolution (entry2, yresolution);
+
+ chain_checked = (ABS (x_value - y_value) < 1);
+
+ gimp_unit_entry_set_bounds (entry1,
+ unit_value,
+ x_upper,
+ x_lower);
+
+ gimp_unit_entry_set_bounds (entry2,
+ unit_value,
+ y_upper,
+ y_lower);
+
+ gimp_unit_entry_set_value_in_unit (entry1, x_value, GIMP_UNIT_PIXEL);
+ gimp_unit_entry_set_value_in_unit (entry2, y_value, GIMP_UNIT_PIXEL);
+
+ g_object_set_data (G_OBJECT (entry), "gimp-config-param-spec-x",
+ x_param_spec);
+ g_object_set_data (G_OBJECT (entry), "gimp-config-param-spec-y",
+ y_param_spec);
+
+ old_x_value = g_new0 (gdouble, 1);
+ *old_x_value = x_value;
+ g_object_set_data_full (G_OBJECT (entry), "old-x-value",
+ old_x_value,
+ (GDestroyNotify) g_free);
+
+ old_y_value = g_new0 (gdouble, 1);
+ *old_y_value = y_value;
+ g_object_set_data_full (G_OBJECT (entry), "old-y-value",
+ old_y_value,
+ (GDestroyNotify) g_free);
+
+ if (chainbutton)
+ {
+ if (chain_checked)
+ gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainbutton), TRUE);
+
+ g_object_set_data (G_OBJECT (entry), "chainbutton", chainbutton);
+ }
+
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (gimp_prop_coordinates_callback2),
+ config);
+
+ connect_notify (config, x_property_name,
+ G_CALLBACK (gimp_prop_coordinates_notify_x2),
+ entry);
+ connect_notify (config, y_property_name,
+ G_CALLBACK (gimp_prop_coordinates_notify_y2),
+ entry);
+
+ if (unit_property_name)
+ {
+ g_object_set_data (G_OBJECT (entry), "gimp-config-param-spec-unit",
+ unit_param_spec);
+
+ old_unit_value = g_new0 (GimpUnit, 1);
+ *old_unit_value = unit_value;
+ g_object_set_data_full (G_OBJECT (entry), "old-unit-value",
+ old_unit_value,
+ (GDestroyNotify) g_free);
+
+ g_signal_connect (entry1, "unit-changed",
+ G_CALLBACK (gimp_prop_coordinates_callback2),
+ config);
+
+ connect_notify (config, unit_property_name,
+ G_CALLBACK (gimp_prop_coordinates_notify_unit2),
+ entry);
+ }
+
+ return TRUE;
+}
+
static void
gimp_prop_coordinates_callback (GimpSizeEntry *entry,
GObject *config)
@@ -3149,6 +3309,119 @@ gimp_prop_coordinates_callback (GimpSizeEntry *entry,
}
static void
+gimp_prop_coordinates_callback2 (GimpUnitEntryTable *entry,
+ GimpUnitEntry *e,
+ GObject *config)
+{
+ GParamSpec *x_param_spec;
+ GParamSpec *y_param_spec;
+ GParamSpec *unit_param_spec;
+ gdouble x_value;
+ gdouble y_value;
+ GimpUnit unit_value;
+ gdouble *old_x_value;
+ gdouble *old_y_value;
+ GimpUnit *old_unit_value;
+ gboolean backwards;
+ GimpUnitEntry *entry1, *entry2;
+
+ x_param_spec = g_object_get_data (G_OBJECT (entry),
+ "gimp-config-param-spec-x");
+ y_param_spec = g_object_get_data (G_OBJECT (entry),
+ "gimp-config-param-spec-y");
+ if (! x_param_spec || ! y_param_spec)
+ return;
+
+ unit_param_spec = g_object_get_data (G_OBJECT (entry),
+ "gimp-config-param-spec-unit");
+
+ entry1 = gimp_unit_entry_table_get_nth_entry (entry, 0);
+ entry2 = gimp_unit_entry_table_get_nth_entry (entry, 1);
+
+ x_value = gimp_unit_entry_get_value_in_unit (entry1, GIMP_UNIT_PIXEL);
+ y_value = gimp_unit_entry_get_value_in_unit (entry2, GIMP_UNIT_PIXEL);
+ unit_value = gimp_unit_entry_get_unit (entry1);
+
+ old_x_value = g_object_get_data (G_OBJECT (entry), "old-x-value");
+ old_y_value = g_object_get_data (G_OBJECT (entry), "old-y-value");
+ old_unit_value = g_object_get_data (G_OBJECT (entry), "old-unit-value");
+
+ if (! old_x_value || ! old_y_value || (unit_param_spec && ! old_unit_value))
+ return;
+
+ /*
+ * FIXME: if the entry was created using gimp_coordinates_new, then
+ * the chain button is handled automatically and the following block
+ * of code is unnecessary (and, in fact, redundant).
+ */
+ if (x_value != y_value)
+ {
+ GtkWidget *chainbutton;
+
+ chainbutton = g_object_get_data (G_OBJECT (entry), "chainbutton");
+
+ if (chainbutton &&
+ gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chainbutton)) &&
+ ! g_object_get_data (G_OBJECT (chainbutton), "constrains-ratio"))
+ {
+ if (x_value != *old_x_value)
+ y_value = x_value;
+ else if (y_value != *old_y_value)
+ x_value = y_value;
+ }
+ }
+
+ backwards = (*old_x_value == x_value);
+
+ if (*old_x_value == x_value &&
+ *old_y_value == y_value &&
+ (old_unit_value == NULL || *old_unit_value == unit_value))
+ return;
+
+ *old_x_value = x_value;
+ *old_y_value = y_value;
+
+ if (old_unit_value)
+ *old_unit_value = unit_value;
+
+ if (unit_param_spec)
+ g_object_set (config,
+ unit_param_spec->name, unit_value,
+ NULL);
+
+ if (G_IS_PARAM_SPEC_INT (x_param_spec) &&
+ G_IS_PARAM_SPEC_INT (y_param_spec))
+ {
+ if (backwards)
+ g_object_set (config,
+ y_param_spec->name, ROUND (y_value),
+ x_param_spec->name, ROUND (x_value),
+ NULL);
+ else
+ g_object_set (config,
+ x_param_spec->name, ROUND (x_value),
+ y_param_spec->name, ROUND (y_value),
+ NULL);
+
+ }
+ else if (G_IS_PARAM_SPEC_DOUBLE (x_param_spec) &&
+ G_IS_PARAM_SPEC_DOUBLE (y_param_spec))
+ {
+ if (backwards)
+ g_object_set (config,
+ y_param_spec->name, y_value,
+ x_param_spec->name, x_value,
+ NULL);
+ else
+ g_object_set (config,
+ x_param_spec->name, x_value,
+ y_param_spec->name, y_value,
+ NULL);
+ }
+
+}
+
+static void
gimp_prop_coordinates_notify_x (GObject *config,
GParamSpec *param_spec,
GimpSizeEntry *entry)
@@ -3267,6 +3540,122 @@ gimp_prop_coordinates_notify_unit (GObject *config,
}
}
+static void
+gimp_prop_coordinates_notify_unit2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entryTable)
+{
+ GimpUnit value;
+ GimpUnitEntry *entry = gimp_unit_entry_table_get_nth_entry (entryTable, 0);
+
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+
+ if (value != gimp_unit_entry_get_unit (entry))
+ {
+ g_signal_handlers_block_by_func (entryTable,
+ gimp_prop_coordinates_callback2,
+ config);
+
+ gimp_unit_entry_set_unit (entry, value);
+
+ g_signal_handlers_unblock_by_func (entryTable,
+ gimp_prop_coordinates_callback2,
+ config);
+ }
+}
+
+static void
+gimp_prop_coordinates_notify_x2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entry)
+{
+ gdouble value;
+ GimpUnitEntry *entry1 = gimp_unit_entry_table_get_nth_entry (entry, 0);
+
+ if (G_IS_PARAM_SPEC_INT (param_spec))
+ {
+ gint int_value;
+
+ g_object_get (config,
+ param_spec->name, &int_value,
+ NULL);
+
+ value = int_value;
+ }
+ else
+ {
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+ }
+
+ if (value != gimp_unit_entry_get_value_in_unit (entry1, GIMP_UNIT_PIXEL))
+ {
+ gdouble *old_x_value = g_object_get_data (G_OBJECT (entry),
+ "old-x-value");
+
+ g_signal_handlers_block_by_func (entry,
+ gimp_prop_coordinates_callback2,
+ config);
+
+ gimp_unit_entry_set_value_in_unit (entry1, value, GIMP_UNIT_PIXEL);
+
+ if (old_x_value)
+ *old_x_value = value;
+
+ g_signal_handlers_unblock_by_func (entry,
+ gimp_prop_coordinates_callback2,
+ config);
+ }
+}
+
+static void
+gimp_prop_coordinates_notify_y2 (GObject *config,
+ GParamSpec *param_spec,
+ GimpUnitEntryTable *entry)
+{
+ gdouble value;
+ GimpUnitEntry *entry1 = gimp_unit_entry_table_get_nth_entry (entry, 1);
+
+ if (G_IS_PARAM_SPEC_INT (param_spec))
+ {
+ gint int_value;
+
+ g_object_get (config,
+ param_spec->name, &int_value,
+ NULL);
+
+ value = int_value;
+ }
+ else
+ {
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+ }
+
+ if (value != gimp_unit_entry_get_value_in_unit (entry1, GIMP_UNIT_PIXEL))
+ {
+ gdouble *old_y_value = g_object_get_data (G_OBJECT (entry),
+ "old-y-value");
+
+ g_signal_handlers_block_by_func (entry,
+ gimp_prop_coordinates_callback2,
+ config);
+
+ gimp_unit_entry_set_value_in_unit (entry1, value, GIMP_UNIT_PIXEL);
+
+ if (old_y_value)
+ *old_y_value = value;
+
+ g_signal_handlers_unblock_by_func (entry,
+ gimp_prop_coordinates_callback2,
+ config);
+ }
+}
+
/****************/
/* color area */
diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h
index 18b7d30..621a085 100644
--- a/libgimpwidgets/gimppropwidgets.h
+++ b/libgimpwidgets/gimppropwidgets.h
@@ -195,6 +195,15 @@ gboolean gimp_prop_coordinates_connect (GObject *config,
gdouble xresolution,
gdouble yresolution);
+gboolean gimp_prop_coordinates_connect2 (GObject *config,
+ const gchar *x_property_name,
+ const gchar *y_property_name,
+ const gchar *unit_property_name,
+ GObject *sizeentry,
+ GtkWidget *chainbutton,
+ gdouble xresolution,
+ gdouble yresolution);
+
/* GimpParamColor */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]