mirror of https://github.com/GNOME/gimp.git
Fixed GimpData's default "writable" and "deletable" behaviour:
2004-02-13 Michael Natterer <mitch@gimp.org> Fixed GimpData's default "writable" and "deletable" behaviour: * app/core/gimpdata.c (gimp_data_init): default to writable and deletable == TRUE (something that has no filename was never loaded from disk and can't be undeletable or read-only). Fixes bug #134274. * app/core/gimpdata.[ch]: added new function gimp_data_make_internal() which frees the filename and sets the data's flags accordingly. * app/core/gimp-gradients.c (gimp_gradients_add_gradient) * app/core/gimpbrush.c (gimp_brush_get_standard) * app/core/gimpgradient.c (gimp_gradient_get_standard) * app/core/gimppalette.c (gimp_palette_get_standard) * app/core/gimppattern.c (gimp_pattern_get_standard): use the new function for internal data objects. * app/core/gimpdata.c (gimp_data_save, gimp_data_delete_from_disk) * app/core/gimpdatafactory.c (gimp_data_factory_save_single): bail out with g_return_if_fail() is the data is not writable or deletable. * app/widgets/gimpdataeditor.c * app/widgets/gimpdatafactoryview.c: changed accordingly.
This commit is contained in:
parent
1797d6c7fd
commit
d991e64b38
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
|||
2004-02-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Fixed GimpData's default "writable" and "deletable" behaviour:
|
||||
|
||||
* app/core/gimpdata.c (gimp_data_init): default to writable and
|
||||
deletable == TRUE (something that has no filename was never loaded
|
||||
from disk and can't be undeletable or read-only).
|
||||
Fixes bug #134274.
|
||||
|
||||
* app/core/gimpdata.[ch]: added new function
|
||||
gimp_data_make_internal() which frees the filename and sets the
|
||||
data's flags accordingly.
|
||||
|
||||
* app/core/gimp-gradients.c (gimp_gradients_add_gradient)
|
||||
* app/core/gimpbrush.c (gimp_brush_get_standard)
|
||||
* app/core/gimpgradient.c (gimp_gradient_get_standard)
|
||||
* app/core/gimppalette.c (gimp_palette_get_standard)
|
||||
* app/core/gimppattern.c (gimp_pattern_get_standard): use the
|
||||
new function for internal data objects.
|
||||
|
||||
* app/core/gimpdata.c (gimp_data_save, gimp_data_delete_from_disk)
|
||||
* app/core/gimpdatafactory.c (gimp_data_factory_save_single):
|
||||
bail out with g_return_if_fail() is the data is not writable
|
||||
or deletable.
|
||||
|
||||
* app/widgets/gimpdataeditor.c
|
||||
* app/widgets/gimpdatafactoryview.c: changed accordingly.
|
||||
|
||||
2004-02-12 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/display/gimpcanvas.c (gimp_canvas_gc_new): use
|
||||
|
|
|
@ -114,7 +114,7 @@ gimp_gradients_add_gradient (Gimp *gimp,
|
|||
gradient = GIMP_GRADIENT (gimp_gradient_new (name,
|
||||
base_config->stingy_memory_use));
|
||||
|
||||
GIMP_DATA (gradient)->internal = TRUE;
|
||||
gimp_data_make_internal (GIMP_DATA (gradient));
|
||||
|
||||
gimp_context_get_foreground (gimp->user_context,
|
||||
&gradient->segments->left_color);
|
||||
|
|
|
@ -370,7 +370,7 @@ gimp_brush_get_standard (void)
|
|||
standard_brush = gimp_brush_new ("Standard", FALSE);
|
||||
|
||||
standard_brush->dirty = FALSE;
|
||||
standard_brush->internal = TRUE;
|
||||
gimp_data_make_internal (standard_brush);
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard brush */
|
||||
g_object_ref (standard_brush);
|
||||
|
|
|
@ -370,7 +370,7 @@ gimp_brush_get_standard (void)
|
|||
standard_brush = gimp_brush_new ("Standard", FALSE);
|
||||
|
||||
standard_brush->dirty = FALSE;
|
||||
standard_brush->internal = TRUE;
|
||||
gimp_data_make_internal (standard_brush);
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard brush */
|
||||
g_object_ref (standard_brush);
|
||||
|
|
|
@ -137,10 +137,14 @@ static void
|
|||
gimp_data_init (GimpData *data)
|
||||
{
|
||||
data->filename = NULL;
|
||||
data->writable = FALSE;
|
||||
data->deletable = FALSE;
|
||||
data->writable = TRUE;
|
||||
data->deletable = TRUE;
|
||||
data->dirty = TRUE;
|
||||
data->internal = FALSE;
|
||||
|
||||
/* if we can't save, we are not writable */
|
||||
if (! GIMP_DATA_GET_CLASS (data)->save)
|
||||
data->writable = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -187,6 +191,7 @@ gimp_data_save (GimpData *data,
|
|||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
|
||||
g_return_val_if_fail (data->writable == TRUE, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
if (data->internal)
|
||||
|
@ -228,6 +233,7 @@ gimp_data_delete_from_disk (GimpData *data,
|
|||
{
|
||||
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
|
||||
g_return_val_if_fail (data->filename != NULL, FALSE);
|
||||
g_return_val_if_fail (data->deletable == TRUE, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
if (data->internal)
|
||||
|
@ -268,10 +274,7 @@ gimp_data_set_filename (GimpData *data,
|
|||
return;
|
||||
|
||||
if (data->filename)
|
||||
{
|
||||
g_free (data->filename);
|
||||
data->filename = NULL;
|
||||
}
|
||||
|
||||
data->filename = g_strdup (filename);
|
||||
data->writable = FALSE;
|
||||
|
@ -353,19 +356,28 @@ GimpData *
|
|||
gimp_data_duplicate (GimpData *data,
|
||||
gboolean stingy_memory_use)
|
||||
{
|
||||
GimpData *new = NULL;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
|
||||
|
||||
if (GIMP_DATA_GET_CLASS (data)->duplicate)
|
||||
{
|
||||
new = GIMP_DATA_GET_CLASS (data)->duplicate (data, stingy_memory_use);
|
||||
return GIMP_DATA_GET_CLASS (data)->duplicate (data, stingy_memory_use);
|
||||
|
||||
if (new)
|
||||
new->dirty = TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new;
|
||||
void
|
||||
gimp_data_make_internal (GimpData *data)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DATA (data));
|
||||
|
||||
if (data->filename)
|
||||
{
|
||||
g_free (data->filename);
|
||||
data->filename = NULL;
|
||||
}
|
||||
|
||||
data->internal = TRUE;
|
||||
data->writable = FALSE;
|
||||
data->deletable = FALSE;
|
||||
}
|
||||
|
||||
GQuark
|
||||
|
|
|
@ -93,6 +93,8 @@ void gimp_data_create_filename (GimpData *data,
|
|||
GimpData * gimp_data_duplicate (GimpData *data,
|
||||
gboolean stingy_memory_use);
|
||||
|
||||
void gimp_data_make_internal (GimpData *data);
|
||||
|
||||
|
||||
#define GIMP_DATA_ERROR (gimp_data_error_quark ())
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ gimp_data_factory_data_save (GimpDataFactory *factory)
|
|||
if (! data->filename)
|
||||
gimp_data_create_filename (data, GIMP_OBJECT (data)->name, writable_dir);
|
||||
|
||||
if (data->dirty)
|
||||
if (data->dirty && data->writable)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
|
@ -453,6 +453,7 @@ gimp_data_factory_data_save_single (GimpDataFactory *factory,
|
|||
|
||||
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
|
||||
g_return_val_if_fail (data->writable == TRUE, FALSE);
|
||||
|
||||
if (! data->dirty)
|
||||
return TRUE;
|
||||
|
|
|
@ -319,7 +319,7 @@ gimp_gradient_get_standard (void)
|
|||
standard_gradient = gimp_gradient_new ("Standard", FALSE);
|
||||
|
||||
standard_gradient->dirty = FALSE;
|
||||
standard_gradient->internal = TRUE;
|
||||
gimp_data_make_internal (standard_gradient);
|
||||
|
||||
g_object_ref (standard_gradient);
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ gimp_palette_get_standard (void)
|
|||
standard_palette = gimp_palette_new ("Standard", FALSE);
|
||||
|
||||
standard_palette->dirty = FALSE;
|
||||
standard_palette->internal = TRUE;
|
||||
gimp_data_make_internal (standard_palette);
|
||||
|
||||
g_object_ref (standard_palette);
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ gimp_palette_get_standard (void)
|
|||
standard_palette = gimp_palette_new ("Standard", FALSE);
|
||||
|
||||
standard_palette->dirty = FALSE;
|
||||
standard_palette->internal = TRUE;
|
||||
gimp_data_make_internal (standard_palette);
|
||||
|
||||
g_object_ref (standard_palette);
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ gimp_palette_get_standard (void)
|
|||
standard_palette = gimp_palette_new ("Standard", FALSE);
|
||||
|
||||
standard_palette->dirty = FALSE;
|
||||
standard_palette->internal = TRUE;
|
||||
gimp_data_make_internal (standard_palette);
|
||||
|
||||
g_object_ref (standard_palette);
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ gimp_pattern_get_standard (void)
|
|||
standard_pattern = gimp_pattern_new ("Standard", FALSE);
|
||||
|
||||
standard_pattern->dirty = FALSE;
|
||||
standard_pattern->internal = TRUE;
|
||||
gimp_data_make_internal (standard_pattern);
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard pattern */
|
||||
g_object_ref (standard_pattern);
|
||||
|
|
|
@ -297,7 +297,7 @@ gimp_pattern_get_standard (void)
|
|||
standard_pattern = gimp_pattern_new ("Standard", FALSE);
|
||||
|
||||
standard_pattern->dirty = FALSE;
|
||||
standard_pattern->internal = TRUE;
|
||||
gimp_data_make_internal (standard_pattern);
|
||||
|
||||
/* set ref_count to 2 --> never swap the standard pattern */
|
||||
g_object_ref (standard_pattern);
|
||||
|
|
|
@ -374,7 +374,7 @@ gimp_data_editor_save_dirty (GimpDataEditor *editor)
|
|||
{
|
||||
GimpData *data = editor->data;
|
||||
|
||||
if (data && data->dirty)
|
||||
if (data && data->dirty && data->writable)
|
||||
gimp_data_factory_data_save_single (editor->data_factory, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -350,16 +350,16 @@ gimp_data_factory_view_delete_callback (GtkWidget *widget,
|
|||
gboolean delete,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataDeleteData *delete_data;
|
||||
|
||||
delete_data = (GimpDataDeleteData *) data;
|
||||
|
||||
if (! delete)
|
||||
return;
|
||||
GimpDataDeleteData *delete_data = data;
|
||||
|
||||
if (gimp_container_have (delete_data->factory->container,
|
||||
GIMP_OBJECT (delete_data->data)))
|
||||
{
|
||||
g_object_ref (delete_data->data);
|
||||
|
||||
gimp_container_remove (delete_data->factory->container,
|
||||
GIMP_OBJECT (delete_data->data));
|
||||
|
||||
if (delete_data->data->filename)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
@ -371,8 +371,7 @@ gimp_data_factory_view_delete_callback (GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
gimp_container_remove (delete_data->factory->container,
|
||||
GIMP_OBJECT (delete_data->data));
|
||||
g_object_unref (delete_data->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,7 +385,7 @@ gimp_data_factory_view_delete_clicked (GtkWidget *widget,
|
|||
gimp_context_get_by_type (GIMP_CONTAINER_EDITOR (view)->view->context,
|
||||
view->factory->container->children_type);
|
||||
|
||||
if (data && ! data->internal && gimp_container_have (view->factory->container,
|
||||
if (data && data->deletable && gimp_container_have (view->factory->container,
|
||||
GIMP_OBJECT (data)))
|
||||
{
|
||||
GimpDataDeleteData *delete_data;
|
||||
|
|
Loading…
Reference in New Issue