73
static void gimp_template_class_init (GimpTemplateClass *klass);
75
static void gimp_template_finalize (GObject *object);
76
static void gimp_template_set_property (GObject *object,
80
static void gimp_template_get_property (GObject *object,
84
static void gimp_template_notify (GObject *object,
88
static GimpViewableClass *parent_class = NULL;
92
gimp_template_get_type (void)
94
static GType template_type = 0;
98
static const GTypeInfo template_info =
100
sizeof (GimpTemplateClass),
101
(GBaseInitFunc) NULL,
102
(GBaseFinalizeFunc) NULL,
103
(GClassInitFunc) gimp_template_class_init,
104
NULL, /* class_finalize */
105
NULL, /* class_data */
106
sizeof (GimpTemplate),
108
NULL /* instance_init */
110
static const GInterfaceInfo config_iface_info =
112
NULL, /* iface_init */
113
NULL, /* iface_finalize */
114
NULL /* iface_data */
117
template_type = g_type_register_static (GIMP_TYPE_VIEWABLE,
121
g_type_add_interface_static (template_type, GIMP_TYPE_CONFIG,
125
return template_type;
72
static void gimp_template_finalize (GObject *object);
73
static void gimp_template_set_property (GObject *object,
77
static void gimp_template_get_property (GObject *object,
81
static void gimp_template_notify (GObject *object,
85
G_DEFINE_TYPE_WITH_CODE (GimpTemplate, gimp_template, GIMP_TYPE_VIEWABLE,
86
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
88
#define parent_class gimp_template_parent_class
129
92
gimp_template_class_init (GimpTemplateClass *klass)
131
GObjectClass *object_class;
132
GimpViewableClass *viewable_class;
134
object_class = G_OBJECT_CLASS (klass);
135
viewable_class = GIMP_VIEWABLE_CLASS (klass);
137
parent_class = g_type_class_peek_parent (klass);
139
object_class->finalize = gimp_template_finalize;
94
GObjectClass *object_class = G_OBJECT_CLASS (klass);
95
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
97
object_class->finalize = gimp_template_finalize;
141
99
object_class->set_property = gimp_template_set_property;
142
100
object_class->get_property = gimp_template_get_property;
149
107
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
150
108
DEFAULT_IMAGE_WIDTH,
109
GIMP_PARAM_STATIC_STRINGS);
152
110
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_HEIGHT, "height",
154
112
GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE,
155
113
DEFAULT_IMAGE_HEIGHT,
114
GIMP_PARAM_STATIC_STRINGS);
157
115
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_UNIT, "unit",
158
116
N_("The unit used for coordinate display "
159
117
"when not in dot-for-dot mode."),
160
118
TRUE, FALSE, GIMP_UNIT_PIXEL,
119
GIMP_PARAM_STATIC_STRINGS);
163
121
GIMP_CONFIG_INSTALL_PROP_RESOLUTION (object_class, PROP_XRESOLUTION,
165
123
N_("The horizontal image resolution."),
125
GIMP_PARAM_STATIC_STRINGS);
168
126
GIMP_CONFIG_INSTALL_PROP_RESOLUTION (object_class, PROP_YRESOLUTION,
170
128
N_("The vertical image resolution."),
130
GIMP_PARAM_STATIC_STRINGS);
173
131
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_RESOLUTION_UNIT,
174
132
"resolution-unit",
176
134
FALSE, FALSE, GIMP_UNIT_INCH,
135
GIMP_PARAM_STATIC_STRINGS);
179
137
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_IMAGE_TYPE,
182
140
GIMP_TYPE_IMAGE_BASE_TYPE, GIMP_RGB,
141
GIMP_PARAM_STATIC_STRINGS);
184
142
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_TYPE,
187
145
GIMP_TYPE_FILL_TYPE, GIMP_BACKGROUND_FILL,
146
GIMP_PARAM_STATIC_STRINGS);
190
148
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_COMMENT,
152
GIMP_PARAM_STATIC_STRINGS);
196
154
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_FILENAME,
158
GIMP_PARAM_STATIC_STRINGS);
162
gimp_template_init (GimpTemplate *template)
320
283
gimp_template_notify (GObject *object,
321
284
GParamSpec *pspec)
323
GimpTemplate *template;
286
GimpTemplate *template = GIMP_TEMPLATE (object);
326
template = GIMP_TEMPLATE (object);
328
289
if (G_OBJECT_CLASS (parent_class)->notify)
329
290
G_OBJECT_CLASS (parent_class)->notify (object, pspec);
358
319
gimp_template_set_from_image (GimpTemplate *template,
363
GimpImageBaseType image_type;
364
GimpParasite *parasite;
365
gchar *comment = NULL;
324
GimpImageBaseType image_type;
325
const GimpParasite *parasite;
326
gchar *comment = NULL;
367
328
g_return_if_fail (GIMP_IS_TEMPLATE (template));
368
g_return_if_fail (GIMP_IS_IMAGE (gimage));
370
gimp_image_get_resolution (gimage, &xresolution, &yresolution);
372
image_type = gimp_image_base_type (gimage);
329
g_return_if_fail (GIMP_IS_IMAGE (image));
331
gimp_image_get_resolution (image, &xresolution, &yresolution);
333
image_type = gimp_image_base_type (image);
374
335
if (image_type == GIMP_INDEXED)
375
336
image_type = GIMP_RGB;
377
parasite = gimp_image_parasite_find (gimage, "gimp-comment");
338
parasite = gimp_image_parasite_find (image, "gimp-comment");
379
340
comment = g_strndup (gimp_parasite_data (parasite),
380
341
gimp_parasite_data_size (parasite));
382
343
g_object_set (template,
383
"width", gimp_image_get_width (gimage),
384
"height", gimp_image_get_height (gimage),
344
"width", gimp_image_get_width (image),
345
"height", gimp_image_get_height (image),
385
346
"xresolution", xresolution,
386
347
"yresolution", yresolution,
387
"resolution-unit", gimp_image_get_unit (gimage),
348
"resolution-unit", gimp_image_get_unit (image),
388
349
"image-type", image_type,
389
350
"comment", comment,
407
368
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
408
369
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
410
gimage = gimp_create_image (gimp,
411
template->width, template->height,
412
template->image_type,
371
image = gimp_create_image (gimp,
372
template->width, template->height,
373
template->image_type,
415
gimp_image_undo_disable (gimage);
376
gimp_image_undo_disable (image);
417
378
if (template->comment)
422
383
GIMP_PARASITE_PERSISTENT,
423
384
strlen (template->comment) + 1,
424
385
template->comment);
425
gimp_image_parasite_attach (gimage, parasite);
386
gimp_image_parasite_attach (image, parasite);
426
387
gimp_parasite_free (parasite);
429
gimp_image_set_resolution (gimage,
390
gimp_image_set_resolution (image,
430
391
template->xresolution, template->yresolution);
432
gimp_image_set_unit (gimage, template->resolution_unit);
434
width = gimp_image_get_width (gimage);
435
height = gimp_image_get_height (gimage);
392
gimp_image_set_unit (image, template->resolution_unit);
394
width = gimp_image_get_width (image);
395
height = gimp_image_get_height (image);
437
397
switch (template->fill_type)
449
layer = gimp_layer_new (gimage, width, height, type,
409
layer = gimp_layer_new (image, width, height, type,
451
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
453
gimp_image_add_layer (gimage, layer, 0);
455
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer), context,
456
template->fill_type);
458
gimp_image_undo_enable (gimage);
459
gimp_image_clean_all (gimage);
461
gimp_create_display (gimp, gimage, template->unit, 1.0);
463
g_object_unref (gimage);
411
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
413
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
414
context, template->fill_type);
416
gimp_image_add_layer (image, layer, 0);
418
gimp_image_undo_enable (image);
419
gimp_image_clean_all (image);
421
gimp_create_display (gimp, image, template->unit, 1.0);
423
g_object_unref (image);