2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-07-07 11:18:54 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-07-07 11:18:54 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 11:18:54 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-07-07 11:18:54 +08:00
|
|
|
*/
|
1999-09-06 08:07:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-12-04 06:16:56 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpimage.h"
|
2005-09-19 20:44:06 +08:00
|
|
|
#include "core/gimpimage-quick-mask.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2001-04-11 09:13:53 +08:00
|
|
|
|
2004-10-19 17:17:37 +08:00
|
|
|
#include "dialogs/channel-options-dialog.h"
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2005-09-19 20:44:06 +08:00
|
|
|
#include "quick-mask-commands.h"
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-09-19 20:44:06 +08:00
|
|
|
static void quick_mask_configure_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
ChannelOptionsDialog *options);
|
2001-11-30 22:41:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functionss */
|
|
|
|
|
|
|
|
void
|
2005-09-19 20:44:06 +08:00
|
|
|
quick_mask_toggle_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
1999-08-08 04:55:26 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-04-29 20:52:29 +08:00
|
|
|
gboolean active;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2001-01-15 12:37:01 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (active != gimp_image_get_quick_mask_state (image))
|
2003-01-11 01:55:53 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_set_quick_mask_state (image, active);
|
|
|
|
gimp_image_flush (image);
|
2003-01-11 01:55:53 +08:00
|
|
|
}
|
1999-08-08 04:55:26 +08:00
|
|
|
}
|
|
|
|
|
1999-07-07 11:18:54 +08:00
|
|
|
void
|
2005-09-19 20:44:06 +08:00
|
|
|
quick_mask_invert_cmd_callback (GtkAction *action,
|
|
|
|
GtkAction *current,
|
|
|
|
gpointer data)
|
1999-07-07 11:18:54 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-09-20 05:43:43 +08:00
|
|
|
gint value;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2001-11-30 00:44:51 +08:00
|
|
|
|
2004-09-20 05:43:43 +08:00
|
|
|
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2010-02-04 16:49:45 +08:00
|
|
|
if (value != gimp_image_get_quick_mask_inverted (image))
|
2004-09-20 05:43:43 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_quick_mask_invert (image);
|
|
|
|
gimp_image_flush (image);
|
2001-11-30 22:41:56 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
void
|
2005-09-19 20:44:06 +08:00
|
|
|
quick_mask_configure_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2004-10-19 17:17:37 +08:00
|
|
|
ChannelOptionsDialog *options;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-19 17:17:37 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GimpRGB color;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-10-19 17:17:37 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_get_quick_mask_color (image, &color);
|
2004-10-19 17:17:37 +08:00
|
|
|
|
2006-09-01 19:26:54 +08:00
|
|
|
options = channel_options_dialog_new (image, NULL,
|
2004-10-19 17:17:37 +08:00
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
&color,
|
|
|
|
NULL,
|
|
|
|
_("Quick Mask Attributes"),
|
2005-09-19 20:44:06 +08:00
|
|
|
"gimp-quick-mask-edit",
|
|
|
|
GIMP_STOCK_QUICK_MASK_ON,
|
2004-10-19 17:17:37 +08:00
|
|
|
_("Edit Quick Mask Attributes"),
|
2005-09-19 20:44:06 +08:00
|
|
|
GIMP_HELP_QUICK_MASK_EDIT,
|
2004-10-19 17:17:37 +08:00
|
|
|
_("Edit Quick Mask Color"),
|
2005-08-23 07:39:12 +08:00
|
|
|
_("_Mask opacity:"),
|
2006-04-12 20:49:29 +08:00
|
|
|
FALSE);
|
2004-10-19 17:17:37 +08:00
|
|
|
|
|
|
|
g_signal_connect (options->dialog, "response",
|
2005-09-19 20:44:06 +08:00
|
|
|
G_CALLBACK (quick_mask_configure_response),
|
2004-10-19 17:17:37 +08:00
|
|
|
options);
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2004-10-19 17:17:37 +08:00
|
|
|
gtk_widget_show (options->dialog);
|
2001-11-30 22:41:56 +08:00
|
|
|
}
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
1999-08-08 04:55:26 +08:00
|
|
|
static void
|
2005-09-19 20:44:06 +08:00
|
|
|
quick_mask_configure_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
ChannelOptionsDialog *options)
|
1999-08-08 04:55:26 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
2004-07-05 19:18:34 +08:00
|
|
|
GimpRGB old_color;
|
|
|
|
GimpRGB new_color;
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_get_quick_mask_color (options->image, &old_color);
|
2004-07-05 19:18:34 +08:00
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
|
|
|
&new_color);
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2004-07-05 19:18:34 +08:00
|
|
|
if (gimp_rgba_distance (&old_color, &new_color) > 0.0001)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_set_quick_mask_color (options->image, &new_color);
|
2001-01-15 14:24:24 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (options->image);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
1999-08-08 04:55:26 +08:00
|
|
|
}
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2004-10-19 17:17:37 +08:00
|
|
|
gtk_widget_destroy (options->dialog);
|
2001-11-11 03:10:28 +08:00
|
|
|
}
|