mirror of https://github.com/GNOME/gimp.git
app/dialogs/Makefile.am removed...
2004-09-23 Michael Natterer <mitch@gimp.org> * app/dialogs/Makefile.am * app/dialogs/color-dialog.[ch]: removed... * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpcolordialog.[ch]: ...and added as widget. * app/core/gimpmarshal.list: new marshaller VOID__BOXED_ENUM. * app/widgets/widgets-enums.[ch]: new enum GimpColorDialogState. * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcolorpanel.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimptoolbox-color-area.c * app/actions/gradient-editor-commands.c * app/actions/view-commands.c: ported to GimpColorDialog. Removes a whole bunch of ugly widgets/ -> dialogs/ dependencies.
This commit is contained in:
parent
58b08f867a
commit
ee5354e4b7
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2004-09-23 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/dialogs/Makefile.am
|
||||
* app/dialogs/color-dialog.[ch]: removed...
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpcolordialog.[ch]: ...and added as widget.
|
||||
|
||||
* app/core/gimpmarshal.list: new marshaller VOID__BOXED_ENUM.
|
||||
|
||||
* app/widgets/widgets-enums.[ch]: new enum GimpColorDialogState.
|
||||
|
||||
* app/widgets/gimpcolormapeditor.[ch]
|
||||
* app/widgets/gimpcolorpanel.[ch]
|
||||
* app/widgets/gimpgradienteditor.[ch]
|
||||
* app/widgets/gimppaletteeditor.[ch]
|
||||
* app/widgets/gimptoolbox-color-area.c
|
||||
* app/actions/gradient-editor-commands.c
|
||||
* app/actions/view-commands.c: ported to GimpColorDialog. Removes
|
||||
a whole bunch of ugly widgets/ -> dialogs/ dependencies.
|
||||
|
||||
2004-09-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/script-fu-interface.c: put the text view into
|
||||
|
@ -48,7 +70,7 @@
|
|||
* tools/pdbgen/pdb/gradients.pdb
|
||||
* tools/pdbgen/pdb/palettes.pdb
|
||||
* tools/pdbgen/pdb/patterns.pdb: removed the foos_set_foo()
|
||||
procedures and marked the foos_set_foo() ones as deprecated. For
|
||||
procedures and marked the foos_get_foo() ones as deprecated. For
|
||||
brushes, patterns and palettes, added foos_get_foo_info()
|
||||
procedures which work like foos_get_foo_data() but return just the
|
||||
properties, not the actual data. Allow NULL or "" to be passed
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
#include "core/gimpdatafactory.h"
|
||||
#include "core/gimpgradient.h"
|
||||
|
||||
#include "widgets/gimpcolordialog.h"
|
||||
#include "widgets/gimpgradienteditor.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gradient-editor-commands.h"
|
||||
|
||||
|
@ -43,14 +43,14 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gradient_editor_left_color_changed (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data);
|
||||
static void gradient_editor_right_color_changed (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data);
|
||||
static void gradient_editor_left_color_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpGradientEditor *editor);
|
||||
static void gradient_editor_right_color_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpGradientEditor *editor);
|
||||
|
||||
static GimpGradientSegment *
|
||||
gradient_editor_save_selection (GimpGradientEditor *editor);
|
||||
|
@ -80,18 +80,27 @@ gradient_editor_left_color_cmd_callback (GtkAction *action,
|
|||
editor->left_saved_segments = gradient_editor_save_selection (editor);
|
||||
|
||||
editor->color_dialog =
|
||||
color_dialog_new (GIMP_VIEWABLE (gradient),
|
||||
_("Left Endpoint Color"),
|
||||
GIMP_STOCK_GRADIENT,
|
||||
_("Gradient Segment's Left Endpoint Color"),
|
||||
GTK_WIDGET (editor),
|
||||
global_dialog_factory,
|
||||
"gimp-gradient-editor-color-dialog",
|
||||
&editor->control_sel_l->left_color,
|
||||
gradient_editor_left_color_changed, editor,
|
||||
editor->instant_update, TRUE);
|
||||
gimp_color_dialog_new (GIMP_VIEWABLE (gradient),
|
||||
_("Left Endpoint Color"),
|
||||
GIMP_STOCK_GRADIENT,
|
||||
_("Gradient Segment's Left Endpoint Color"),
|
||||
GTK_WIDGET (editor),
|
||||
global_dialog_factory,
|
||||
"gimp-gradient-editor-color-dialog",
|
||||
&editor->control_sel_l->left_color,
|
||||
editor->instant_update, TRUE);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&editor->color_dialog);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "update",
|
||||
G_CALLBACK (gradient_editor_left_color_update),
|
||||
editor);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (editor->color_dialog));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,18 +182,27 @@ gradient_editor_right_color_cmd_callback (GtkAction *action,
|
|||
editor->right_saved_segments = gradient_editor_save_selection (editor);
|
||||
|
||||
editor->color_dialog =
|
||||
color_dialog_new (GIMP_VIEWABLE (gradient),
|
||||
_("Right Endpoint Color"),
|
||||
GIMP_STOCK_GRADIENT,
|
||||
_("Gradient Segment's Right Endpoint Color"),
|
||||
GTK_WIDGET (editor),
|
||||
global_dialog_factory,
|
||||
"gimp-gradient-editor-color-dialog",
|
||||
&editor->control_sel_l->right_color,
|
||||
gradient_editor_right_color_changed, editor,
|
||||
editor->instant_update, TRUE);
|
||||
gimp_color_dialog_new (GIMP_VIEWABLE (gradient),
|
||||
_("Right Endpoint Color"),
|
||||
GIMP_STOCK_GRADIENT,
|
||||
_("Gradient Segment's Right Endpoint Color"),
|
||||
GTK_WIDGET (editor),
|
||||
global_dialog_factory,
|
||||
"gimp-gradient-editor-color-dialog",
|
||||
&editor->control_sel_l->right_color,
|
||||
editor->instant_update, TRUE);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&editor->color_dialog);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "update",
|
||||
G_CALLBACK (gradient_editor_right_color_update),
|
||||
editor);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (editor->color_dialog));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -559,19 +577,16 @@ gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
|
|||
/* private functions */
|
||||
|
||||
static void
|
||||
gradient_editor_left_color_changed (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
gradient_editor_left_color_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpGradientEditor *editor)
|
||||
{
|
||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||
GimpGradient *gradient;
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
gimp_gradient_segment_range_blend (gradient,
|
||||
editor->control_sel_l,
|
||||
editor->control_sel_r,
|
||||
|
@ -580,7 +595,7 @@ gradient_editor_left_color_changed (ColorDialog *cnb,
|
|||
TRUE, TRUE);
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_OK:
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
gimp_gradient_segment_range_blend (gradient,
|
||||
editor->control_sel_l,
|
||||
editor->control_sel_r,
|
||||
|
@ -588,16 +603,16 @@ gradient_editor_left_color_changed (ColorDialog *cnb,
|
|||
&editor->control_sel_r->right_color,
|
||||
TRUE, TRUE);
|
||||
gimp_gradient_segments_free (editor->left_saved_segments);
|
||||
color_dialog_free (cnb);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gradient_editor_replace_selection (editor, editor->left_saved_segments);
|
||||
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||
color_dialog_free (cnb);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
break;
|
||||
|
@ -605,19 +620,16 @@ gradient_editor_left_color_changed (ColorDialog *cnb,
|
|||
}
|
||||
|
||||
static void
|
||||
gradient_editor_right_color_changed (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
gradient_editor_right_color_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpGradientEditor *editor)
|
||||
{
|
||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||
GimpGradient *gradient;
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
gimp_gradient_segment_range_blend (gradient,
|
||||
editor->control_sel_l,
|
||||
editor->control_sel_r,
|
||||
|
@ -626,7 +638,7 @@ gradient_editor_right_color_changed (ColorDialog *cnb,
|
|||
TRUE, TRUE);
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_OK:
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
gimp_gradient_segment_range_blend (gradient,
|
||||
editor->control_sel_l,
|
||||
editor->control_sel_r,
|
||||
|
@ -634,16 +646,16 @@ gradient_editor_right_color_changed (ColorDialog *cnb,
|
|||
color,
|
||||
TRUE, TRUE);
|
||||
gimp_gradient_segments_free (editor->right_saved_segments);
|
||||
color_dialog_free (cnb);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gradient_editor_replace_selection (editor, editor->right_saved_segments);
|
||||
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient));
|
||||
color_dialog_free (cnb);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
break;
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
#include "display/gimpdisplayshell-scale.h"
|
||||
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimpcolordialog.h"
|
||||
#include "widgets/gimpdock.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
|
||||
#include "dialogs/color-dialog.h"
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "dialogs/info-dialog.h"
|
||||
#include "dialogs/info-window.h"
|
||||
|
@ -65,6 +65,19 @@
|
|||
gimp_context_get_display (gimp_get_user_context ((gdisp)->gimage->gimp)))
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void view_padding_color_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpDisplayShell *shell);
|
||||
static void view_change_screen_confirm_callback (GtkWidget *query_box,
|
||||
gint value,
|
||||
gpointer data);
|
||||
static void view_change_screen_destroy_callback (GtkWidget *query_box,
|
||||
GtkWidget *shell);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
|
@ -473,41 +486,6 @@ view_snap_to_grid_cmd_callback (GtkAction *action,
|
|||
gimp_display_shell_set_snap_to_grid (shell, active);
|
||||
}
|
||||
|
||||
static void
|
||||
view_padding_color_callback (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
||||
GimpDisplayOptions *options;
|
||||
gboolean fullscreen;
|
||||
|
||||
fullscreen = gimp_display_shell_get_fullscreen (shell);
|
||||
|
||||
if (fullscreen)
|
||||
options = shell->fullscreen_options;
|
||||
else
|
||||
options = shell->options;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_OK:
|
||||
options->padding_mode_set = TRUE;
|
||||
|
||||
gimp_display_shell_set_padding (shell, GIMP_CANVAS_PADDING_MODE_CUSTOM,
|
||||
color);
|
||||
/* fallthru */
|
||||
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
view_padding_color_cmd_callback (GtkAction *action,
|
||||
gint value,
|
||||
|
@ -543,29 +521,32 @@ view_padding_color_cmd_callback (GtkAction *action,
|
|||
|
||||
case GIMP_CANVAS_PADDING_MODE_CUSTOM:
|
||||
{
|
||||
ColorDialog *color_dialog;
|
||||
GtkWidget *color_dialog;
|
||||
|
||||
color_dialog = g_object_get_data (G_OBJECT (shell),
|
||||
"padding-color-dialog");
|
||||
"padding-color-dialog");
|
||||
|
||||
if (! color_dialog)
|
||||
{
|
||||
color_dialog = color_dialog_new (GIMP_VIEWABLE (gdisp->gimage),
|
||||
_("Set Canvas Padding Color"),
|
||||
GTK_STOCK_SELECT_COLOR,
|
||||
NULL,
|
||||
gdisp->shell,
|
||||
NULL, NULL,
|
||||
&options->padding_color,
|
||||
view_padding_color_callback,
|
||||
shell,
|
||||
FALSE, FALSE);
|
||||
color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (gdisp->gimage),
|
||||
_("Set Canvas Padding Color"),
|
||||
GTK_STOCK_SELECT_COLOR,
|
||||
_("Set Custom Canvas Padding Color"),
|
||||
gdisp->shell,
|
||||
NULL, NULL,
|
||||
&options->padding_color,
|
||||
FALSE, FALSE);
|
||||
|
||||
g_signal_connect (color_dialog, "update",
|
||||
G_CALLBACK (view_padding_color_dialog_update),
|
||||
gdisp->shell);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (shell), "padding-color-dialog",
|
||||
color_dialog,
|
||||
(GDestroyNotify) color_dialog_free);
|
||||
(GDestroyNotify) gtk_widget_destroy);
|
||||
}
|
||||
|
||||
color_dialog_show (color_dialog);
|
||||
gtk_window_present (GTK_WINDOW (color_dialog));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -632,27 +613,6 @@ view_fullscreen_cmd_callback (GtkAction *action,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
view_change_screen_confirm_callback (GtkWidget *query_box,
|
||||
gint value,
|
||||
gpointer data)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
|
||||
screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)),
|
||||
value);
|
||||
|
||||
if (screen)
|
||||
gtk_window_set_screen (GTK_WINDOW (data), screen);
|
||||
}
|
||||
|
||||
static void
|
||||
view_change_screen_destroy_callback (GtkWidget *query_box,
|
||||
GtkWidget *shell)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (shell), "gimp-change-screen-dialog", NULL);
|
||||
}
|
||||
|
||||
void
|
||||
view_change_screen_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -697,3 +657,61 @@ view_change_screen_cmd_callback (GtkAction *action,
|
|||
|
||||
gtk_widget_show (qbox);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
view_padding_color_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpDisplayOptions *options;
|
||||
gboolean fullscreen;
|
||||
|
||||
fullscreen = gimp_display_shell_get_fullscreen (shell);
|
||||
|
||||
if (fullscreen)
|
||||
options = shell->fullscreen_options;
|
||||
else
|
||||
options = shell->options;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
options->padding_mode_set = TRUE;
|
||||
|
||||
gimp_display_shell_set_padding (shell, GIMP_CANVAS_PADDING_MODE_CUSTOM,
|
||||
color);
|
||||
/* fallthru */
|
||||
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
view_change_screen_confirm_callback (GtkWidget *query_box,
|
||||
gint value,
|
||||
gpointer data)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
|
||||
screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)),
|
||||
value);
|
||||
|
||||
if (screen)
|
||||
gtk_window_set_screen (GTK_WINDOW (data), screen);
|
||||
}
|
||||
|
||||
static void
|
||||
view_change_screen_destroy_callback (GtkWidget *query_box,
|
||||
GtkWidget *shell)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (shell), "gimp-change-screen-dialog", NULL);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ BOOLEAN: OBJECT, POINTER, STRING
|
|||
|
||||
VOID: BOOLEAN, INT, INT, INT, INT
|
||||
VOID: BOXED
|
||||
VOID: BOXED, ENUM
|
||||
VOID: DOUBLE
|
||||
VOID: DOUBLE, DOUBLE
|
||||
VOID: ENUM
|
||||
|
|
|
@ -12,8 +12,6 @@ libappdialogs_a_SOURCES = \
|
|||
about-dialog.c \
|
||||
about-dialog.h \
|
||||
authors.h \
|
||||
color-dialog.c \
|
||||
color-dialog.h \
|
||||
convert-dialog.c \
|
||||
convert-dialog.h \
|
||||
file-open-dialog.c \
|
||||
|
|
|
@ -1,462 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* color_dialog module (C) 1998 Austin Donnelly <austin@greenend.org.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 <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "dialogs-types.h"
|
||||
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
||||
#include "gui/color-history.h"
|
||||
|
||||
#include "color-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define RESPONSE_RESET 1
|
||||
#define COLOR_AREA_SIZE 20
|
||||
|
||||
|
||||
struct _ColorDialog
|
||||
{
|
||||
GtkWidget *shell;
|
||||
GtkWidget *selection;
|
||||
|
||||
GtkWidget *history[COLOR_HISTORY_SIZE];
|
||||
|
||||
ColorDialogCallback callback;
|
||||
gpointer client_data;
|
||||
|
||||
gboolean wants_updates;
|
||||
};
|
||||
|
||||
|
||||
static void color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data);
|
||||
|
||||
static void color_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDialog *cnp);
|
||||
|
||||
static void color_dialog_color_changed (GimpColorSelection *selection,
|
||||
ColorDialog *cnp);
|
||||
|
||||
static void color_history_color_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp);
|
||||
static void color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void color_history_add_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp);
|
||||
|
||||
|
||||
static GList *color_dialogs = NULL;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
ColorDialog *
|
||||
color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
ColorDialogCallback callback,
|
||||
gpointer client_data,
|
||||
gboolean wants_updates,
|
||||
gboolean show_alpha)
|
||||
{
|
||||
ColorDialog *cnp;
|
||||
GtkWidget *table;
|
||||
GtkWidget *button;
|
||||
GtkWidget *arrow;
|
||||
const gchar *role;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
|
||||
g_return_val_if_fail (dialog_factory == NULL ||
|
||||
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
||||
g_return_val_if_fail (dialog_factory == NULL || dialog_identifier != NULL,
|
||||
NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
cnp = g_new0 (ColorDialog, 1);
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
|
||||
role = dialog_identifier ? dialog_identifier : "gimp-color-selector";
|
||||
|
||||
if (desc)
|
||||
{
|
||||
cnp->shell = gimp_viewable_dialog_new (viewable, title, role,
|
||||
stock_id, desc,
|
||||
parent,
|
||||
color_dialog_help_func, NULL,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (cnp->shell), FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
cnp->shell = gimp_dialog_new (title, role,
|
||||
parent, 0,
|
||||
color_dialog_help_func, NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (cnp->shell), "color-dialog", cnp);
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (cnp->shell),
|
||||
GIMP_STOCK_RESET, RESPONSE_RESET,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (cnp->shell), GTK_RESPONSE_OK);
|
||||
|
||||
g_signal_connect (cnp->shell, "response",
|
||||
G_CALLBACK (color_dialog_response),
|
||||
cnp);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (cnp->shell), (gpointer *) &cnp->shell);
|
||||
|
||||
if (dialog_factory)
|
||||
gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier,
|
||||
cnp->shell);
|
||||
|
||||
cnp->selection = gimp_color_selection_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (cnp->selection), 12);
|
||||
gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
show_alpha);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
color);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->selection);
|
||||
gtk_widget_show (cnp->selection);
|
||||
|
||||
g_signal_connect (cnp->selection, "color_changed",
|
||||
G_CALLBACK (color_dialog_color_changed),
|
||||
cnp);
|
||||
|
||||
/* The color history */
|
||||
table = gtk_table_new (2, 1 + COLOR_HISTORY_SIZE / 2, TRUE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
||||
gtk_box_pack_end (GTK_BOX (GIMP_COLOR_SELECTION (cnp->selection)->right_vbox),
|
||||
table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1);
|
||||
gimp_help_set_help_data (button,
|
||||
_("Add the current color to the color history"),
|
||||
NULL);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (color_history_add_clicked),
|
||||
cnp);
|
||||
|
||||
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (button), arrow);
|
||||
gtk_widget_show (arrow);
|
||||
|
||||
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
|
||||
{
|
||||
GimpRGB history_color;
|
||||
gint row, column;
|
||||
|
||||
color_history_get (i, &history_color);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
|
||||
|
||||
column = i % (COLOR_HISTORY_SIZE / 2);
|
||||
row = i / (COLOR_HISTORY_SIZE / 2);
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button,
|
||||
column + 1, column + 2, row, row + 1);
|
||||
|
||||
cnp->history[i] = gimp_color_area_new (&history_color,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GDK_BUTTON2_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (button), cnp->history[i]);
|
||||
gtk_widget_show (cnp->history[i]);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (color_history_color_clicked),
|
||||
cnp);
|
||||
|
||||
g_signal_connect (cnp->history[i], "color_changed",
|
||||
G_CALLBACK (color_history_color_changed),
|
||||
GINT_TO_POINTER (i));
|
||||
}
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
color_dialogs = g_list_prepend (color_dialogs, cnp);
|
||||
|
||||
return cnp;
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_free (ColorDialog *cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
color_dialogs = g_list_remove (color_dialogs, cnp);
|
||||
|
||||
/* may be already destroyed by dialog factory */
|
||||
if (cnp->shell)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (cnp->shell),
|
||||
(gpointer *) &cnp->shell);
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_viewable (ColorDialog *cnb,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
g_return_if_fail (cnb != NULL);
|
||||
|
||||
if (GIMP_IS_VIEWABLE_DIALOG (cnb->shell))
|
||||
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (cnb->shell),
|
||||
viewable);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_title (ColorDialog *cnb,
|
||||
const gchar *title)
|
||||
{
|
||||
g_return_if_fail (cnb != NULL);
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (cnb->shell), title);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_color (ColorDialog *cnp,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
g_signal_handlers_block_by_func (cnp->selection,
|
||||
color_dialog_color_changed,
|
||||
cnp);
|
||||
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (cnp->selection,
|
||||
color_dialog_color_changed,
|
||||
cnp);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_get_color (ColorDialog *cnp,
|
||||
GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_show (ColorDialog *cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (cnp->shell));
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_hide (ColorDialog *cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_hide (cnp->shell);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data)
|
||||
{
|
||||
ColorDialog *cnp;
|
||||
GimpColorNotebook *notebook;
|
||||
|
||||
cnp = g_object_get_data (G_OBJECT (help_data), "color-notebook");
|
||||
|
||||
notebook =
|
||||
GIMP_COLOR_NOTEBOOK (GIMP_COLOR_SELECTION (cnp->selection)->notebook);
|
||||
|
||||
help_id = GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->help_id;
|
||||
|
||||
gimp_standard_help_func (help_id, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
color_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDialog *cnp)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
case RESPONSE_RESET:
|
||||
gimp_color_selection_reset (GIMP_COLOR_SELECTION (cnp->selection));
|
||||
break;
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
color_history_add_clicked (NULL, cnp);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
|
||||
if (cnp->callback)
|
||||
cnp->callback (cnp, &color,
|
||||
COLOR_DIALOG_OK,
|
||||
cnp->client_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
|
||||
if (cnp->callback)
|
||||
cnp->callback (cnp, &color,
|
||||
COLOR_DIALOG_CANCEL,
|
||||
cnp->client_data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_dialog_color_changed (GimpColorSelection *selection,
|
||||
ColorDialog *cnp)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_selection_get_color (selection, &color);
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
cnp->callback (cnp,
|
||||
&color,
|
||||
COLOR_DIALOG_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
/* color history callbacks */
|
||||
|
||||
static void
|
||||
color_history_color_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp)
|
||||
{
|
||||
GimpColorArea *color_area;
|
||||
GimpRGB color;
|
||||
|
||||
color_area = GIMP_COLOR_AREA (GTK_BIN (widget)->child);
|
||||
|
||||
gimp_color_area_get_color (color_area, &color);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
}
|
||||
|
||||
static void
|
||||
color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB changed_color;
|
||||
gint color_index;
|
||||
GList *list;
|
||||
|
||||
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &changed_color);
|
||||
|
||||
color_index = GPOINTER_TO_INT (data);
|
||||
|
||||
color_history_set (color_index, &changed_color);
|
||||
|
||||
for (list = color_dialogs; list; list = g_list_next (list))
|
||||
{
|
||||
ColorDialog *dialog = list->data;
|
||||
|
||||
if (dialog->history[color_index] != widget)
|
||||
{
|
||||
g_signal_handlers_block_by_func (dialog->history[color_index],
|
||||
color_history_color_changed,
|
||||
data);
|
||||
|
||||
gimp_color_area_set_color
|
||||
(GIMP_COLOR_AREA (dialog->history[color_index]), &changed_color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (dialog->history[color_index],
|
||||
color_history_color_changed,
|
||||
data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_history_add_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp)
|
||||
{
|
||||
GimpRGB color;
|
||||
gint shift_begin;
|
||||
gint i;
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
|
||||
shift_begin = color_history_add (&color);
|
||||
|
||||
for (i = shift_begin; i >= 0; i--)
|
||||
{
|
||||
color_history_get (i, &color);
|
||||
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (cnp->history[i]), &color);
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/* 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_DIALOG_H__
|
||||
#define __COLOR_DIALOG_H__
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COLOR_DIALOG_OK,
|
||||
COLOR_DIALOG_CANCEL,
|
||||
COLOR_DIALOG_UPDATE
|
||||
} ColorDialogState;
|
||||
|
||||
|
||||
typedef void (* ColorDialogCallback) (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer callback_data);
|
||||
|
||||
|
||||
ColorDialog * color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
ColorDialogCallback callback,
|
||||
gpointer callback_data,
|
||||
gboolean wants_update,
|
||||
gboolean show_alpha);
|
||||
|
||||
void color_dialog_free (ColorDialog *cnb);
|
||||
|
||||
void color_dialog_set_viewable (ColorDialog *cnb,
|
||||
GimpViewable *viewable);
|
||||
void color_dialog_set_title (ColorDialog *cnb,
|
||||
const gchar *title);
|
||||
|
||||
void color_dialog_show (ColorDialog *cnb);
|
||||
void color_dialog_hide (ColorDialog *cnb);
|
||||
|
||||
void color_dialog_set_color (ColorDialog *cnb,
|
||||
const GimpRGB *color);
|
||||
void color_dialog_get_color (ColorDialog *cnb,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
#endif /* __COLOR_DIALOG_H__ */
|
|
@ -47,6 +47,8 @@ libappwidgets_a_sources = \
|
|||
gimpclipboard.h \
|
||||
gimpcolorbar.c \
|
||||
gimpcolorbar.h \
|
||||
gimpcolordialog.c \
|
||||
gimpcolordialog.h \
|
||||
gimpcolordisplayeditor.c \
|
||||
gimpcolordisplayeditor.h \
|
||||
gimpcoloreditor.c \
|
||||
|
|
|
@ -25,16 +25,13 @@
|
|||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "dialogs-types.h"
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
||||
#include "gui/color-history.h"
|
||||
|
||||
#include "color-dialog.h"
|
||||
#include "gimpcolordialog.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -43,63 +40,166 @@
|
|||
#define COLOR_AREA_SIZE 20
|
||||
|
||||
|
||||
struct _ColorDialog
|
||||
enum
|
||||
{
|
||||
GtkWidget *shell;
|
||||
GtkWidget *selection;
|
||||
|
||||
GtkWidget *history[COLOR_HISTORY_SIZE];
|
||||
|
||||
ColorDialogCallback callback;
|
||||
gpointer client_data;
|
||||
|
||||
gboolean wants_updates;
|
||||
UPDATE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data);
|
||||
static void gimp_color_dialog_class_init (GimpColorDialogClass *klass);
|
||||
static void gimp_color_dialog_init (GimpColorDialog *dialog);
|
||||
|
||||
static void color_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDialog *cnp);
|
||||
static void gimp_color_dialog_dispose (GObject *object);
|
||||
|
||||
static void color_dialog_color_changed (GimpColorSelection *selection,
|
||||
ColorDialog *cnp);
|
||||
static void gimp_color_dialog_response (GtkDialog *dialog,
|
||||
gint response_id);
|
||||
|
||||
static void color_history_color_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp);
|
||||
static void color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void color_history_add_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp);
|
||||
|
||||
static void gimp_color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data);
|
||||
|
||||
|
||||
static void gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
||||
GimpColorDialog *dialog);
|
||||
|
||||
static void gimp_color_history_color_clicked (GtkWidget *widget,
|
||||
GimpColorDialog *dialog);
|
||||
static void gimp_color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_history_add_clicked (GtkWidget *widget,
|
||||
GimpColorDialog *dialog);
|
||||
|
||||
|
||||
static GimpViewableDialogClass *parent_class = NULL;
|
||||
|
||||
static guint color_dialog_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
static GList *color_dialogs = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_color_dialog_get_type (void)
|
||||
{
|
||||
static GType dialog_type = 0;
|
||||
|
||||
if (! dialog_type)
|
||||
{
|
||||
static const GTypeInfo dialog_info =
|
||||
{
|
||||
sizeof (GimpColorDialogClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_color_dialog_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpColorDialog),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_color_dialog_init,
|
||||
};
|
||||
|
||||
dialog_type = g_type_register_static (GIMP_TYPE_VIEWABLE_DIALOG,
|
||||
"GimpColorDialog",
|
||||
&dialog_info, 0);
|
||||
}
|
||||
|
||||
return dialog_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_dialog_class_init (GimpColorDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->dispose = gimp_color_dialog_dispose;
|
||||
|
||||
dialog_class->response = gimp_color_dialog_response;
|
||||
|
||||
color_dialog_signals[UPDATE] =
|
||||
g_signal_new ("update",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GimpColorDialogClass, update),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__BOXED_ENUM,
|
||||
G_TYPE_NONE, 2,
|
||||
GIMP_TYPE_RGB,
|
||||
GIMP_TYPE_COLOR_DIALOG_STATE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_dialog_init (GimpColorDialog *dialog)
|
||||
{
|
||||
color_dialogs = g_list_prepend (color_dialogs, dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_dialog_dispose (GObject *object)
|
||||
{
|
||||
GimpColorDialog *dialog = GIMP_COLOR_DIALOG (object);
|
||||
|
||||
color_dialogs = g_list_remove (color_dialogs, dialog);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
||||
gint response_id)
|
||||
{
|
||||
GimpColorDialog *dialog = GIMP_COLOR_DIALOG (gtk_dialog);
|
||||
GimpRGB color;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
case RESPONSE_RESET:
|
||||
gimp_color_selection_reset (GIMP_COLOR_SELECTION (dialog->selection));
|
||||
break;
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
gimp_color_history_add_clicked (NULL, dialog);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&color);
|
||||
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&color, GIMP_COLOR_DIALOG_OK);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&color);
|
||||
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&color, GIMP_COLOR_DIALOG_CANCEL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
ColorDialog *
|
||||
color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
ColorDialogCallback callback,
|
||||
gpointer client_data,
|
||||
gboolean wants_updates,
|
||||
gboolean show_alpha)
|
||||
GtkWidget *
|
||||
gimp_color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
gboolean wants_updates,
|
||||
gboolean show_alpha)
|
||||
{
|
||||
ColorDialog *cnp;
|
||||
GtkWidget *table;
|
||||
GtkWidget *button;
|
||||
GtkWidget *arrow;
|
||||
const gchar *role;
|
||||
gint i;
|
||||
GimpColorDialog *dialog;
|
||||
GtkWidget *table;
|
||||
GtkWidget *button;
|
||||
GtkWidget *arrow;
|
||||
const gchar *role;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
|
||||
|
@ -109,72 +209,58 @@ color_dialog_new (GimpViewable *viewable,
|
|||
NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
cnp = g_new0 (ColorDialog, 1);
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
|
||||
role = dialog_identifier ? dialog_identifier : "gimp-color-selector";
|
||||
|
||||
if (desc)
|
||||
{
|
||||
cnp->shell = gimp_viewable_dialog_new (viewable, title, role,
|
||||
stock_id, desc,
|
||||
parent,
|
||||
color_dialog_help_func, NULL,
|
||||
NULL);
|
||||
dialog = g_object_new (GIMP_TYPE_COLOR_DIALOG,
|
||||
"title", title,
|
||||
"role", role,
|
||||
"help-func", gimp_color_dialog_help_func,
|
||||
"stock-id", stock_id,
|
||||
"description", desc,
|
||||
"parent", parent,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (cnp->shell), FALSE);
|
||||
}
|
||||
if (viewable)
|
||||
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (dialog),
|
||||
viewable);
|
||||
else
|
||||
{
|
||||
cnp->shell = gimp_dialog_new (title, role,
|
||||
parent, 0,
|
||||
color_dialog_help_func, NULL,
|
||||
NULL);
|
||||
}
|
||||
gtk_widget_hide (GIMP_VIEWABLE_DIALOG (dialog)->icon->parent->parent);
|
||||
|
||||
g_object_set_data (G_OBJECT (cnp->shell), "color-dialog", cnp);
|
||||
dialog->wants_updates = wants_updates;
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (cnp->shell),
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||
GIMP_STOCK_RESET, RESPONSE_RESET,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (cnp->shell), GTK_RESPONSE_OK);
|
||||
|
||||
g_signal_connect (cnp->shell, "response",
|
||||
G_CALLBACK (color_dialog_response),
|
||||
cnp);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (cnp->shell), (gpointer *) &cnp->shell);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
if (dialog_factory)
|
||||
gimp_dialog_factory_add_foreign (dialog_factory, dialog_identifier,
|
||||
cnp->shell);
|
||||
GTK_WIDGET (dialog));
|
||||
|
||||
cnp->selection = gimp_color_selection_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (cnp->selection), 12);
|
||||
gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
dialog->selection = gimp_color_selection_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog->selection), 12);
|
||||
gimp_color_selection_set_show_alpha (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
show_alpha);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->selection);
|
||||
gtk_widget_show (cnp->selection);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
|
||||
dialog->selection);
|
||||
gtk_widget_show (dialog->selection);
|
||||
|
||||
g_signal_connect (cnp->selection, "color_changed",
|
||||
G_CALLBACK (color_dialog_color_changed),
|
||||
cnp);
|
||||
g_signal_connect (dialog->selection, "color_changed",
|
||||
G_CALLBACK (gimp_color_dialog_color_changed),
|
||||
dialog);
|
||||
|
||||
/* The color history */
|
||||
table = gtk_table_new (2, 1 + COLOR_HISTORY_SIZE / 2, TRUE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
||||
gtk_box_pack_end (GTK_BOX (GIMP_COLOR_SELECTION (cnp->selection)->right_vbox),
|
||||
gtk_box_pack_end (GTK_BOX (GIMP_COLOR_SELECTION (dialog->selection)->right_vbox),
|
||||
table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
|
@ -186,8 +272,8 @@ color_dialog_new (GimpViewable *viewable,
|
|||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (color_history_add_clicked),
|
||||
cnp);
|
||||
G_CALLBACK (gimp_color_history_add_clicked),
|
||||
dialog);
|
||||
|
||||
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (button), arrow);
|
||||
|
@ -209,128 +295,69 @@ color_dialog_new (GimpViewable *viewable,
|
|||
gtk_table_attach_defaults (GTK_TABLE (table), button,
|
||||
column + 1, column + 2, row, row + 1);
|
||||
|
||||
cnp->history[i] = gimp_color_area_new (&history_color,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GDK_BUTTON2_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (button), cnp->history[i]);
|
||||
gtk_widget_show (cnp->history[i]);
|
||||
dialog->history[i] = gimp_color_area_new (&history_color,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS,
|
||||
GDK_BUTTON2_MASK);
|
||||
gtk_container_add (GTK_CONTAINER (button), dialog->history[i]);
|
||||
gtk_widget_show (dialog->history[i]);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (color_history_color_clicked),
|
||||
cnp);
|
||||
G_CALLBACK (gimp_color_history_color_clicked),
|
||||
dialog);
|
||||
|
||||
g_signal_connect (cnp->history[i], "color_changed",
|
||||
G_CALLBACK (color_history_color_changed),
|
||||
g_signal_connect (dialog->history[i], "color_changed",
|
||||
G_CALLBACK (gimp_color_history_color_changed),
|
||||
GINT_TO_POINTER (i));
|
||||
}
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
color_dialogs = g_list_prepend (color_dialogs, cnp);
|
||||
|
||||
return cnp;
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_free (ColorDialog *cnp)
|
||||
gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
color_dialogs = g_list_remove (color_dialogs, cnp);
|
||||
|
||||
/* may be already destroyed by dialog factory */
|
||||
if (cnp->shell)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (cnp->shell),
|
||||
(gpointer *) &cnp->shell);
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_viewable (ColorDialog *cnb,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
g_return_if_fail (cnb != NULL);
|
||||
|
||||
if (GIMP_IS_VIEWABLE_DIALOG (cnb->shell))
|
||||
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (cnb->shell),
|
||||
viewable);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_title (ColorDialog *cnb,
|
||||
const gchar *title)
|
||||
{
|
||||
g_return_if_fail (cnb != NULL);
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (cnb->shell), title);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_set_color (ColorDialog *cnp,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
g_signal_handlers_block_by_func (cnp->selection,
|
||||
color_dialog_color_changed,
|
||||
cnp);
|
||||
g_signal_handlers_block_by_func (dialog->selection,
|
||||
gimp_color_dialog_color_changed,
|
||||
dialog);
|
||||
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (cnp->selection,
|
||||
color_dialog_color_changed,
|
||||
cnp);
|
||||
g_signal_handlers_unblock_by_func (dialog->selection,
|
||||
gimp_color_dialog_color_changed,
|
||||
dialog);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_get_color (ColorDialog *cnp,
|
||||
GimpRGB *color)
|
||||
gimp_color_dialog_get_color (GimpColorDialog *dialog,
|
||||
GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection), color);
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_show (ColorDialog *cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (cnp->shell));
|
||||
}
|
||||
|
||||
void
|
||||
color_dialog_hide (ColorDialog *cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_hide (cnp->shell);
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data)
|
||||
gimp_color_dialog_help_func (const gchar *help_id,
|
||||
gpointer help_data)
|
||||
{
|
||||
ColorDialog *cnp;
|
||||
GimpColorDialog *dialog = GIMP_COLOR_DIALOG (help_data);
|
||||
GimpColorNotebook *notebook;
|
||||
|
||||
cnp = g_object_get_data (G_OBJECT (help_data), "color-notebook");
|
||||
|
||||
notebook =
|
||||
GIMP_COLOR_NOTEBOOK (GIMP_COLOR_SELECTION (cnp->selection)->notebook);
|
||||
GIMP_COLOR_NOTEBOOK (GIMP_COLOR_SELECTION (dialog->selection)->notebook);
|
||||
|
||||
help_id = GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->help_id;
|
||||
|
||||
|
@ -338,63 +365,26 @@ color_dialog_help_func (const gchar *help_id,
|
|||
}
|
||||
|
||||
static void
|
||||
color_dialog_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ColorDialog *cnp)
|
||||
gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
||||
GimpColorDialog *dialog)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
switch (response_id)
|
||||
if (dialog->wants_updates)
|
||||
{
|
||||
case RESPONSE_RESET:
|
||||
gimp_color_selection_reset (GIMP_COLOR_SELECTION (cnp->selection));
|
||||
break;
|
||||
GimpRGB color;
|
||||
|
||||
case GTK_RESPONSE_OK:
|
||||
color_history_add_clicked (NULL, cnp);
|
||||
gimp_color_selection_get_color (selection, &color);
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
|
||||
if (cnp->callback)
|
||||
cnp->callback (cnp, &color,
|
||||
COLOR_DIALOG_OK,
|
||||
cnp->client_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
&color);
|
||||
|
||||
if (cnp->callback)
|
||||
cnp->callback (cnp, &color,
|
||||
COLOR_DIALOG_CANCEL,
|
||||
cnp->client_data);
|
||||
break;
|
||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||
&color, GIMP_COLOR_DIALOG_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_dialog_color_changed (GimpColorSelection *selection,
|
||||
ColorDialog *cnp)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_selection_get_color (selection, &color);
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
cnp->callback (cnp,
|
||||
&color,
|
||||
COLOR_DIALOG_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
/* color history callbacks */
|
||||
|
||||
static void
|
||||
color_history_color_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp)
|
||||
gimp_color_history_color_clicked (GtkWidget *widget,
|
||||
GimpColorDialog *dialog)
|
||||
{
|
||||
GimpColorArea *color_area;
|
||||
GimpRGB color;
|
||||
|
@ -402,13 +392,13 @@ color_history_color_clicked (GtkWidget *widget,
|
|||
color_area = GIMP_COLOR_AREA (GTK_BIN (widget)->child);
|
||||
|
||||
gimp_color_area_get_color (color_area, &color);
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&color);
|
||||
}
|
||||
|
||||
static void
|
||||
color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gimp_color_history_color_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpRGB changed_color;
|
||||
gint color_index;
|
||||
|
@ -422,33 +412,33 @@ color_history_color_changed (GtkWidget *widget,
|
|||
|
||||
for (list = color_dialogs; list; list = g_list_next (list))
|
||||
{
|
||||
ColorDialog *dialog = list->data;
|
||||
GimpColorDialog *dialog = list->data;
|
||||
|
||||
if (dialog->history[color_index] != widget)
|
||||
{
|
||||
g_signal_handlers_block_by_func (dialog->history[color_index],
|
||||
color_history_color_changed,
|
||||
gimp_color_history_color_changed,
|
||||
data);
|
||||
|
||||
gimp_color_area_set_color
|
||||
(GIMP_COLOR_AREA (dialog->history[color_index]), &changed_color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (dialog->history[color_index],
|
||||
color_history_color_changed,
|
||||
gimp_color_history_color_changed,
|
||||
data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_history_add_clicked (GtkWidget *widget,
|
||||
ColorDialog *cnp)
|
||||
gimp_color_history_add_clicked (GtkWidget *widget,
|
||||
GimpColorDialog *dialog)
|
||||
{
|
||||
GimpRGB color;
|
||||
gint shift_begin;
|
||||
gint i;
|
||||
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (cnp->selection),
|
||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
&color);
|
||||
|
||||
shift_begin = color_history_add (&color);
|
||||
|
@ -457,6 +447,6 @@ color_history_add_clicked (GtkWidget *widget,
|
|||
{
|
||||
color_history_get (i, &color);
|
||||
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (cnp->history[i]), &color);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (dialog->history[i]), &color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpcolordialog.h
|
||||
*
|
||||
* 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
|
||||
|
@ -16,51 +18,62 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_DIALOG_H__
|
||||
#define __COLOR_DIALOG_H__
|
||||
#ifndef __GIMP_COLOR_DIALOG_H__
|
||||
#define __GIMP_COLOR_DIALOG_H__
|
||||
|
||||
|
||||
typedef enum
|
||||
#include "gimpviewabledialog.h"
|
||||
|
||||
#include "gui/color-history.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_DIALOG (gimp_color_dialog_get_type ())
|
||||
#define GIMP_COLOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_DIALOG, GimpColorDialog))
|
||||
#define GIMP_COLOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_DIALOG, GimpColorDialogClass))
|
||||
#define GIMP_IS_COLOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_DIALOG))
|
||||
#define GIMP_IS_COLOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_DIALOG))
|
||||
#define GIMP_COLOR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_DIALOG, GimpColorDialogClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorDialogClass GimpColorDialogClass;
|
||||
|
||||
struct _GimpColorDialog
|
||||
{
|
||||
COLOR_DIALOG_OK,
|
||||
COLOR_DIALOG_CANCEL,
|
||||
COLOR_DIALOG_UPDATE
|
||||
} ColorDialogState;
|
||||
GimpViewableDialog parent_instance;
|
||||
|
||||
gboolean wants_updates;
|
||||
|
||||
GtkWidget *selection;
|
||||
GtkWidget *history[COLOR_HISTORY_SIZE];
|
||||
};
|
||||
|
||||
struct _GimpColorDialogClass
|
||||
{
|
||||
GimpViewableDialogClass parent_class;
|
||||
|
||||
void (* update) (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state);
|
||||
};
|
||||
|
||||
|
||||
typedef void (* ColorDialogCallback) (ColorDialog *cnb,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer callback_data);
|
||||
GType gimp_color_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
gboolean wants_update,
|
||||
gboolean show_alpha);
|
||||
|
||||
void gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_dialog_get_color (GimpColorDialog *dialog,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
ColorDialog * color_dialog_new (GimpViewable *viewable,
|
||||
const gchar *title,
|
||||
const gchar *stock_id,
|
||||
const gchar *desc,
|
||||
GtkWidget *parent,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
const gchar *dialog_identifier,
|
||||
const GimpRGB *color,
|
||||
ColorDialogCallback callback,
|
||||
gpointer callback_data,
|
||||
gboolean wants_update,
|
||||
gboolean show_alpha);
|
||||
|
||||
void color_dialog_free (ColorDialog *cnb);
|
||||
|
||||
void color_dialog_set_viewable (ColorDialog *cnb,
|
||||
GimpViewable *viewable);
|
||||
void color_dialog_set_title (ColorDialog *cnb,
|
||||
const gchar *title);
|
||||
|
||||
void color_dialog_show (ColorDialog *cnb);
|
||||
void color_dialog_hide (ColorDialog *cnb);
|
||||
|
||||
void color_dialog_set_color (ColorDialog *cnb,
|
||||
const GimpRGB *color);
|
||||
void color_dialog_get_color (ColorDialog *cnb,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
#endif /* __COLOR_DIALOG_H__ */
|
||||
#endif /* __GIMP_COLOR_DIALOG_H__ */
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include "display/gimpdisplayshell-render.h"
|
||||
|
||||
#include "gimpcolordialog.h"
|
||||
#include "gimpcolormapeditor.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
|
@ -57,8 +58,6 @@
|
|||
#include "gimpmenufactory.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
|
@ -260,7 +259,7 @@ gimp_colormap_editor_destroy (GtkObject *object)
|
|||
|
||||
if (editor->color_dialog)
|
||||
{
|
||||
color_dialog_free (editor->color_dialog);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
}
|
||||
|
||||
|
@ -273,7 +272,7 @@ gimp_colormap_editor_unmap (GtkWidget *widget)
|
|||
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (widget);
|
||||
|
||||
if (editor->color_dialog)
|
||||
color_dialog_hide (editor->color_dialog);
|
||||
gtk_widget_hide (editor->color_dialog);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
||||
}
|
||||
|
@ -294,7 +293,7 @@ gimp_colormap_editor_set_image (GimpImageEditor *image_editor,
|
|||
editor);
|
||||
|
||||
if (editor->color_dialog)
|
||||
color_dialog_hide (editor->color_dialog);
|
||||
gtk_widget_hide (editor->color_dialog);
|
||||
|
||||
if (! HAVE_COLORMAP (gimage))
|
||||
{
|
||||
|
@ -863,27 +862,25 @@ gimp_colormap_hex_entry_focus_out (GtkEntry *entry,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_colormap_color_dialog_callback (ColorDialog *color_dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
gimp_colormap_color_dialog_update (GimpColorDialog *color_dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpColormapEditor *editor)
|
||||
{
|
||||
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
|
||||
GimpImage *gimage;
|
||||
|
||||
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
||||
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_OK:
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
gimp_image_set_colormap_entry (gimage, editor->col_index, color, TRUE);
|
||||
gimp_image_flush (gimage);
|
||||
/* Fall through */
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
color_dialog_hide (editor->color_dialog);
|
||||
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gtk_widget_hide (editor->color_dialog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -911,25 +908,33 @@ gimp_colormap_edit_clicked (GtkWidget *widget,
|
|||
toplevel_factory = gimp_dialog_factory_from_name ("toplevel");
|
||||
|
||||
editor->color_dialog =
|
||||
color_dialog_new (GIMP_VIEWABLE (gimage),
|
||||
_("Edit Indexed Color"),
|
||||
GIMP_STOCK_CONVERT_INDEXED,
|
||||
_("Edit indexed image palette color"),
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-colormap-editor-color-dialog",
|
||||
(const GimpRGB *) &color,
|
||||
gimp_colormap_color_dialog_callback,
|
||||
editor,
|
||||
FALSE, FALSE);
|
||||
gimp_color_dialog_new (GIMP_VIEWABLE (gimage),
|
||||
_("Edit Indexed Color"),
|
||||
GIMP_STOCK_CONVERT_INDEXED,
|
||||
_("Edit indexed image palette color"),
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-colormap-editor-color-dialog",
|
||||
(const GimpRGB *) &color,
|
||||
FALSE, FALSE);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&editor->color_dialog);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "update",
|
||||
G_CALLBACK (gimp_colormap_color_dialog_update),
|
||||
editor);
|
||||
}
|
||||
else
|
||||
{
|
||||
color_dialog_set_viewable (editor->color_dialog,
|
||||
GIMP_VIEWABLE (gimage));
|
||||
color_dialog_show (editor->color_dialog);
|
||||
color_dialog_set_color (editor->color_dialog, &color);
|
||||
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog),
|
||||
GIMP_VIEWABLE (gimage));
|
||||
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog),
|
||||
&color);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (editor->color_dialog));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include "gimpimageeditor.h"
|
||||
|
||||
#include "gui/gui-types.h" /* temp hack */
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLORMAP_EDITOR (gimp_colormap_editor_get_type ())
|
||||
#define GIMP_COLORMAP_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLORMAP_EDITOR, GimpColormapEditor))
|
||||
|
@ -53,7 +51,7 @@ struct _GimpColormapEditor
|
|||
GtkWidget *index_spinbutton;
|
||||
GtkWidget *color_entry;
|
||||
|
||||
ColorDialog *color_dialog;
|
||||
GtkWidget *color_dialog;
|
||||
};
|
||||
|
||||
struct _GimpColormapEditorClass
|
||||
|
|
|
@ -27,41 +27,26 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME #include "dialogs/dialogs-types.h"
|
||||
#endif
|
||||
#include "dialogs/dialogs-types.h"
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gimpcolordialog.h"
|
||||
#include "gimpcolorpanel.h"
|
||||
#include "gimpitemfactory.h"
|
||||
|
||||
|
||||
struct _GimpColorPanel
|
||||
{
|
||||
GimpColorButton parent;
|
||||
|
||||
GimpContext *context;
|
||||
|
||||
ColorDialog *color_dialog;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||
static void gimp_color_panel_class_init (GimpColorPanelClass *klass);
|
||||
static void gimp_color_panel_init (GimpColorPanel *panel);
|
||||
|
||||
static void gimp_color_panel_destroy (GtkObject *object);
|
||||
static gboolean gimp_color_panel_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||
static void gimp_color_panel_clicked (GtkButton *button);
|
||||
static void gimp_color_panel_destroy (GtkObject *object);
|
||||
static gboolean gimp_color_panel_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent);
|
||||
static void gimp_color_panel_color_changed (GimpColorButton *button);
|
||||
static void gimp_color_panel_clicked (GtkButton *button);
|
||||
|
||||
static void gimp_color_panel_select_callback (ColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data);
|
||||
static void gimp_color_panel_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpColorPanel *panel);
|
||||
|
||||
|
||||
static GimpColorButtonClass *parent_class = NULL;
|
||||
|
@ -125,8 +110,7 @@ gimp_color_panel_destroy (GtkObject *object)
|
|||
|
||||
if (panel->color_dialog)
|
||||
{
|
||||
color_dialog_hide (panel->color_dialog);
|
||||
color_dialog_free (panel->color_dialog);
|
||||
gtk_widget_destroy (panel->color_dialog);
|
||||
panel->color_dialog = NULL;
|
||||
}
|
||||
|
||||
|
@ -228,7 +212,8 @@ gimp_color_panel_color_changed (GimpColorButton *button)
|
|||
if (panel->color_dialog)
|
||||
{
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
|
||||
color_dialog_set_color (panel->color_dialog, &color);
|
||||
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (panel->color_dialog),
|
||||
&color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,40 +228,43 @@ gimp_color_panel_clicked (GtkButton *button)
|
|||
if (! panel->color_dialog)
|
||||
{
|
||||
panel->color_dialog =
|
||||
color_dialog_new (NULL, GIMP_COLOR_BUTTON (button)->title, NULL, NULL,
|
||||
GTK_WIDGET (button),
|
||||
NULL, NULL,
|
||||
(const GimpRGB *) &color,
|
||||
gimp_color_panel_select_callback,
|
||||
panel,
|
||||
FALSE,
|
||||
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||
}
|
||||
else
|
||||
{
|
||||
color_dialog_show (panel->color_dialog);
|
||||
gimp_color_dialog_new (NULL,
|
||||
GIMP_COLOR_BUTTON (button)->title,
|
||||
NULL, NULL,
|
||||
GTK_WIDGET (button),
|
||||
NULL, NULL,
|
||||
(const GimpRGB *) &color,
|
||||
FALSE,
|
||||
gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button)));
|
||||
|
||||
g_signal_connect (panel->color_dialog, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&panel->color_dialog);
|
||||
|
||||
g_signal_connect (panel->color_dialog, "update",
|
||||
G_CALLBACK (gimp_color_panel_dialog_update),
|
||||
panel);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (panel->color_dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_panel_select_callback (ColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
gimp_color_panel_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpColorPanel *panel)
|
||||
{
|
||||
GimpColorPanel *panel = GIMP_COLOR_PANEL (data);
|
||||
|
||||
if (panel->color_dialog)
|
||||
switch (state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
break;
|
||||
case COLOR_DIALOG_OK:
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
/* Fallthrough */
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
color_dialog_hide (panel->color_dialog);
|
||||
}
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color);
|
||||
/* Fallthrough */
|
||||
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gtk_widget_hide (panel->color_dialog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
|
||||
typedef struct _GimpColorPanelClass GimpColorPanelClass;
|
||||
|
||||
struct _GimpColorPanel
|
||||
{
|
||||
GimpColorButton parent_instance;
|
||||
|
||||
GimpContext *context;
|
||||
GtkWidget *color_dialog;
|
||||
};
|
||||
|
||||
struct _GimpColorPanelClass
|
||||
{
|
||||
GimpColorButtonClass parent_class;
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
*/
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* - Fix memory leaks: grad_free_gradient_editor() and any others
|
||||
* which I may have missed.
|
||||
*
|
||||
* - Add all of Marcelo's neat suggestions:
|
||||
* - Hue rotate, saturation, brightness, contrast.
|
||||
|
@ -73,8 +70,6 @@
|
|||
#include "gimpviewrenderergradient.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
|
@ -463,7 +458,7 @@ gimp_gradient_editor_set_data (GimpDataEditor *editor,
|
|||
|
||||
if (gradient_editor->color_dialog)
|
||||
{
|
||||
color_dialog_free (gradient_editor->color_dialog);
|
||||
gtk_widget_destroy (gradient_editor->color_dialog);
|
||||
gradient_editor->color_dialog = NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include "gimpdataeditor.h"
|
||||
|
||||
#include "dialogs/dialogs-types.h" /* FIXME */
|
||||
|
||||
|
||||
#define GRAD_NUM_COLORS 10
|
||||
|
||||
|
@ -70,7 +68,7 @@ struct _GimpGradientEditor
|
|||
gboolean instant_update;
|
||||
|
||||
/* Color dialog */
|
||||
ColorDialog *color_dialog;
|
||||
GtkWidget *color_dialog;
|
||||
|
||||
/* Gradient preview */
|
||||
gint preview_last_x;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "core/gimpdatafactory.h"
|
||||
#include "core/gimppalette.h"
|
||||
|
||||
#include "gimpcolordialog.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimpdocked.h"
|
||||
|
@ -47,8 +48,6 @@
|
|||
#include "gimpsessioninfo.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
|
@ -138,10 +137,10 @@ static void palette_editor_viewport_resized (GtkWidget *widget,
|
|||
static void palette_editor_viewport_realize (GtkWidget *widget,
|
||||
GimpPaletteEditor *editor);
|
||||
|
||||
static void palette_editor_color_dialog_callback (ColorDialog *color_dialog,
|
||||
static void palette_editor_color_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data);
|
||||
GimpColorDialogState state,
|
||||
GimpPaletteEditor *editor);
|
||||
|
||||
|
||||
static GimpDataEditorClass *parent_class = NULL;
|
||||
|
@ -412,7 +411,7 @@ gimp_palette_editor_destroy (GtkObject *object)
|
|||
|
||||
if (editor->color_dialog)
|
||||
{
|
||||
color_dialog_free (editor->color_dialog);
|
||||
gtk_widget_destroy (editor->color_dialog);
|
||||
editor->color_dialog = NULL;
|
||||
}
|
||||
|
||||
|
@ -425,7 +424,7 @@ gimp_palette_editor_unmap (GtkWidget *widget)
|
|||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (widget);
|
||||
|
||||
if (editor->color_dialog)
|
||||
color_dialog_hide (editor->color_dialog);
|
||||
gtk_widget_hide (editor->color_dialog);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
||||
}
|
||||
|
@ -444,7 +443,7 @@ gimp_palette_editor_set_data (GimpDataEditor *editor,
|
|||
{
|
||||
if (palette_editor->color_dialog)
|
||||
{
|
||||
color_dialog_free (palette_editor->color_dialog);
|
||||
gtk_widget_destroy (palette_editor->color_dialog);
|
||||
palette_editor->color_dialog = NULL;
|
||||
}
|
||||
|
||||
|
@ -1045,24 +1044,33 @@ palette_editor_edit_clicked (GtkWidget *widget,
|
|||
toplevel_factory = gimp_dialog_factory_from_name ("toplevel");
|
||||
|
||||
editor->color_dialog =
|
||||
color_dialog_new (GIMP_VIEWABLE (palette),
|
||||
_("Edit Palette Color"),
|
||||
GIMP_STOCK_PALETTE,
|
||||
_("Edit Color Palette Entry"),
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-palette-editor-color-dialog",
|
||||
(const GimpRGB *) &editor->color->color,
|
||||
palette_editor_color_dialog_callback,
|
||||
editor,
|
||||
FALSE, FALSE);
|
||||
gimp_color_dialog_new (GIMP_VIEWABLE (palette),
|
||||
_("Edit Palette Color"),
|
||||
GIMP_STOCK_PALETTE,
|
||||
_("Edit Color Palette Entry"),
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-palette-editor-color-dialog",
|
||||
(const GimpRGB *) &editor->color->color,
|
||||
FALSE, FALSE);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&editor->color_dialog);
|
||||
|
||||
g_signal_connect (editor->color_dialog, "update",
|
||||
G_CALLBACK (palette_editor_color_dialog_update),
|
||||
editor);
|
||||
}
|
||||
else
|
||||
{
|
||||
color_dialog_set_viewable (editor->color_dialog, GIMP_VIEWABLE (palette));
|
||||
color_dialog_set_color (editor->color_dialog, &editor->color->color);
|
||||
color_dialog_show (editor->color_dialog);
|
||||
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog),
|
||||
GIMP_VIEWABLE (palette));
|
||||
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog),
|
||||
&editor->color->color);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (editor->color_dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1262,33 +1270,27 @@ palette_editor_viewport_realize (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
palette_editor_color_dialog_callback (ColorDialog *color_dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
palette_editor_color_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpPaletteEditor *editor)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
|
||||
GimpPalette *palette;
|
||||
GimpContext *user_context;
|
||||
|
||||
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_OK:
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
if (editor->color)
|
||||
{
|
||||
editor->color->color = *color;
|
||||
gimp_data_dirty (GIMP_DATA (palette));
|
||||
}
|
||||
|
||||
/* Fallthrough */
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
color_dialog_hide (editor->color_dialog);
|
||||
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gtk_widget_hide (editor->color_dialog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include "gimpdataeditor.h"
|
||||
|
||||
#include "dialogs/dialogs-types.h" /* FIXME */
|
||||
|
||||
|
||||
#define GIMP_TYPE_PALETTE_EDITOR (gimp_palette_editor_get_type ())
|
||||
#define GIMP_PALETTE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PALETTE_EDITOR, GimpPaletteEditor))
|
||||
|
@ -52,7 +50,7 @@ struct _GimpPaletteEditor
|
|||
GtkWidget *zoom_in_button;
|
||||
GtkWidget *zoom_all_button;
|
||||
|
||||
ColorDialog *color_dialog;
|
||||
GtkWidget *color_dialog;
|
||||
|
||||
GimpPaletteEntry *color;
|
||||
GimpPaletteEntry *dnd_color;
|
||||
|
|
|
@ -27,35 +27,30 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "gimpcolordialog.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpfgbgeditor.h"
|
||||
#include "gimptoolbox.h"
|
||||
#include "gimptoolbox-color-area.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME #include "dialogs/dialogs-types.h"
|
||||
#endif
|
||||
#include "dialogs/dialogs-types.h"
|
||||
#include "dialogs/color-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void color_area_color_clicked (GimpFgBgEditor *editor,
|
||||
GimpActiveColor active_color,
|
||||
GimpContext *context);
|
||||
static void color_area_select_callback (ColorDialog *color_dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data);
|
||||
static void color_area_color_clicked (GimpFgBgEditor *editor,
|
||||
GimpActiveColor active_color,
|
||||
GimpContext *context);
|
||||
static void color_area_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpContext *context);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
||||
static GtkWidget *color_area = NULL;
|
||||
static ColorDialog *color_dialog = NULL;
|
||||
static GtkWidget *color_area = NULL;
|
||||
static GtkWidget *color_dialog = NULL;
|
||||
static gboolean color_dialog_active = FALSE;
|
||||
static GimpActiveColor edit_color;
|
||||
static GimpRGB revert_fg;
|
||||
|
@ -92,36 +87,31 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
|||
/* private functions */
|
||||
|
||||
static void
|
||||
color_area_select_callback (ColorDialog *color_dialog,
|
||||
const GimpRGB *color,
|
||||
ColorDialogState state,
|
||||
gpointer data)
|
||||
color_area_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
GimpColorDialogState state,
|
||||
GimpContext *context)
|
||||
{
|
||||
GimpContext *context = GIMP_CONTEXT (data);
|
||||
|
||||
if (color_dialog)
|
||||
switch (state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_DIALOG_OK:
|
||||
color_dialog_hide (color_dialog);
|
||||
color_dialog_active = FALSE;
|
||||
/* Fallthrough */
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
gtk_widget_hide (color_dialog);
|
||||
color_dialog_active = FALSE;
|
||||
/* Fallthrough */
|
||||
|
||||
case COLOR_DIALOG_UPDATE:
|
||||
if (edit_color == GIMP_ACTIVE_COLOR_FOREGROUND)
|
||||
gimp_context_set_foreground (context, color);
|
||||
else
|
||||
gimp_context_set_background (context, color);
|
||||
break;
|
||||
case GIMP_COLOR_DIALOG_UPDATE:
|
||||
if (edit_color == GIMP_ACTIVE_COLOR_FOREGROUND)
|
||||
gimp_context_set_foreground (context, color);
|
||||
else
|
||||
gimp_context_set_background (context, color);
|
||||
break;
|
||||
|
||||
case COLOR_DIALOG_CANCEL:
|
||||
color_dialog_hide (color_dialog);
|
||||
color_dialog_active = FALSE;
|
||||
gimp_context_set_foreground (context, &revert_fg);
|
||||
gimp_context_set_background (context, &revert_bg);
|
||||
break;
|
||||
}
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gtk_widget_hide (color_dialog);
|
||||
color_dialog_active = FALSE;
|
||||
gimp_context_set_foreground (context, &revert_fg);
|
||||
gimp_context_set_background (context, &revert_bg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,21 +148,24 @@ color_area_color_clicked (GimpFgBgEditor *editor,
|
|||
|
||||
toplevel_factory = gimp_dialog_factory_from_name ("toplevel");
|
||||
|
||||
color_dialog = color_dialog_new (NULL, title, NULL, NULL,
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-toolbox-color-dialog",
|
||||
(const GimpRGB *) &color,
|
||||
color_area_select_callback,
|
||||
context, TRUE, FALSE);
|
||||
color_dialog = gimp_color_dialog_new (NULL, title, NULL, NULL,
|
||||
GTK_WIDGET (editor),
|
||||
toplevel_factory,
|
||||
"gimp-toolbox-color-dialog",
|
||||
(const GimpRGB *) &color,
|
||||
TRUE, FALSE);
|
||||
color_dialog_active = TRUE;
|
||||
|
||||
g_signal_connect (color_dialog, "update",
|
||||
G_CALLBACK (color_area_dialog_update),
|
||||
context);
|
||||
}
|
||||
else
|
||||
{
|
||||
color_dialog_set_title (color_dialog, title);
|
||||
color_dialog_set_color (color_dialog, &color);
|
||||
gtk_window_set_title (GTK_WINDOW (color_dialog), title);
|
||||
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (color_dialog), &color);
|
||||
|
||||
color_dialog_show (color_dialog);
|
||||
gtk_window_present (GTK_WINDOW (color_dialog));
|
||||
color_dialog_active = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,25 @@ gimp_aspect_type_get_type (void)
|
|||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_color_dialog_state_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_COLOR_DIALOG_OK, "GIMP_COLOR_DIALOG_OK", "ok" },
|
||||
{ GIMP_COLOR_DIALOG_CANCEL, "GIMP_COLOR_DIALOG_CANCEL", "cancel" },
|
||||
{ GIMP_COLOR_DIALOG_UPDATE, "GIMP_COLOR_DIALOG_UPDATE", "update" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
type = g_enum_register_static ("GimpColorDialogState", values);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_color_frame_mode_get_type (void)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,18 @@ typedef enum
|
|||
} GimpAspectType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_DIALOG_STATE (gimp_color_dialog_state_get_type ())
|
||||
|
||||
GType gimp_color_dialog_state_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_COLOR_DIALOG_OK,
|
||||
GIMP_COLOR_DIALOG_CANCEL,
|
||||
GIMP_COLOR_DIALOG_UPDATE
|
||||
} GimpColorDialogState;
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_FRAME_MODE (gimp_color_frame_mode_get_type ())
|
||||
|
||||
GType gimp_color_frame_mode_get_type (void) G_GNUC_CONST;
|
||||
|
|
|
@ -122,6 +122,7 @@ typedef struct _GimpUIManager GimpUIManager;
|
|||
|
||||
/* misc dialogs */
|
||||
|
||||
typedef struct _GimpColorDialog GimpColorDialog;
|
||||
typedef struct _GimpErrorDialog GimpErrorDialog;
|
||||
typedef struct _GimpFileDialog GimpFileDialog;
|
||||
typedef struct _GimpProgressDialog GimpProgressDialog;
|
||||
|
|
Loading…
Reference in New Issue