DND cleanup part 1:

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

	DND cleanup part 1:

	* app/widgets/gimpdnd.[ch]: changed all gimp_dnd_*_dest_set() and
	_unset() functions to _dest_add() and _dest_remove(). Switch from
	using static arrays of GtkTargetEntries to dynamic GtkTargetLists.
	The _add() and _remove() functions configure the drag dest
	automatically if not already done, so there is no need to call
	gtk_drag_dest_set() on the widget any more. Drag source cleanup
	will follow...

	Renamed silly function names gimp_gtk_* to gimp_dnd_*

	* app/display/gimpdisplayshell.c
	* app/tools/gimpblendtool.c
	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpcontainerview.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimplistitem.c
	* app/widgets/gimpmenuitem.c
	* app/widgets/gimppreview.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimptoolbox-color-area.c
	* app/widgets/gimptoolbox-indicator-area.c
	* app/widgets/gimptoolbox.c
	* app/gui/about-dialog.c
	* app/gui/color-select.c
	* app/gui/device-status-dialog.c
	* app/gui/tool-options-dialog.c: changed accordingly. Removed
	all calls to gtk_drag_dest_set() and their GtkTargetEntry tables.

	* app/widgets/gimpchannellistitem.c: enabled some commented out
	dnd code (which will not work since dnd needs more love...)

	* app/widgets/gimpitemlistview.[ch]: added a third
	"gboolean interactive" parameter to GimpItemNewFunc.

	* app/gui/channels-commands.[ch]
	* app/gui/layers-commands.[ch]
	* app/gui/vectors-commands.[ch]: if the new_item_func is called
	with "interactive == FALSE", don't pop up a dialog but silently
	create a new item of the image's size.

	* app/widgets/gimpdrawablelistview.c: use the new feature to allow
	color and pattern drops to the "New" button, which creates a new
	layer/channel filled with the color/pattern.
	(special feature for drc ;-)

	* app/widgets/gimppaletteeditor.c: fixed event handling so we see
	the context menu again. Also, don't redraw on "expose", since
	GtkPreview does that for us.
This commit is contained in:
Michael Natterer
2002-09-02 14:39:08 +00:00
committed by Michael Natterer
parent e6a9cc4de1
commit c5d4b7020b
46 changed files with 635 additions and 473 deletions

View File

@ -33,12 +33,17 @@
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimpmarshal.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "gimpchannellistview.h"
#include "gimpdnd.h"
@ -48,6 +53,8 @@
#include "gimplistitem.h"
#include "gimppreview.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
@ -61,6 +68,15 @@ static void gimp_drawable_list_view_floating_selection_changed
(GimpImage *gimage,
GimpDrawableListView *view);
static void gimp_drawable_list_view_new_pattern_dropped
(GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void gimp_drawable_list_view_new_color_dropped
(GtkWidget *widget,
const GimpRGB *color,
gpointer data);
static GimpItemListViewClass *parent_class = NULL;
@ -108,6 +124,16 @@ gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
static void
gimp_drawable_list_view_init (GimpDrawableListView *view)
{
GimpItemListView *item_view;
item_view = GIMP_ITEM_LIST_VIEW (view);
gimp_dnd_viewable_dest_add (item_view->new_button, GIMP_TYPE_PATTERN,
gimp_drawable_list_view_new_pattern_dropped,
view);
gimp_dnd_color_dest_add (item_view->new_button,
gimp_drawable_list_view_new_color_dropped,
view);
}
static void
@ -171,3 +197,68 @@ gimp_drawable_list_view_floating_selection_changed (GimpImage *gimage
/* update button states */
/* gimp_drawable_list_view_drawable_changed (gimage, view); */
}
static void
gimp_drawable_list_view_new_dropped (GimpItemListView *view,
GimpBucketFillMode fill_mode,
const GimpRGB *color,
GimpPattern *pattern)
{
GimpDrawable *drawable;
GimpToolInfo *tool_info;
GimpContext *context;
undo_push_group_start (view->gimage, EDIT_PASTE_UNDO_GROUP);
view->new_item_func (view->gimage, NULL, FALSE);
drawable = gimp_image_active_drawable (view->gimage);
/* Get the bucket fill context */
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (view->gimage->gimp->tool_info_list,
"gimp-bucket-fill-tool");
if (tool_info && tool_info->context)
{
context = tool_info->context;
}
else
{
context = gimp_get_user_context (view->gimage->gimp);
}
gimp_drawable_bucket_fill_full (drawable,
fill_mode,
color, pattern,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
FALSE /* no seed fill */,
FALSE, 0.0, FALSE, 0.0, 0.0 /* fill params */);
undo_push_group_end (view->gimage);
gimp_image_flush (view->gimage);
}
static void
gimp_drawable_list_view_new_pattern_dropped (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
gimp_drawable_list_view_new_dropped (GIMP_ITEM_LIST_VIEW (data),
GIMP_PATTERN_BUCKET_FILL,
NULL,
GIMP_PATTERN (viewable));
}
static void
gimp_drawable_list_view_new_color_dropped (GtkWidget *widget,
const GimpRGB *color,
gpointer data)
{
gimp_drawable_list_view_new_dropped (GIMP_ITEM_LIST_VIEW (data),
GIMP_FG_BUCKET_FILL,
color,
NULL);
}