From 63e5c0471697d5a70982af6226d548593cc6e3b8 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 10 Jun 2004 14:25:04 +0000 Subject: [PATCH] app/actions/image-actions.c app/actions/image-commands.[ch] 2004-06-10 Michael Natterer * app/actions/image-actions.c * app/actions/image-commands.[ch] * app/actions/layers-actions.c * app/actions/layers-commands.[ch]: made the "image-convert-rgb/grayscale/indexed" and the "layers-mask-apply/delete" actions GimpEnumActions and merged their callbacks. --- ChangeLog | 12 +++++++- app/actions/image-actions.c | 38 ++++++++++++++--------- app/actions/image-commands.c | 43 ++++++++++---------------- app/actions/image-commands.h | 57 +++++++++++++++++------------------ app/actions/layers-actions.c | 28 +++++++++++------ app/actions/layers-commands.c | 25 +++++---------- app/actions/layers-commands.h | 3 +- 7 files changed, 103 insertions(+), 103 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0745957126..13c1b53db0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,17 @@ +2004-06-10 Michael Natterer + + * app/actions/image-actions.c + * app/actions/image-commands.[ch] + * app/actions/layers-actions.c + * app/actions/layers-commands.[ch]: made the + "image-convert-rgb/grayscale/indexed" and the + "layers-mask-apply/delete" actions GimpEnumActions and merged + their callbacks. + 2004-06-10 Philip Lafleur * app/gui/preferences-dialog.c: restored the 'Show Paint Tool - Cursor' option that was removed during clean-up. + Cursor' option that was removed during clean-up. 2004-06-10 Philip Lafleur diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c index 99cdf0596d..5f72c48a5d 100644 --- a/app/actions/image-actions.c +++ b/app/actions/image-actions.c @@ -67,21 +67,6 @@ static GimpActionEntry image_actions[] = G_CALLBACK (image_new_from_image_cmd_callback), GIMP_HELP_FILE_NEW }, - { "image-convert-rgb", GIMP_STOCK_CONVERT_RGB, - N_("_RGB"), NULL, NULL, - G_CALLBACK (image_convert_rgb_cmd_callback), - GIMP_HELP_IMAGE_CONVERT_RGB }, - - { "image-convert-grayscale", GIMP_STOCK_CONVERT_GRAYSCALE, - N_("_Grayscale"), NULL, NULL, - G_CALLBACK (image_convert_grayscale_cmd_callback), - GIMP_HELP_IMAGE_CONVERT_GRAYSCALE }, - - { "image-convert-indexed", GIMP_STOCK_CONVERT_INDEXED, - N_("_Indexed..."), NULL, NULL, - G_CALLBACK (image_convert_indexed_cmd_callback), - GIMP_HELP_IMAGE_CONVERT_INDEXED }, - { "image-resize", GIMP_STOCK_RESIZE, N_("Can_vas Size..."), NULL, NULL, G_CALLBACK (image_resize_cmd_callback), @@ -118,6 +103,24 @@ static GimpActionEntry image_actions[] = GIMP_HELP_IMAGE_GRID } }; +static GimpEnumActionEntry image_convert_actions[] = +{ + { "image-convert-rgb", GIMP_STOCK_CONVERT_RGB, + N_("_RGB"), NULL, NULL, + GIMP_RGB, + GIMP_HELP_IMAGE_CONVERT_RGB }, + + { "image-convert-grayscale", GIMP_STOCK_CONVERT_GRAYSCALE, + N_("_Grayscale"), NULL, NULL, + GIMP_GRAY, + GIMP_HELP_IMAGE_CONVERT_GRAYSCALE }, + + { "image-convert-indexed", GIMP_STOCK_CONVERT_INDEXED, + N_("_Indexed..."), NULL, NULL, + GIMP_INDEXED, + GIMP_HELP_IMAGE_CONVERT_INDEXED } +}; + static GimpEnumActionEntry image_flip_actions[] = { { "image-flip-horizontal", GIMP_STOCK_FLIP_HORIZONTAL, @@ -158,6 +161,11 @@ image_actions_setup (GimpActionGroup *group) image_actions, G_N_ELEMENTS (image_actions)); + gimp_action_group_add_enum_actions (group, + image_convert_actions, + G_N_ELEMENTS (image_convert_actions), + G_CALLBACK (image_convert_cmd_callback)); + gimp_action_group_add_enum_actions (group, image_flip_actions, G_N_ELEMENTS (image_flip_actions), diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c index 78fbb5f2dc..3ca89e4d3b 100644 --- a/app/actions/image-commands.c +++ b/app/actions/image-commands.c @@ -144,39 +144,28 @@ image_new_from_image_cmd_callback (GtkAction *action, } void -image_convert_rgb_cmd_callback (GtkAction *action, - gpointer data) -{ - GimpImage *gimage; - return_if_no_image (gimage, data); - - gimp_image_convert (gimage, GIMP_RGB, 0, 0, FALSE, FALSE, 0, NULL); - gimp_image_flush (gimage); -} - -void -image_convert_grayscale_cmd_callback (GtkAction *action, - gpointer data) -{ - GimpImage *gimage; - return_if_no_image (gimage, data); - - gimp_image_convert (gimage, GIMP_GRAY, 0, 0, FALSE, FALSE, 0, NULL); - gimp_image_flush (gimage); -} - -void -image_convert_indexed_cmd_callback (GtkAction *action, - gpointer data) +image_convert_cmd_callback (GtkAction *action, + gint value, + gpointer data) { GimpImage *gimage; GtkWidget *widget; - GtkWidget *dialog; return_if_no_image (gimage, data); return_if_no_widget (widget, data); - dialog = convert_dialog_new (gimage, widget); - gtk_widget_show (dialog); + switch ((GimpImageBaseType) value) + { + case GIMP_RGB: + case GIMP_GRAY: + gimp_image_convert (gimage, (GimpImageBaseType) value, + 0, 0, FALSE, FALSE, 0, NULL); + gimp_image_flush (gimage); + break; + + case GIMP_INDEXED: + gtk_widget_show (convert_dialog_new (gimage, widget)); + break; + } } void diff --git a/app/actions/image-commands.h b/app/actions/image-commands.h index 45c05e5e6a..f957605703 100644 --- a/app/actions/image-commands.h +++ b/app/actions/image-commands.h @@ -20,41 +20,38 @@ #define __IMAGE_COMMANDS_H__ -void image_new_cmd_callback (GtkAction *action, - gpointer data); -void image_new_from_image_cmd_callback (GtkAction *action, - gpointer data); +void image_new_cmd_callback (GtkAction *action, + gpointer data); +void image_new_from_image_cmd_callback (GtkAction *action, + gpointer data); -void image_convert_rgb_cmd_callback (GtkAction *action, - gpointer data); -void image_convert_grayscale_cmd_callback (GtkAction *action, - gpointer data); -void image_convert_indexed_cmd_callback (GtkAction *action, - gpointer data); +void image_convert_cmd_callback (GtkAction *action, + gint value, + gpointer data); -void image_resize_cmd_callback (GtkAction *action, - gpointer data); -void image_scale_cmd_callback (GtkAction *action, - gpointer data); -void image_flip_cmd_callback (GtkAction *action, - gint value, - gpointer data); -void image_rotate_cmd_callback (GtkAction *action, - gint value, - gpointer data); -void image_crop_cmd_callback (GtkAction *action, - gpointer data); +void image_resize_cmd_callback (GtkAction *action, + gpointer data); +void image_scale_cmd_callback (GtkAction *action, + gpointer data); +void image_flip_cmd_callback (GtkAction *action, + gint value, + gpointer data); +void image_rotate_cmd_callback (GtkAction *action, + gint value, + gpointer data); +void image_crop_cmd_callback (GtkAction *action, + gpointer data); -void image_duplicate_cmd_callback (GtkAction *action, - gpointer data); +void image_duplicate_cmd_callback (GtkAction *action, + gpointer data); -void image_merge_layers_cmd_callback (GtkAction *action, - gpointer data); -void image_flatten_image_cmd_callback (GtkAction *action, - gpointer data); +void image_merge_layers_cmd_callback (GtkAction *action, + gpointer data); +void image_flatten_image_cmd_callback (GtkAction *action, + gpointer data); -void image_configure_grid_cmd_callback (GtkAction *action, - gpointer data); +void image_configure_grid_cmd_callback (GtkAction *action, + gpointer data); #endif /* __IMAGE_COMMANDS_H__ */ diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c index 058f123fa7..93384959e5 100644 --- a/app/actions/layers-actions.c +++ b/app/actions/layers-actions.c @@ -170,22 +170,25 @@ static GimpActionEntry layers_actions[] = G_CALLBACK (layers_mask_add_cmd_callback), GIMP_HELP_LAYER_MASK_ADD }, - { "layers-mask-apply", NULL, - N_("Apply Layer _Mask"), NULL, NULL, - G_CALLBACK (layers_mask_apply_cmd_callback), - GIMP_HELP_LAYER_MASK_APPLY }, - - { "layers-mask-delete", GTK_STOCK_DELETE, - N_("Delete Layer Mas_k"), "", NULL, - G_CALLBACK (layers_mask_delete_cmd_callback), - GIMP_HELP_LAYER_MASK_DELETE }, - { "layers-alpha-add", GIMP_STOCK_TRANSPARENCY, N_("Add Alpha C_hannel"), NULL, NULL, G_CALLBACK (layers_alpha_add_cmd_callback), GIMP_HELP_LAYER_ALPHA_ADD } }; +static GimpEnumActionEntry layers_mask_apply_actions[] = +{ + { "layers-mask-apply", NULL, + N_("Apply Layer _Mask"), NULL, NULL, + GIMP_MASK_APPLY, + GIMP_HELP_LAYER_MASK_APPLY }, + + { "layers-mask-delete", GTK_STOCK_DELETE, + N_("Delete Layer Mas_k"), "", NULL, + GIMP_MASK_DISCARD, + GIMP_HELP_LAYER_MASK_DELETE } +}; + static GimpEnumActionEntry layers_mask_to_selection_actions[] = { { "layers-mask-selection-replace", GIMP_STOCK_SELECTION_REPLACE, @@ -239,6 +242,11 @@ layers_actions_setup (GimpActionGroup *group) layers_actions, G_N_ELEMENTS (layers_actions)); + gimp_action_group_add_enum_actions (group, + layers_mask_apply_actions, + G_N_ELEMENTS (layers_mask_apply_actions), + G_CALLBACK (layers_mask_apply_cmd_callback)); + gimp_action_group_add_enum_actions (group, layers_mask_to_selection_actions, G_N_ELEMENTS (layers_mask_to_selection_actions), diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index e249fbe100..fc3261fe35 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -424,30 +424,19 @@ layers_mask_add_cmd_callback (GtkAction *action, void layers_mask_apply_cmd_callback (GtkAction *action, + gint value, gpointer data) { - GimpImage *gimage; - GimpLayer *layer; + GimpImage *gimage; + GimpLayer *layer; + GimpMaskApplyMode mode; return_if_no_layer (gimage, layer, data); + mode = (GimpMaskApplyMode) value; + if (gimp_layer_get_mask (layer)) { - gimp_layer_apply_mask (layer, GIMP_MASK_APPLY, TRUE); - gimp_image_flush (gimage); - } -} - -void -layers_mask_delete_cmd_callback (GtkAction *action, - gpointer data) -{ - GimpImage *gimage; - GimpLayer *layer; - return_if_no_layer (gimage, layer, data); - - if (gimp_layer_get_mask (layer)) - { - gimp_layer_apply_mask (layer, GIMP_MASK_DISCARD, TRUE); + gimp_layer_apply_mask (layer, mode, TRUE); gimp_image_flush (gimage); } } diff --git a/app/actions/layers-commands.h b/app/actions/layers-commands.h index 946546a7d3..840219a621 100644 --- a/app/actions/layers-commands.h +++ b/app/actions/layers-commands.h @@ -68,8 +68,7 @@ void layers_crop_cmd_callback (GtkAction *action, void layers_mask_add_cmd_callback (GtkAction *action, gpointer data); void layers_mask_apply_cmd_callback (GtkAction *action, - gpointer data); -void layers_mask_delete_cmd_callback (GtkAction *action, + gint value, gpointer data); void layers_mask_to_selection_cmd_callback (GtkAction *action, gint value,