mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-19 22:34:37 +00:00
renamed gimp_prop_size_entry_connect() to gimp_prop_coordinates_connect().
2003-10-01 Sven Neumann <sven@gimp.org> * app/widgets/gimppropwidgets.[ch]: renamed gimp_prop_size_entry_connect() to gimp_prop_coordinates_connect(). Added a new property widget that is a single GimpSizeEntry and is connected to size and unit properties. * app/widgets/gimptemplateeditor.c: changed accordingly. * app/widgets/gimpstrokeeditor.c: added a "resolution" property and use the new property widget. * app/gui/stroke-dialog.c: pass the image resolution to gimp_stroke_editor_new().
This commit is contained in:
parent
768b34b1ff
commit
ef94033e26
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimppropwidgets.[ch]: renamed
|
||||
gimp_prop_size_entry_connect() to gimp_prop_coordinates_connect().
|
||||
Added a new property widget that is a single GimpSizeEntry and is
|
||||
connected to size and unit properties.
|
||||
|
||||
* app/widgets/gimptemplateeditor.c: changed accordingly.
|
||||
|
||||
* app/widgets/gimpstrokeeditor.c: added a "resolution" property
|
||||
and use the new property widget.
|
||||
|
||||
* app/gui/stroke-dialog.c: pass the image resolution to
|
||||
gimp_stroke_editor_new().
|
||||
|
||||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/composite/gimp-composite-altivec.c
|
||||
|
|
|
@ -139,7 +139,7 @@ stroke_dialog_new (GimpItem *item,
|
|||
{
|
||||
GtkWidget *stroke_editor;
|
||||
|
||||
stroke_editor = gimp_stroke_editor_new (options);
|
||||
stroke_editor = gimp_stroke_editor_new (options, image->yresolution);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (stroke_editor), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
|
||||
gtk_widget_show (stroke_editor);
|
||||
|
|
|
@ -139,7 +139,7 @@ stroke_dialog_new (GimpItem *item,
|
|||
{
|
||||
GtkWidget *stroke_editor;
|
||||
|
||||
stroke_editor = gimp_stroke_editor_new (options);
|
||||
stroke_editor = gimp_stroke_editor_new (options, image->yresolution);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (stroke_editor), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
|
||||
gtk_widget_show (stroke_editor);
|
||||
|
|
|
@ -310,10 +310,10 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
|
||||
NULL);
|
||||
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
@ -591,7 +591,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
|
|||
config,
|
||||
&button);
|
||||
}
|
||||
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
|
@ -867,7 +867,7 @@ gimp_prop_opacity_entry_new (GObject *config,
|
|||
g_object_get (config, property_name, &value, NULL);
|
||||
|
||||
tooltip = gettext (g_param_spec_get_blurb (param_spec));
|
||||
|
||||
|
||||
value *= 100.0;
|
||||
lower = G_PARAM_SPEC_DOUBLE (param_spec)->minimum * 100.0;
|
||||
upper = G_PARAM_SPEC_DOUBLE (param_spec)->maximum * 100.0;
|
||||
|
@ -1270,7 +1270,7 @@ gimp_prop_text_buffer_callback (GtkTextBuffer *text_buffer,
|
|||
|
||||
if (max_len > 0 && strlen (text) > max_len)
|
||||
{
|
||||
g_message (_("This text input field is limited to %d characters."),
|
||||
g_message (_("This text input field is limited to %d characters."),
|
||||
max_len);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (text_buffer, &start_iter,
|
||||
|
@ -1618,6 +1618,254 @@ gimp_prop_path_editor_notify (GObject *config,
|
|||
}
|
||||
|
||||
|
||||
/***************/
|
||||
/* sizeentry */
|
||||
/***************/
|
||||
|
||||
static void gimp_prop_size_entry_callback (GimpSizeEntry *sizeentry,
|
||||
GObject *config);
|
||||
static void gimp_prop_size_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
static void gimp_prop_size_entry_notify_unit (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_size_entry_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *unit_property_name,
|
||||
const gchar *unit_format,
|
||||
GimpSizeEntryUpdatePolicy update_policy,
|
||||
gdouble resolution)
|
||||
{
|
||||
GtkWidget *sizeentry;
|
||||
GParamSpec *param_spec;
|
||||
GParamSpec *unit_param_spec;
|
||||
gboolean show_pixels;
|
||||
gdouble value;
|
||||
GimpUnit unit_value;
|
||||
|
||||
param_spec = find_param_spec (config, property_name, G_STRLOC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
|
||||
unit_param_spec = check_param_spec (config, unit_property_name,
|
||||
GIMP_TYPE_PARAM_UNIT, G_STRLOC);
|
||||
if (! unit_param_spec)
|
||||
return NULL;
|
||||
|
||||
g_value_init (&value, unit_param_spec->value_type);
|
||||
g_value_set_int (&value, GIMP_UNIT_PIXEL);
|
||||
show_pixels =
|
||||
(g_param_value_validate (unit_param_spec, &value) == FALSE);
|
||||
g_value_unset (&value);
|
||||
|
||||
g_object_get (config,
|
||||
unit_property_name, &unit_value,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
unit_param_spec = NULL;
|
||||
unit_value = GIMP_UNIT_INCH;
|
||||
show_pixels = FALSE;
|
||||
}
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT (param_spec))
|
||||
{
|
||||
gint int_value;
|
||||
|
||||
g_object_get (config,
|
||||
property_name, &int_value,
|
||||
NULL);
|
||||
|
||||
value = int_value;
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
||||
{
|
||||
g_object_get (config,
|
||||
property_name, &value,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: property '%s' of %s is not int nor double",
|
||||
G_STRLOC,
|
||||
property_name,
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (config)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sizeentry = gimp_size_entry_new (1, unit_value, unit_format,
|
||||
TRUE, FALSE, FALSE, 10,
|
||||
update_policy);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 1, 4);
|
||||
|
||||
switch (GIMP_SIZE_ENTRY (sizeentry)->update_policy)
|
||||
{
|
||||
case GIMP_SIZE_ENTRY_UPDATE_SIZE:
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
resolution, FALSE);
|
||||
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
GIMP_MIN_IMAGE_SIZE,
|
||||
GIMP_MAX_IMAGE_SIZE);
|
||||
break;
|
||||
|
||||
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
|
||||
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
GIMP_MIN_RESOLUTION,
|
||||
GIMP_MAX_RESOLUTION);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), unit_value);
|
||||
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (sizeentry), 0, value);
|
||||
|
||||
g_object_set_data (G_OBJECT (sizeentry), "gimp-config-param-spec",
|
||||
param_spec);
|
||||
g_object_set_data (G_OBJECT (sizeentry), "gimp-config-param-spec-unit",
|
||||
unit_param_spec);
|
||||
|
||||
g_signal_connect (sizeentry, "value_changed",
|
||||
G_CALLBACK (gimp_prop_size_entry_callback),
|
||||
config);
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
g_signal_connect (sizeentry, "unit_changed",
|
||||
G_CALLBACK (gimp_prop_size_entry_callback),
|
||||
config);
|
||||
}
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_size_entry_notify),
|
||||
sizeentry);
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
connect_notify (config, unit_property_name,
|
||||
G_CALLBACK (gimp_prop_size_entry_notify_unit),
|
||||
sizeentry);
|
||||
}
|
||||
|
||||
return sizeentry;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_callback (GimpSizeEntry *sizeentry,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GParamSpec *unit_param_spec;
|
||||
gdouble value;
|
||||
GimpUnit unit_value;
|
||||
|
||||
param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec");
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
value = gimp_size_entry_get_value (sizeentry, 0);
|
||||
unit_value = gimp_size_entry_get_unit (sizeentry);
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT (param_spec))
|
||||
{
|
||||
g_object_set (config,
|
||||
param_spec->name, ROUND (value),
|
||||
|
||||
unit_param_spec ?
|
||||
unit_param_spec->name : NULL, unit_value,
|
||||
|
||||
NULL);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
||||
{
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
|
||||
unit_param_spec ?
|
||||
unit_param_spec->name : NULL, unit_value,
|
||||
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry)
|
||||
{
|
||||
gdouble value;
|
||||
|
||||
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_size_entry_get_value (sizeentry, 0))
|
||||
{
|
||||
g_signal_handlers_block_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_size_entry_set_value (sizeentry, 0, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_notify_unit (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry)
|
||||
{
|
||||
GimpUnit value;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
if (value != gimp_size_entry_get_unit (sizeentry))
|
||||
{
|
||||
g_signal_handlers_block_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_size_entry_set_unit (sizeentry, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************/
|
||||
/* coordinates */
|
||||
/*****************/
|
||||
|
@ -1634,6 +1882,7 @@ static void gimp_prop_coordinates_notify_unit (GObject *config,
|
|||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_coordinates_new (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
|
@ -1661,14 +1910,14 @@ gimp_prop_coordinates_new (GObject *config,
|
|||
gtk_widget_show (chainbutton);
|
||||
}
|
||||
|
||||
if (! gimp_prop_size_entry_connect (config,
|
||||
x_property_name,
|
||||
y_property_name,
|
||||
unit_property_name,
|
||||
sizeentry,
|
||||
chainbutton,
|
||||
xresolution,
|
||||
yresolution))
|
||||
if (! gimp_prop_coordinates_connect (config,
|
||||
x_property_name,
|
||||
y_property_name,
|
||||
unit_property_name,
|
||||
sizeentry,
|
||||
chainbutton,
|
||||
xresolution,
|
||||
yresolution))
|
||||
{
|
||||
gtk_widget_destroy (sizeentry);
|
||||
return NULL;
|
||||
|
@ -1678,14 +1927,14 @@ gimp_prop_coordinates_new (GObject *config,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gimp_prop_size_entry_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
GtkWidget *sizeentry,
|
||||
GtkWidget *chainbutton,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution)
|
||||
gimp_prop_coordinates_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
GtkWidget *sizeentry,
|
||||
GtkWidget *chainbutton,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution)
|
||||
{
|
||||
GParamSpec *x_param_spec;
|
||||
GParamSpec *y_param_spec;
|
||||
|
@ -1884,12 +2133,13 @@ gimp_prop_coordinates_callback (GimpSizeEntry *sizeentry,
|
|||
"gimp-config-param-spec-x");
|
||||
y_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-y");
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
if (! x_param_spec || ! y_param_spec)
|
||||
return;
|
||||
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
x_value = gimp_size_entry_get_refval (sizeentry, 0);
|
||||
y_value = gimp_size_entry_get_refval (sizeentry, 1);
|
||||
unit_value = gimp_size_entry_get_unit (sizeentry);
|
||||
|
|
|
@ -128,6 +128,16 @@ GtkWidget * gimp_prop_path_editor_new (GObject *config,
|
|||
const gchar *filesel_title);
|
||||
|
||||
|
||||
/* GParamInt, GParamDouble unit: GimpParamUnit */
|
||||
|
||||
GtkWidget * gimp_prop_size_entry_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *unit_property_name,
|
||||
const gchar *unit_format,
|
||||
GimpSizeEntryUpdatePolicy update_policy,
|
||||
gdouble resolution);
|
||||
|
||||
|
||||
/* x,y: GParamInt, GParamDouble unit: GimpParamUnit */
|
||||
|
||||
GtkWidget * gimp_prop_coordinates_new (GObject *config,
|
||||
|
@ -139,8 +149,7 @@ GtkWidget * gimp_prop_coordinates_new (GObject *config,
|
|||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gboolean has_chainbutton);
|
||||
|
||||
gboolean gimp_prop_size_entry_connect (GObject *config,
|
||||
gboolean gimp_prop_coordinates_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
|
|
|
@ -33,12 +33,11 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define SB_WIDTH 10
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OPTIONS
|
||||
PROP_OPTIONS,
|
||||
PROP_RESOLUTION
|
||||
};
|
||||
|
||||
static void gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass);
|
||||
|
@ -104,6 +103,13 @@ gimp_stroke_editor_class_init (GimpStrokeEditorClass *klass)
|
|||
GIMP_TYPE_STROKE_OPTIONS,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_RESOLUTION,
|
||||
g_param_spec_double ("resolution", NULL, NULL,
|
||||
GIMP_MIN_RESOLUTION,
|
||||
GIMP_MAX_RESOLUTION,
|
||||
72.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -119,6 +125,9 @@ gimp_stroke_editor_set_property (GObject *object,
|
|||
case PROP_OPTIONS:
|
||||
editor->options = GIMP_STROKE_OPTIONS (g_value_dup_object (value));
|
||||
break;
|
||||
case PROP_RESOLUTION:
|
||||
editor->resolution = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -139,6 +148,9 @@ gimp_stroke_editor_get_property (GObject *object,
|
|||
case PROP_OPTIONS:
|
||||
g_value_set_object (value, editor->options);
|
||||
break;
|
||||
case PROP_RESOLUTION:
|
||||
g_value_set_double (value, editor->resolution);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -153,12 +165,10 @@ gimp_stroke_editor_constructor (GType type,
|
|||
{
|
||||
GimpStrokeEditor *editor;
|
||||
GtkWidget *table;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *box;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *size;
|
||||
GtkWidget *button;
|
||||
GObject *object;
|
||||
gint digits;
|
||||
gint row = 0;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
@ -173,20 +183,14 @@ gimp_stroke_editor_constructor (GType type,
|
|||
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
digits = gimp_unit_get_digits (editor->options->unit);
|
||||
spinbutton = gimp_prop_spin_button_new (G_OBJECT (editor->options), "width",
|
||||
1.0, 10.0, digits);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row,
|
||||
_("Stroke _Width:"), 1.0, 0.5,
|
||||
spinbutton, 1, FALSE);
|
||||
size = gimp_prop_size_entry_new (G_OBJECT (editor->options), "width", "unit",
|
||||
"%a", GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||
editor->resolution);
|
||||
gimp_size_entry_set_pixel_digits (GIMP_SIZE_ENTRY (size), 1);
|
||||
|
||||
menu = gimp_prop_unit_menu_new (G_OBJECT (editor->options), "unit", "%a");
|
||||
g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
|
||||
gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 1);
|
||||
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, row, row + 1,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (menu);
|
||||
row++;
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||
_("Stroke _Width:"), 1.0, 0.5,
|
||||
size, 1, FALSE);
|
||||
|
||||
box = gimp_prop_enum_stock_box_new (G_OBJECT (editor->options), "cap-style",
|
||||
"gimp-cap", 0, 0);
|
||||
|
@ -238,11 +242,13 @@ gimp_stroke_editor_finalize (GObject *object)
|
|||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_stroke_editor_new (GimpStrokeOptions *options)
|
||||
gimp_stroke_editor_new (GimpStrokeOptions *options,
|
||||
gdouble resolution)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
|
||||
|
||||
return GTK_WIDGET (g_object_new (GIMP_TYPE_STROKE_EDITOR,
|
||||
"options", options,
|
||||
"options", options,
|
||||
"resolution", resolution,
|
||||
NULL));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ struct _GimpStrokeEditor
|
|||
GtkVBox parent_instance;
|
||||
|
||||
GimpStrokeOptions *options;
|
||||
gdouble resolution;
|
||||
};
|
||||
|
||||
struct _GimpStrokeEditorClass
|
||||
|
@ -51,7 +52,8 @@ struct _GimpStrokeEditorClass
|
|||
|
||||
GType gimp_stroke_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options);
|
||||
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options,
|
||||
gdouble resolution);
|
||||
|
||||
|
||||
#endif /* __GIMP_STROKE_EDITOR_H__ */
|
||||
|
|
|
@ -269,11 +269,11 @@ gimp_template_editor_init (GimpTemplateEditor *editor)
|
|||
GTK_SPIN_BUTTON (width_pixels));
|
||||
|
||||
/* initialize the sizeentry */
|
||||
gimp_prop_size_entry_connect (G_OBJECT (editor->template),
|
||||
"width", "height", "unit",
|
||||
editor->size_se, NULL,
|
||||
editor->template->xresolution,
|
||||
editor->template->yresolution);
|
||||
gimp_prop_coordinates_connect (G_OBJECT (editor->template),
|
||||
"width", "height", "unit",
|
||||
editor->size_se, NULL,
|
||||
editor->template->xresolution,
|
||||
editor->template->yresolution);
|
||||
|
||||
focus_chain = g_list_append (focus_chain, width_pixels);
|
||||
focus_chain = g_list_append (focus_chain, height_pixels);
|
||||
|
@ -341,11 +341,11 @@ gimp_template_editor_init (GimpTemplateEditor *editor)
|
|||
1, 2, 0, 2);
|
||||
gtk_widget_show (chainbutton);
|
||||
|
||||
gimp_prop_size_entry_connect (G_OBJECT (editor->template),
|
||||
"xresolution", "yresolution",
|
||||
"resolution-unit",
|
||||
editor->resolution_se, chainbutton,
|
||||
1.0, 1.0);
|
||||
gimp_prop_coordinates_connect (G_OBJECT (editor->template),
|
||||
"xresolution", "yresolution",
|
||||
"resolution-unit",
|
||||
editor->resolution_se, chainbutton,
|
||||
1.0, 1.0);
|
||||
|
||||
focus_chain = g_list_append (focus_chain, xres);
|
||||
focus_chain = g_list_append (focus_chain, yres);
|
||||
|
|
|
@ -310,10 +310,10 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
|
||||
NULL);
|
||||
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
@ -591,7 +591,7 @@ gimp_prop_enum_stock_box_new (GObject *config,
|
|||
config,
|
||||
&button);
|
||||
}
|
||||
|
||||
|
||||
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
|
@ -867,7 +867,7 @@ gimp_prop_opacity_entry_new (GObject *config,
|
|||
g_object_get (config, property_name, &value, NULL);
|
||||
|
||||
tooltip = gettext (g_param_spec_get_blurb (param_spec));
|
||||
|
||||
|
||||
value *= 100.0;
|
||||
lower = G_PARAM_SPEC_DOUBLE (param_spec)->minimum * 100.0;
|
||||
upper = G_PARAM_SPEC_DOUBLE (param_spec)->maximum * 100.0;
|
||||
|
@ -1270,7 +1270,7 @@ gimp_prop_text_buffer_callback (GtkTextBuffer *text_buffer,
|
|||
|
||||
if (max_len > 0 && strlen (text) > max_len)
|
||||
{
|
||||
g_message (_("This text input field is limited to %d characters."),
|
||||
g_message (_("This text input field is limited to %d characters."),
|
||||
max_len);
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (text_buffer, &start_iter,
|
||||
|
@ -1618,6 +1618,254 @@ gimp_prop_path_editor_notify (GObject *config,
|
|||
}
|
||||
|
||||
|
||||
/***************/
|
||||
/* sizeentry */
|
||||
/***************/
|
||||
|
||||
static void gimp_prop_size_entry_callback (GimpSizeEntry *sizeentry,
|
||||
GObject *config);
|
||||
static void gimp_prop_size_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
static void gimp_prop_size_entry_notify_unit (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_size_entry_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *unit_property_name,
|
||||
const gchar *unit_format,
|
||||
GimpSizeEntryUpdatePolicy update_policy,
|
||||
gdouble resolution)
|
||||
{
|
||||
GtkWidget *sizeentry;
|
||||
GParamSpec *param_spec;
|
||||
GParamSpec *unit_param_spec;
|
||||
gboolean show_pixels;
|
||||
gdouble value;
|
||||
GimpUnit unit_value;
|
||||
|
||||
param_spec = find_param_spec (config, property_name, G_STRLOC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
GValue value = { 0 };
|
||||
|
||||
unit_param_spec = check_param_spec (config, unit_property_name,
|
||||
GIMP_TYPE_PARAM_UNIT, G_STRLOC);
|
||||
if (! unit_param_spec)
|
||||
return NULL;
|
||||
|
||||
g_value_init (&value, unit_param_spec->value_type);
|
||||
g_value_set_int (&value, GIMP_UNIT_PIXEL);
|
||||
show_pixels =
|
||||
(g_param_value_validate (unit_param_spec, &value) == FALSE);
|
||||
g_value_unset (&value);
|
||||
|
||||
g_object_get (config,
|
||||
unit_property_name, &unit_value,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
unit_param_spec = NULL;
|
||||
unit_value = GIMP_UNIT_INCH;
|
||||
show_pixels = FALSE;
|
||||
}
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT (param_spec))
|
||||
{
|
||||
gint int_value;
|
||||
|
||||
g_object_get (config,
|
||||
property_name, &int_value,
|
||||
NULL);
|
||||
|
||||
value = int_value;
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
||||
{
|
||||
g_object_get (config,
|
||||
property_name, &value,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: property '%s' of %s is not int nor double",
|
||||
G_STRLOC,
|
||||
property_name,
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (config)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sizeentry = gimp_size_entry_new (1, unit_value, unit_format,
|
||||
TRUE, FALSE, FALSE, 10,
|
||||
update_policy);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 1, 4);
|
||||
|
||||
switch (GIMP_SIZE_ENTRY (sizeentry)->update_policy)
|
||||
{
|
||||
case GIMP_SIZE_ENTRY_UPDATE_SIZE:
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
resolution, FALSE);
|
||||
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
GIMP_MIN_IMAGE_SIZE,
|
||||
GIMP_MAX_IMAGE_SIZE);
|
||||
break;
|
||||
|
||||
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
|
||||
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
GIMP_MIN_RESOLUTION,
|
||||
GIMP_MAX_RESOLUTION);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), unit_value);
|
||||
gimp_size_entry_set_value (GIMP_SIZE_ENTRY (sizeentry), 0, value);
|
||||
|
||||
g_object_set_data (G_OBJECT (sizeentry), "gimp-config-param-spec",
|
||||
param_spec);
|
||||
g_object_set_data (G_OBJECT (sizeentry), "gimp-config-param-spec-unit",
|
||||
unit_param_spec);
|
||||
|
||||
g_signal_connect (sizeentry, "value_changed",
|
||||
G_CALLBACK (gimp_prop_size_entry_callback),
|
||||
config);
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
g_signal_connect (sizeentry, "unit_changed",
|
||||
G_CALLBACK (gimp_prop_size_entry_callback),
|
||||
config);
|
||||
}
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_size_entry_notify),
|
||||
sizeentry);
|
||||
|
||||
if (unit_property_name)
|
||||
{
|
||||
connect_notify (config, unit_property_name,
|
||||
G_CALLBACK (gimp_prop_size_entry_notify_unit),
|
||||
sizeentry);
|
||||
}
|
||||
|
||||
return sizeentry;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_callback (GimpSizeEntry *sizeentry,
|
||||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GParamSpec *unit_param_spec;
|
||||
gdouble value;
|
||||
GimpUnit unit_value;
|
||||
|
||||
param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec");
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
value = gimp_size_entry_get_value (sizeentry, 0);
|
||||
unit_value = gimp_size_entry_get_unit (sizeentry);
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT (param_spec))
|
||||
{
|
||||
g_object_set (config,
|
||||
param_spec->name, ROUND (value),
|
||||
|
||||
unit_param_spec ?
|
||||
unit_param_spec->name : NULL, unit_value,
|
||||
|
||||
NULL);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
||||
{
|
||||
g_object_set (config,
|
||||
param_spec->name, value,
|
||||
|
||||
unit_param_spec ?
|
||||
unit_param_spec->name : NULL, unit_value,
|
||||
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_notify (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry)
|
||||
{
|
||||
gdouble value;
|
||||
|
||||
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_size_entry_get_value (sizeentry, 0))
|
||||
{
|
||||
g_signal_handlers_block_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_size_entry_set_value (sizeentry, 0, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prop_size_entry_notify_unit (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry)
|
||||
{
|
||||
GimpUnit value;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
if (value != gimp_size_entry_get_unit (sizeentry))
|
||||
{
|
||||
g_signal_handlers_block_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
|
||||
gimp_size_entry_set_unit (sizeentry, value);
|
||||
|
||||
g_signal_handlers_unblock_by_func (sizeentry,
|
||||
gimp_prop_size_entry_callback,
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************/
|
||||
/* coordinates */
|
||||
/*****************/
|
||||
|
@ -1634,6 +1882,7 @@ static void gimp_prop_coordinates_notify_unit (GObject *config,
|
|||
GParamSpec *param_spec,
|
||||
GimpSizeEntry *sizeentry);
|
||||
|
||||
|
||||
GtkWidget *
|
||||
gimp_prop_coordinates_new (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
|
@ -1661,14 +1910,14 @@ gimp_prop_coordinates_new (GObject *config,
|
|||
gtk_widget_show (chainbutton);
|
||||
}
|
||||
|
||||
if (! gimp_prop_size_entry_connect (config,
|
||||
x_property_name,
|
||||
y_property_name,
|
||||
unit_property_name,
|
||||
sizeentry,
|
||||
chainbutton,
|
||||
xresolution,
|
||||
yresolution))
|
||||
if (! gimp_prop_coordinates_connect (config,
|
||||
x_property_name,
|
||||
y_property_name,
|
||||
unit_property_name,
|
||||
sizeentry,
|
||||
chainbutton,
|
||||
xresolution,
|
||||
yresolution))
|
||||
{
|
||||
gtk_widget_destroy (sizeentry);
|
||||
return NULL;
|
||||
|
@ -1678,14 +1927,14 @@ gimp_prop_coordinates_new (GObject *config,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gimp_prop_size_entry_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
GtkWidget *sizeentry,
|
||||
GtkWidget *chainbutton,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution)
|
||||
gimp_prop_coordinates_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
GtkWidget *sizeentry,
|
||||
GtkWidget *chainbutton,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution)
|
||||
{
|
||||
GParamSpec *x_param_spec;
|
||||
GParamSpec *y_param_spec;
|
||||
|
@ -1884,12 +2133,13 @@ gimp_prop_coordinates_callback (GimpSizeEntry *sizeentry,
|
|||
"gimp-config-param-spec-x");
|
||||
y_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-y");
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
if (! x_param_spec || ! y_param_spec)
|
||||
return;
|
||||
|
||||
unit_param_spec = g_object_get_data (G_OBJECT (sizeentry),
|
||||
"gimp-config-param-spec-unit");
|
||||
|
||||
x_value = gimp_size_entry_get_refval (sizeentry, 0);
|
||||
y_value = gimp_size_entry_get_refval (sizeentry, 1);
|
||||
unit_value = gimp_size_entry_get_unit (sizeentry);
|
||||
|
|
|
@ -128,6 +128,16 @@ GtkWidget * gimp_prop_path_editor_new (GObject *config,
|
|||
const gchar *filesel_title);
|
||||
|
||||
|
||||
/* GParamInt, GParamDouble unit: GimpParamUnit */
|
||||
|
||||
GtkWidget * gimp_prop_size_entry_new (GObject *config,
|
||||
const gchar *property_name,
|
||||
const gchar *unit_property_name,
|
||||
const gchar *unit_format,
|
||||
GimpSizeEntryUpdatePolicy update_policy,
|
||||
gdouble resolution);
|
||||
|
||||
|
||||
/* x,y: GParamInt, GParamDouble unit: GimpParamUnit */
|
||||
|
||||
GtkWidget * gimp_prop_coordinates_new (GObject *config,
|
||||
|
@ -139,8 +149,7 @@ GtkWidget * gimp_prop_coordinates_new (GObject *config,
|
|||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
gboolean has_chainbutton);
|
||||
|
||||
gboolean gimp_prop_size_entry_connect (GObject *config,
|
||||
gboolean gimp_prop_coordinates_connect (GObject *config,
|
||||
const gchar *x_property_name,
|
||||
const gchar *y_property_name,
|
||||
const gchar *unit_property_name,
|
||||
|
|
Loading…
Reference in a new issue