diff --git a/ChangeLog b/ChangeLog index 820f2740c3..d0fefdab7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-05-26 Sven Neumann + + * app/core/gimpdata.[ch]: added MIME type as a construct property + to GimpData. + + * app/core/gimpbrush-load.c + * app/core/gimpbrushgenerated.c + * app/core/gimpbrushpipe.c + * app/core/gimpgradient-load.c + * app/core/gimppalette.c + * app/core/gimppattern.c: set the MIME type when loading a data + object from file. MIME types needs review and GimpPalette isn't + quite done yet... + + * app/core/gimpdashpattern.c: cosmetics. + 2005-05-25 Nathan Summers * app/sanity.c (sanity_check_filename_encoding): made the diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index b907ff5c2f..8cfaf7523a 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -268,9 +268,9 @@ gimp_brush_load_brush (gint fd, name = g_strdup (_("Unnamed")); brush = g_object_new (GIMP_TYPE_BRUSH, - "name", name, + "name", name, + "mime-type", "image/x-gimp-gbr", NULL); - g_free (name); brush->mask = temp_buf_new (header.width, header.height, 1, 0, 0, NULL); @@ -532,7 +532,9 @@ gimp_brush_load_abr_brush (FILE *file, g_free (tmp); brush = g_object_new (GIMP_TYPE_BRUSH, - "name", name, + "name", name, + /* FIXME: MIME type!! */ + "mime-type", "application/x-photoshop-abr", NULL); g_free (name); diff --git a/app/core/gimpbrushgenerated-load.c b/app/core/gimpbrushgenerated-load.c index 0cd7fdd2c9..894c359e62 100644 --- a/app/core/gimpbrushgenerated-load.c +++ b/app/core/gimpbrushgenerated-load.c @@ -552,6 +552,7 @@ gimp_brush_generated_new (const gchar *name, brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, "name", name, + "mime-type", "application/x-gimp-brush-generated", "shape", shape, "radius", radius, "spikes", spikes, diff --git a/app/core/gimpbrushgenerated-save.c b/app/core/gimpbrushgenerated-save.c index 0cd7fdd2c9..894c359e62 100644 --- a/app/core/gimpbrushgenerated-save.c +++ b/app/core/gimpbrushgenerated-save.c @@ -552,6 +552,7 @@ gimp_brush_generated_new (const gchar *name, brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, "name", name, + "mime-type", "application/x-gimp-brush-generated", "shape", shape, "radius", radius, "spikes", spikes, diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c index 0cd7fdd2c9..894c359e62 100644 --- a/app/core/gimpbrushgenerated.c +++ b/app/core/gimpbrushgenerated.c @@ -552,6 +552,7 @@ gimp_brush_generated_new (const gchar *name, brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED, "name", name, + "mime-type", "application/x-gimp-brush-generated", "shape", shape, "radius", radius, "spikes", spikes, diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c index e50e8c2334..011bed2de2 100644 --- a/app/core/gimpbrushpipe-load.c +++ b/app/core/gimpbrushpipe-load.c @@ -349,7 +349,8 @@ gimp_brush_pipe_load (const gchar *filename, gimp_filename_to_utf8 (filename)); pipe = g_object_new (GIMP_TYPE_BRUSH_PIPE, - "name", utf8, + "name", utf8, + "mime-type", "image/x-gimp-gih", NULL); g_free (utf8); diff --git a/app/core/gimpbrushpipe.c b/app/core/gimpbrushpipe.c index e50e8c2334..011bed2de2 100644 --- a/app/core/gimpbrushpipe.c +++ b/app/core/gimpbrushpipe.c @@ -349,7 +349,8 @@ gimp_brush_pipe_load (const gchar *filename, gimp_filename_to_utf8 (filename)); pipe = g_object_new (GIMP_TYPE_BRUSH_PIPE, - "name", utf8, + "name", utf8, + "mime-type", "image/x-gimp-gih", NULL); g_free (utf8); diff --git a/app/core/gimpdashpattern.c b/app/core/gimpdashpattern.c index 081ad9960c..6953e125a2 100644 --- a/app/core/gimpdashpattern.c +++ b/app/core/gimpdashpattern.c @@ -40,20 +40,28 @@ gimp_dash_pattern_from_preset (GimpDashPreset preset) switch (preset) { + case GIMP_DASH_CUSTOM: + g_warning ("GIMP_DASH_CUSTOM passed to gimp_dash_pattern_from_preset()"); + break; + case GIMP_DASH_LINE: break; + case GIMP_DASH_LONG_DASH: dash = 9.0; g_array_append_val (pattern, dash); dash = 3.0; g_array_append_val (pattern, dash); break; + case GIMP_DASH_MEDIUM_DASH: dash = 6.0; g_array_append_val (pattern, dash); dash = 6.0; g_array_append_val (pattern, dash); break; + case GIMP_DASH_SHORT_DASH: dash = 3.0; g_array_append_val (pattern, dash); dash = 9.0; g_array_append_val (pattern, dash); break; + case GIMP_DASH_SPARSE_DOTS: for (i = 0; i < 2; i++) { @@ -61,6 +69,7 @@ gimp_dash_pattern_from_preset (GimpDashPreset preset) dash = 5.0; g_array_append_val (pattern, dash); } break; + case GIMP_DASH_NORMAL_DOTS: for (i = 0; i < 3; i++) { @@ -68,24 +77,28 @@ gimp_dash_pattern_from_preset (GimpDashPreset preset) dash = 3.0; g_array_append_val (pattern, dash); } break; + case GIMP_DASH_DENSE_DOTS: for (i = 0; i < 12; i++) { dash = 1.0; g_array_append_val (pattern, dash); } break; + case GIMP_DASH_STIPPLES: for (i = 0; i < 24; i++) { dash = 0.5; g_array_append_val (pattern, dash); } break; + case GIMP_DASH_DASH_DOT: dash = 7.0; g_array_append_val (pattern, dash); dash = 2.0; g_array_append_val (pattern, dash); dash = 1.0; g_array_append_val (pattern, dash); dash = 2.0; g_array_append_val (pattern, dash); break; + case GIMP_DASH_DASH_DOT_DOT: dash = 7.0; g_array_append_val (pattern, dash); for (i=0; i < 5; i++) @@ -93,8 +106,6 @@ gimp_dash_pattern_from_preset (GimpDashPreset preset) dash = 1.0; g_array_append_val (pattern, dash); } break; - case GIMP_DASH_CUSTOM: - g_warning ("GIMP_DASH_CUSTOM passed to gimp_dash_pattern_from_preset()"); } if (pattern->len < 2) diff --git a/app/core/gimpdata.c b/app/core/gimpdata.c index bbeddc5027..b611078e18 100644 --- a/app/core/gimpdata.c +++ b/app/core/gimpdata.c @@ -51,12 +51,26 @@ enum LAST_SIGNAL }; +enum +{ + PROP_0, + PROP_MIME_TYPE +}; + static void gimp_data_class_init (GimpDataClass *klass); static void gimp_data_init (GimpData *data, GimpDataClass *data_class); static void gimp_data_finalize (GObject *object); +static void gimp_data_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_data_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); static void gimp_data_name_changed (GimpObject *object); static gint64 gimp_data_get_memsize (GimpObject *object, @@ -116,6 +130,8 @@ gimp_data_class_init (GimpDataClass *klass) G_TYPE_NONE, 0); object_class->finalize = gimp_data_finalize; + object_class->set_property = gimp_data_set_property; + object_class->get_property = gimp_data_get_property; gimp_object_class->name_changed = gimp_data_name_changed; gimp_object_class->get_memsize = gimp_data_get_memsize; @@ -124,6 +140,13 @@ gimp_data_class_init (GimpDataClass *klass) klass->save = NULL; klass->get_extension = NULL; klass->duplicate = NULL; + + g_object_class_install_property (object_class, PROP_MIME_TYPE, + g_param_spec_string ("mime-type", + NULL, NULL, + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } static void @@ -131,6 +154,7 @@ gimp_data_init (GimpData *data, GimpDataClass *data_class) { data->filename = NULL; + data->mime_type = 0; data->writable = TRUE; data->deletable = TRUE; data->dirty = TRUE; @@ -158,6 +182,49 @@ gimp_data_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +gimp_data_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpData *data = GIMP_DATA (object); + + switch (property_id) + { + case PROP_MIME_TYPE: + if (g_value_get_string (value)) + data->mime_type = g_quark_from_string (g_value_get_string (value)); + else + data->mime_type = 0; + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_data_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpData *data = GIMP_DATA (object); + + switch (property_id) + { + case PROP_MIME_TYPE: + g_value_set_string (value, g_quark_to_string (data->mime_type)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + static void gimp_data_name_changed (GimpObject *object) { @@ -461,6 +528,14 @@ gimp_data_create_filename (GimpData *data, g_free (fullpath); } +const gchar * +gimp_data_get_mime_type (GimpData *data) +{ + g_return_val_if_fail (GIMP_IS_DATA (data), NULL); + + return g_quark_to_string (data->mime_type); +} + /** * gimp_data_duplicate: * @data: a #GimpData object diff --git a/app/core/gimpdata.h b/app/core/gimpdata.h index 0fca76bf69..f30cae836e 100644 --- a/app/core/gimpdata.h +++ b/app/core/gimpdata.h @@ -50,6 +50,7 @@ struct _GimpData GimpViewable parent_instance; gchar *filename; + GQuark mime_type; guint writable : 1; guint deletable : 1; guint dirty : 1; @@ -94,6 +95,8 @@ void gimp_data_set_filename (GimpData *data, void gimp_data_create_filename (GimpData *data, const gchar *dest_dir); +const gchar * gimp_data_get_mime_type (GimpData *data); + GimpData * gimp_data_duplicate (GimpData *data, gboolean stingy_memory_use); diff --git a/app/core/gimpgradient-load.c b/app/core/gimpgradient-load.c index 91899c098b..0b94c6ad03 100644 --- a/app/core/gimpgradient-load.c +++ b/app/core/gimpgradient-load.c @@ -76,7 +76,9 @@ gimp_gradient_load (const gchar *filename, return NULL; } - gradient = g_object_new (GIMP_TYPE_GRADIENT, NULL); + gradient = g_object_new (GIMP_TYPE_GRADIENT, + "mime-type", "application/x-gimp-gradient", + NULL); fgets (line, 1024, file); if (! strncmp (line, "Name: ", strlen ("Name: "))) @@ -325,7 +327,8 @@ svg_parser_start_element (GMarkupParseContext *context, } parser->gradient = g_object_new (GIMP_TYPE_GRADIENT, - "name", name, + "name", name, + "mime-type", "image/svg+xml", NULL); } else if (parser->gradient && strcmp (element_name, "stop") == 0) diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index 1bc6b21199..d3ddde4a7a 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -388,7 +388,9 @@ gimp_palette_load (const gchar *filename, return NULL; } - palette = g_object_new (GIMP_TYPE_PALETTE, NULL); + palette = g_object_new (GIMP_TYPE_PALETTE, + "mime-type", "application/x-gimp-palette", + NULL); if (! fgets (str, sizeof (str), file)) { diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index 1bc6b21199..d3ddde4a7a 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -388,7 +388,9 @@ gimp_palette_load (const gchar *filename, return NULL; } - palette = g_object_new (GIMP_TYPE_PALETTE, NULL); + palette = g_object_new (GIMP_TYPE_PALETTE, + "mime-type", "application/x-gimp-palette", + NULL); if (! fgets (str, sizeof (str), file)) { diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index 1bc6b21199..d3ddde4a7a 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -388,7 +388,9 @@ gimp_palette_load (const gchar *filename, return NULL; } - palette = g_object_new (GIMP_TYPE_PALETTE, NULL); + palette = g_object_new (GIMP_TYPE_PALETTE, + "mime-type", "application/x-gimp-palette", + NULL); if (! fgets (str, sizeof (str), file)) { diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index bf46750ca1..98cbea12d3 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -390,7 +390,8 @@ gimp_pattern_load (const gchar *filename, name = g_strdup (_("Unnamed")); pattern = g_object_new (GIMP_TYPE_PATTERN, - "name", name, + "name", name, + "mime-type", "image/x-gimp-pat", NULL); g_free (name); @@ -461,7 +462,8 @@ gimp_pattern_load_pixbuf (const gchar *filename, name = g_filename_display_basename (filename); pattern = g_object_new (GIMP_TYPE_PATTERN, - "name", name, + "name", name, + "mime-type", NULL, /* FIXME!! */ NULL); g_free (name); diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index bf46750ca1..98cbea12d3 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -390,7 +390,8 @@ gimp_pattern_load (const gchar *filename, name = g_strdup (_("Unnamed")); pattern = g_object_new (GIMP_TYPE_PATTERN, - "name", name, + "name", name, + "mime-type", "image/x-gimp-pat", NULL); g_free (name); @@ -461,7 +462,8 @@ gimp_pattern_load_pixbuf (const gchar *filename, name = g_filename_display_basename (filename); pattern = g_object_new (GIMP_TYPE_PATTERN, - "name", name, + "name", name, + "mime-type", NULL, /* FIXME!! */ NULL); g_free (name);