2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-07-08 21:44:52 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-07-08 21:44:52 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-07-08 21:44:52 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-07-08 21:44:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-03-29 17:19:01 +00:00
|
|
|
#include <gegl.h>
|
2001-07-08 21:44:52 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "actions-types.h"
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
#include "core/gimppalette.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2003-03-20 13:05:52 +00:00
|
|
|
#include "widgets/gimpcontainertreeview.h"
|
2004-05-10 23:22:39 +00:00
|
|
|
#include "widgets/gimpcontainerview.h"
|
2001-07-08 21:44:52 +00:00
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2006-09-03 16:39:00 +00:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2003-08-22 01:42:57 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-08-24 17:16:46 +00:00
|
|
|
#include "widgets/gimpview.h"
|
2001-07-08 21:44:52 +00:00
|
|
|
|
2006-09-03 16:39:00 +00:00
|
|
|
#include "actions.h"
|
2001-07-08 21:44:52 +00:00
|
|
|
#include "palettes-commands.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-01-14 13:30:05 +00:00
|
|
|
static void palettes_merge_callback (GtkWidget *widget,
|
|
|
|
const gchar *palette_name,
|
|
|
|
gpointer data);
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* public functionss */
|
|
|
|
|
|
|
|
void
|
2005-01-14 13:30:05 +00:00
|
|
|
palettes_import_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-07-08 21:44:52 +00:00
|
|
|
{
|
2006-09-03 16:39:00 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_widget (widget, data);
|
2004-05-10 17:16:50 +00:00
|
|
|
|
2010-02-28 22:20:57 +00:00
|
|
|
gimp_dialog_factory_dialog_new (gimp_dialog_factory_get_singleton (),
|
2006-09-03 16:39:00 +00:00
|
|
|
gtk_widget_get_screen (widget),
|
2010-05-16 10:19:18 +00:00
|
|
|
NULL /*ui_manager*/,
|
2006-09-03 16:39:00 +00:00
|
|
|
"gimp-palette-import-dialog", -1, TRUE);
|
2001-07-08 21:44:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-14 13:30:05 +00:00
|
|
|
palettes_merge_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-07-08 21:44:52 +00:00
|
|
|
{
|
2004-04-29 12:52:29 +00:00
|
|
|
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
|
2004-10-19 14:08:44 +00: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 13:30:05 +00:00
|
|
|
palettes_merge_callback,
|
2004-10-19 14:08:44 +00:00
|
|
|
editor);
|
|
|
|
gtk_widget_show (dialog);
|
2001-07-08 21:44:52 +00:00
|
|
|
}
|
|
|
|
|
2004-10-18 11:29:58 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-07-08 21:44:52 +00:00
|
|
|
static void
|
2005-01-14 13:30:05 +00:00
|
|
|
palettes_merge_callback (GtkWidget *widget,
|
|
|
|
const gchar *palette_name,
|
|
|
|
gpointer data)
|
2001-07-08 21:44:52 +00:00
|
|
|
{
|
2009-07-20 09:53:02 +00:00
|
|
|
/* FIXME: reimplement palettes_merge_callback() */
|
2003-03-20 13:05:52 +00:00
|
|
|
#if 0
|
2001-07-08 21:44:52 +00:00
|
|
|
GimpContainerEditor *editor;
|
|
|
|
GimpPalette *palette;
|
|
|
|
GimpPalette *new_palette;
|
|
|
|
GList *sel_list;
|
|
|
|
|
|
|
|
editor = (GimpContainerEditor *) data;
|
|
|
|
|
|
|
|
sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (editor->view)->gtk_list)->selection;
|
|
|
|
|
|
|
|
if (! sel_list)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (gimp,
|
2013-09-14 16:59:20 +00:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
"Can't merge palettes because "
|
|
|
|
"there are no palettes selected.");
|
2001-07-08 21:44:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-30 16:31:39 +00:00
|
|
|
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name, FALSE));
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
while (sel_list)
|
|
|
|
{
|
|
|
|
GimpListItem *list_item;
|
|
|
|
|
|
|
|
list_item = GIMP_LIST_ITEM (sel_list->data);
|
|
|
|
|
2004-08-24 17:16:46 +00:00
|
|
|
palette = (GimpPalette *) GIMP_VIEW (list_item->preview)->viewable;
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
if (palette)
|
2006-04-12 12:49:29 +00:00
|
|
|
{
|
2010-10-27 12:36:44 +00:00
|
|
|
GList *cols;
|
|
|
|
|
|
|
|
for (cols = gimp_palette_get_colors (palette);
|
|
|
|
cols;
|
|
|
|
cols = g_list_next (cols))
|
2006-04-12 12:49:29 +00:00
|
|
|
{
|
2010-10-27 12:36:44 +00:00
|
|
|
GimpPaletteEntry *entry = cols->data;
|
2001-07-08 21:44:52 +00:00
|
|
|
|
2006-04-12 12:49:29 +00:00
|
|
|
gimp_palette_add_entry (new_palette,
|
|
|
|
entry->name,
|
|
|
|
&entry->color);
|
|
|
|
}
|
|
|
|
}
|
2001-07-08 21:44:52 +00:00
|
|
|
|
|
|
|
sel_list = sel_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_container_add (editor->view->container,
|
2006-04-12 12:49:29 +00:00
|
|
|
GIMP_OBJECT (new_palette));
|
2003-03-20 13:05:52 +00:00
|
|
|
#endif
|
2001-07-08 21:44:52 +00:00
|
|
|
}
|