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

app/Makefile.am app/apptypes.h app/gimpdrawablelistitem.[ch] new widgets

2001-03-04  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/apptypes.h
	* app/gimpdrawablelistitem.[ch]
	* app/gimplistitem.[ch]: new widgets capable of reordering
	themselves using DND.

	* app/gimpcontainerlistview.c: removed stuff which is now done
	by the GimpListItem.

	* app/gimpdnd.[ch]: new function gimp_dnd_get_drag_data(widget)
	which returns a GimpViewable using the widget's drag callback.

	* app/gimpdrawablelistview.c: implement GimpContainerView's
	"insert_item" method and enable reordering for the created
	GimpListItem.
parent f1d9ba63
2001-03-04 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/apptypes.h
* app/gimpdrawablelistitem.[ch]
* app/gimplistitem.[ch]: new widgets capable of reordering
themselves using DND.
* app/gimpcontainerlistview.c: removed stuff which is now done
by the GimpListItem.
* app/gimpdnd.[ch]: new function gimp_dnd_get_drag_data(widget)
which returns a GimpViewable using the widget's drag callback.
* app/gimpdrawablelistview.c: implement GimpContainerView's
"insert_item" method and enable reordering for the created
GimpListItem.
2001-03-03 Michael Natterer <mitch@gimp.org>
* app/appenums.h: renamed ZoomType to GimpZoomZype and added it
......
......@@ -293,6 +293,8 @@ gimp_SOURCES = \
gimpcontainerview.c \
gimpdatafactoryview.h \
gimpdatafactoryview.c \
gimpdrawablelistitem.c \
gimpdrawablelistitem.h \
gimpdrawablelistview.c \
gimpdrawablelistview.h \
gimpdrawablepreview.c \
......@@ -301,6 +303,8 @@ gimp_SOURCES = \
gimpgradientpreview.c \
gimpimagepreview.h \
gimpimagepreview.c \
gimplistitem.h \
gimplistitem.c \
gimppalettepreview.h \
gimppalettepreview.c \
gimppatternpreview.h \
......
......@@ -98,6 +98,10 @@ typedef struct _GimpContainerListView GimpContainerListView;
typedef struct _GimpContainerGridView GimpContainerGridView;
typedef struct _GimpDataFactoryView GimpDataFactoryView;
typedef struct _GimpDrawableListView GimpDrawableListView;
typedef struct _GimpListItem GimpListItem;
typedef struct _GimpDrawableListItem GimpDrawableListItem;
typedef struct _HistogramWidget HistogramWidget;
......
......@@ -30,6 +30,7 @@
#include "gimpcontext.h"
#include "gimpdnd.h"
#include "gimplist.h"
#include "gimplistitem.h"
#include "gimppreview.h"
......@@ -53,16 +54,12 @@ static void gimp_container_list_view_select_item (GimpContainerView *v
static void gimp_container_list_view_clear_items (GimpContainerView *view);
static void gimp_container_list_view_set_preview_size (GimpContainerView *view);
static void gimp_container_list_view_name_changed (GimpViewable *viewable,
GtkLabel *label);
static void gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child,
gpointer data);
static gint gimp_container_list_view_item_activated (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static GimpViewable * gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data);
static GimpContainerViewClass *parent_class = NULL;
......@@ -210,51 +207,16 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
{
GimpContainerListView *list_view;
GtkWidget *list_item;
GtkWidget *hbox;
GtkWidget *preview;
GtkWidget *label;
GList *list;
list_view = GIMP_CONTAINER_LIST_VIEW (view);
list_item = gtk_list_item_new ();
hbox = gtk_hbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_container_add (GTK_CONTAINER (list_item), hbox);
gtk_widget_show (hbox);
preview = gimp_preview_new (viewable, view->preview_size, 1, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_object_set_data (GTK_OBJECT (list_item), "preview", preview);
label = gtk_label_new (gimp_object_get_name (GIMP_OBJECT (viewable)));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_object_set_data (GTK_OBJECT (list_item), "label", label);
gtk_signal_connect_while_alive
(GTK_OBJECT (viewable), "name_changed",
GTK_SIGNAL_FUNC (gimp_container_list_view_name_changed),
label,
GTK_OBJECT (list_view));
list_item = gimp_list_item_new (viewable, view->preview_size);
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activated),
list_view);
gimp_gtk_drag_source_set_by_type (list_item,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
view->container->children_type,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (list_item),
view->container->children_type,
gimp_container_list_view_drag_viewable,
list_view);
gtk_widget_show (list_item);
list = g_list_prepend (NULL, list_item);
......@@ -415,7 +377,7 @@ gimp_container_list_view_set_preview_size (GimpContainerView *view)
{
GimpPreview *preview;
preview = gtk_object_get_data (GTK_OBJECT (list->data), "preview");
preview = GIMP_PREVIEW (GIMP_LIST_ITEM (list->data)->preview);
gimp_preview_set_size (preview, view->preview_size);
}
......@@ -423,13 +385,6 @@ gimp_container_list_view_set_preview_size (GimpContainerView *view)
gtk_widget_queue_resize (list_view->gtk_list);
}
static void
gimp_container_list_view_name_changed (GimpViewable *viewable,
GtkLabel *label)
{
gtk_label_set_text (label, gimp_object_get_name (GIMP_OBJECT (viewable)));
}
static void
gimp_container_list_view_item_selected (GtkWidget *widget,
GtkWidget *child,
......@@ -437,8 +392,7 @@ gimp_container_list_view_item_selected (GtkWidget *widget,
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (child),
"preview"))->viewable;
viewable = GIMP_PREVIEW (GIMP_LIST_ITEM (child)->preview)->viewable;
gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), viewable);
}
......@@ -452,23 +406,10 @@ gimp_container_list_view_item_activated (GtkWidget *widget,
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
viewable = GIMP_PREVIEW (GIMP_LIST_ITEM (widget)->preview)->viewable;
gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data), viewable);
}
return FALSE;
}
static GimpViewable *
gimp_container_list_view_drag_viewable (GtkWidget *widget,
gpointer data)
{
GimpViewable *viewable;
viewable = GIMP_PREVIEW (gtk_object_get_data (GTK_OBJECT (widget),
"preview"))->viewable;
return viewable;
}
......@@ -1016,6 +1016,36 @@ gimp_dnd_viewable_dest_unset (GtkWidget *widget,
gimp_dnd_data_dest_unset (dnd_type, widget);
}
GimpViewable *
gimp_dnd_get_drag_data (GtkWidget *widget)
{
GimpDndDataType data_type;
GimpDndDragViewableFunc get_data_func;
gpointer get_data_data;
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
data_type =
(GimpDndDataType) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_data_type");
if (! data_type)
return NULL;
get_data_func =
(GimpDndDragViewableFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_data_func");
get_data_data =
(gpointer) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dnd_get_data_data");
if (! get_data_func)
return NULL;
return (GimpViewable *) (* get_data_func) (widget, get_data_data);
}
/****************************/
/* drawable dnd functions */
......
......@@ -139,6 +139,8 @@ void gimp_dnd_viewable_dest_set (GtkWidget *widget,
void gimp_dnd_viewable_dest_unset (GtkWidget *widget,
GtkType type);
GimpViewable * gimp_dnd_get_drag_data (GtkWidget *widget);
/* OLD drawable dnd functions */
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdrawablelistitem.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"
#include <gtk/gtk.h>
#include "apptypes.h"
#include "gdisplay.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
#include "gimpdnd.h"
#include "gimpdrawablelistitem.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimppreview.h"
#include "gimpviewable.h"
static void gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass);
static void gimp_drawable_list_item_init (GimpDrawableListItem *list_item);
static gboolean gimp_drawable_list_item_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static gboolean gimp_drawable_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static GimpListItemClass *parent_class = NULL;
GtkType
gimp_drawable_list_item_get_type (void)
{
static GtkType list_item_type = 0;
if (! list_item_type)
{
static const GtkTypeInfo list_item_info =
{
"GimpDrawableListItem",
sizeof (GimpDrawableListItem),
sizeof (GimpDrawableListItemClass),
(GtkClassInitFunc) gimp_drawable_list_item_class_init,
(GtkObjectInitFunc) gimp_drawable_list_item_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
list_item_type = gtk_type_unique (GIMP_TYPE_LIST_ITEM, &list_item_info);
}
return list_item_type;
}
static void
gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
parent_class = gtk_type_class (GTK_TYPE_LIST_ITEM);
widget_class->drag_motion = gimp_drawable_list_item_drag_motion;
widget_class->drag_drop = gimp_drawable_list_item_drag_drop;
}
static void
gimp_drawable_list_item_init (GimpDrawableListItem *list_item)
{
}
static gboolean
gimp_drawable_list_item_drag_motion (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);
gdk_drag_status (context, drag_action, time);
list_item->drop_type = drop_type;
return return_val;
}
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 (GIMP_IS_LAYER (src_viewable))
{
gimp_image_position_layer (gimp_drawable_gimage (GIMP_DRAWABLE (src_viewable)),
GIMP_LAYER (src_viewable),
dest_index,
TRUE);
gdisplays_flush ();
}
else if (GIMP_IS_CHANNEL (src_viewable))
{
gimp_image_position_channel (gimp_drawable_gimage (GIMP_DRAWABLE (src_viewable)),
GIMP_CHANNEL (src_viewable),
dest_index);
gdisplays_flush ();
}
}
return return_val;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdrawablelistitem.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_DRAWABLE_LIST_ITEM_H__
#define __GIMP_DRAWABLE_LIST_ITEM_H__
#include "gimplistitem.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_DRAWABLE_LIST_ITEM (gimp_drawable_list_item_get_type ())
#define GIMP_DRAWABLE_LIST_ITEM(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_ITEM, GimpDrawableListItem))
#define GIMP_DRAWABLE_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_ITEM, GimpDrawableListItemClass))
#define GIMP_IS_DRAWABLE_LIST_ITEM(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_ITEM))
#define GIMP_IS_DRAWABLE_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_ITEM))
typedef struct _GimpDrawableListItemClass GimpDrawableListItemClass;
struct _GimpDrawableListItem
{
GimpListItem parent_instance;
};
struct _GimpDrawableListItemClass
{
GimpListItemClass parent_class;
};
GtkType gimp_drawable_list_item_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_DRAWABLE_LIST_ITEM_H__ */
......@@ -30,6 +30,7 @@
#include "gimpdrawablelistview.h"
#include "gimpdnd.h"
#include "gimpimage.h"
#include "gimplistitem.h"
#include "gimpmarshal.h"
#include "gimprc.h"
#include "gimpviewable.h"
......@@ -48,6 +49,9 @@ static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *kla
static void gimp_drawable_list_view_init (GimpDrawableListView *view);
static void gimp_drawable_list_view_destroy (GtkObject *object);
static gpointer gimp_drawable_list_view_insert_item (GimpContainerView *view,
GimpViewable *viewable,
gint index);
static void gimp_drawable_list_view_select_item (GimpContainerView *view,
GimpViewable *item,
gpointer insert_data);
......@@ -125,6 +129,7 @@ gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass)
object_class->destroy = gimp_drawable_list_view_destroy;
container_view_class->insert_item = gimp_drawable_list_view_insert_item;
container_view_class->select_item = gimp_drawable_list_view_select_item;
container_view_class->activate_item = gimp_drawable_list_view_activate_item;
}
......@@ -265,6 +270,25 @@ gimp_drawable_list_view_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static gpointer
gimp_drawable_list_view_insert_item (GimpContainerView *view,
GimpViewable *viewable,
gint index)
{
gpointer list_item = NULL;
if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item)
list_item = GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item (view,
viewable,
index);
if (list_item)
gimp_list_item_set_reorderable (GIMP_LIST_ITEM (list_item),
TRUE, view->container);
return (gpointer) list_item;
}
GtkWidget *
gimp_drawable_list_view_new (GimpImage *gimage,
GtkType drawable_type,
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimplistitem.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"
#include <gtk/gtk.h>
#include "apptypes.h"
#include "gimpcontainer.h"
#include "gimpdnd.h"
#include "gimpdrawable.h"
#include "gimpdrawablelistitem.h"
#include "gimplistitem.h"
#include "gimppreview.h"
#include "gimpviewable.h"
static void gimp_list_item_class_init (GimpListItemClass *klass);
static void gimp_list_item_init (GimpListItem *list_item);
static void gimp_list_item_draw (GtkWidget *widget,
GdkRectangle *area);
static void gimp_list_item_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time);
static gboolean gimp_list_item_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static gboolean gimp_list_item_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static void gimp_list_item_name_changed (GimpViewable *viewable,
GtkLabel *label);
static GimpViewable * gimp_list_item_drag_viewable (GtkWidget *widget,
gpointer data);
static GtkListItemClass *parent_class = NULL;
GtkType
gimp_list_item_get_type (void)
{
static GtkType list_item_type = 0;
if (!list_item_type)
{
static const GtkTypeInfo list_item_info =
{
"GimpListItem",
sizeof (GimpListItem),
sizeof (GimpListItemClass),
(GtkClassInitFunc) gimp_list_item_class_init,
(GtkObjectInitFunc) gimp_list_item_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
list_item_type = gtk_type_unique (GTK_TYPE_LIST_ITEM, &list_item_info);
}
return list_item_type;
}
static void
gimp_list_item_class_init (GimpListItemClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
parent_class = gtk_type_class (GTK_TYPE_LIST_ITEM);
widget_class->draw = gimp_list_item_draw;
widget_class->drag_leave = gimp_list_item_drag_leave;
widget_class->drag_motion = gimp_list_item_drag_motion;
widget_class->drag_drop = gimp_list_item_drag_drop;
}