aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-02-12 06:08:09 +0800
committerChris Lahey <clahey@src.gnome.org>2000-02-12 06:08:09 +0800
commit4a25f612c0fb701a774d20c19888957c555e54a2 (patch)
tree0e0f46269cd0522aaa793ef5552ec499d0613176 /widgets/table
parent4a7411c370d573842a35354f88201a29f180aad0 (diff)
downloadgsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar
gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.gz
gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.bz2
gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.lz
gsoc2013-evolution-4a25f612c0fb701a774d20c19888957c555e54a2.tar.xz
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')
-rw-r--r--widgets/table/e-table-header-item.c87
-rw-r--r--widgets/table/e-table-header-item.h2
-rw-r--r--widgets/table/e-table-header.c6
3 files changed, 70 insertions, 25 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);
diff --git a/widgets/table/e-table-header-item.h b/widgets/table/e-table-header-item.h
index 5522d24fae..156e25beef 100644
--- a/widgets/table/e-table-header-item.h
+++ b/widgets/table/e-table-header-item.h
@@ -42,7 +42,7 @@ typedef struct {
guint dnd_ready:1;
int click_x, click_y;
int drag_col, drag_mark;
- guint drag_motion_id, drag_end_id, drag_leave_id;
+ guint drag_motion_id, drag_end_id, drag_leave_id, drag_drop_id;
GnomeCanvasItem *drag_mark_item, *remove_item;
GdkBitmap *stipple;
} ETableHeaderItem;
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index 7c54bd936e..2147869678 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -100,9 +100,10 @@ e_table_header_new (void)
static void
eth_do_insert (ETableHeader *eth, int pos, ETableCol *val)
{
- memcpy (&eth->columns [pos+1], &eth->columns [pos],
+ memmove (&eth->columns [pos+1], &eth->columns [pos],
sizeof (ETableCol *) * (eth->col_count - pos));
eth->columns [pos] = val;
+ eth->col_count ++;
}
static void
@@ -139,7 +140,6 @@ e_table_header_add_column (ETableHeader *eth, ETableCol *tc, int pos)
gtk_object_sink (GTK_OBJECT (tc));
eth_do_insert (eth, pos, tc);
- eth->col_count++;
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [STRUCTURE_CHANGE]);
@@ -261,7 +261,7 @@ eth_do_remove (ETableHeader *eth, int idx, gboolean do_unref)
if (do_unref)
gtk_object_unref (GTK_OBJECT (eth->columns [idx]));
- memcpy (&eth->columns [idx], &eth->columns [idx+1],
+ memmove (&eth->columns [idx], &eth->columns [idx+1],
sizeof (ETableCol *) * eth->col_count - idx);
eth->col_count--;
}