1997-11-24 22:05:25 +00: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
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-01-16 14:47:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-08 03:48:54 +00:00
|
|
|
#include "widgets-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-08-17 14:27:31 +00:00
|
|
|
#include "gui/gui-types.h"
|
2001-04-17 21:43:29 +00:00
|
|
|
#include "gui/color-notebook.h"
|
|
|
|
|
2001-04-11 01:13:53 +00:00
|
|
|
#include "gimpcolorpanel.h"
|
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
struct _GimpColorPanel
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorButton parent;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
ColorNotebook *color_notebook;
|
|
|
|
gboolean color_notebook_active;
|
1997-11-24 22:05:25 +00:00
|
|
|
};
|
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-10 19:16:16 +00:00
|
|
|
|
1999-08-22 11:45:31 +00:00
|
|
|
/* local function prototypes */
|
2001-01-20 15:37:26 +00:00
|
|
|
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
|
|
|
static void gimp_color_panel_init (GimpColorPanel *panel);
|
2001-10-17 11:33:43 +00:00
|
|
|
|
2001-01-20 15:37:26 +00:00
|
|
|
static void gimp_color_panel_destroy (GtkObject *object);
|
|
|
|
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
|
|
|
static void gimp_color_panel_clicked (GtkButton *button);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-21 13:41:07 +00:00
|
|
|
static void gimp_color_panel_select_callback (ColorNotebook *notebook,
|
|
|
|
const GimpRGB *color,
|
2001-01-20 15:37:26 +00:00
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data);
|
1999-08-23 14:19:26 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
static GimpColorButtonClass *parent_class = NULL;
|
2001-01-15 01:48:53 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
GType
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_panel_get_type (void)
|
1999-08-24 02:52:40 +00:00
|
|
|
{
|
2001-10-17 11:33:43 +00:00
|
|
|
static GType panel_type = 0;
|
1999-08-24 02:52:40 +00:00
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
if (! panel_type)
|
2001-01-15 06:24:24 +00:00
|
|
|
{
|
2001-10-17 11:33:43 +00:00
|
|
|
static const GTypeInfo panel_info =
|
2001-01-15 06:24:24 +00:00
|
|
|
{
|
2001-10-17 11:33:43 +00:00
|
|
|
sizeof (GimpColorPanelClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) gimp_color_panel_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpColorPanel),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_color_panel_init,
|
2001-01-15 06:24:24 +00:00
|
|
|
};
|
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
panel_type = g_type_register_static (GIMP_TYPE_COLOR_BUTTON,
|
|
|
|
"GimpColorPanel",
|
|
|
|
&panel_info, 0);
|
2001-01-15 06:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return panel_type;
|
|
|
|
}
|
1999-08-24 02:52:40 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
static void
|
|
|
|
gimp_color_panel_class_init (GimpColorPanelClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkButtonClass *button_class;
|
|
|
|
GimpColorButtonClass *color_button_class;
|
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
button_class = GTK_BUTTON_CLASS (klass);
|
|
|
|
color_button_class = GIMP_COLOR_BUTTON_CLASS (klass);
|
2001-01-15 06:24:24 +00:00
|
|
|
|
2001-10-17 11:33:43 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-01-15 06:24:24 +00:00
|
|
|
|
|
|
|
object_class->destroy = gimp_color_panel_destroy;
|
|
|
|
button_class->clicked = gimp_color_panel_clicked;
|
2001-01-15 09:27:48 +00:00
|
|
|
color_button_class->color_changed = gimp_color_panel_color_changed;
|
1999-08-24 02:52:40 +00:00
|
|
|
}
|
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
static void
|
|
|
|
gimp_color_panel_init (GimpColorPanel *panel)
|
|
|
|
{
|
|
|
|
panel->color_notebook = NULL;
|
|
|
|
panel->color_notebook_active = FALSE;
|
|
|
|
}
|
1999-08-23 14:19:26 +00:00
|
|
|
|
2000-04-03 15:40:30 +00:00
|
|
|
static void
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_panel_destroy (GtkObject *object)
|
2000-04-03 15:40:30 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorPanel *panel;
|
2000-04-03 15:40:30 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_PANEL (object));
|
|
|
|
|
|
|
|
panel = GIMP_COLOR_PANEL (object);
|
2000-04-03 15:40:30 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
if (panel->color_notebook)
|
2000-04-03 15:40:30 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
color_notebook_hide (panel->color_notebook);
|
|
|
|
color_notebook_free (panel->color_notebook);
|
2001-07-31 16:55:59 +00:00
|
|
|
panel->color_notebook = NULL;
|
2000-04-03 15:40:30 +00:00
|
|
|
}
|
2001-10-17 11:33:43 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2000-04-03 15:40:30 +00:00
|
|
|
}
|
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
GtkWidget *
|
2001-01-21 13:41:07 +00:00
|
|
|
gimp_color_panel_new (const gchar *title,
|
|
|
|
const GimpRGB *color,
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorAreaType type,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorPanel *panel;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
2001-01-15 01:48:53 +00:00
|
|
|
|
2001-08-10 14:41:39 +00:00
|
|
|
panel = g_object_new (GIMP_TYPE_COLOR_PANEL, NULL);
|
2001-01-21 13:41:07 +00:00
|
|
|
|
|
|
|
GIMP_COLOR_BUTTON (panel)->title = g_strdup (title);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type);
|
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
|
|
|
gtk_widget_set_usize (GTK_WIDGET (panel), width, height);
|
2001-01-21 13:41:07 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
return GTK_WIDGET (panel);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
static void
|
|
|
|
gimp_color_panel_color_changed (GimpColorButton *button)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorPanel *panel;
|
|
|
|
GimpRGB color;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
panel = GIMP_COLOR_PANEL (button);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
if (panel->color_notebook_active)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
|
|
|
color_notebook_set_color (panel->color_notebook, &color);
|
|
|
|
}
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
static void
|
|
|
|
gimp_color_panel_clicked (GtkButton *button)
|
|
|
|
{
|
|
|
|
GimpColorPanel *panel;
|
|
|
|
GimpRGB color;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
panel = GIMP_COLOR_PANEL (button);
|
1999-08-22 11:45:31 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
1999-08-22 11:45:31 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
if (! panel->color_notebook)
|
|
|
|
{
|
|
|
|
panel->color_notebook =
|
2001-01-21 13:41:07 +00:00
|
|
|
color_notebook_new (GIMP_COLOR_BUTTON (button)->title,
|
|
|
|
(const GimpRGB *) &color,
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_panel_select_callback,
|
|
|
|
panel,
|
|
|
|
FALSE,
|
|
|
|
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
|
|
|
panel->color_notebook_active = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (! panel->color_notebook_active)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
color_notebook_show (panel->color_notebook);
|
|
|
|
panel->color_notebook_active = TRUE;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2001-01-15 06:24:24 +00:00
|
|
|
color_notebook_set_color (panel->color_notebook, &color);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-21 13:41:07 +00:00
|
|
|
gimp_color_panel_select_callback (ColorNotebook *notebook,
|
|
|
|
const GimpRGB *color,
|
2001-01-15 06:24:24 +00:00
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-15 06:24:24 +00:00
|
|
|
GimpColorPanel *panel;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
panel = GIMP_COLOR_PANEL (data);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-15 06:24:24 +00:00
|
|
|
if (panel->color_notebook)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1999-08-22 11:45:31 +00:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
|
|
|
break;
|
|
|
|
case COLOR_NOTEBOOK_OK:
|
2001-01-15 06:24:24 +00:00
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
1999-08-22 11:45:31 +00:00
|
|
|
/* Fallthrough */
|
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
2001-01-15 06:24:24 +00:00
|
|
|
color_notebook_hide (panel->color_notebook);
|
|
|
|
panel->color_notebook_active = FALSE;
|
1999-08-22 11:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|