Commit 1345ece5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/widgets/Makefile.am app/widgets/widgets-types.h new GimpListItem

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

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpitemlistitem.[ch]: new GimpListItem subclass
	which handles DND reordering of GimpItems.

	* app/widgets/gimpdrawablelistitem.[ch]: derive from GimpItemListItem
	and removed the reordering code.

	* app/widgets/gimplistitem.c: create a GimpItemListItem if the
	passed viewable is a GimpItem.
parent 80aa8233
2002-02-25 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpitemlistitem.[ch]: new GimpListItem subclass
which handles DND reordering of GimpItems.
* app/widgets/gimpdrawablelistitem.[ch]: derive from GimpItemListItem
and removed the reordering code.
* app/widgets/gimplistitem.c: create a GimpItemListItem if the
passed viewable is a GimpItem.
2002-02-25 Sven Neumann <sven@gimp.org>
* README.i18n: updated
......
......@@ -76,6 +76,8 @@ libappwidgets_a_SOURCES = @STRIP_BEGIN@ \
gimpimagepreview.h \
gimpitemfactory.c \
gimpitemfactory.h \
gimpitemlistitem.c \
gimpitemlistitem.h \
gimpitemlistview.c \
gimpitemlistview.h \
gimplayerlistitem.c \
......
......@@ -45,17 +45,11 @@
static void gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass);
static void gimp_drawable_list_item_init (GimpDrawableListItem *list_item);
static void gimp_drawable_list_item_set_viewable (GimpListItem *list_item,
GimpViewable *viewable);
static void gimp_drawable_list_item_set_viewable (GimpListItem *list_item,
GimpViewable *viewable);
static gboolean gimp_drawable_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static void gimp_drawable_list_item_eye_toggled (GtkWidget *widget,
gpointer data);
static void gimp_drawable_list_item_eye_toggled (GtkWidget *widget,
gpointer data);
static void gimp_drawable_list_item_visibility_changed (GimpDrawable *drawable,
gpointer data);
......@@ -84,7 +78,7 @@ gimp_drawable_list_item_get_type (void)
(GInstanceInitFunc) gimp_drawable_list_item_init,
};
list_item_type = g_type_register_static (GIMP_TYPE_LIST_ITEM,
list_item_type = g_type_register_static (GIMP_TYPE_ITEM_LIST_ITEM,
"GimpDrawableListItem",
&list_item_info, 0);
}
......@@ -95,16 +89,12 @@ gimp_drawable_list_item_get_type (void)
static void
gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass)
{
GtkWidgetClass *widget_class;
GimpListItemClass *list_item_class;
widget_class = GTK_WIDGET_CLASS (klass);
list_item_class = GIMP_LIST_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class->drag_drop = gimp_drawable_list_item_drag_drop;
list_item_class->set_viewable = gimp_drawable_list_item_set_viewable;
}
......@@ -180,76 +170,6 @@ gimp_drawable_list_item_set_viewable (GimpListItem *list_item,
0);
}
static gboolean
gimp_drawable_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GimpListItem *list_item;
GimpViewable *src_viewable;
gint dest_index;
GdkDragAction drag_action;
GimpDropType drop_type;
gboolean return_val;
list_item = GIMP_LIST_ITEM (widget);
return_val = gimp_list_item_check_drag (list_item, context, x, y,
&src_viewable,
&dest_index,
&drag_action,
&drop_type);
gtk_drag_finish (context, return_val, FALSE, time);
list_item->drop_type = GIMP_DROP_NONE;
if (return_val)
{
if (widget->parent && /* EEK */
widget->parent->parent && /* EEEEK */
widget->parent->parent->parent && /* EEEEEEK */
widget->parent->parent->parent->parent && /* EEEEEEEEK */
GIMP_IS_ITEM_LIST_VIEW (widget->parent->parent->parent->parent))
{
GimpItemListView *item_view;
item_view =
GIMP_ITEM_LIST_VIEW (widget->parent->parent->parent->parent);
if (item_view->gimage == gimp_item_get_image (GIMP_ITEM (src_viewable)))
{
item_view->reorder_item_func (item_view->gimage,
src_viewable,
dest_index,
TRUE);
}
else if (item_view->convert_item_func)
{
GimpViewable *new_viewable;
new_viewable = item_view->convert_item_func (src_viewable,
item_view->gimage);
item_view->add_item_func (item_view->gimage,
new_viewable,
dest_index);
}
gdisplays_flush ();
}
else
{
g_warning ("%s(): GimpDrawableListItem is not "
"part of a GimpItemListView", G_GNUC_FUNCTION);
}
}
return return_val;
}
static void
gimp_drawable_list_item_eye_toggled (GtkWidget *widget,
gpointer data)
......
......@@ -22,7 +22,8 @@
#ifndef __GIMP_DRAWABLE_LIST_ITEM_H__
#define __GIMP_DRAWABLE_LIST_ITEM_H__
#include "gimplistitem.h"
#include "gimpitemlistitem.h"
#define GIMP_TYPE_DRAWABLE_LIST_ITEM (gimp_drawable_list_item_get_type ())
......@@ -37,14 +38,14 @@ typedef struct _GimpDrawableListItemClass GimpDrawableListItemClass;
struct _GimpDrawableListItem
{
GimpListItem parent_instance;
GimpItemListItem parent_instance;
GtkWidget *eye_button;
GtkWidget *eye_button;
};
struct _GimpDrawableListItemClass
{
GimpListItemClass parent_class;
GimpItemListItemClass parent_class;
};
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpitemlistitem.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpitem.h"
#include "display/gimpdisplay-foreach.h"
#include "gimpdnd.h"
#include "gimpitemlistitem.h"
#include "gimpitemlistview.h"
#include "gimppreview.h"
static void gimp_item_list_item_class_init (GimpItemListItemClass *klass);
static void gimp_item_list_item_init (GimpItemListItem *list_item);
static gboolean gimp_item_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static GimpListItemClass *parent_class = NULL;
GType
gimp_item_list_item_get_type (void)
{
static GType list_item_type = 0;
if (! list_item_type)
{
static const GTypeInfo list_item_info =
{
sizeof (GimpItemListItemClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_item_list_item_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpItemListItem),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_item_list_item_init,
};
list_item_type = g_type_register_static (GIMP_TYPE_LIST_ITEM,
"GimpItemListItem",
&list_item_info, 0);
}
return list_item_type;
}
static void
gimp_item_list_item_class_init (GimpItemListItemClass *klass)
{
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class->drag_drop = gimp_item_list_item_drag_drop;
}
static void
gimp_item_list_item_init (GimpItemListItem *list_item)
{
}
static gboolean
gimp_item_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GimpListItem *list_item;
GimpViewable *src_viewable;
gint dest_index;
GdkDragAction drag_action;
GimpDropType drop_type;
gboolean return_val;
list_item = GIMP_LIST_ITEM (widget);
return_val = gimp_list_item_check_drag (list_item, context, x, y,
&src_viewable,
&dest_index,
&drag_action,
&drop_type);
gtk_drag_finish (context, return_val, FALSE, time);
list_item->drop_type = GIMP_DROP_NONE;
if (return_val)
{
if (widget->parent && /* EEK */
widget->parent->parent && /* EEEEK */
widget->parent->parent->parent && /* EEEEEEK */
widget->parent->parent->parent->parent && /* EEEEEEEEK */
GIMP_IS_ITEM_LIST_VIEW (widget->parent->parent->parent->parent))
{
GimpItemListView *item_view;
item_view =
GIMP_ITEM_LIST_VIEW (widget->parent->parent->parent->parent);
if (item_view->gimage == gimp_item_get_image (GIMP_ITEM (src_viewable)))
{
item_view->reorder_item_func (item_view->gimage,
src_viewable,
dest_index,
TRUE);
}
else if (item_view->convert_item_func)
{
GimpViewable *new_viewable;
new_viewable = item_view->convert_item_func (src_viewable,
item_view->gimage);
item_view->add_item_func (item_view->gimage,
new_viewable,
dest_index);
}
gdisplays_flush ();
}
else
{
g_warning ("%s(): GimpItemListItem is not "
"part of a GimpItemListView", G_GNUC_FUNCTION);
}
}
return return_val;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpitemlistitem.h
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_ITEM_LIST_ITEM_H__
#define __GIMP_ITEM_LIST_ITEM_H__
#include "gimplistitem.h"
#define GIMP_TYPE_ITEM_LIST_ITEM (gimp_item_list_item_get_type ())
#define GIMP_ITEM_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ITEM_LIST_ITEM, GimpItemListItem))
#define GIMP_ITEM_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ITEM_LIST_ITEM, GimpItemListItemClass))
#define GIMP_IS_ITEM_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ITEM_LIST_ITEM))
#define GIMP_IS_ITEM_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ITEM_LIST_ITEM))
#define GIMP_ITEM_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ITEM_LIST_ITEM, GimpItemListItemClass))
typedef struct _GimpItemListItemClass GimpItemListItemClass;
struct _GimpItemListItem
{
GimpListItem parent_instance;
};
struct _GimpItemListItemClass
{
GimpListItemClass parent_class;
};
GType gimp_item_list_item_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_ITEM_LIST_ITEM_H__ */
......@@ -282,6 +282,10 @@ gimp_list_item_new (GimpViewable *viewable,
{
list_item = g_object_new (GIMP_TYPE_DRAWABLE_LIST_ITEM, NULL);
}
else if (GIMP_IS_ITEM (viewable))
{
list_item = g_object_new (GIMP_TYPE_ITEM_LIST_ITEM, NULL);
}
else
{
list_item = g_object_new (GIMP_TYPE_LIST_ITEM, NULL);
......
......@@ -168,6 +168,7 @@ typedef struct _GimpDataFactoryView GimpDataFactoryView;
typedef struct _GimpBrushFactoryView GimpBrushFactoryView;
typedef struct _GimpListItem GimpListItem;
typedef struct _GimpItemListItem GimpItemListItem;
typedef struct _GimpChannelListItem GimpChannelListItem;
typedef struct _GimpDrawableListItem GimpDrawableListItem;
typedef struct _GimpLayerListItem GimpLayerListItem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment