2001-07-09 05:44:52 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
#include "core/gimppalette.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2003-03-20 21:05:52 +08:00
|
|
|
#include "widgets/gimpcontainertreeview.h"
|
2004-05-11 07:22:39 +08:00
|
|
|
#include "widgets/gimpcontainerview.h"
|
2001-07-09 05:44:52 +08:00
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "widgets/gimpview.h"
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/palette-import-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2001-07-09 05:44:52 +08:00
|
|
|
#include "palettes-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-01-14 21:30:05 +08:00
|
|
|
static void palettes_merge_callback (GtkWidget *widget,
|
|
|
|
const gchar *palette_name,
|
|
|
|
gpointer data);
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functionss */
|
|
|
|
|
|
|
|
void
|
2005-01-14 21:30:05 +08:00
|
|
|
palettes_import_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-07-09 05:44:52 +08:00
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
|
2004-05-11 01:16:50 +08:00
|
|
|
GimpContext *context;
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2004-05-11 01:16:50 +08:00
|
|
|
context = gimp_container_view_get_context (editor->view);
|
|
|
|
|
|
|
|
palette_import_dialog_show (context->gimp);
|
2001-07-09 05:44:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-14 21:30:05 +08:00
|
|
|
palettes_merge_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-07-09 05:44:52 +08:00
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gimp_query_string_box (_("Merge Palette"),
|
|
|
|
GTK_WIDGET (editor),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_PALETTE_MERGE,
|
|
|
|
_("Enter a name for the merged palette"),
|
|
|
|
NULL,
|
|
|
|
G_OBJECT (editor), "destroy",
|
2005-01-14 21:30:05 +08:00
|
|
|
palettes_merge_callback,
|
2004-10-19 22:08:44 +08:00
|
|
|
editor);
|
|
|
|
gtk_widget_show (dialog);
|
2001-07-09 05:44:52 +08:00
|
|
|
}
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-07-09 05:44:52 +08:00
|
|
|
static void
|
2005-01-14 21:30:05 +08:00
|
|
|
palettes_merge_callback (GtkWidget *widget,
|
|
|
|
const gchar *palette_name,
|
|
|
|
gpointer data)
|
2001-07-09 05:44:52 +08:00
|
|
|
{
|
2003-03-20 21:05:52 +08:00
|
|
|
#ifdef __GNUC__
|
2005-01-14 21:30:05 +08:00
|
|
|
#warning FIXME: reimplement palettes_merge_callback()
|
2003-03-20 21:05:52 +08:00
|
|
|
#endif
|
|
|
|
#if 0
|
2001-07-09 05:44:52 +08:00
|
|
|
GimpContainerEditor *editor;
|
|
|
|
GimpPalette *palette;
|
|
|
|
GimpPalette *new_palette;
|
|
|
|
GimpPaletteEntry *entry;
|
|
|
|
GList *sel_list;
|
|
|
|
|
|
|
|
editor = (GimpContainerEditor *) data;
|
|
|
|
|
|
|
|
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (editor->view)->gtk_list)->selection;
|
|
|
|
|
|
|
|
if (! sel_list)
|
|
|
|
{
|
|
|
|
g_message ("Can't merge palettes because there are no palettes selected.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-01 00:31:39 +08:00
|
|
|
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name, FALSE));
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
while (sel_list)
|
|
|
|
{
|
|
|
|
GimpListItem *list_item;
|
|
|
|
GList *cols;
|
|
|
|
|
|
|
|
list_item = GIMP_LIST_ITEM (sel_list->data);
|
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
palette = (GimpPalette *) GIMP_VIEW (list_item->preview)->viewable;
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
if (palette)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
for (cols = palette->colors; cols; cols = g_list_next (cols))
|
|
|
|
{
|
|
|
|
entry = (GimpPaletteEntry *) cols->data;
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_palette_add_entry (new_palette,
|
|
|
|
entry->name,
|
|
|
|
&entry->color);
|
|
|
|
}
|
|
|
|
}
|
2001-07-09 05:44:52 +08:00
|
|
|
|
|
|
|
sel_list = sel_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_container_add (editor->view->container,
|
2006-04-12 20:49:29 +08:00
|
|
|
GIMP_OBJECT (new_palette));
|
2003-03-20 21:05:52 +08:00
|
|
|
#endif
|
2001-07-09 05:44:52 +08:00
|
|
|
}
|