Commit ee5354e4 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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.
parent 58b08f86
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 \
......
/* 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);
}