aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-06-22 06:49:34 +0800
committerChris Lahey <clahey@src.gnome.org>2000-06-22 06:49:34 +0800
commita30a2c116239e615c685194c9287c3adc05594a5 (patch)
treed1914a4a7a36f9974058011d0d808f91c0aec078
parent36f9a550565abe5d08cccb61fe26293ea7aa30c9 (diff)
downloadgsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar.gz
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar.bz2
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar.lz
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar.xz
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.tar.zst
gsoc2013-evolution-a30a2c116239e615c685194c9287c3adc05594a5.zip
Changed this to move the cell to the nearest edge instead of to the left
2000-06-21 Christopher James Lahey <clahey@helixcode.com> * e-table-header-item.c: Changed this to move the cell to the nearest edge instead of to the left of the column it's over. * e-table-header.c: Made target_index equal to eti->col_count be a valid parameter to e_table_header_move. svn path=/trunk/; revision=3683
-rw-r--r--widgets/e-table/ChangeLog8
-rw-r--r--widgets/e-table/e-table-header-item.c48
-rw-r--r--widgets/e-table/e-table-header.c2
-rw-r--r--widgets/table/e-table-header-item.c48
-rw-r--r--widgets/table/e-table-header.c2
5 files changed, 102 insertions, 6 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 6b3b94eef3..f21c68648b 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,13 @@
2000-06-21 Christopher James Lahey <clahey@helixcode.com>
+ * e-table-header-item.c: Changed this to move the cell to the
+ nearest edge instead of to the left of the column it's over.
+
+ * e-table-header.c: Made target_index equal to eti->col_count be a
+ valid parameter to e_table_header_move.
+
+2000-06-21 Christopher James Lahey <clahey@helixcode.com>
+
* e-table-header.c: Made moving columns to the right work
properly.
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index 8ee5242447..1ff89a306d 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -304,6 +304,31 @@ ethi_find_col_by_x (ETableHeaderItem *ethi, int x)
return -1;
}
+static int
+ethi_find_col_by_x_nearest (ETableHeaderItem *ethi, int x)
+{
+ const int cols = e_table_header_count (ethi->eth);
+ int x1 = 0;
+ int col;
+
+ if (x < x1)
+ return -1;
+
+ x1 += ethi->group_indent_width;
+
+ for (col = 0; col < cols; col++){
+ ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
+
+ x1 += (ecol->width / 2);
+
+ if (x <= x1)
+ return col;
+
+ x1 += (ecol->width + 1) / 2;
+ }
+ return col;
+}
+
static void
ethi_remove_drop_marker (ETableHeaderItem *ethi)
{
@@ -420,6 +445,24 @@ ethi_remove_destroy_marker (ETableHeaderItem *ethi)
ethi->remove_item = NULL;
}
+#if 0
+static gboolean
+moved (ETableHeaderItem *ethi, guint col, guint model_col)
+{
+ if (col == -1)
+ return TRUE;
+ ecol = e_table_header_get_column (ethi->eth, col);
+ if (ecol->col_idx == model_col)
+ return FALSE;
+ if (col > 0) {
+ ecol = e_table_header_get_column (ethi->eth, col - 1);
+ if (ecol->col_idx == model_col)
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
static gboolean
ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
gint x, gint y, guint time,
@@ -430,11 +473,12 @@ ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
(y >= 0) && (y <= (ethi->height))){
int col;
- col = ethi_find_col_by_x (ethi, x);
+ col = ethi_find_col_by_x_nearest (ethi, x);
if (col != -1){
if (ethi->drag_col != -1)
ethi_remove_destroy_marker (ethi);
+
ethi_add_drop_marker (ethi, col);
gdk_drag_status (context, context->suggested_action, time);
} else {
@@ -538,7 +582,7 @@ ethi_drag_drop (GtkWidget *canvas,
(y >= 0) && (y <= (ethi->height))){
int col;
- col = ethi_find_col_by_x (ethi, x);
+ col = ethi_find_col_by_x_nearest (ethi, x);
ethi_add_drop_marker (ethi, col);
diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c
index 2ac82215df..06aeb50b3f 100644
--- a/widgets/e-table/e-table-header.c
+++ b/widgets/e-table/e-table-header.c
@@ -447,7 +447,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
g_return_if_fail (source_index >= 0);
g_return_if_fail (target_index >= 0);
g_return_if_fail (source_index < eth->col_count);
- g_return_if_fail (target_index < eth->col_count);
+ g_return_if_fail (target_index < eth->col_count + 1); /* Can be moved beyond the last item. */
if (source_index < target_index)
target_index --;
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index 8ee5242447..1ff89a306d 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -304,6 +304,31 @@ ethi_find_col_by_x (ETableHeaderItem *ethi, int x)
return -1;
}
+static int
+ethi_find_col_by_x_nearest (ETableHeaderItem *ethi, int x)
+{
+ const int cols = e_table_header_count (ethi->eth);
+ int x1 = 0;
+ int col;
+
+ if (x < x1)
+ return -1;
+
+ x1 += ethi->group_indent_width;
+
+ for (col = 0; col < cols; col++){
+ ETableCol *ecol = e_table_header_get_column (ethi->eth, col);
+
+ x1 += (ecol->width / 2);
+
+ if (x <= x1)
+ return col;
+
+ x1 += (ecol->width + 1) / 2;
+ }
+ return col;
+}
+
static void
ethi_remove_drop_marker (ETableHeaderItem *ethi)
{
@@ -420,6 +445,24 @@ ethi_remove_destroy_marker (ETableHeaderItem *ethi)
ethi->remove_item = NULL;
}
+#if 0
+static gboolean
+moved (ETableHeaderItem *ethi, guint col, guint model_col)
+{
+ if (col == -1)
+ return TRUE;
+ ecol = e_table_header_get_column (ethi->eth, col);
+ if (ecol->col_idx == model_col)
+ return FALSE;
+ if (col > 0) {
+ ecol = e_table_header_get_column (ethi->eth, col - 1);
+ if (ecol->col_idx == model_col)
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
static gboolean
ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
gint x, gint y, guint time,
@@ -430,11 +473,12 @@ ethi_drag_motion (GtkObject *canvas, GdkDragContext *context,
(y >= 0) && (y <= (ethi->height))){
int col;
- col = ethi_find_col_by_x (ethi, x);
+ col = ethi_find_col_by_x_nearest (ethi, x);
if (col != -1){
if (ethi->drag_col != -1)
ethi_remove_destroy_marker (ethi);
+
ethi_add_drop_marker (ethi, col);
gdk_drag_status (context, context->suggested_action, time);
} else {
@@ -538,7 +582,7 @@ ethi_drag_drop (GtkWidget *canvas,
(y >= 0) && (y <= (ethi->height))){
int col;
- col = ethi_find_col_by_x (ethi, x);
+ col = ethi_find_col_by_x_nearest (ethi, x);
ethi_add_drop_marker (ethi, col);
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index 2ac82215df..06aeb50b3f 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -447,7 +447,7 @@ e_table_header_move (ETableHeader *eth, int source_index, int target_index)
g_return_if_fail (source_index >= 0);
g_return_if_fail (target_index >= 0);
g_return_if_fail (source_index < eth->col_count);
- g_return_if_fail (target_index < eth->col_count);
+ g_return_if_fail (target_index < eth->col_count + 1); /* Can be moved beyond the last item. */
if (source_index < target_index)
target_index --;