changed the GimpNewDrawableFunc typedef to take an additional

2001-12-17  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdrawablelistview.[ch]: changed
	the GimpNewDrawableFunc typedef to take an additional
	"GimpDrawable *template" paramater, added the "Drop to New"
	feature again by passing the dropped drawable to
	view->new_drawable_func().

	* app/gui/channels-commands.[ch]: channels_new_channel_query:
	* app/gui/layers-commands.[ch]: layers_new_layer_query:

	Added the "template" parameter because they are used as the
	views' new_drawable_func(), create layers/channels with
	the template's properties if a template is passed.
This commit is contained in:
Michael Natterer 2001-12-17 13:41:23 +00:00 committed by Michael Natterer
parent 9901ec4846
commit d15b07b486
17 changed files with 181 additions and 88 deletions

View file

@ -1,3 +1,18 @@
2001-12-17 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdrawablelistview.[ch]: changed
the GimpNewDrawableFunc typedef to take an additional
"GimpDrawable *template" paramater, added the "Drop to New"
feature again by passing the dropped drawable to
view->new_drawable_func().
* app/gui/channels-commands.[ch]: channels_new_channel_query:
* app/gui/layers-commands.[ch]: layers_new_layer_query:
Added the "template" parameter because they are used as the
views' new_drawable_func(), create layers/channels with
the template's properties if a template is passed.
2001-12-17 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.c: oops, GIMP_IS_DRAWABLE(gimage) will

View file

