1
/* The GIMP -- an 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-qmask.h"
33
#include "widgets/gimphelp-ids.h"
35
#include "dialogs/channel-options-dialog.h"
38
#include "qmask-commands.h"
40
#include "gimp-intl.h"
43
/* local function prototypes */
45
static void qmask_configure_response (GtkWidget *widget,
47
ChannelOptionsDialog *options);
50
/* public functionss */
53
qmask_toggle_cmd_callback (GtkAction *action,
58
return_if_no_image (gimage, data);
60
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
62
if (active != gimp_image_get_qmask_state (gimage))
64
gimp_image_set_qmask_state (gimage, active);
65
gimp_image_flush (gimage);
70
qmask_invert_cmd_callback (GtkAction *action,
76
return_if_no_image (gimage, data);
78
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
80
if (value != gimage->qmask_inverted)
82
gimp_image_qmask_invert (gimage);
83
gimp_image_flush (gimage);
88
qmask_configure_cmd_callback (GtkAction *action,
91
ChannelOptionsDialog *options;
95
return_if_no_image (gimage, data);
96
return_if_no_widget (widget, data);
98
gimp_image_get_qmask_color (gimage, &color);
100
options = channel_options_dialog_new (gimage,
101
action_data_get_context (data),
106
_("Quick Mask Attributes"),
109
_("Edit Quick Mask Attributes"),
110
GIMP_HELP_QMASK_EDIT,
111
_("Edit Quick Mask Color"),
114
g_signal_connect (options->dialog, "response",
115
G_CALLBACK (qmask_configure_response),
118
gtk_widget_show (options->dialog);
122
/* private functions */
125
qmask_configure_response (GtkWidget *widget,
127
ChannelOptionsDialog *options)
129
if (response_id == GTK_RESPONSE_OK)
134
gimp_image_get_qmask_color (options->gimage, &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_qmask_color (options->gimage, &new_color);
142
gimp_image_flush (options->gimage);
146
gtk_widget_destroy (options->dialog);