1999-11-01 05:00:32 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2001-11-16 22:13:10 +08:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
1999-11-01 05:00:32 +08:00
|
|
|
*
|
2000-02-26 11:41:06 +08:00
|
|
|
* gimpcolorbutton.c
|
2001-01-11 06:49:45 +08:00
|
|
|
* Copyright (C) 1999-2001 Sven Neumann
|
1999-11-01 05:00:32 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-11-01 05:00:32 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-11-01 05:00:32 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1999-11-20 09:01:25 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
#include "gimpcolorarea.h"
|
1999-11-01 05:00:32 +08:00
|
|
|
#include "gimpcolorbutton.h"
|
|
|
|
|
2001-01-25 09:20:05 +08:00
|
|
|
#include "libgimp/gimppalette_pdb.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
|
|
|
#include "libgimp/libgimp-intl.h"
|
2000-01-27 09:54:52 +08:00
|
|
|
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
#define TODOUBLE(i) (i / 65535.0)
|
|
|
|
#define TOUINT16(d) ((guint16) (d * 65535 + 0.5))
|
|
|
|
|
|
|
|
|
2001-11-16 22:13:10 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GIMP_COLOR_BUTTON_COLOR_FG,
|
|
|
|
GIMP_COLOR_BUTTON_COLOR_BG,
|
|
|
|
GIMP_COLOR_BUTTON_COLOR_BLACK,
|
|
|
|
GIMP_COLOR_BUTTON_COLOR_WHITE,
|
|
|
|
} GimpColorButtonColor;
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLOR_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static void gimp_color_button_class_init (GimpColorButtonClass *klass);
|
2003-01-05 23:41:23 +08:00
|
|
|
static void gimp_color_button_init (GimpColorButton *button);
|
|
|
|
static void gimp_color_button_destroy (GtkObject *object);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static gboolean gimp_color_button_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent);
|
|
|
|
static void gimp_color_button_state_changed (GtkWidget *widget,
|
|
|
|
GtkStateType prev_state);
|
|
|
|
static void gimp_color_button_clicked (GtkButton *button);
|
2001-01-15 04:25:46 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static void gimp_color_button_dialog_ok (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2001-01-15 04:25:46 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static void gimp_color_button_use_color (gpointer callback_data,
|
|
|
|
guint callback_action,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static gchar * gimp_color_button_menu_translate (const gchar *path,
|
|
|
|
gpointer func_data);
|
2001-01-15 04:25:46 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static void gimp_color_button_color_changed (GtkObject *object,
|
|
|
|
gpointer data);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
static GtkItemFactoryEntry menu_items[] =
|
|
|
|
{
|
2001-11-16 22:13:10 +08:00
|
|
|
{ N_("/Foreground Color"), NULL,
|
|
|
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_FG, NULL },
|
|
|
|
{ N_("/Background Color"), NULL,
|
|
|
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_BG, NULL },
|
2002-12-04 06:16:56 +08:00
|
|
|
{ "/fg-bg-separator", NULL, NULL, 0, "<Separator>"},
|
2001-11-16 22:13:10 +08:00
|
|
|
{ N_("/Black"), NULL,
|
|
|
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_BLACK, NULL },
|
|
|
|
{ N_("/White"), NULL,
|
|
|
|
gimp_color_button_use_color, GIMP_COLOR_BUTTON_COLOR_WHITE, NULL },
|
1999-11-16 02:37:03 +08:00
|
|
|
};
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 };
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static GimpButtonClass * parent_class = NULL;
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
GType
|
|
|
|
gimp_color_button_get_type (void)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
static GType button_type = 0;
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
if (!button_type)
|
2001-07-31 01:17:36 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
static const GTypeInfo button_info =
|
2001-09-21 18:47:19 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpColorButtonClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_color_button_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpColorButton),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_color_button_init,
|
|
|
|
};
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button_type = g_type_register_static (GIMP_TYPE_BUTTON,
|
2001-09-21 18:47:19 +08:00
|
|
|
"GimpColorButton",
|
2003-01-05 23:41:23 +08:00
|
|
|
&button_info, 0);
|
2001-07-31 01:17:36 +08:00
|
|
|
}
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
return button_type;
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-15 14:24:24 +08:00
|
|
|
gimp_color_button_class_init (GimpColorButtonClass *klass)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
1999-11-17 07:19:04 +08:00
|
|
|
GtkWidgetClass *widget_class;
|
2000-11-18 08:25:42 +08:00
|
|
|
GtkButtonClass *button_class;
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
button_class = GTK_BUTTON_CLASS (klass);
|
2001-01-15 14:24:24 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
|
|
|
gimp_color_button_signals[COLOR_CHANGED] =
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_signal_new ("color_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorButtonClass, color_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
object_class->destroy = gimp_color_button_destroy;
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
widget_class->button_press_event = gimp_color_button_button_press;
|
|
|
|
widget_class->state_changed = gimp_color_button_state_changed;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
button_class->clicked = gimp_color_button_clicked;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
klass->color_changed = NULL;
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_init (GimpColorButton *button)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2001-01-15 14:24:24 +08:00
|
|
|
GimpRGB color;
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button->title = NULL;
|
|
|
|
button->dialog = NULL;
|
2001-01-15 14:24:24 +08:00
|
|
|
|
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
|
2003-01-05 23:41:23 +08:00
|
|
|
button->color_area = gimp_color_area_new (&color, FALSE, GDK_BUTTON2_MASK);
|
|
|
|
g_signal_connect (G_OBJECT (button->color_area), "color_changed",
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (gimp_color_button_color_changed),
|
2003-01-05 23:41:23 +08:00
|
|
|
button);
|
2001-01-15 14:24:24 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), button->color_area);
|
|
|
|
gtk_widget_show (button->color_area);
|
2001-01-15 14:24:24 +08:00
|
|
|
|
|
|
|
/* right-click opens a popup */
|
2003-01-05 23:41:23 +08:00
|
|
|
button->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
|
|
|
gtk_item_factory_set_translate_func (button->item_factory,
|
2001-01-15 14:24:24 +08:00
|
|
|
gimp_color_button_menu_translate,
|
|
|
|
NULL, NULL);
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_item_factory_create_items (button->item_factory,
|
|
|
|
G_N_ELEMENTS (menu_items), menu_items, button);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static void
|
|
|
|
gimp_color_button_destroy (GtkObject *object)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *button;
|
2001-11-28 07:26:25 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button = GIMP_COLOR_BUTTON (object);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
if (button->title)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
g_free (button->title);
|
|
|
|
button->title = NULL;
|
2001-09-21 18:47:19 +08:00
|
|
|
}
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
if (button->dialog)
|
2001-09-21 18:47:19 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_destroy (button->dialog);
|
|
|
|
button->dialog = NULL;
|
2001-09-21 18:47:19 +08:00
|
|
|
}
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
if (button->color_area)
|
2001-09-21 18:47:19 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_destroy (button->color_area);
|
|
|
|
button->color_area = NULL;
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_button_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *button;
|
2001-11-28 07:26:25 +08:00
|
|
|
gint x;
|
|
|
|
gint y;
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button = GIMP_COLOR_BUTTON (widget);
|
2001-11-28 07:26:25 +08:00
|
|
|
|
|
|
|
if (bevent->button == 3)
|
|
|
|
{
|
|
|
|
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
|
|
|
|
x += widget->allocation.x;
|
|
|
|
y += widget->allocation.y;
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_item_factory_popup (button->item_factory,
|
2001-11-28 07:26:25 +08:00
|
|
|
x + bevent->x, y + bevent->y,
|
|
|
|
bevent->button, bevent->time);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
|
|
|
|
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
static void
|
|
|
|
gimp_color_button_state_changed (GtkWidget *widget,
|
2001-11-28 07:26:25 +08:00
|
|
|
GtkStateType prev_state)
|
2001-09-21 18:47:19 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget));
|
|
|
|
|
2001-11-28 07:26:25 +08:00
|
|
|
if (! GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
|
2001-09-21 18:47:19 +08:00
|
|
|
gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->state_changed)
|
2001-11-28 07:26:25 +08:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->state_changed (widget, prev_state);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
2000-02-18 07:48:13 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_button_new:
|
|
|
|
* @title: String that will be used as title for the color_selector.
|
|
|
|
* @width: Width of the colorpreview in pixels.
|
|
|
|
* @height: Height of the colorpreview in pixels.
|
|
|
|
* @color: A pointer to a #GimpRGB color.
|
2001-01-15 14:24:24 +08:00
|
|
|
* @type:
|
2001-01-11 06:49:45 +08:00
|
|
|
*
|
|
|
|
* Creates a new #GimpColorButton widget.
|
|
|
|
*
|
|
|
|
* This returns a button with a preview showing the color.
|
|
|
|
* When the button is clicked a GtkColorSelectionDialog is opened.
|
|
|
|
* If the user changes the color the new color is written into the
|
|
|
|
* array that was used to pass the initial color and the "color_changed"
|
|
|
|
* signal is emitted.
|
|
|
|
*
|
|
|
|
* Returns: Pointer to the new #GimpColorButton widget.
|
|
|
|
**/
|
|
|
|
GtkWidget *
|
2001-01-15 14:24:24 +08:00
|
|
|
gimp_color_button_new (const gchar *title,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
const GimpRGB *color,
|
|
|
|
GimpColorAreaType type)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *button;
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button = g_object_new (GIMP_TYPE_COLOR_BUTTON, NULL);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button->title = g_strdup (title);
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (button->color_area), width, height);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
|
|
|
|
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
|
2001-01-15 17:27:48 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
return GTK_WIDGET (button);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
2000-02-18 07:48:13 +08:00
|
|
|
/**
|
2001-01-11 06:49:45 +08:00
|
|
|
* gimp_color_button_set_color:
|
2003-01-05 23:41:23 +08:00
|
|
|
* @button: Pointer to a #GimpColorButton.
|
2001-01-11 06:49:45 +08:00
|
|
|
* @color: Pointer to the new #GimpRGB color.
|
2000-02-18 07:48:13 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Sets the @button to the given @color.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2001-01-11 06:49:45 +08:00
|
|
|
void
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_set_color (GimpColorButton *button,
|
2001-01-15 14:24:24 +08:00
|
|
|
const GimpRGB *color)
|
2000-02-18 07:48:13 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
2001-01-11 06:49:45 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (button->color_area), color);
|
2000-02-18 07:48:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-01-11 06:49:45 +08:00
|
|
|
* gimp_color_button_get_color:
|
2003-01-05 23:41:23 +08:00
|
|
|
* @button: Pointer to a #GimpColorButton.
|
|
|
|
* @color: Pointer to a #GimpRGB struct used to return the color.
|
2000-02-18 07:48:13 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Retrieves the currently set color from the @button.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2001-01-11 06:49:45 +08:00
|
|
|
void
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_get_color (GimpColorButton *button,
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB *color)
|
2000-02-18 07:48:13 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
2001-01-15 14:24:24 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_area_get_color (GIMP_COLOR_AREA (button->color_area), color);
|
2000-02-18 07:48:13 +08:00
|
|
|
}
|
|
|
|
|
2000-02-03 10:35:08 +08:00
|
|
|
/**
|
2001-01-11 06:49:45 +08:00
|
|
|
* gimp_color_button_has_alpha:
|
2003-01-05 23:41:23 +08:00
|
|
|
* @button: Pointer to a #GimpColorButton.
|
2001-05-05 04:39:29 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Checks whether the @buttons shows transparency information.
|
2001-05-05 04:39:29 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Returns: %TRUE if the @button shows transparency information, %FALSE
|
|
|
|
* otherwise.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2001-01-11 06:49:45 +08:00
|
|
|
gboolean
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_has_alpha (GimpColorButton *button)
|
1999-11-16 02:37:03 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), FALSE);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
return gimp_color_area_has_alpha (GIMP_COLOR_AREA (button->color_area));
|
1999-11-16 02:37:03 +08:00
|
|
|
}
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_button_set_type:
|
|
|
|
* @button: Pointer to a #GimpColorButton.
|
|
|
|
* @type: the new #GimpColorAreaType
|
|
|
|
*
|
|
|
|
* Sets the @button to the given @type. See also gimp_color_area_set_type().
|
|
|
|
**/
|
2001-01-15 14:24:24 +08:00
|
|
|
void
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_set_type (GimpColorButton *button,
|
2001-01-15 14:24:24 +08:00
|
|
|
GimpColorAreaType type)
|
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
2001-01-15 14:24:24 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_area_set_type (GIMP_COLOR_AREA (button->color_area), type);
|
2001-01-15 14:24:24 +08:00
|
|
|
}
|
|
|
|
|
1999-11-01 05:00:32 +08:00
|
|
|
static void
|
|
|
|
gimp_color_button_clicked (GtkButton *button)
|
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *color_button;
|
|
|
|
GtkWidget *dialog;
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB color;
|
2001-12-29 21:26:29 +08:00
|
|
|
GdkColor gdk_color;
|
|
|
|
guint16 alpha;
|
1999-11-01 05:00:32 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
color_button = GIMP_COLOR_BUTTON (button);
|
2001-11-28 07:26:25 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_get_color (color_button, &color);
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gdk_color.red = TOUINT16 (color.r);
|
|
|
|
gdk_color.green = TOUINT16 (color.g);
|
|
|
|
gdk_color.blue = TOUINT16 (color.b);
|
|
|
|
alpha = TOUINT16 (color.a);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
dialog = color_button->dialog;
|
|
|
|
|
|
|
|
if (!dialog)
|
1999-11-01 05:00:32 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
dialog = gtk_color_selection_dialog_new (color_button->title);
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), TRUE);
|
2001-01-11 06:49:45 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_destroy (GTK_COLOR_SELECTION_DIALOG (dialog)->help_button);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 2);
|
2000-03-12 09:34:45 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
g_signal_connect (G_OBJECT (dialog), "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&color_button->dialog);
|
|
|
|
g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (dialog)->ok_button),
|
2001-12-29 21:26:29 +08:00
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (gimp_color_button_dialog_ok),
|
2003-01-05 23:41:23 +08:00
|
|
|
color_button);
|
|
|
|
g_signal_connect (G_OBJECT (GTK_COLOR_SELECTION_DIALOG (dialog)->cancel_button),
|
2001-12-29 21:26:29 +08:00
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (gimp_color_button_dialog_cancel),
|
2003-01-05 23:41:23 +08:00
|
|
|
color_button);
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
|
|
|
|
|
|
|
color_button->dialog = dialog;
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), &gdk_color);
|
|
|
|
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel), alpha);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_show (dialog);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_button_dialog_ok (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *button;
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB color;
|
2001-12-29 21:26:29 +08:00
|
|
|
GdkColor gdk_color;
|
|
|
|
guint16 alpha;
|
2000-11-18 08:25:42 +08:00
|
|
|
|
1999-11-01 05:00:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
button = GIMP_COLOR_BUTTON (data);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
|
|
|
|
alpha = gtk_color_selection_get_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel));
|
2001-12-29 21:26:29 +08:00
|
|
|
|
|
|
|
color.r = TODOUBLE (gdk_color.red);
|
|
|
|
color.g = TODOUBLE (gdk_color.green);
|
|
|
|
color.b = TODOUBLE (gdk_color.blue);
|
|
|
|
color.a = TODOUBLE (alpha);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gimp_color_button_set_color (button, &color);
|
1999-11-01 05:00:32 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_widget_hide (button->dialog);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_button_dialog_cancel (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_BUTTON (data));
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
gtk_widget_hide (GIMP_COLOR_BUTTON (data)->dialog);
|
1999-11-01 05:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-16 02:37:03 +08:00
|
|
|
static void
|
2001-11-16 22:13:10 +08:00
|
|
|
gimp_color_button_use_color (gpointer callback_data,
|
|
|
|
guint callback_action,
|
|
|
|
GtkWidget *widget)
|
1999-11-16 02:37:03 +08:00
|
|
|
{
|
2001-11-16 22:13:10 +08:00
|
|
|
GimpRGB color;
|
|
|
|
GimpColorButtonColor type;
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2001-11-16 22:13:10 +08:00
|
|
|
type = (GimpColorButtonColor) callback_action;
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2001-11-16 22:13:10 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_BUTTON_COLOR_FG:
|
|
|
|
gimp_palette_get_foreground (&color);
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_BUTTON_COLOR_BG:
|
|
|
|
gimp_palette_get_background (&color);
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_BUTTON_COLOR_BLACK:
|
|
|
|
gimp_rgb_set (&color, 0.0, 0.0, 0.0);
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_BUTTON_COLOR_WHITE:
|
|
|
|
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
|
|
|
|
break;
|
|
|
|
}
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (callback_data), &color);
|
1999-11-16 02:37:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-11 06:49:45 +08:00
|
|
|
gimp_color_button_color_changed (GtkObject *object,
|
|
|
|
gpointer data)
|
1999-11-16 02:37:03 +08:00
|
|
|
{
|
2003-01-05 23:41:23 +08:00
|
|
|
GimpColorButton *button = GIMP_COLOR_BUTTON (data);
|
1999-11-16 02:37:03 +08:00
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
if (button->dialog)
|
2000-02-18 07:48:13 +08:00
|
|
|
{
|
2001-01-11 06:49:45 +08:00
|
|
|
GimpRGB color;
|
2001-12-29 21:26:29 +08:00
|
|
|
GdkColor gdk_color;
|
|
|
|
guint16 alpha;
|
2001-01-11 06:49:45 +08:00
|
|
|
|
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gdk_color.red = TOUINT16 (color.r);
|
|
|
|
gdk_color.green = TOUINT16 (color.g);
|
|
|
|
gdk_color.blue = TOUINT16 (color.b);
|
|
|
|
alpha = TOUINT16 (color.a);
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), &gdk_color);
|
|
|
|
gtk_color_selection_set_current_alpha (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (button->dialog)->colorsel), alpha);
|
2000-02-18 07:48:13 +08:00
|
|
|
}
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
g_signal_emit (G_OBJECT (button),
|
2001-07-31 19:33:13 +08:00
|
|
|
gimp_color_button_signals[COLOR_CHANGED], 0);
|
1999-11-16 02:37:03 +08:00
|
|
|
}
|
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_color_button_menu_translate (const gchar *path,
|
|
|
|
gpointer func_data)
|
1999-11-16 02:37:03 +08:00
|
|
|
{
|
2001-01-11 06:49:45 +08:00
|
|
|
return (gettext (path));
|
1999-11-16 02:37:03 +08:00
|
|
|
}
|