2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-04-21 02:11:12 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-04-21 02:11:12 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-04-21 02:11:12 +00: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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-04-21 02:11:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 00:10:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2001-04-21 02:11:12 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-10-26 14:45:25 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "actions-types.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2016-08-24 18:27:49 +02:00
|
|
|
#include "config/gimpdialogconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpchannel.h"
|
2003-10-06 12:17:11 +00:00
|
|
|
#include "core/gimpchannel-select.h"
|
2004-05-25 14:37:02 +00:00
|
|
|
#include "core/gimpcontext.h"
|
2016-03-08 01:38:05 +01:00
|
|
|
#include "core/gimpdrawable-fill.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2003-02-13 11:23:50 +00:00
|
|
|
#include "core/gimpimage-undo.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2004-10-16 15:48:23 +00:00
|
|
|
#include "widgets/gimpaction.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
#include "widgets/gimpcolorpanel.h"
|
2003-03-12 17:12:01 +00:00
|
|
|
#include "widgets/gimpcomponenteditor.h"
|
2004-01-31 20:23:53 +00:00
|
|
|
#include "widgets/gimpdock.h"
|
2003-08-21 15:54:47 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-10-19 09:17:37 +00:00
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
#include "dialogs/dialogs.h"
|
2004-10-19 09:17:37 +00:00
|
|
|
#include "dialogs/channel-options-dialog.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2004-05-03 14:03:51 +00:00
|
|
|
#include "actions.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
#include "channels-commands.h"
|
2016-10-29 16:50:13 +02:00
|
|
|
#include "items-commands.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2001-04-21 02:11:12 +00:00
|
|
|
|
|
|
|
|
2002-02-26 16:30:14 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
static void channels_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannel *channel,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *channel_name,
|
|
|
|
const GimpRGB *channel_color,
|
|
|
|
gboolean save_selection,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_visible,
|
|
|
|
gboolean channel_linked,
|
2016-10-29 16:50:13 +02:00
|
|
|
GimpColorTag channel_color_tag,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_lock_content,
|
|
|
|
gboolean channel_lock_position,
|
2016-09-24 22:10:32 +02:00
|
|
|
gpointer user_data);
|
|
|
|
static void channels_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannel *channel,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *channel_name,
|
|
|
|
const GimpRGB *channel_color,
|
|
|
|
gboolean save_selection,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_visible,
|
|
|
|
gboolean channel_linked,
|
2016-10-29 16:50:13 +02:00
|
|
|
GimpColorTag channel_color_tag,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_lock_content,
|
|
|
|
gboolean channel_lock_position,
|
2016-09-24 22:10:32 +02:00
|
|
|
gpointer user_data);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
|
|
|
|
2001-11-27 19:27:55 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 14:37:02 +00:00
|
|
|
void
|
|
|
|
channels_edit_attributes_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2016-09-24 22:10:32 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2004-05-25 14:37:02 +00:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
#define EDIT_DIALOG_KEY "gimp-channel-edit-attributes-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
2016-10-26 16:51:56 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
dialog = channel_options_dialog_new (image, channel,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("Channel Attributes"),
|
|
|
|
"gimp-channel-edit",
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_EDIT,
|
2016-09-24 22:10:32 +02:00
|
|
|
_("Edit Channel Attributes"),
|
|
|
|
GIMP_HELP_CHANNEL_EDIT,
|
|
|
|
_("Edit Channel Color"),
|
2016-10-26 16:51:56 +02:00
|
|
|
_("_Fill opacity:"),
|
2016-09-24 22:10:32 +02:00
|
|
|
FALSE,
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_object_get_name (channel),
|
|
|
|
&channel->color,
|
|
|
|
gimp_item_get_visible (item),
|
|
|
|
gimp_item_get_linked (item),
|
2016-10-29 16:50:13 +02:00
|
|
|
gimp_item_get_color_tag (item),
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_item_get_lock_content (item),
|
|
|
|
gimp_item_get_lock_position (item),
|
2016-09-24 22:10:32 +02:00
|
|
|
channels_edit_attributes_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY, dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-05-25 14:37:02 +00:00
|
|
|
}
|
|
|
|
|
2001-04-21 02:11:12 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_new_cmd_callback (GtkAction *action,
|
2003-08-21 15:54:47 +00:00
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2016-09-24 22:10:32 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2004-04-29 12:52:29 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
#define NEW_DIALOG_KEY "gimp-channel-new-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), NEW_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
|
|
dialog = channel_options_dialog_new (image, NULL,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("New Channel"),
|
|
|
|
"gimp-channel-new",
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_CHANNEL,
|
2016-10-23 23:01:47 +02:00
|
|
|
_("Create a New Channel"),
|
2016-09-24 22:10:32 +02:00
|
|
|
GIMP_HELP_CHANNEL_NEW,
|
2016-10-26 16:51:56 +02:00
|
|
|
_("New Channel Color"),
|
|
|
|
_("_Fill opacity:"),
|
|
|
|
TRUE,
|
2016-09-24 22:10:32 +02:00
|
|
|
config->channel_new_name,
|
|
|
|
&config->channel_new_color,
|
|
|
|
TRUE,
|
2016-10-26 16:51:56 +02:00
|
|
|
FALSE,
|
2016-10-29 16:50:13 +02:00
|
|
|
GIMP_COLOR_TAG_NONE,
|
2016-10-26 16:51:56 +02:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2016-09-24 22:10:32 +02:00
|
|
|
channels_new_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), NEW_DIALOG_KEY, dialog);
|
|
|
|
}
|
2016-08-24 18:27:49 +02:00
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-10-16 15:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-23 00:53:48 +00:00
|
|
|
channels_new_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2004-10-16 15:48:23 +00:00
|
|
|
{
|
2016-08-24 18:27:49 +02:00
|
|
|
GimpImage *image;
|
2018-03-25 14:08:50 +02:00
|
|
|
GimpChannel *channel;
|
2016-08-24 18:27:49 +02:00
|
|
|
GimpDialogConfig *config;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
2016-08-24 18:27:49 +02:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
2018-03-25 14:08:50 +02:00
|
|
|
channel = gimp_channel_new (image,
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image),
|
|
|
|
config->channel_new_name,
|
|
|
|
&config->channel_new_color);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
2018-03-25 14:08:50 +02:00
|
|
|
gimp_drawable_fill (GIMP_DRAWABLE (channel),
|
2014-06-03 14:11:59 +02:00
|
|
|
action_data_get_context (data),
|
|
|
|
GIMP_FILL_TRANSPARENT);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
2018-03-25 14:08:50 +02:00
|
|
|
gimp_image_add_channel (image, channel,
|
2009-08-03 22:30:36 +02:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_raise_cmd_callback (GtkAction *action,
|
2003-08-21 15:54:47 +00:00
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2010-07-08 18:08:13 +02:00
|
|
|
gimp_image_raise_item (image, GIMP_ITEM (channel), NULL);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 14:54:24 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_raise_to_top_cmd_callback (GtkAction *action,
|
2004-04-19 14:54:24 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2004-04-19 14:54:24 +00:00
|
|
|
|
2010-07-08 18:08:13 +02:00
|
|
|
gimp_image_raise_item_to_top (image, GIMP_ITEM (channel));
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2004-04-19 14:54:24 +00:00
|
|
|
}
|
|
|
|
|
2001-04-21 02:11:12 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_lower_cmd_callback (GtkAction *action,
|
2003-08-21 15:54:47 +00:00
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2010-07-08 18:08:13 +02:00
|
|
|
gimp_image_lower_item (image, GIMP_ITEM (channel), NULL);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 14:54:24 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_lower_to_bottom_cmd_callback (GtkAction *action,
|
2004-04-19 14:54:24 +00:00
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2004-04-19 14:54:24 +00:00
|
|
|
|
2010-07-08 18:08:13 +02:00
|
|
|
gimp_image_lower_item_to_bottom (image, GIMP_ITEM (channel));
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2004-04-19 14:54:24 +00:00
|
|
|
}
|
|
|
|
|
2001-04-21 02:11:12 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_duplicate_cmd_callback (GtkAction *action,
|
2003-08-21 15:54:47 +00:00
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2001-04-21 02:11:12 +00:00
|
|
|
GimpChannel *new_channel;
|
2009-08-03 23:19:25 +02:00
|
|
|
GimpChannel *parent = GIMP_IMAGE_ACTIVE_PARENT;
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2003-03-12 17:12:01 +00:00
|
|
|
if (GIMP_IS_COMPONENT_EDITOR (data))
|
|
|
|
{
|
|
|
|
GimpChannelType component;
|
2004-10-26 14:45:25 +00:00
|
|
|
const gchar *desc;
|
2003-03-12 17:12:01 +00:00
|
|
|
gchar *name;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2003-03-12 17:12:01 +00:00
|
|
|
|
|
|
|
component = GIMP_COMPONENT_EDITOR (data)->clicked_component;
|
|
|
|
|
2004-10-26 14:45:25 +00:00
|
|
|
gimp_enum_get_value (GIMP_TYPE_CHANNEL_TYPE, component,
|
|
|
|
NULL, NULL, &desc, NULL);
|
2003-09-11 19:52:29 +00:00
|
|
|
|
2004-10-26 14:45:25 +00:00
|
|
|
name = g_strdup_printf (_("%s Channel Copy"), desc);
|
2003-03-12 17:12:01 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
new_channel = gimp_channel_new_from_component (image, component,
|
2005-01-15 16:59:34 +00:00
|
|
|
name, NULL);
|
2003-03-12 17:12:01 +00:00
|
|
|
|
2003-08-21 15:54:47 +00:00
|
|
|
/* copied components are invisible by default so subsequent copies
|
|
|
|
* of components don't affect each other
|
|
|
|
*/
|
2003-09-11 19:52:29 +00:00
|
|
|
gimp_item_set_visible (GIMP_ITEM (new_channel), FALSE, FALSE);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2003-03-12 17:12:01 +00:00
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2003-03-12 17:12:01 +00:00
|
|
|
|
|
|
|
new_channel =
|
2004-05-25 14:37:02 +00:00
|
|
|
GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
|
2008-01-08 11:46:15 +00:00
|
|
|
G_TYPE_FROM_INSTANCE (channel)));
|
2009-08-03 23:19:25 +02:00
|
|
|
|
|
|
|
/* use the actual parent here, not GIMP_IMAGE_ACTIVE_PARENT because
|
|
|
|
* the latter would add a duplicated group inside itself instead of
|
|
|
|
* above it
|
|
|
|
*/
|
2010-02-07 13:46:46 +01:00
|
|
|
parent = gimp_channel_get_parent (channel);
|
2003-03-12 17:12:01 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 23:19:25 +02:00
|
|
|
gimp_image_add_channel (image, new_channel, parent, -1, TRUE);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_delete_cmd_callback (GtkAction *action,
|
2003-08-21 15:54:47 +00:00
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-05-25 14:37:02 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2008-10-09 19:40:41 +00:00
|
|
|
gimp_image_remove_channel (image, channel, TRUE, NULL);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
2003-08-27 00:52:00 +00:00
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
channels_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2003-08-27 00:52:00 +00:00
|
|
|
GimpChannelOps op;
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2003-08-27 00:52:00 +00:00
|
|
|
|
2004-04-29 12:52:29 +00:00
|
|
|
op = (GimpChannelOps) value;
|
2003-03-12 17:12:01 +00:00
|
|
|
|
|
|
|
if (GIMP_IS_COMPONENT_EDITOR (data))
|
|
|
|
{
|
|
|
|
GimpChannelType component;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2003-03-12 17:12:01 +00:00
|
|
|
|
|
|
|
component = GIMP_COMPONENT_EDITOR (data)->clicked_component;
|
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_channel_select_component (gimp_image_get_mask (image), component,
|
2003-10-06 12:17:11 +00:00
|
|
|
op, FALSE, 0.0, 0.0);
|
2003-03-12 17:12:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-21 15:54:47 +00:00
|
|
|
GimpChannel *channel;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_channel (image, channel, data);
|
2003-08-21 15:54:47 +00:00
|
|
|
|
2010-07-20 23:09:19 +02:00
|
|
|
gimp_item_to_selection (GIMP_ITEM (channel),
|
|
|
|
op, TRUE, FALSE, 0.0, 0.0);
|
2003-03-12 17:12:01 +00:00
|
|
|
}
|
2002-02-26 16:30:14 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
2016-10-29 16:50:13 +02:00
|
|
|
void
|
|
|
|
channels_visible_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
items_visible_cmd_callback (action, image, GIMP_ITEM (channel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
channels_linked_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
items_linked_cmd_callback (action, image, GIMP_ITEM (channel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
channels_lock_content_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
items_lock_content_cmd_callback (action, image, GIMP_ITEM (channel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
channels_lock_position_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
items_lock_position_cmd_callback (action, image, GIMP_ITEM (channel));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
channels_color_tag_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
items_color_tag_cmd_callback (action, image, GIMP_ITEM (channel),
|
|
|
|
(GimpColorTag) value);
|
|
|
|
}
|
|
|
|
|
2017-11-16 01:26:19 +01:00
|
|
|
void
|
|
|
|
channels_select_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpChannel *channel;
|
|
|
|
GimpChannel *channel2;
|
|
|
|
GimpContainer *container;
|
|
|
|
return_if_no_channel (image, channel, data);
|
|
|
|
|
|
|
|
container = gimp_image_get_channels (image);
|
|
|
|
channel2 = (GimpChannel *) action_select_object ((GimpActionSelectType) value,
|
|
|
|
container,
|
|
|
|
(GimpObject *) channel);
|
|
|
|
|
|
|
|
if (channel2 && channel2 != channel)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_channel (image, channel2);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
}
|
2004-09-19 22:26:41 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2016-09-24 22:10:32 +02:00
|
|
|
channels_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannel *channel,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *channel_name,
|
|
|
|
const GimpRGB *channel_color,
|
|
|
|
gboolean save_selection,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_visible,
|
|
|
|
gboolean channel_linked,
|
2016-10-29 16:50:13 +02:00
|
|
|
GimpColorTag channel_color_tag,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_lock_content,
|
|
|
|
gboolean channel_lock_position,
|
2016-09-24 22:10:32 +02:00
|
|
|
gpointer user_data)
|
2004-09-19 22:26:41 +00:00
|
|
|
{
|
2016-09-24 22:10:32 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
"channel-new-name", channel_name,
|
|
|
|
"channel-new-color", channel_color,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (save_selection)
|
2004-09-19 22:26:41 +00:00
|
|
|
{
|
2016-09-24 22:10:32 +02:00
|
|
|
GimpChannel *selection = gimp_image_get_mask (image);
|
|
|
|
|
|
|
|
channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
|
|
|
|
GIMP_TYPE_CHANNEL));
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (channel),
|
|
|
|
config->channel_new_name);
|
|
|
|
gimp_channel_set_color (channel, &config->channel_new_color, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
channel = gimp_channel_new (image,
|
|
|
|
gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image),
|
|
|
|
config->channel_new_name,
|
|
|
|
&config->channel_new_color);
|
|
|
|
|
|
|
|
gimp_drawable_fill (GIMP_DRAWABLE (channel), context,
|
|
|
|
GIMP_FILL_TRANSPARENT);
|
2004-09-19 22:26:41 +00:00
|
|
|
}
|
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_item_set_visible (GIMP_ITEM (channel), channel_visible, FALSE);
|
|
|
|
gimp_item_set_linked (GIMP_ITEM (channel), channel_linked, FALSE);
|
2016-10-29 16:50:13 +02:00
|
|
|
gimp_item_set_color_tag (GIMP_ITEM (channel), channel_color_tag, FALSE);
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_item_set_lock_content (GIMP_ITEM (channel), channel_lock_content, FALSE);
|
|
|
|
gimp_item_set_lock_position (GIMP_ITEM (channel), channel_lock_position, FALSE);
|
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
gimp_image_add_channel (image, channel,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
2004-09-19 22:26:41 +00:00
|
|
|
}
|
2001-04-21 02:11:12 +00:00
|
|
|
|
|
|
|
static void
|
2016-09-24 22:10:32 +02:00
|
|
|
channels_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpChannel *channel,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *channel_name,
|
|
|
|
const GimpRGB *channel_color,
|
|
|
|
gboolean save_selection,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_visible,
|
|
|
|
gboolean channel_linked,
|
2016-10-29 16:50:13 +02:00
|
|
|
GimpColorTag channel_color_tag,
|
2016-10-26 16:51:56 +02:00
|
|
|
gboolean channel_lock_content,
|
|
|
|
gboolean channel_lock_position,
|
2016-09-24 22:10:32 +02:00
|
|
|
gpointer user_data)
|
2001-04-21 02:11:12 +00:00
|
|
|
{
|
2016-10-26 16:51:56 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (channel);
|
|
|
|
|
|
|
|
if (strcmp (channel_name, gimp_object_get_name (channel)) ||
|
|
|
|
gimp_rgba_distance (channel_color, &channel->color) > 0.0001 ||
|
|
|
|
channel_visible != gimp_item_get_visible (item) ||
|
|
|
|
channel_linked != gimp_item_get_linked (item) ||
|
2016-10-29 16:50:13 +02:00
|
|
|
channel_color_tag != gimp_item_get_color_tag (item) ||
|
2016-10-26 16:51:56 +02:00
|
|
|
channel_lock_content != gimp_item_get_lock_content (item) ||
|
|
|
|
channel_lock_position != gimp_item_get_lock_position (item))
|
2016-09-24 22:10:32 +02:00
|
|
|
{
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
|
|
|
_("Channel Attributes"));
|
2003-03-17 02:25:39 +00:00
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
if (strcmp (channel_name, gimp_object_get_name (channel)))
|
2016-09-24 22:10:32 +02:00
|
|
|
gimp_item_rename (GIMP_ITEM (channel), channel_name, NULL);
|
2003-03-17 02:25:39 +00:00
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
if (gimp_rgba_distance (channel_color, &channel->color) > 0.0001)
|
2016-09-24 22:10:32 +02:00
|
|
|
gimp_channel_set_color (channel, channel_color, TRUE);
|
2001-04-21 02:11:12 +00:00
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
if (channel_visible != gimp_item_get_visible (item))
|
|
|
|
gimp_item_set_visible (item, channel_visible, TRUE);
|
|
|
|
|
|
|
|
if (channel_linked != gimp_item_get_linked (item))
|
|
|
|
gimp_item_set_linked (item, channel_linked, TRUE);
|
|
|
|
|
2016-10-29 16:50:13 +02:00
|
|
|
if (channel_color_tag != gimp_item_get_color_tag (item))
|
|
|
|
gimp_item_set_color_tag (item, channel_color_tag, TRUE);
|
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
if (channel_lock_content != gimp_item_get_lock_content (item))
|
|
|
|
gimp_item_set_lock_content (item, channel_lock_content, TRUE);
|
|
|
|
|
|
|
|
if (channel_lock_position != gimp_item_get_lock_position (item))
|
|
|
|
gimp_item_set_lock_position (item, channel_lock_position, TRUE);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
2003-11-06 15:27:05 +00:00
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
gimp_image_flush (image);
|
2001-04-21 02:11:12 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 22:10:32 +02:00
|
|
|
gtk_widget_destroy (dialog);
|
2002-02-26 16:30:14 +00:00
|
|
|
}
|