Added "default-aspect-numerator", "default-aspect-denominator",

2007-08-10  Martin Nordholts  <martinn@svn.gnome.org>

	* app/tools/gimprectangleoptions.c: Added
	"default-aspect-numerator", "default-aspect-denominator",
	"default-fixed-size-width" and "default-fixed-size-height" as
	non-serialized tool options, and "overridden-fixed-aspect" and
	"overridden-fixed-size" as serialized ones.

	* app/widgets/gimppropwidgets.c (gimp_prop_number_pair_entry_*):
	Added support for the new GimpRectangleOptions.

svn path=/trunk/; revision=23187
This commit is contained in:
Martin Nordholts 2007-08-10 14:57:27 +00:00 committed by Martin Nordholts
parent f1fb36551d
commit 49df5ada5b
5 changed files with 273 additions and 36 deletions

View File

@ -1,3 +1,14 @@
2007-08-10 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangleoptions.c: Added
"default-aspect-numerator", "default-aspect-denominator",
"default-fixed-size-width" and "default-fixed-size-height" as
non-serialized tool options, and "overridden-fixed-aspect" and
"overridden-fixed-size" as serialized ones.
* app/widgets/gimppropwidgets.c (gimp_prop_number_pair_entry_*):
Added support for the new GimpRectangleOptions.
2007-08-10 Martin Nordholts <martinn@svn.gnome.org>
* libgimpwidgets/gimpnumberpairentry.c

View File

