Commit 59cb5d75 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added MIME type as a construct property to GimpData.

2005-05-26  Sven Neumann  <sven@gimp.org>

	* 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.
parent 79f57d5b
2005-05-26 Sven Neumann <sven@gimp.org>
* 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 <rock@gimp.org>
* app/sanity.c (sanity_check_filename_encoding): made the
......
......@@ -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);
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -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))
{
......
......@@ -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))
{
......
......@@ -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))
{
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment