Commit a00a565c authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added GimpData::duplicate() implementation so read-only palettes can be

2003-03-10  Michael Natterer  <mitch@gimp.org>

	* app/core/gimppalette.[ch]: added GimpData::duplicate()
	implementation so read-only palettes can be edited again by
	duplicating them first.

	* app/gui/dialogs-constructors.c: pass the <Palettes>, not the
	<Gradients> menu identifier to the palette grid and tree view
	constructors (spotted by Tigert).
parent 6f3f9556
2003-03-10 Michael Natterer <mitch@gimp.org>
* app/core/gimppalette.[ch]: added GimpData::duplicate()
implementation so read-only palettes can be edited again by
duplicating them first.
* app/gui/dialogs-constructors.c: pass the <Palettes>, not the
<Gradients> menu identifier to the palette grid and tree view
constructors (spotted by Tigert).
2003-03-10 Sven Neumann <sven@gimp.org>
 
* app/config/gimpconfigwriter.[ch]: fixed creation of config file,
......@@ -67,6 +67,8 @@ static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data,
GError **error);
static gchar * gimp_palette_get_extension (GimpData *data);
static GimpData * gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use);
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
......@@ -130,6 +132,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->duplicate = gimp_palette_duplicate;
}
static void
......@@ -310,9 +313,9 @@ gimp_palette_new (const gchar *name,
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (*name != '\0', NULL);
palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL));
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
gimp_data_dirty (GIMP_DATA (palette));
......@@ -326,7 +329,7 @@ gimp_palette_get_standard (void)
if (! standard_palette)
{
standard_palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE, NULL));
standard_palette = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_object_set_name (GIMP_OBJECT (standard_palette), "Standard");
}
......@@ -587,6 +590,32 @@ gimp_palette_get_extension (GimpData *data)
return GIMP_PALETTE_FILE_EXTENSION;
}
static GimpData *
gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpPalette *palette;
GimpPalette *new;
GList *list;
palette = GIMP_PALETTE (data);
new = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_data_dirty (GIMP_DATA (new));
new->n_columns = palette->n_columns;
for (list = palette->colors; list; list = g_list_next (list))
{
GimpPaletteEntry *entry = list->data;
gimp_palette_add_entry (new, entry->name, &entry->color);
}
return GIMP_DATA (new);
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
const gchar *name,
......
......@@ -67,6 +67,8 @@ static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data,
GError **error);
static gchar * gimp_palette_get_extension (GimpData *data);
static GimpData * gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use);
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
......@@ -130,6 +132,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->duplicate = gimp_palette_duplicate;
}
static void
......@@ -310,9 +313,9 @@ gimp_palette_new (const gchar *name,
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (*name != '\0', NULL);
palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL));
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
gimp_data_dirty (GIMP_DATA (palette));
......@@ -326,7 +329,7 @@ gimp_palette_get_standard (void)
if (! standard_palette)
{
standard_palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE, NULL));
standard_palette = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_object_set_name (GIMP_OBJECT (standard_palette), "Standard");
}
......@@ -587,6 +590,32 @@ gimp_palette_get_extension (GimpData *data)
return GIMP_PALETTE_FILE_EXTENSION;
}
static GimpData *
gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpPalette *palette;
GimpPalette *new;
GList *list;
palette = GIMP_PALETTE (data);
new = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_data_dirty (GIMP_DATA (new));
new->n_columns = palette->n_columns;
for (list = palette->colors; list; list = g_list_next (list))
{
GimpPaletteEntry *entry = list->data;
gimp_palette_add_entry (new, entry->name, &entry->color);
}
return GIMP_DATA (new);
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
const gchar *name,
......
......@@ -67,6 +67,8 @@ static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data,
GError **error);
static gchar * gimp_palette_get_extension (GimpData *data);
static GimpData * gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use);
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
......@@ -130,6 +132,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save;
data_class->get_extension = gimp_palette_get_extension;
data_class->duplicate = gimp_palette_duplicate;
}
static void
......@@ -310,9 +313,9 @@ gimp_palette_new (const gchar *name,
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (*name != '\0', NULL);
palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL));
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
gimp_data_dirty (GIMP_DATA (palette));
......@@ -326,7 +329,7 @@ gimp_palette_get_standard (void)
if (! standard_palette)
{
standard_palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE, NULL));
standard_palette = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_object_set_name (GIMP_OBJECT (standard_palette), "Standard");
}
......@@ -587,6 +590,32 @@ gimp_palette_get_extension (GimpData *data)
return GIMP_PALETTE_FILE_EXTENSION;
}
static GimpData *
gimp_palette_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpPalette *palette;
GimpPalette *new;
GList *list;
palette = GIMP_PALETTE (data);
new = g_object_new (GIMP_TYPE_PALETTE, NULL);
gimp_data_dirty (GIMP_DATA (new));
new->n_columns = palette->n_columns;
for (list = palette->colors; list; list = g_list_next (list))
{
GimpPaletteEntry *entry = list->data;
gimp_palette_add_entry (new, entry->name, &entry->color);
}
return GIMP_DATA (new);
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
const gchar *name,
......
......@@ -50,10 +50,10 @@ struct _GimpPalette
{
GimpData parent_instance;
GList *colors;
gint n_colors;
GList *colors;
gint n_colors;
gint n_columns;
gint n_columns;
};
struct _GimpPaletteClass
......
......@@ -541,7 +541,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
factory->menu_factory, "<Gradients>");
factory->menu_factory, "<Palettes>");
return dialogs_dockable_new (view,
_("Palette Grid"), _("Palettes"), NULL,
......@@ -689,7 +689,7 @@ dialogs_palette_tree_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
factory->menu_factory, "<Gradients>");
factory->menu_factory, "<Palettes>");
return dialogs_dockable_new (view,
_("Palette Tree"), _("Palettes"), NULL,
......
......@@ -541,7 +541,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
factory->menu_factory, "<Gradients>");
factory->menu_factory, "<Palettes>");
return dialogs_dockable_new (view,
_("Palette Grid"), _("Palettes"), NULL,
......@@ -689,7 +689,7 @@ dialogs_palette_tree_view_new (GimpDialogFactory *factory,
context,
preview_size,
5, 3,
factory->menu_factory, "<Gradients>");
factory->menu_factory, "<Palettes>");
return dialogs_dockable_new (view,
_("Palette Tree"), _("Palettes"), NULL,
......
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