Commit 1e9c264a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

moved "Merge Layers" and "Flatten Image" from "Layer/" to "Image/",

2002-02-13  Michael Natterer  <mitch@gimp.org>

	* app/gui/menus.c: moved "Merge Layers" and "Flatten Image" from
	"Layer/" to "Image/", removed them from the "<Layers>" menu
	entirely, moved "Merge Down" after "Anchor Layer" in both menus.

	* app/gui/image-commands.[ch]: moved callbacks from here...

	* app/gui/layers-commands.[ch]: ...to here.

	* app/gui/layers-commands.[ch]
	* app/display/gimpdisplayshell.c: changed menu_update functions
	accordingly.
parent ebc12901
2002-02-13 Michael Natterer <mitch@gimp.org>
* app/gui/menus.c: moved "Merge Layers" and "Flatten Image" from
"Layer/" to "Image/", removed them from the "<Layers>" menu
entirely, moved "Merge Down" after "Anchor Layer" in both menus.
* app/gui/image-commands.[ch]: moved callbacks from here...
* app/gui/layers-commands.[ch]: ...to here.
* app/gui/layers-commands.[ch]
* app/display/gimpdisplayshell.c: changed menu_update functions
accordingly.
2002-02-12 Nathan Summers <rock@gimp.org>
* plug-ins/tools/.cvsignore
......
......@@ -28,6 +28,7 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-resize.h"
#include "core/gimpimage-scale.h"
......@@ -35,6 +36,7 @@
#include "display/gimpdisplay-foreach.h"
#include "convert-dialog.h"
#include "image-commands.h"
#include "resize-dialog.h"
#include "gimpprogress.h"
......@@ -195,6 +197,124 @@ image_duplicate_cmd_callback (GtkWidget *widget,
g_object_unref (G_OBJECT (new_gimage));
}
void
image_merge_layers_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
image_layers_merge_query (gimage, TRUE);
}
void
image_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
gimp_image_flatten (gimage);
gdisplays_flush ();
}
/****************************/
/* The layer merge dialog */
/****************************/
typedef struct _LayerMergeOptions LayerMergeOptions;
struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
gboolean merge_visible;
MergeType merge_type;
};
static void
image_layers_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GimpImage *gimage;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
if (options->merge_visible)
gimp_image_merge_visible_layers (gimage, options->merge_type);
gdisplays_flush ();
gtk_widget_destroy (options->query_box);
}
void
image_layers_merge_query (GimpImage *gimage,
/* if FALSE, anchor active layer */
gboolean merge_visible)
{
LayerMergeOptions *options;
GtkWidget *vbox;
GtkWidget *frame;
/* The new options structure */
options = g_new (LayerMergeOptions, 1);
options->gimage = gimage;
options->merge_visible = merge_visible;
options->merge_type = EXPAND_AS_NECESSARY;
/* The dialog */
options->query_box =
gimp_dialog_new (_("Layers Merge Options"), "layers_merge_options",
gimp_standard_help_func,
"dialogs/layers/merge_visible_layers.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, image_layers_merge_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
frame = gimp_radio_group_new2 (TRUE,
merge_visible ?
_("Final, Merged Layer should be:") :
_("Final, Anchored Layer should be:"),
G_CALLBACK (gimp_radio_button_update),
&options->merge_type,
GINT_TO_POINTER (options->merge_type),
_("Expanded as necessary"),
GINT_TO_POINTER (EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
gtk_widget_show (vbox);
gtk_widget_show (options->query_box);
}
/* private functions */
......
......@@ -26,12 +26,22 @@ void image_convert_grayscale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_convert_indexed_cmd_callback (GtkWidget *widget,
gpointer data);
void image_resize_cmd_callback (GtkWidget *widget,
gpointer data);
void image_scale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_duplicate_cmd_callback (GtkWidget *widget,
gpointer data);
void image_merge_layers_cmd_callback (GtkWidget *widet,
gpointer data);
void image_flatten_image_cmd_callback (GtkWidget *widet,
gpointer data);
void image_layers_merge_query (GimpImage *gimage,
gboolean merge_visible);
#endif /* __IMAGE_COMMANDS_H__ */
......@@ -67,7 +67,7 @@ static void layers_resize_layer_query (GimpImage *gimage,
#define return_if_no_image(gimage) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! gimage) \
if (GIMP_IS_IMAGE (gimage)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
if (! gimage) \
return
......@@ -207,6 +207,18 @@ layers_anchor_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
layers_merge_down_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage);
gimp_image_merge_down (gimage, gimp_image_get_active_layer (gimage),
EXPAND_AS_NECESSARY);
gdisplays_flush ();
}
void
layers_delete_cmd_callback (GtkWidget *widget,
gpointer data)
......@@ -399,39 +411,6 @@ layers_delete_layer_mask_cmd_callback (GtkWidget *widget,
}
}
void
layers_merge_layers_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage);
layers_layer_merge_query (gimage, TRUE);
}
void
layers_merge_down_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage);
gimp_image_merge_down (gimage, gimp_image_get_active_layer (gimage),
EXPAND_AS_NECESSARY);
gdisplays_flush ();
}
void
layers_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage);
gimp_image_flatten (gimage);
gdisplays_flush ();
}
void
layers_alpha_select_cmd_callback (GtkWidget *widget,
gpointer data)
......@@ -1164,104 +1143,6 @@ layers_resize_layer_query (GimpImage *gimage,
gtk_widget_show (options->resize->resize_shell);
}
/****************************/
/* The layer merge dialog */
/****************************/
typedef struct _LayerMergeOptions LayerMergeOptions;
struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
gboolean merge_visible;
MergeType merge_type;
};
static void
layer_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GimpImage *gimage;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
if (options->merge_visible)
gimp_image_merge_visible_layers (gimage, options->merge_type);
gdisplays_flush ();
gtk_widget_destroy (options->query_box);
}
void
layers_layer_merge_query (GimpImage *gimage,
/* if FALSE, anchor active layer */
gboolean merge_visible)
{
LayerMergeOptions *options;
GtkWidget *vbox;
GtkWidget *frame;
/* The new options structure */
options = g_new (LayerMergeOptions, 1);
options->gimage = gimage;
options->merge_visible = merge_visible;
options->merge_type = EXPAND_AS_NECESSARY;
/* The dialog */
options->query_box =
gimp_dialog_new (_("Layer Merge Options"), "layer_merge_options",
gimp_standard_help_func,
"dialogs/layers/merge_visible_layers.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, layer_merge_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
frame = gimp_radio_group_new2 (TRUE,
merge_visible ?
_("Final, Merged Layer should be:") :
_("Final, Anchored Layer should be:"),
G_CALLBACK (gimp_radio_button_update),
&options->merge_type,
GINT_TO_POINTER (options->merge_type),
_("Expanded as necessary"),
GINT_TO_POINTER (EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
gtk_widget_show (vbox);
gtk_widget_show (options->query_box);
}
void
layers_menu_update (GtkItemFactory *factory,
gpointer data)
......@@ -1326,16 +1207,13 @@ layers_menu_update (GtkItemFactory *factory,
SET_SENSITIVE ("/Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("/Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("/Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("/Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("/Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("/Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("/Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("/Apply Layer Mask", !fs && !ac && gimage && lm && lp);
......
......@@ -39,6 +39,8 @@ void layers_duplicate_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_anchor_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_merge_down_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_delete_cmd_callback (GtkWidget *widet,
gpointer data);
......@@ -65,13 +67,6 @@ void layers_apply_layer_mask_cmd_callback (GtkWidget *widet,
void layers_delete_layer_mask_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_merge_layers_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_merge_down_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_flatten_image_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_alpha_select_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_mask_select_cmd_callback (GtkWidget *widet,
......@@ -88,8 +83,5 @@ void layers_new_layer_query (GimpImage *gimage,
GimpLayer *tamplate);
void layers_edit_layer_query (GimpLayer *layer);
void layers_layer_merge_query (GimpImage *gimage,
gboolean merge_visible);
#endif /* __LAYERS_COMMANDS_H__ */
......@@ -971,6 +971,9 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Image/Mode/Indexed...", (base_type != GIMP_INDEXED));
}
SET_SENSITIVE ("Image/Merge Visible Layers...", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Image/Flatten Image", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Stack", gdisp);
if (gdisp)
{
......@@ -991,6 +994,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Layer/New Layer...", gdisp);
SET_SENSITIVE ("Layer/Duplicate Layer", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Anchor Layer", gdisp && fs && !aux && lp);
SET_SENSITIVE ("Layer/Merge Down", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Delete Layer", gdisp && !aux && lp);
SET_SENSITIVE ("Layer/Layer Boundary Size...", gdisp && !aux && lp);
......@@ -999,10 +1003,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Layer/Transform/Offset...", lp);
SET_SENSITIVE ("Layer/Merge Visible Layers...", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Merge Down", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Flatten Image", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Colors", gdisp);
SET_SENSITIVE ("Layer/Colors/Auto", gdisp);
......
......@@ -971,6 +971,9 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Image/Mode/Indexed...", (base_type != GIMP_INDEXED));
}
SET_SENSITIVE ("Image/Merge Visible Layers...", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Image/Flatten Image", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Stack", gdisp);
if (gdisp)
{
......@@ -991,6 +994,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Layer/New Layer...", gdisp);
SET_SENSITIVE ("Layer/Duplicate Layer", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Anchor Layer", gdisp && fs && !aux && lp);
SET_SENSITIVE ("Layer/Merge Down", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Delete Layer", gdisp && !aux && lp);
SET_SENSITIVE ("Layer/Layer Boundary Size...", gdisp && !aux && lp);
......@@ -999,10 +1003,6 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Layer/Transform/Offset...", lp);
SET_SENSITIVE ("Layer/Merge Visible Layers...", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Merge Down", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Flatten Image", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("Layer/Colors", gdisp);
SET_SENSITIVE ("Layer/Colors/Auto", gdisp);
......
......@@ -28,6 +28,7 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage-resize.h"
#include "core/gimpimage-scale.h"
......@@ -35,6 +36,7 @@
#include "display/gimpdisplay-foreach.h"
#include "convert-dialog.h"
#include "image-commands.h"
#include "resize-dialog.h"
#include "gimpprogress.h"
......@@ -195,6 +197,124 @@ image_duplicate_cmd_callback (GtkWidget *widget,
g_object_unref (G_OBJECT (new_gimage));
}
void
image_merge_layers_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
image_layers_merge_query (gimage, TRUE);
}
void
image_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
gimp_image_flatten (gimage);
gdisplays_flush ();
}
/****************************/
/* The layer merge dialog */
/****************************/
typedef struct _LayerMergeOptions LayerMergeOptions;
struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
gboolean merge_visible;
MergeType merge_type;
};
static void
image_layers_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GimpImage *gimage;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
if (options->merge_visible)
gimp_image_merge_visible_layers (gimage, options->merge_type);
gdisplays_flush ();
gtk_widget_destroy (options->query_box);
}
void
image_layers_merge_query (GimpImage *gimage,
/* if FALSE, anchor active layer */
gboolean merge_visible)
{
LayerMergeOptions *options;
GtkWidget *vbox;
GtkWidget *frame;
/* The new options structure */
options = g_new (LayerMergeOptions, 1);
options->gimage = gimage;
options->merge_visible = merge_visible;
options->merge_type = EXPAND_AS_NECESSARY;
/* The dialog */
options->query_box =
gimp_dialog_new (_("Layers Merge Options"), "layers_merge_options",
gimp_standard_help_func,
"dialogs/layers/merge_visible_layers.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, image_layers_merge_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
frame = gimp_radio_group_new2 (TRUE,
merge_visible ?
_("Final, Merged Layer should be:") :
_("Final, Anchored Layer should be:"),
G_CALLBACK (gimp_radio_button_update),
&options->merge_type,
GINT_TO_POINTER (options->merge_type),
_("Expanded as necessary"),
GINT_TO_POINTER (EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
gtk_widget_show (vbox);
gtk_widget_show (options->query_box);
}
/* private functions */
......
......@@ -26,12 +26,22 @@ void image_convert_grayscale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_convert_indexed_cmd_callback (GtkWidget *widget,
gpointer data);
void image_resize_cmd_callback (GtkWidget *widget,
gpointer data);
void image_scale_cmd_callback (GtkWidget *widget,
gpointer data);
void image_duplicate_cmd_callback (GtkWidget *widget,
gpointer data);
void image_merge_layers_cmd_callback (GtkWidget *widet,
gpointer data);
void image_flatten_image_cmd_callback (GtkWidget *widet,
gpointer data);
void image_layers_merge_query (GimpImage *gimage,