diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-02-12 06:08:09 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-02-12 06:08:09 +0800 |
commit | 4a25f612c0fb701a774d20c19888957c555e54a2 (patch) | |
tree | 0e0f46269cd0522aaa793ef5552ec499d0613176 /widgets/table/e-table-header-item.c | |
parent | 4a7411c370d573842a35354f88201a29f180aad0 (diff) | |
download | gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.gz gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.zst gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.zip |
Added reordering of columns.
2000-02-11 Christopher James Lahey <clahey@helixcode.com>
* e-table-header-item.h, e-table-header-item.c: Added reordering
of columns.
* e-table-header.c: Fixed a couple of bugs in the move column and
remove column functions.
svn path=/trunk/; revision=1736
Diffstat (limited to 'widgets/table/e-table-header-item.c')
-rw-r--r-- | widgets/table/e-table-header-item.c | 87 |
1 files changed, 66 insertions, 21 deletions
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index ad4d12395c..72f78453d9 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * E-table-column-view.c: A canvas item based view of the ETableColumn. * @@ -307,26 +308,27 @@ ethi_drag_motion (GtkObject *canvas, GdkDragContext *context, gint x, gint y, guint time, ETableHeaderItem *ethi) { - - if ((x >= ethi->x1) && (x <= (ethi->x1 + ethi->width)) && - (y >= ethi->y1) && (y <= (ethi->y1 + ethi->height))){ - int col; - - col = ethi_find_col_by_x (ethi, x); - - if (col != -1){ - ethi_remove_destroy_marker (ethi); - ethi_add_drop_marker (ethi, col); + gdk_drag_status (context, 0, time); + if (GTK_WIDGET(canvas) == gtk_drag_get_source_widget(context)) { + if ((x >= ethi->x1) && (x <= (ethi->x1 + ethi->width)) && + (y >= ethi->y1) && (y <= (ethi->y1 + ethi->height))){ + int col; + + col = ethi_find_col_by_x (ethi, x); + + if (col != -1){ + ethi_remove_destroy_marker (ethi); + ethi_add_drop_marker (ethi, col); + gdk_drag_status (context, context->suggested_action, time); + } else { + ethi_remove_drop_marker (ethi); + ethi_add_destroy_marker (ethi); + } } else { ethi_remove_drop_marker (ethi); ethi_add_destroy_marker (ethi); } - } else { - ethi_remove_drop_marker (ethi); - ethi_add_destroy_marker (ethi); } - - gdk_drag_status (context, context->suggested_action, time); return TRUE; } @@ -334,16 +336,54 @@ ethi_drag_motion (GtkObject *canvas, GdkDragContext *context, static void ethi_drag_end (GtkWidget *canvas, GdkDragContext *context, ETableHeaderItem *ethi) { - ethi_remove_drop_marker (ethi); - ethi_remove_destroy_marker (ethi); - ethi->drag_col = -1; + if (canvas == gtk_drag_get_source_widget(context)) { + if (context->action == 0) { + ethi_request_redraw (ethi); + e_table_header_remove(ethi->eth, ethi->drag_col); + } + ethi_remove_drop_marker (ethi); + ethi_remove_destroy_marker (ethi); + ethi->drag_col = -1; + } +} + +static gboolean +ethi_drag_drop (GtkWidget *canvas, + GdkDragContext *context, + gint x, + gint y, + guint time, + ETableHeaderItem *ethi) +{ + gboolean successful = FALSE; + if (GTK_WIDGET(canvas) == gtk_drag_get_source_widget(context)) { + if ((x >= ethi->x1) && (x <= (ethi->x1 + ethi->width)) && + (y >= ethi->y1) && (y <= (ethi->y1 + ethi->height))){ + int col; + + col = ethi_find_col_by_x (ethi, x); + ethi_add_drop_marker(ethi, col); + + if (col != -1) { + if (col != ethi->drag_col) { + ethi_request_redraw (ethi); + e_table_header_move(ethi->eth, ethi->drag_col, col); + } + successful = TRUE; + } + } + } + gtk_drag_finish(context, successful, successful, time); + return successful; } static void ethi_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, ETableHeaderItem *ethi) { - ethi_remove_drop_marker (ethi); - ethi_add_destroy_marker (ethi); + if (widget == gtk_drag_get_source_widget(context)) { + ethi_remove_drop_marker (ethi); + ethi_add_destroy_marker (ethi); + } } static void @@ -372,7 +412,7 @@ ethi_realize (GnomeCanvasItem *item) /* * Now, configure DnD */ - gtk_drag_dest_set (GTK_WIDGET (item->canvas), GTK_DEST_DEFAULT_ALL, + gtk_drag_dest_set (GTK_WIDGET (item->canvas), 0, ethi_drop_types, ELEMENTS (ethi_drop_types), GDK_ACTION_MOVE); @@ -387,6 +427,10 @@ ethi_realize (GnomeCanvasItem *item) ethi->drag_end_id = gtk_signal_connect ( GTK_OBJECT (item->canvas), "drag_end", GTK_SIGNAL_FUNC (ethi_drag_end), ethi); + + ethi->drag_drop_id = gtk_signal_connect ( + GTK_OBJECT (item->canvas), "drag_drop", + GTK_SIGNAL_FUNC (ethi_drag_drop), ethi); } static void @@ -403,6 +447,7 @@ ethi_unrealize (GnomeCanvasItem *item) gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_motion_id); gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_end_id); gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_leave_id); + gtk_signal_disconnect (GTK_OBJECT (item->canvas), ethi->drag_drop_id); if (ethi->stipple){ gdk_bitmap_unref (ethi->stipple); |