gimp/app/gui/palette-select.c
Michael Natterer 0164596064 app/core/Makefile.am app/core/core-types.h added an "application object"
2001-07-04  Michael Natterer  <mitch@gimp.org>

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimp.[ch]: added an "application object" called Gimp.

	Currently, it contains the image list, the clipboard, the data
	factories, the procedural hashtable and the tool info list.  It's
	the toplevel object of the core object system. Finally, creating a
	Gimp object will return a standalone gimp core engine instance
	with no other global states/variables involved.

	* app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :)
	Removed stuff which is now done by the "Gimp" object. Merged
	gimp_init() into app_init() because gimp_init() is taken now.

	* app/context_manager.[ch]: removed stuff done by "Gimp".

	* app/batch.[ch]
	* app/gimage.[ch]
	* app/xcf/xcf-load.[ch]
	* app/xcf/xcf.[ch]
	* app/core/gimpedit.[ch]
	* app/tools/tool_manager.[ch]: pass around an additional "Gimp"
	argument.

	* app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first
	parameter to all internal procedures and to all procedural_db_*
	functions.

	* app/core/gimpcontext.[ch]
	* app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs.

	* app/devices.c
	* app/errors.c
	* app/file-open.c
	* app/file-save.c
	* app/gimphelp.c
	* app/gimpunit.c
	* app/image_new.c
	* app/main.c
	* app/nav_window.c
	* app/plug_in.c
	* app/base/base.c
	* app/core/gimpdatafactory.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-mask.c
	* app/core/gimptoolinfo.[ch]
	* app/gui/brush-select.c
	* app/gui/convert-dialog.c
	* app/gui/dialogs-constructors.c
	* app/gui/edit-commands.c
	* app/gui/file-open-dialog.c
	* app/gui/file-save-dialog.c
	* app/gui/gradient-editor.c
	* app/gui/gradient-select.c
	* app/gui/gui.c
	* app/gui/image-commands.c
	* app/gui/info-window.c
	* app/gui/menus.c
	* app/gui/palette-editor.c
	* app/gui/palette-import-dialog.c
	* app/gui/palette-select.c
	* app/gui/paths-dialog.c
	* app/gui/pattern-select.c
	* app/gui/preferences-dialog.c
	* app/gui/test-commands.c
	* app/gui/toolbox.c
	* app/gui/tools-commands.c
	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimppainttool.h
	* app/tools/gimptexttool.c
	* app/tools/gimptransformtool.h
	* app/widgets/gimpbufferview.c
	* app/widgets/gimpcontainerview-utils.c
	* app/widgets/gimpcursor.c
	* app/widgets/gimpdnd.c
	* app/widgets/gimpimagedock.c: changed accordingly. Cleaned up
	lots of includes. Many files still access the global "the_gimp"
	variable exported by app_procs.h.

	* tools/pdbgen/app.pl
	* tools/pdbgen/pdb/brush_select.pdb
	* tools/pdbgen/pdb/brushes.pdb
	* tools/pdbgen/pdb/convert.pdb
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/fileops.pdb
	* tools/pdbgen/pdb/gradient_select.pdb
	* tools/pdbgen/pdb/gradients.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/palette.pdb
	* tools/pdbgen/pdb/pattern_select.pdb
	* tools/pdbgen/pdb/patterns.pdb
	* tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't
	use "the_gimp" here because all procedures get passed a "Gimp"
	pointer now.

	* app/pdb/*: regenerated.
2001-07-04 19:31:35 +00:00

217 lines
5.3 KiB
C

/* 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.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "widgets/widgets-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpdnd.h"
#include "dialog_handler.h"
#include "dialogs-constructors.h"
#include "palette-editor.h"
#include "palette-select.h"
#include "appenv.h"
#include "app_procs.h"
#include "libgimp/gimpintl.h"
#define STD_PALETTE_COLUMNS 6
#define STD_PALETTE_ROWS 5
/* local function prototypes */
static void palette_select_drop_palette (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void palette_select_close_callback (GtkWidget *widget,
gpointer data);
/* list of active dialogs */
static GSList *palette_active_dialogs = NULL;
/* public functions */
PaletteSelect *
palette_select_new (const gchar *title,
const gchar *initial_palette)
{
PaletteSelect *psp;
GtkWidget *vbox;
GimpPalette *active = NULL;
static gboolean first_call = TRUE;
psp = g_new0 (PaletteSelect, 1);
psp->callback_name = NULL;
/* The shell and main vbox */
psp->shell = gimp_dialog_new (title ? title : _("Palette Selection"),
"palette_selection",
gimp_standard_help_func,
"dialogs/palette_selection.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
"_delete_event_", palette_select_close_callback,
psp, NULL, NULL, FALSE, TRUE,
NULL);
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (psp->shell)->vbox)), 0)));
gtk_widget_hide (GTK_DIALOG (psp->shell)->action_area);
if (title)
{
psp->context = gimp_context_new (the_gimp, title, NULL);
}
else
{
psp->context = gimp_context_get_user ();
/*
session_set_window_geometry (psp->shell, &palette_select_session_info,
TRUE);
*/
dialog_register (psp->shell);
}
if (no_data && first_call)
gimp_data_factory_data_init (the_gimp->palette_factory, FALSE);
first_call = FALSE;
if (title && initial_palette && strlen (initial_palette))
{
active = (GimpPalette *)
gimp_container_get_child_by_name (the_gimp->palette_factory->container,
initial_palette);
}
else
{
active = gimp_context_get_palette (gimp_context_get_user ());
}
if (!active)
active = gimp_context_get_palette (gimp_context_get_standard (the_gimp));
if (title)
gimp_context_set_palette (psp->context, active);
/* 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);
/* The Palette List */
psp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
the_gimp->palette_factory,
dialogs_edit_palette_func,
psp->context,
32,
5, 3);
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);
gtk_widget_show (vbox);
gtk_widget_show (psp->shell);
palette_active_dialogs = g_slist_append (palette_active_dialogs, psp);
return psp;
}
/* 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));
}
static void
palette_select_free (PaletteSelect *psp)
{
if (psp)
{
/*
if(psp->callback_name)
g_free (gsp->callback_name);
*/
/* remove from active list */
palette_active_dialogs = g_slist_remove (palette_active_dialogs, psp);
g_free (psp);
}
}
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);
}