mirror of https://github.com/GNOME/gimp.git
app: make the ChannelOptionsDialog private
and provide a custom callback instead. Also attach the "New Layer", "Edit Layer Attributes" and "Configure Quick Mask" dialogs to their image/channel.
This commit is contained in:
parent
c2f264f5ca
commit
e703f8482e
|
@ -44,6 +44,7 @@
|
|||
#include "widgets/gimpdock.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "dialogs/channel-options-dialog.h"
|
||||
|
||||
#include "actions.h"
|
||||
|
@ -54,12 +55,22 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void channels_new_channel_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *options);
|
||||
static void channels_edit_channel_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *options);
|
||||
static void channels_new_callback (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
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,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -68,14 +79,20 @@ void
|
|||
channels_edit_attributes_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
ChannelOptionsDialog *options;
|
||||
GimpImage *image;
|
||||
GimpChannel *channel;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_channel (image, channel, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
options = channel_options_dialog_new (image, channel,
|
||||
#define EDIT_DIALOG_KEY "gimp-channel-edit-attributes-dialog"
|
||||
|
||||
dialog = dialogs_get_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY);
|
||||
|
||||
if (! dialog)
|
||||
{
|
||||
dialog = channel_options_dialog_new (image, channel,
|
||||
action_data_get_context (data),
|
||||
widget,
|
||||
_("Channel Attributes"),
|
||||
|
@ -83,33 +100,39 @@ channels_edit_attributes_cmd_callback (GtkAction *action,
|
|||
"gtk-edit",
|
||||
_("Edit Channel Attributes"),
|
||||
GIMP_HELP_CHANNEL_EDIT,
|
||||
&channel->color,
|
||||
gimp_object_get_name (channel),
|
||||
&channel->color,
|
||||
_("Edit Channel Color"),
|
||||
_("_Fill opacity:"),
|
||||
FALSE);
|
||||
FALSE,
|
||||
channels_edit_attributes_callback,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (options->dialog, "response",
|
||||
G_CALLBACK (channels_edit_channel_response),
|
||||
options);
|
||||
dialogs_attach_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY, dialog);
|
||||
}
|
||||
|
||||
gtk_widget_show (options->dialog);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
void
|
||||
channels_new_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
ChannelOptionsDialog *options;
|
||||
GimpImage *image;
|
||||
GtkWidget *widget;
|
||||
GimpDialogConfig *config;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_image (image, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||
#define NEW_DIALOG_KEY "gimp-channel-new-dialog"
|
||||
|
||||
options = channel_options_dialog_new (image, NULL,
|
||||
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"),
|
||||
|
@ -117,17 +140,18 @@ channels_new_cmd_callback (GtkAction *action,
|
|||
GIMP_STOCK_CHANNEL,
|
||||
_("New Channel Options"),
|
||||
GIMP_HELP_CHANNEL_NEW,
|
||||
&config->channel_new_color,
|
||||
config->channel_new_name,
|
||||
&config->channel_new_color,
|
||||
_("New Channel Color"),
|
||||
_("_Fill opacity:"),
|
||||
TRUE);
|
||||
TRUE,
|
||||
channels_new_callback,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (options->dialog, "response",
|
||||
G_CALLBACK (channels_new_channel_response),
|
||||
options);
|
||||
dialogs_attach_dialog (G_OBJECT (image), NEW_DIALOG_KEY, dialog);
|
||||
}
|
||||
|
||||
gtk_widget_show (options->dialog);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -325,30 +349,25 @@ channels_to_selection_cmd_callback (GtkAction *action,
|
|||
/* private functions */
|
||||
|
||||
static void
|
||||
channels_new_channel_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *dialog)
|
||||
channels_new_callback (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GimpDialogConfig *config;
|
||||
GimpChannel *channel;
|
||||
GimpRGB channel_color;
|
||||
|
||||
config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (dialog->color_panel),
|
||||
&channel_color);
|
||||
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||
|
||||
g_object_set (config,
|
||||
"channel-new-name",
|
||||
gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)),
|
||||
"channel-new-color", &channel_color,
|
||||
"channel-new-name", channel_name,
|
||||
"channel-new-color", channel_color,
|
||||
NULL);
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->save_sel_checkbutton)))
|
||||
if (save_selection)
|
||||
{
|
||||
GimpChannel *selection = gimp_image_get_mask (dialog->image);
|
||||
GimpChannel *selection = gimp_image_get_mask (image);
|
||||
|
||||
channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
|
||||
GIMP_TYPE_CHANNEL));
|
||||
|
@ -359,67 +378,60 @@ channels_new_channel_response (GtkWidget *widget,
|
|||
}
|
||||
else
|
||||
{
|
||||
channel = gimp_channel_new (dialog->image,
|
||||
gimp_image_get_width (dialog->image),
|
||||
gimp_image_get_height (dialog->image),
|
||||
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),
|
||||
dialog->context,
|
||||
gimp_drawable_fill (GIMP_DRAWABLE (channel), context,
|
||||
GIMP_FILL_TRANSPARENT);
|
||||
}
|
||||
|
||||
gimp_image_add_channel (dialog->image, channel,
|
||||
gimp_image_add_channel (image, channel,
|
||||
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
||||
gimp_image_flush (image);
|
||||
|
||||
gimp_image_flush (dialog->image);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog->dialog);
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
channels_edit_channel_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *options)
|
||||
channels_edit_attributes_callback (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GimpChannel *channel = options->channel;
|
||||
const gchar *new_name;
|
||||
GimpRGB color;
|
||||
gboolean name_changed = FALSE;
|
||||
gboolean color_changed = FALSE;
|
||||
|
||||
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&color);
|
||||
|
||||
if (strcmp (new_name, gimp_object_get_name (channel)))
|
||||
if (strcmp (channel_name, gimp_object_get_name (channel)))
|
||||
name_changed = TRUE;
|
||||
|
||||
if (gimp_rgba_distance (&color, &channel->color) > 0.0001)
|
||||
if (gimp_rgba_distance (channel_color, &channel->color) > 0.0001)
|
||||
color_changed = TRUE;
|
||||
|
||||
if (name_changed || color_changed)
|
||||
{
|
||||
if (name_changed && color_changed)
|
||||
gimp_image_undo_group_start (options->image,
|
||||
gimp_image_undo_group_start (image,
|
||||
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
||||
_("Channel Attributes"));
|
||||
|
||||
if (name_changed)
|
||||
gimp_item_rename (GIMP_ITEM (channel), new_name, NULL);
|
||||
gimp_item_rename (GIMP_ITEM (channel), channel_name, NULL);
|
||||
|
||||
if (color_changed)
|
||||
gimp_channel_set_color (channel, &color, TRUE);
|
||||
gimp_channel_set_color (channel, channel_color, TRUE);
|
||||
|
||||
if (name_changed && color_changed)
|
||||
gimp_image_undo_group_end (options->image);
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
if (name_changed || color_changed)
|
||||
gimp_image_flush (options->image);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (options->dialog);
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "dialogs/channel-options-dialog.h"
|
||||
|
||||
#include "actions.h"
|
||||
|
@ -42,9 +43,14 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void quick_mask_configure_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *options);
|
||||
static void quick_mask_configure_callback (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
/* public functionss */
|
||||
|
@ -88,16 +94,23 @@ void
|
|||
quick_mask_configure_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
ChannelOptionsDialog *options;
|
||||
GimpImage *image;
|
||||
GtkWidget *widget;
|
||||
GimpRGB color;
|
||||
GtkWidget *dialog;
|
||||
return_if_no_image (image, data);
|
||||
return_if_no_widget (widget, data);
|
||||
|
||||
#define CONFIGURE_DIALOG_KEY "gimp-image-quick-mask-configure-dialog"
|
||||
|
||||
dialog = dialogs_get_dialog (G_OBJECT (image), CONFIGURE_DIALOG_KEY);
|
||||
|
||||
if (! dialog)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_image_get_quick_mask_color (image, &color);
|
||||
|
||||
options = channel_options_dialog_new (image, NULL,
|
||||
dialog = channel_options_dialog_new (image, NULL,
|
||||
action_data_get_context (data),
|
||||
widget,
|
||||
_("Quick Mask Attributes"),
|
||||
|
@ -105,43 +118,42 @@ quick_mask_configure_cmd_callback (GtkAction *action,
|
|||
GIMP_STOCK_QUICK_MASK_ON,
|
||||
_("Edit Quick Mask Attributes"),
|
||||
GIMP_HELP_QUICK_MASK_EDIT,
|
||||
&color,
|
||||
NULL,
|
||||
&color,
|
||||
_("Edit Quick Mask Color"),
|
||||
_("_Mask opacity:"),
|
||||
FALSE);
|
||||
FALSE,
|
||||
quick_mask_configure_callback,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (options->dialog, "response",
|
||||
G_CALLBACK (quick_mask_configure_response),
|
||||
options);
|
||||
dialogs_attach_dialog (G_OBJECT (image), CONFIGURE_DIALOG_KEY, dialog);
|
||||
}
|
||||
|
||||
gtk_widget_show (options->dialog);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
quick_mask_configure_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *options)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
quick_mask_configure_callback (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpRGB old_color;
|
||||
GimpRGB new_color;
|
||||
|
||||
gimp_image_get_quick_mask_color (options->image, &old_color);
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
|
||||
&new_color);
|
||||
gimp_image_get_quick_mask_color (image, &old_color);
|
||||
|
||||
if (gimp_rgba_distance (&old_color, &new_color) > 0.0001)
|
||||
if (gimp_rgba_distance (&old_color, channel_color) > 0.0001)
|
||||
{
|
||||
gimp_image_set_quick_mask_color (options->image, &new_color);
|
||||
|
||||
gimp_image_flush (options->image);
|
||||
}
|
||||
gimp_image_set_quick_mask_color (image, channel_color);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (options->dialog);
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
|
|
@ -37,18 +37,37 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
typedef struct _ChannelOptionsDialog ChannelOptionsDialog;
|
||||
|
||||
struct _ChannelOptionsDialog
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpContext *context;
|
||||
GimpChannel *channel;
|
||||
GimpChannelOptionsCallback callback;
|
||||
gpointer user_data;
|
||||
|
||||
GtkWidget *name_entry;
|
||||
GtkWidget *color_panel;
|
||||
GtkWidget *save_sel_checkbutton;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void channel_options_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *private);
|
||||
static void channel_options_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data);
|
||||
static void channel_options_color_changed (GimpColorButton *button,
|
||||
gpointer data);
|
||||
static void channel_options_dialog_free (ChannelOptionsDialog *options);
|
||||
GimpColorButton *color_button);
|
||||
static void channel_options_color_changed (GimpColorButton *color_button,
|
||||
GtkAdjustment *adjustment);
|
||||
static void channel_options_dialog_free (ChannelOptionsDialog *private);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
ChannelOptionsDialog *
|
||||
GtkWidget *
|
||||
channel_options_dialog_new (GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
|
@ -58,13 +77,16 @@ channel_options_dialog_new (GimpImage *image,
|
|||
const gchar *icon_name,
|
||||
const gchar *desc,
|
||||
const gchar *help_id,
|
||||
const GimpRGB *channel_color,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
const gchar *color_label,
|
||||
const gchar *opacity_label,
|
||||
gboolean show_from_sel)
|
||||
gboolean show_from_sel,
|
||||
GimpChannelOptionsCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ChannelOptionsDialog *options;
|
||||
ChannelOptionsDialog *private;
|
||||
GtkWidget *dialog;
|
||||
GimpViewable *viewable;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
|
@ -83,27 +105,22 @@ channel_options_dialog_new (GimpImage *image,
|
|||
g_return_val_if_fail (channel_color != NULL, NULL);
|
||||
g_return_val_if_fail (color_label != NULL, NULL);
|
||||
g_return_val_if_fail (opacity_label != NULL, NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
options = g_slice_new0 (ChannelOptionsDialog);
|
||||
private = g_slice_new0 (ChannelOptionsDialog);
|
||||
|
||||
options->image = image;
|
||||
options->context = context;
|
||||
options->channel = channel;
|
||||
|
||||
options->color_panel = gimp_color_panel_new (color_label,
|
||||
channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (options->color_panel),
|
||||
context);
|
||||
private->image = image;
|
||||
private->channel = channel;
|
||||
private->context = context;
|
||||
private->callback = callback;
|
||||
private->user_data = user_data;
|
||||
|
||||
if (channel)
|
||||
viewable = GIMP_VIEWABLE (channel);
|
||||
else
|
||||
viewable = GIMP_VIEWABLE (image);
|
||||
|
||||
options->dialog =
|
||||
gimp_viewable_dialog_new (viewable, context,
|
||||
dialog = gimp_viewable_dialog_new (viewable, context,
|
||||
title, role, icon_name, desc,
|
||||
parent,
|
||||
gimp_standard_help_func, help_id,
|
||||
|
@ -113,18 +130,21 @@ channel_options_dialog_new (GimpImage *image,
|
|||
|
||||
NULL);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (options->dialog),
|
||||
(GWeakNotify) channel_options_dialog_free,
|
||||
options);
|
||||
|
||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (options->dialog),
|
||||
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (dialog),
|
||||
(GWeakNotify) channel_options_dialog_free, private);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (channel_options_dialog_response),
|
||||
private);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (options->dialog))),
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||
hbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -140,13 +160,13 @@ channel_options_dialog_new (GimpImage *image,
|
|||
|
||||
if (channel_name)
|
||||
{
|
||||
options->name_entry = gtk_entry_new ();
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (options->name_entry), TRUE);
|
||||
private->name_entry = gtk_entry_new ();
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (private->name_entry), TRUE);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Channel _name:"), 0.0, 0.5,
|
||||
options->name_entry, 2, FALSE);
|
||||
private->name_entry, 2, FALSE);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (options->name_entry), channel_name);
|
||||
gtk_entry_set_text (GTK_ENTRY (private->name_entry), channel_name);
|
||||
}
|
||||
|
||||
opacity_adj = gimp_scale_entry_new (GTK_TABLE (table),
|
||||
|
@ -157,54 +177,96 @@ channel_options_dialog_new (GimpImage *image,
|
|||
TRUE, 0.0, 0.0,
|
||||
NULL, NULL);
|
||||
|
||||
private->color_panel = gimp_color_panel_new (color_label,
|
||||
channel_color,
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS,
|
||||
48, 64);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (private->color_panel),
|
||||
context);
|
||||
|
||||
g_signal_connect (opacity_adj, "value-changed",
|
||||
G_CALLBACK (channel_options_opacity_update),
|
||||
options->color_panel);
|
||||
private->color_panel);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), options->color_panel,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), private->color_panel,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (options->color_panel);
|
||||
gtk_widget_show (private->color_panel);
|
||||
|
||||
g_signal_connect (options->color_panel, "color-changed",
|
||||
g_signal_connect (private->color_panel, "color-changed",
|
||||
G_CALLBACK (channel_options_color_changed),
|
||||
opacity_adj);
|
||||
|
||||
if (show_from_sel)
|
||||
{
|
||||
options->save_sel_checkbutton =
|
||||
private->save_sel_checkbutton =
|
||||
gtk_check_button_new_with_mnemonic (_("Initialize from _selection"));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), options->save_sel_checkbutton,
|
||||
gtk_box_pack_start (GTK_BOX (vbox), private->save_sel_checkbutton,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (options->save_sel_checkbutton);
|
||||
gtk_widget_show (private->save_sel_checkbutton);
|
||||
}
|
||||
|
||||
return options;
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
channel_options_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
ChannelOptionsDialog *private)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
const gchar *name = NULL;
|
||||
GimpRGB color;
|
||||
gboolean save_selection = FALSE;
|
||||
|
||||
if (private->name_entry)
|
||||
name = gtk_entry_get_text (GTK_ENTRY (private->name_entry));
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (private->color_panel),
|
||||
&color);
|
||||
|
||||
if (private->save_sel_checkbutton)
|
||||
save_selection =
|
||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (private->save_sel_checkbutton));
|
||||
|
||||
private->callback (dialog,
|
||||
private->image,
|
||||
private->channel,
|
||||
private->context,
|
||||
name,
|
||||
&color,
|
||||
save_selection,
|
||||
private->user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
channel_options_opacity_update (GtkAdjustment *adjustment,
|
||||
gpointer data)
|
||||
GimpColorButton *color_button)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_color_button_get_color (color_button, &color);
|
||||
gimp_rgb_set_alpha (&color, gtk_adjustment_get_value (adjustment) / 100.0);
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
|
||||
gimp_color_button_set_color (color_button, &color);
|
||||
}
|
||||
|
||||
static void
|
||||
channel_options_color_changed (GimpColorButton *button,
|
||||
gpointer data)
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_button_get_color (button, &color);
|
||||
gtk_adjustment_set_value (adj, color.a * 100.0);
|
||||
gtk_adjustment_set_value (adjustment, color.a * 100.0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -19,22 +19,17 @@
|
|||
#define __CHANNEL_OPTIONS_DIALOG_H__
|
||||
|
||||
|
||||
typedef struct _ChannelOptionsDialog ChannelOptionsDialog;
|
||||
|
||||
struct _ChannelOptionsDialog
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *name_entry;
|
||||
GtkWidget *color_panel;
|
||||
GtkWidget *save_sel_checkbutton;
|
||||
|
||||
GimpImage *image;
|
||||
GimpContext *context;
|
||||
GimpChannel *channel;
|
||||
};
|
||||
typedef void (* GimpChannelOptionsCallback) (GtkWidget *dialog,
|
||||
GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
gboolean save_selection,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
ChannelOptionsDialog * channel_options_dialog_new (GimpImage *image,
|
||||
GtkWidget * channel_options_dialog_new (GimpImage *image,
|
||||
GimpChannel *channel,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
|
@ -43,11 +38,13 @@ ChannelOptionsDialog * channel_options_dialog_new (GimpImage *image,
|
|||
const gchar *icon_name,
|
||||
const gchar *desc,
|
||||
const gchar *help_id,
|
||||
const GimpRGB *channel_color,
|
||||
const gchar *channel_name,
|
||||
const GimpRGB *channel_color,
|
||||
const gchar *color_label,
|
||||
const gchar *opacity_label,
|
||||
gboolean show_from_sel);
|
||||
gboolean show_from_sel,
|
||||
GimpChannelOptionsCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __CHANNEL_OPTIONS_DIALOG_H__ */
|
||||
|
|
Loading…
Reference in New Issue