@ -184,6 +184,29 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("default-aspect-numerator",
NULL, NULL,
0.001, GIMP_MAX_IMAGE_SIZE,
1.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_interface_install_property (iface,
g_param_spec_double ("default-aspect-denominator",
NULL, NULL,
0.001, GIMP_MAX_IMAGE_SIZE,
1.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_interface_install_property (iface,
g_param_spec_boolean ("overridden-fixed-aspect",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("fixed-center",
NULL, NULL,
@ -238,6 +261,29 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("default-fixed-size-width",
NULL, NULL,
0.0, GIMP_MAX_IMAGE_SIZE,
100.0,
GIMP_PARAM_READWRITE |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("default-fixed-size-height",
NULL, NULL,
0.0, GIMP_MAX_IMAGE_SIZE,
100.0,
GIMP_PARAM_READWRITE |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_boolean ("overridden-fixed-size",
NULL, NULL,
FALSE,
GIMP_CONFIG_PARAM_FLAGS |
GIMP_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
g_param_spec_double ("center-x",
NULL, NULL,
@ -363,6 +409,15 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
"aspect-denominator");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_NUMERATOR,
"default-aspect-numerator");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_DENOMINATOR,
"default-aspect-denominator");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT,
"overridden-fixed-aspect");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE,
"fixed-rule-active");
@ -381,6 +436,15 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT,
"desired-fixed-size-height");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_WIDTH,
"default-fixed-size-width");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_HEIGHT,
"default-fixed-size-height");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_SIZE,
"overridden-fixed-size");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
"fixed-center");
@ -438,6 +502,15 @@ gimp_rectangle_options_set_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
private->aspect_denominator = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_NUMERATOR:
private->default_aspect_numerator = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_DENOMINATOR:
private->default_aspect_denominator = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT:
private->overridden_fixed_aspect = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
private->fixed_center = g_value_get_boolean (value);
break;
@ -459,6 +532,15 @@ gimp_rectangle_options_set_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT:
private->desired_fixed_size_height = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_WIDTH:
private->default_fixed_size_width = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_HEIGHT:
private->default_fixed_size_height = g_value_get_double (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_SIZE:
private->overridden_fixed_size = g_value_get_boolean (value);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
private->center_x = g_value_get_double (value);
break;
@ -518,6 +600,15 @@ gimp_rectangle_options_get_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
g_value_set_double (value, private->aspect_denominator);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_NUMERATOR:
g_value_set_double (value, private->default_aspect_numerator);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_DENOMINATOR:
g_value_set_double (value, private->default_aspect_denominator);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT:
g_value_set_boolean (value, private->overridden_fixed_aspect);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
g_value_set_boolean (value, private->fixed_center);
break;
@ -539,6 +630,15 @@ gimp_rectangle_options_get_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT:
g_value_set_double (value, private->desired_fixed_size_height);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_WIDTH:
g_value_set_double (value, private->default_fixed_size_width);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_HEIGHT:
g_value_set_double (value, private->default_fixed_size_height);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_SIZE:
g_value_set_boolean (value, private->overridden_fixed_size);
break;
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
g_value_set_double (value, private->center_x);
break;
@ -761,6 +861,9 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
gimp_prop_number_pair_entry_new (config,
"aspect-numerator",
"aspect-denominator",
"default-aspect-numerator",
"default-aspect-denominator",
"overridden-fixed-aspect",
FALSE, TRUE,
":/",
TRUE,
@ -811,6 +914,9 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
gimp_prop_number_pair_entry_new (config,
"desired-fixed-size-width",
"desired-fixed-size-height",
"default-fixed-size-width",
"default-fixed-size-height",
"overridden-fixed-size",
TRUE, FALSE,
"xX*",
FALSE,

View File

@ -35,8 +35,14 @@ typedef enum
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT,
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_HEIGHT,
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_SIZE,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR,
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_NUMERATOR,
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_DENOMINATOR,
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
@ -77,17 +83,23 @@ struct _GimpRectangleOptionsPrivate
gdouble width;
gdouble height;
/* Width and height for Fixed: Width and Fixed: Height */
gdouble desired_fixed_width;
gdouble desired_fixed_height;
/* Width and height for Fixed: Size */
gdouble desired_fixed_size_width;
gdouble desired_fixed_size_height;
gdouble default_fixed_size_width;
gdouble default_fixed_size_height;
gboolean overridden_fixed_size;
gdouble aspect_numerator;
gdouble aspect_denominator;
gdouble default_aspect_numerator;
gdouble default_aspect_denominator;
gboolean overridden_fixed_aspect;
gboolean fixed_rule_active;
GimpRectangleToolFixedRule fixed_rule;

View File

@ -466,6 +466,9 @@ typedef struct
GObject *config;
const gchar *left_number_property;
const gchar *right_number_property;
const gchar *default_left_number_property;
const gchar *default_right_number_property;
const gchar *user_override_property;
} GimpPropNumberPairEntryData;
static void
@ -482,16 +485,24 @@ static void gimp_prop_number_pair_entry_config_notify
static void gimp_prop_number_pair_entry_number_pair_numbers_changed
(GtkWidget *widget,
GimpPropNumberPairEntryData *data);
static void gimp_prop_number_pair_entry_number_pair_user_override_changed
(GtkWidget *entry,
GParamSpec *param_spec,
GimpPropNumberPairEntryData *data);
/**
* gimp_prop_number_pair_entry_new:
* @config: Object to which properties are attached.
* @left_number_property: Name of double property for numerator.
* @right_number_property: Name of double property for denominator.
* @connect_numbers_changed: %TRUE to connect to the widgets "numbers-changed"
* signal, %FALSE to not connect.
* @connect_numbers_changed: %TRUE to connect to the widgets "ratio-changed"
* signal, %FALSE to not connect.
* @config: Object to which properties are attached.
* @left_number_property: Name of double property for left number.
* @right_number_property: Name of double property for right number.
* @default_left_number_property: Name of double property for default left number.
* @default_right_number_property: Name of double property for default right number.
* @user_override_property: Name of boolean property for user override mode.
* @connect_numbers_changed: %TRUE to connect to the widgets "numbers-changed"
* signal, %FALSE to not connect.
* @connect_numbers_changed: %TRUE to connect to the widgets "ratio-changed"
* signal, %FALSE to not connect.
* @separators:
* @allow_simplification:
* @min_valid_value:
@ -502,6 +513,9 @@ static void gimp_prop_number_pair_entry_number_pair_numbers_changed
GtkWidget * gimp_prop_number_pair_entry_new (GObject *config,
const gchar *left_number_property,
const gchar *right_number_property,
const gchar *default_left_number_property,
const gchar *default_right_number_property,
const gchar *user_override_property,
gboolean connect_numbers_changed,
gboolean connect_ratio_changed,
const gchar *separators,
@ -513,32 +527,58 @@ GtkWidget * gimp_prop_number_pair_entry_new (GObject *config,
GtkWidget *number_pair_entry;
gdouble left_number;
gdouble right_number;
gdouble default_left_number;
gdouble default_right_number;
gboolean user_override;
g_object_get (config,
left_number_property, &left_number,
right_number_property, &right_number,
NULL);
/* Setup config data */
data = g_slice_new (GimpPropNumberPairEntryData);
data->config = config;
data->left_number_property = left_number_property;
data->right_number_property = right_number_property;
data->config = config;
data->left_number_property = left_number_property;
data->right_number_property = right_number_property;
data->default_left_number_property = default_left_number_property;
data->default_right_number_property = default_right_number_property;
data->user_override_property = user_override_property;
/* Read current values of config properties */
g_object_get (config,
left_number_property, &left_number,
right_number_property, &right_number,
default_left_number_property, &default_left_number,
default_right_number_property, &default_right_number,
user_override_property, &user_override,
NULL);
/* Create a GimpNumberPairEntry and setup with config property values */
number_pair_entry = gimp_number_pair_entry_new (separators,
allow_simplification,
min_valid_value,
max_valid_value);
gtk_entry_set_width_chars (GTK_ENTRY (number_pair_entry), 7);
g_object_set_data_full (G_OBJECT (number_pair_entry),
"gimp-prop-number-pair-entry-data", data,
(GDestroyNotify) gimp_prop_number_pair_entry_data_free);
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
left_number,
right_number);
gtk_entry_set_width_chars (GTK_ENTRY (number_pair_entry), 7);
gimp_number_pair_entry_set_user_override (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
user_override);
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
left_number,
right_number);
gimp_number_pair_entry_set_default_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
default_left_number,
default_right_number);
/* Connect to GimpNumberPairEntry signals */
if (connect_ratio_changed)
g_signal_connect (number_pair_entry, "ratio-changed",
@ -550,12 +590,31 @@ GtkWidget * gimp_prop_number_pair_entry_new (GObject *config,
G_CALLBACK (gimp_prop_number_pair_entry_number_pair_numbers_changed),
data);
g_signal_connect (number_pair_entry, "notify::user-override",
G_CALLBACK (gimp_prop_number_pair_entry_number_pair_user_override_changed),
data);
/* Connect to connfig object signals */
connect_notify (config, left_number_property,
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
number_pair_entry);
connect_notify (config, right_number_property,
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
number_pair_entry);
connect_notify (config, default_left_number_property,
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
number_pair_entry);
connect_notify (config, default_right_number_property,
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
number_pair_entry);
connect_notify (config, user_override_property,
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
number_pair_entry);
/* Done */
return number_pair_entry;
}
@ -565,23 +624,53 @@ gimp_prop_number_pair_entry_config_notify (GObject *config,
GParamSpec *param_spec,
GtkEntry *number_pair_entry)
{
GimpPropNumberPairEntryData *data;
gdouble left_number;
gdouble right_number;
data = g_object_get_data (G_OBJECT (number_pair_entry),
"gimp-prop-number-pair-entry-data");
GimpPropNumberPairEntryData *data =
g_object_get_data (G_OBJECT (number_pair_entry),
"gimp-prop-number-pair-entry-data");
g_return_if_fail (data != NULL);
g_object_get (config,
data->left_number_property, &left_number,
data->right_number_property, &right_number,
NULL);
if (strcmp (param_spec->name, "left-number") == 0 ||
strcmp (param_spec->name, "right-number") == 0)
{
gdouble left_number;
gdouble right_number;
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
left_number,
right_number);
g_object_get (config,
data->left_number_property, &left_number,
data->right_number_property, &right_number,
NULL);
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
left_number,
right_number);
}
else if (strcmp (param_spec->name, "default-left-number") == 0 ||
strcmp (param_spec->name, "default-right-number") == 0)
{
gdouble default_left_number;
gdouble default_right_number;
g_object_get (config,
data->default_left_number_property, &default_left_number,
data->default_right_number_property, &default_right_number,
NULL);
gimp_number_pair_entry_set_default_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
default_left_number,
default_right_number);
}
else if (strcmp (param_spec->name, "user-override") == 0)
{
gboolean user_override;
g_object_get (config,
data->user_override_property, &user_override,
NULL);
gimp_number_pair_entry_set_user_override (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
user_override);
}
}
static void
@ -601,6 +690,23 @@ gimp_prop_number_pair_entry_number_pair_numbers_changed (GtkWidget
NULL);
}
static void
gimp_prop_number_pair_entry_number_pair_user_override_changed (GtkWidget *entry,
GParamSpec *param_spec,
GimpPropNumberPairEntryData *data)
{
gboolean user_override;
user_override =
gimp_number_pair_entry_get_user_override (GIMP_NUMBER_PAIR_ENTRY (entry));
g_object_set (data->config,
data->user_override_property, user_override,
NULL);
}
/*******************************/
/* private utility functions */
/*******************************/

View File

@ -57,13 +57,15 @@ GtkWidget * gimp_prop_view_new (GObject *config,
GimpContext *context,
gint size);
/* GParamDouble, GParamDouble */
/* GParamDouble, GParamDouble, GParamDouble, GParamDouble, GParamBoolean */
GtkWidget * gimp_prop_number_pair_entry_new
(GObject *config,
const gchar *left_number_property,
const gchar *right_number_property,
const gchar *default_numerator_property,
const gchar *default_denominator_property,
const gchar *overridden_fixed_aspect_property,
gboolean connect_numbers_changed,
gboolean connect_ratio_changed,
const gchar *separators,