From c28bd004a14441c10e7ff37aec809840b6b1d850 Mon Sep 17 00:00:00 2001 From: Nate Summers Date: Thu, 26 May 2005 04:12:31 +0000 Subject: [PATCH] added an "initialize from selection option to the new channel dialog * app/dialogs/channel-options-dialog.[ch]: added an "initialize from selection option to the new channel dialog * app/actions/channels-commands.c * app/actions/qmask-commands.c: modified accordingly --- app/actions/channels-commands.c | 37 ++++++++++++++++++++-------- app/actions/qmask-commands.c | 3 ++- app/actions/quick-mask-commands.c | 3 ++- app/dialogs/channel-options-dialog.c | 13 +++++++++- app/dialogs/channel-options-dialog.h | 4 ++- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/app/actions/channels-commands.c b/app/actions/channels-commands.c index 757fc16970..5b49514953 100644 --- a/app/actions/channels-commands.c +++ b/app/actions/channels-commands.c @@ -89,7 +89,8 @@ channels_edit_attributes_cmd_callback (GtkAction *action, _("Edit Channel Attributes"), GIMP_HELP_CHANNEL_EDIT, _("Edit Channel Color"), - _("Fill Opacity:")); + _("Fill Opacity:"), + FALSE); g_signal_connect (options->dialog, "response", G_CALLBACK (channels_edit_channel_response), @@ -121,7 +122,8 @@ channels_new_cmd_callback (GtkAction *action, _("New Channel Options"), GIMP_HELP_CHANNEL_NEW, _("New Channel Color"), - _("Fill Opacity:")); + _("Fill Opacity:"), + TRUE); g_signal_connect (options->dialog, "response", G_CALLBACK (channels_new_channel_response), @@ -333,15 +335,30 @@ channels_new_channel_response (GtkWidget *widget, gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel), &channel_color); - new_channel = gimp_channel_new (options->gimage, - options->gimage->width, - options->gimage->height, - channel_name, - &channel_color); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (options->save_sel_checkbutton))) + { + GimpChannel *selection; - gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel), - options->context, - GIMP_TRANSPARENT_FILL); + selection = gimp_image_get_mask(options->gimage); + + new_channel = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection), + GIMP_TYPE_CHANNEL, + FALSE)); + + gimp_object_set_name (GIMP_OBJECT (new_channel), channel_name); + } + else + { + new_channel = gimp_channel_new (options->gimage, + options->gimage->width, + options->gimage->height, + channel_name, + &channel_color); + + gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel), + options->context, + GIMP_TRANSPARENT_FILL); + } gimp_image_add_channel (options->gimage, new_channel, -1); gimp_image_flush (options->gimage); diff --git a/app/actions/qmask-commands.c b/app/actions/qmask-commands.c index 870eea941d..531dbae1e4 100644 --- a/app/actions/qmask-commands.c +++ b/app/actions/qmask-commands.c @@ -109,7 +109,8 @@ qmask_configure_cmd_callback (GtkAction *action, _("Edit Quick Mask Attributes"), GIMP_HELP_QMASK_EDIT, _("Edit Quick Mask Color"), - _("Mask Opacity:")); + _("Mask Opacity:"), + FALSE); g_signal_connect (options->dialog, "response", G_CALLBACK (qmask_configure_response), diff --git a/app/actions/quick-mask-commands.c b/app/actions/quick-mask-commands.c index 870eea941d..531dbae1e4 100644 --- a/app/actions/quick-mask-commands.c +++ b/app/actions/quick-mask-commands.c @@ -109,7 +109,8 @@ qmask_configure_cmd_callback (GtkAction *action, _("Edit Quick Mask Attributes"), GIMP_HELP_QMASK_EDIT, _("Edit Quick Mask Color"), - _("Mask Opacity:")); + _("Mask Opacity:"), + FALSE); g_signal_connect (options->dialog, "response", G_CALLBACK (qmask_configure_response), diff --git a/app/dialogs/channel-options-dialog.c b/app/dialogs/channel-options-dialog.c index e1e612d406..35f7274808 100644 --- a/app/dialogs/channel-options-dialog.c +++ b/app/dialogs/channel-options-dialog.c @@ -60,7 +60,8 @@ channel_options_dialog_new (GimpImage *gimage, const gchar *desc, const gchar *help_id, const gchar *color_label, - const gchar *opacity_label) + const gchar *opacity_label, + gboolean show_from_sel) { ChannelOptionsDialog *options; GimpViewable *viewable; @@ -165,6 +166,16 @@ channel_options_dialog_new (GimpImage *gimage, G_CALLBACK (channel_options_color_changed), opacity_adj); + if (show_from_sel) + { + options->save_sel_checkbutton = gtk_check_button_new_with_mnemonic (_("_Initialize From Selection")); + + gtk_box_pack_start (GTK_BOX (vbox), options->save_sel_checkbutton, + FALSE, FALSE, 0); + gtk_widget_show (options->save_sel_checkbutton); + } + else + options->save_sel_checkbutton = NULL; return options; } diff --git a/app/dialogs/channel-options-dialog.h b/app/dialogs/channel-options-dialog.h index a17c26e106..b079d5ce07 100644 --- a/app/dialogs/channel-options-dialog.h +++ b/app/dialogs/channel-options-dialog.h @@ -27,6 +27,7 @@ struct _ChannelOptionsDialog GtkWidget *dialog; GtkWidget *name_entry; GtkWidget *color_panel; + GtkWidget *save_sel_checkbutton; GimpImage *gimage; GimpContext *context; @@ -46,7 +47,8 @@ ChannelOptionsDialog * channel_options_dialog_new (GimpImage *gimage, const gchar *desc, const gchar *help_id, const gchar *color_label, - const gchar *opacity_label); + const gchar *opacity_label, + gboolean show_from_sel); #endif /* __CHANNEL_OPTIONS_DIALOG_H__ */