1998-12-24 08:08:39 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
* Copyright (C) 1998 Andy Thomas (alt@picnic.demon.co.uk)
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-02-01 07:59:05 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets/widgets-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdatafactory.h"
|
|
|
|
#include "core/gimppalette.h"
|
|
|
|
|
2001-04-11 09:13:53 +08:00
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
#include "widgets/gimpdnd.h"
|
2001-04-11 09:13:53 +08:00
|
|
|
|
2001-04-20 10:30:43 +08:00
|
|
|
#include "dialogs-constructors.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "palette-editor.h"
|
|
|
|
#include "palette-select.h"
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
#include "appenv.h"
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "app_procs.h"
|
1998-12-24 08:08:39 +08:00
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
#define STD_PALETTE_COLUMNS 6
|
|
|
|
#define STD_PALETTE_ROWS 5
|
|
|
|
|
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
static void palette_select_drop_palette (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
2001-01-21 21:41:07 +08:00
|
|
|
gpointer data);
|
|
|
|
static void palette_select_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
|
|
|
|
/* list of active dialogs */
|
2001-02-19 03:44:28 +08:00
|
|
|
static GSList *palette_active_dialogs = NULL;
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* the main palette selection dialog */
|
|
|
|
PaletteSelect *palette_select_dialog = NULL;
|
|
|
|
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* public functions */
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
GtkWidget *
|
|
|
|
palette_dialog_create (void)
|
|
|
|
{
|
|
|
|
if (! palette_select_dialog)
|
|
|
|
{
|
|
|
|
palette_select_dialog = palette_select_new (NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return palette_select_dialog->shell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
palette_dialog_free (void)
|
|
|
|
{
|
|
|
|
if (palette_select_dialog)
|
|
|
|
{
|
|
|
|
palette_select_free (palette_select_dialog);
|
|
|
|
palette_select_dialog = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
PaletteSelect *
|
2001-01-22 03:53:56 +08:00
|
|
|
palette_select_new (const gchar *title,
|
|
|
|
const gchar *initial_palette)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
PaletteSelect *psp;
|
|
|
|
GtkWidget *vbox;
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpPalette *active = NULL;
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
static gboolean first_call = TRUE;
|
|
|
|
|
|
|
|
psp = g_new0 (PaletteSelect, 1);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
|
|
|
psp->callback_name = NULL;
|
|
|
|
|
|
|
|
/* The shell and main vbox */
|
1999-09-28 01:58:10 +08:00
|
|
|
psp->shell = gimp_dialog_new (title ? title : _("Palette Selection"),
|
|
|
|
"palette_selection",
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/palette_selection.html",
|
2000-01-29 00:47:57 +08:00
|
|
|
GTK_WIN_POS_MOUSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
"_delete_event_", palette_select_close_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
psp, NULL, NULL, FALSE, TRUE,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
NULL);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox)), 0)));
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_hide (GTK_DIALOG (psp->shell)->action_area);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (title)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
psp->context = gimp_create_context (the_gimp, title, NULL);
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
|
|
|
else
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
psp->context = gimp_get_user_context (the_gimp);
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (no_data && first_call)
|
2001-07-05 03:31:35 +08:00
|
|
|
gimp_data_factory_data_init (the_gimp->palette_factory, FALSE);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
first_call = FALSE;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (title && initial_palette && strlen (initial_palette))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-19 03:44:28 +08:00
|
|
|
active = (GimpPalette *)
|
2001-07-05 03:31:35 +08:00
|
|
|
gimp_container_get_child_by_name (the_gimp->palette_factory->container,
|
2001-02-19 03:44:28 +08:00
|
|
|
initial_palette);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
2001-02-19 03:44:28 +08:00
|
|
|
else
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
active = gimp_context_get_palette (gimp_get_user_context (the_gimp));
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (!active)
|
2001-07-07 20:17:23 +08:00
|
|
|
active = gimp_context_get_palette (gimp_get_standard_context (the_gimp));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (title)
|
|
|
|
gimp_context_set_palette (psp->context, active);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* The main vbox */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox), vbox);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* The Palette List */
|
|
|
|
psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
2001-07-05 03:31:35 +08:00
|
|
|
the_gimp->palette_factory,
|
2001-04-20 10:30:43 +08:00
|
|
|
dialogs_edit_palette_func,
|
2001-02-19 03:44:28 +08:00
|
|
|
psp->context,
|
2001-05-13 19:35:20 +08:00
|
|
|
32,
|
2001-07-09 05:44:52 +08:00
|
|
|
5, 3,
|
|
|
|
NULL);
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), psp->view, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (psp->view);
|
|
|
|
|
|
|
|
gimp_gtk_drag_dest_set_by_type (psp->view,
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
GIMP_TYPE_PALETTE,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_viewable_dest_set (GTK_WIDGET (psp->view),
|
|
|
|
GIMP_TYPE_PALETTE,
|
|
|
|
palette_select_drop_palette,
|
|
|
|
psp);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (psp->shell);
|
2000-01-29 00:47:57 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
palette_active_dialogs = g_slist_append (palette_active_dialogs, psp);
|
2000-01-29 00:47:57 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
return psp;
|
|
|
|
}
|
2000-01-29 00:47:57 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
palette_select_free (PaletteSelect *psp)
|
|
|
|
{
|
|
|
|
if (psp)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if(psp->callback_name)
|
|
|
|
g_free (gsp->callback_name);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* remove from active list */
|
2001-02-19 03:44:28 +08:00
|
|
|
palette_active_dialogs = g_slist_remove (palette_active_dialogs, psp);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
g_free (psp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
palette_select_drop_palette (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PaletteSelect *psp;
|
|
|
|
|
|
|
|
psp = (PaletteSelect *) data;
|
|
|
|
|
|
|
|
gimp_context_set_palette (psp->context, GIMP_PALETTE (viewable));
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
palette_select_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PaletteSelect *psp;
|
|
|
|
|
|
|
|
psp = (PaletteSelect *) data;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (psp->shell))
|
|
|
|
gtk_widget_hide (psp->shell);
|
|
|
|
|
|
|
|
gtk_widget_destroy (psp->shell);
|
|
|
|
palette_select_free (psp);
|
|
|
|
}
|