@ -39,6 +39,8 @@
#include "channels-commands.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
@ -55,7 +57,7 @@ channels_new_channel_cmd_callback (GtkWidget *widget,
if (! gimage)
return;
channels_new_channel_query (gimage);
channels_new_channel_query (gimage, NULL);
}
void
@ -333,7 +335,8 @@ new_channel_query_ok_callback (GtkWidget *widget,
}
void
channels_new_channel_query (GimpImage *gimage)
channels_new_channel_query (GimpImage *gimage,
GimpChannel *template)
{
NewChannelOptions *options;
GtkWidget *hbox;
@ -343,6 +346,38 @@ channels_new_channel_query (GimpImage *gimage)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (! template || GIMP_IS_CHANNEL (template));
if (template)
{
GimpChannel *new_channel;
gint width, height;
gint off_x, off_y;
width = gimp_drawable_width (GIMP_DRAWABLE (template));
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
new_channel = gimp_channel_new (gimage,
width, height,
_("Empty Channel Copy"),
&template->color);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
gimp_channel_translate (new_channel, off_x, off_y);
gimp_image_add_channel (gimage, new_channel, -1);
undo_push_group_end (gimage);
gdisplays_flush ();
return;
}
/* the new options structure */
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;

View file

@ -41,7 +41,8 @@ void channels_intersect_channel_with_sel_cmd_callback (GtkWidget *widget,
void channels_edit_channel_attributes_cmd_callback (GtkWidget *widget,
gpointer data);
void channels_new_channel_query (GimpImage *gimage);
void channels_new_channel_query (GimpImage *gimage,
GimpChannel *tamplate);
void channels_edit_channel_query (GimpChannel *channel);
void channels_menu_update (GtkItemFactory *factory,

View file

@ -175,7 +175,7 @@ layers_new_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage);
layers_new_layer_query (gimage);
layers_new_layer_query (gimage, NULL);
}
void
@ -562,7 +562,8 @@ new_layer_query_ok_callback (GtkWidget *widget,
}
void
layers_new_layer_query (GimpImage *gimage)
layers_new_layer_query (GimpImage *gimage,
GimpLayer *template)
{
NewLayerOptions *options;
GimpLayer *floating_sel;
@ -574,6 +575,7 @@ layers_new_layer_query (GimpImage *gimage)
GtkWidget *frame;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (! template || GIMP_IS_LAYER (template));
/* If there is a floating selection, the new command transforms
* the current fs into a new layer
@ -586,6 +588,36 @@ layers_new_layer_query (GimpImage *gimage)
return;
}
if (template)
{
GimpLayer *new_layer;
gint width, height;
gint off_x, off_y;
width = gimp_drawable_width (GIMP_DRAWABLE (template));
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
new_layer = gimp_layer_new (gimage, width, height,
gimp_image_base_type_with_alpha (gimage),
_("Empty Layer Copy"),
template->opacity,
template->mode);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_layer),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
gimp_layer_translate (new_layer, off_x, off_y);
gimp_image_add_layer (gimage, new_layer, -1);
undo_push_group_end (gimage);
gdisplays_flush ();
return;
}
options = g_new0 (NewLayerOptions, 1);
options->fill_type = fill_type;

View file

@ -84,7 +84,8 @@ void layers_edit_attributes_cmd_callback (GtkWidget *widet,
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_new_layer_query (GimpImage *gimage);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *tamplate);
void layers_edit_layer_query (GimpLayer *layer);
void layers_layer_merge_query (GimpImage *gimage,

View file

@ -39,6 +39,8 @@
#include "channels-commands.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
@ -55,7 +57,7 @@ channels_new_channel_cmd_callback (GtkWidget *widget,
if (! gimage)
return;
channels_new_channel_query (gimage);
channels_new_channel_query (gimage, NULL);
}
void
@ -333,7 +335,8 @@ new_channel_query_ok_callback (GtkWidget *widget,
}
void
channels_new_channel_query (GimpImage *gimage)
channels_new_channel_query (GimpImage *gimage,
GimpChannel *template)
{
NewChannelOptions *options;
GtkWidget *hbox;
@ -343,6 +346,38 @@ channels_new_channel_query (GimpImage *gimage)
GtkWidget *opacity_scale;
GtkObject *opacity_scale_data;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (! template || GIMP_IS_CHANNEL (template));
if (template)
{
GimpChannel *new_channel;
gint width, height;
gint off_x, off_y;
width = gimp_drawable_width (GIMP_DRAWABLE (template));
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
new_channel = gimp_channel_new (gimage,
width, height,
_("Empty Channel Copy"),
&template->color);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
gimp_channel_translate (new_channel, off_x, off_y);
gimp_image_add_channel (gimage, new_channel, -1);
undo_push_group_end (gimage);
gdisplays_flush ();
return;
}
/* the new options structure */
options = g_new (NewChannelOptions, 1);
options->gimage = gimage;

View file

@ -41,7 +41,8 @@ void channels_intersect_channel_with_sel_cmd_callback (GtkWidget *widget,
void channels_edit_channel_attributes_cmd_callback (GtkWidget *widget,
gpointer data);
void channels_new_channel_query (GimpImage *gimage);
void channels_new_channel_query (GimpImage *gimage,
GimpChannel *tamplate);
void channels_edit_channel_query (GimpChannel *channel);
void channels_menu_update (GtkItemFactory *factory,

View file

@ -175,7 +175,7 @@ layers_new_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage);
layers_new_layer_query (gimage);
layers_new_layer_query (gimage, NULL);
}
void
@ -562,7 +562,8 @@ new_layer_query_ok_callback (GtkWidget *widget,
}
void
layers_new_layer_query (GimpImage *gimage)
layers_new_layer_query (GimpImage *gimage,
GimpLayer *template)
{
NewLayerOptions *options;
GimpLayer *floating_sel;
@ -574,6 +575,7 @@ layers_new_layer_query (GimpImage *gimage)
GtkWidget *frame;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (! template || GIMP_IS_LAYER (template));
/* If there is a floating selection, the new command transforms
* the current fs into a new layer
@ -586,6 +588,36 @@ layers_new_layer_query (GimpImage *gimage)
return;
}
if (template)
{
GimpLayer *new_layer;
gint width, height;
gint off_x, off_y;
width = gimp_drawable_width (GIMP_DRAWABLE (template));
height = gimp_drawable_height (GIMP_DRAWABLE (template));
gimp_drawable_offsets (GIMP_DRAWABLE (template), &off_x, &off_y);
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
new_layer = gimp_layer_new (gimage, width, height,
gimp_image_base_type_with_alpha (gimage),
_("Empty Layer Copy"),
template->opacity,
template->mode);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_layer),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
gimp_layer_translate (new_layer, off_x, off_y);
gimp_image_add_layer (gimage, new_layer, -1);
undo_push_group_end (gimage);
gdisplays_flush ();
return;
}
options = g_new0 (NewLayerOptions, 1);
options->fill_type = fill_type;

View file

@ -84,7 +84,8 @@ void layers_edit_attributes_cmd_callback (GtkWidget *widet,
void layers_menu_update (GtkItemFactory *factory,
gpointer data);
void layers_new_layer_query (GimpImage *gimage);
void layers_new_layer_query (GimpImage *gimage,
GimpLayer *tamplate);
void layers_edit_layer_query (GimpLayer *layer);
void layers_layer_merge_query (GimpImage *gimage,

View file

@ -72,8 +72,6 @@ static void gimp_drawable_list_view_context_item (GimpContainerView *v
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
@ -526,25 +524,11 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
/* "New" functions */
static void
gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable)
{
if (drawable)
{
g_print ("new with \"%s\"'s properties\n", GIMP_OBJECT (drawable)->name);
}
else
{
view->new_drawable_func (view->gimage);
}
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
gimp_drawable_list_view_new_drawable (view, NULL);
view->new_drawable_func (view->gimage, NULL);
}
static void
@ -559,7 +543,7 @@ gimp_drawable_list_view_new_dropped (GtkWidget *widget,
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_new_drawable (view, GIMP_DRAWABLE (viewable));
view->new_drawable_func (view->gimage, GIMP_DRAWABLE (viewable));
}
}

View file

@ -45,7 +45,8 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef GimpDrawable * (* GimpConvertDrawableFunc) (GimpImage *dest_gimage,
GimpDrawable *drawable);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage,
GimpDrawable *template);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);

