1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpcolor/gimpcolor.h"
24
#include "libgimpwidgets/gimpwidgets.h"
26
#include "actions-types.h"
28
#include "core/gimp.h"
29
#include "core/gimpchannel.h"
30
#include "core/gimpimage.h"
31
#include "core/gimpimage-quick-mask.h"
33
#include "widgets/gimphelp-ids.h"
35
#include "dialogs/channel-options-dialog.h"
38
#include "quick-mask-commands.h"
40
#include "gimp-intl.h"
43
/* local function prototypes */
45
static void quick_mask_configure_response (GtkWidget *widget,
47
ChannelOptionsDialog *options);
50
/* public functionss */
53
quick_mask_toggle_cmd_callback (GtkAction *action,
58
return_if_no_image (image, data);
60
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
62
if (active != gimp_image_get_quick_mask_state (image))
64
gimp_image_set_quick_mask_state (image, active);
65
gimp_image_flush (image);
70
quick_mask_invert_cmd_callback (GtkAction *action,
76
return_if_no_image (image, data);
78
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
80
if (value != image->quick_mask_inverted)
82
gimp_image_quick_mask_invert (image);
83
gimp_image_flush (image);
88
quick_mask_configure_cmd_callback (GtkAction *action,
91
ChannelOptionsDialog *options;
95
return_if_no_image (image, data);
96
return_if_no_widget (widget, data);
98
gimp_image_get_quick_mask_color (image, &color);
100
options = channel_options_dialog_new (image, NULL,
101
action_data_get_context (data),
105
_("Quick Mask Attributes"),
106
"gimp-quick-mask-edit",
107
GIMP_STOCK_QUICK_MASK_ON,
108
_("Edit Quick Mask Attributes"),
109
GIMP_HELP_QUICK_MASK_EDIT,
110
_("Edit Quick Mask Color"),
114
g_signal_connect (options->dialog, "response",
115
G_CALLBACK (quick_mask_configure_response),
118
gtk_widget_show (options->dialog);
122
/* private functions */
125
quick_mask_configure_response (GtkWidget *widget,
127
ChannelOptionsDialog *options)
129
if (response_id == GTK_RESPONSE_OK)
134
gimp_image_get_quick_mask_color (options->image, &old_color);
135
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
138
if (gimp_rgba_distance (&old_color, &new_color) > 0.0001)
140
gimp_image_set_quick_mask_color (options->image, &new_color);
142
gimp_image_flush (options->image);
146
gtk_widget_destroy (options->dialog);