View file

@ -72,8 +72,6 @@ static void gimp_drawable_list_view_context_item (GimpContainerView *v
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
@ -526,25 +524,11 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
/* "New" functions */
static void
gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable)
{
if (drawable)
{
g_print ("new with \"%s\"'s properties\n", GIMP_OBJECT (drawable)->name);
}
else
{
view->new_drawable_func (view->gimage);
}
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
gimp_drawable_list_view_new_drawable (view, NULL);
view->new_drawable_func (view->gimage, NULL);
}
static void
@ -559,7 +543,7 @@ gimp_drawable_list_view_new_dropped (GtkWidget *widget,
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_new_drawable (view, GIMP_DRAWABLE (viewable));
view->new_drawable_func (view->gimage, GIMP_DRAWABLE (viewable));
}
}

View file

@ -45,7 +45,8 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef GimpDrawable * (* GimpConvertDrawableFunc) (GimpImage *dest_gimage,
GimpDrawable *drawable);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage,
GimpDrawable *template);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);

View file

@ -72,8 +72,6 @@ static void gimp_drawable_list_view_context_item (GimpContainerView *v
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
@ -526,25 +524,11 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
/* "New" functions */
static void
gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable)
{
if (drawable)
{
g_print ("new with \"%s\"'s properties\n", GIMP_OBJECT (drawable)->name);
}
else
{
view->new_drawable_func (view->gimage);
}
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
gimp_drawable_list_view_new_drawable (view, NULL);
view->new_drawable_func (view->gimage, NULL);
}
static void
@ -559,7 +543,7 @@ gimp_drawable_list_view_new_dropped (GtkWidget *widget,
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_new_drawable (view, GIMP_DRAWABLE (viewable));
view->new_drawable_func (view->gimage, GIMP_DRAWABLE (viewable));
}
}

View file

@ -45,7 +45,8 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef GimpDrawable * (* GimpConvertDrawableFunc) (GimpImage *dest_gimage,
GimpDrawable *drawable);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage,
GimpDrawable *template);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);

View file

@ -72,8 +72,6 @@ static void gimp_drawable_list_view_context_item (GimpContainerView *v
GimpViewable *item,
gpointer insert_data);
static void gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable);
static void gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_dropped (GtkWidget *widget,
@ -526,25 +524,11 @@ gimp_drawable_list_view_context_item (GimpContainerView *view,
/* "New" functions */
static void
gimp_drawable_list_view_new_drawable (GimpDrawableListView *view,
GimpDrawable *drawable)
{
if (drawable)
{
g_print ("new with \"%s\"'s properties\n", GIMP_OBJECT (drawable)->name);
}
else
{
view->new_drawable_func (view->gimage);
}
}
static void
gimp_drawable_list_view_new_clicked (GtkWidget *widget,
GimpDrawableListView *view)
{
gimp_drawable_list_view_new_drawable (view, NULL);
view->new_drawable_func (view->gimage, NULL);
}
static void
@ -559,7 +543,7 @@ gimp_drawable_list_view_new_dropped (GtkWidget *widget,
if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container,
GIMP_OBJECT (viewable)))
{
gimp_drawable_list_view_new_drawable (view, GIMP_DRAWABLE (viewable));
view->new_drawable_func (view->gimage, GIMP_DRAWABLE (viewable));
}
}

View file

@ -45,7 +45,8 @@ typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable,
typedef GimpDrawable * (* GimpConvertDrawableFunc) (GimpImage *dest_gimage,
GimpDrawable *drawable);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage);
typedef void (* GimpNewDrawableFunc) (GimpImage *gimage,
GimpDrawable *template);
typedef void (* GimpEditDrawableFunc) (GimpDrawable *drawable);