aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-08 12:26:12 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-08 12:26:12 +0800
commitcea054cd54d84479352a43bbabc19c9ce9af5efb (patch)
treeba02763209ba0f22989024004f57689071603ec5 /widgets/table
parent91a6b6899e5568ed34f913bedb538dd6c9e35b32 (diff)
downloadgsoc2013-evolution-cea054cd54d84479352a43bbabc19c9ce9af5efb.tar.gz
gsoc2013-evolution-cea054cd54d84479352a43bbabc19c9ce9af5efb.tar.zst
gsoc2013-evolution-cea054cd54d84479352a43bbabc19c9ce9af5efb.zip
Merge revisions 35747:35930 from trunk.
svn path=/branches/kill-bonobo/; revision=35931
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/ChangeLog19
-rw-r--r--widgets/table/e-table-group-container.c27
-rw-r--r--widgets/table/e-table-group-leaf.c9
-rw-r--r--widgets/table/e-table-group.c11
-rw-r--r--widgets/table/e-table-group.h6
-rw-r--r--widgets/table/e-table-item.c36
-rw-r--r--widgets/table/e-table-item.h5
-rw-r--r--widgets/table/e-table.c18
-rw-r--r--widgets/table/e-table.h1
9 files changed, 131 insertions, 1 deletions
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog
index 0798a43363..d5fe462ccd 100644
--- a/widgets/table/ChangeLog
+++ b/widgets/table/ChangeLog
@@ -1,3 +1,22 @@
+2008-07-15 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #329821
+
+ * e-table-item.c: (find_cell): Do not consider last row's height
+ till the bottom.
+ * e-table-item.h: (e_table_item_compute_mouse_over):
+ * e-table-item.c: (e_table_item_compute_mouse_over):
+ * e-table-group-container.c: (etgc_compute_mouse_over),
+ (etgc_class_init):
+ * e-table-group-leaf.c: (etgl_compute_mouse_over), (etgl_class_init):
+ * e-table.h: (e_table_get_mouse_over_cell):
+ * e-table.c: (e_table_get_mouse_over_cell):
+ * e-table-group.h: (struct ETableGroupClass),
+ (e_table_group_compute_mouse_over):
+ * e-table-group.c: (e_table_group_compute_mouse_over),
+ (etg_class_init): Be able to calculate mouse-over position correctly,
+ relatively to the ETableItem.
+
2008-06-03 Kjartan Maraas <kmaraas@gnome.org>
* e-table-example-1.c: (main):
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index 56562fd5b6..2c61eee775 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -689,6 +689,32 @@ etgc_compute_location (ETableGroup *etg, int *x, int *y, int *row, int *col)
}
static void
+etgc_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+{
+ ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
+
+ if (row)
+ *row = -1;
+ if (col)
+ *col = -1;
+
+ x -= GROUP_INDENT;
+ y -= TITLE_HEIGHT;
+
+ if (x >= 0 && y >= 0 && etgc->children) {
+ GList *list;
+ for (list = etgc->children; list; list = list->next) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ ETableGroup *child = child_node->child;
+
+ e_table_group_compute_mouse_over (child, x, y, row, col);
+ if ((*row != -1) && (*col != -1))
+ return;
+ }
+ }
+}
+
+static void
etgc_get_cell_geometry (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height)
{
ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
@@ -889,6 +915,7 @@ etgc_class_init (ETableGroupContainerClass *klass)
e_group_class->get_focus_column = etgc_get_focus_column;
e_group_class->get_printable = etgc_get_printable;
e_group_class->compute_location = etgc_compute_location;
+ e_group_class->compute_mouse_over = etgc_compute_mouse_over;
e_group_class->get_cell_geometry = etgc_get_cell_geometry;
g_object_class_install_property (object_class, PROP_TABLE_ALTERNATING_ROW_COLORS,
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index ce244d6e04..906208b62d 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -408,6 +408,14 @@ etgl_compute_location (ETableGroup *etg, int *x, int *y, int *row, int *col)
}
static void
+etgl_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+{
+ ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
+
+ e_table_item_compute_mouse_over (etgl->item, x, y, row, col);
+}
+
+static void
etgl_get_cell_geometry (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height)
{
ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
@@ -565,6 +573,7 @@ etgl_class_init (ETableGroupLeafClass *klass)
e_group_class->get_focus_column = etgl_get_focus_column;
e_group_class->get_printable = etgl_get_printable;
e_group_class->compute_location = etgl_compute_location;
+ e_group_class->compute_mouse_over = etgl_compute_mouse_over;
e_group_class->get_cell_geometry = etgl_get_cell_geometry;
g_object_class_install_property (object_class, PROP_TABLE_ALTERNATING_ROW_COLORS,
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
index 7316db8134..0c83c5f608 100644
--- a/widgets/table/e-table-group.c
+++ b/widgets/table/e-table-group.c
@@ -382,6 +382,16 @@ e_table_group_compute_location (ETableGroup *etg, int *x, int *y, int *row, int
ETG_CLASS (etg)->compute_location (etg, x, y, row, col);
}
+void
+e_table_group_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+{
+ g_return_if_fail (etg != NULL);
+ g_return_if_fail (E_IS_TABLE_GROUP (etg));
+
+ g_return_if_fail (ETG_CLASS (etg)->compute_mouse_over != NULL);
+ ETG_CLASS (etg)->compute_mouse_over (etg, x, y, row, col);
+}
+
/**
* e_table_group_get_position
* @eti: %ETableGroup to look in.
@@ -639,6 +649,7 @@ etg_class_init (ETableGroupClass *klass)
klass->get_focus = etg_get_focus;
klass->get_printable = NULL;
klass->compute_location = NULL;
+ klass->compute_mouse_over = NULL;
klass->get_cell_geometry = NULL;
etg_signals [CURSOR_CHANGE] =
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index 490baf6dfa..c6bfd85096 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -90,6 +90,7 @@ typedef struct {
gint (*get_focus_column) (ETableGroup *etg);
EPrintable *(*get_printable) (ETableGroup *etg);
void (*compute_location) (ETableGroup *etg, int *x, int *y, int *row, int *col);
+ void (*compute_mouse_over) (ETableGroup *etg, int x, int y, int *row, int *col);
void (*get_cell_geometry) (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height);
} ETableGroupClass;
@@ -122,6 +123,11 @@ void e_table_group_compute_location (ETableGroup *etg,
int *y,
int *row,
int *col);
+void e_table_group_compute_mouse_over(ETableGroup *etg,
+ int x,
+ int y,
+ int *row,
+ int *col);
void e_table_group_get_cell_geometry (ETableGroup *etg,
int *row,
int *col,
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 3e29680574..a4ec641cc0 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -2171,12 +2171,15 @@ find_cell (ETableItem *eti, double x, double y, int *view_col_res, int *view_row
y1 = y2 = height_extra;
if (y < height_extra)
return FALSE;
- for (row = 0; row < rows - 1; row++, y1 = y2){
+ for (row = 0; row < rows; row++, y1 = y2) {
y2 += ETI_ROW_HEIGHT (eti, row) + height_extra;
if (y <= y2)
break;
}
+
+ if (row == rows)
+ return FALSE;
}
*view_col_res = col;
if (x1_res)
@@ -3442,6 +3445,37 @@ e_table_item_compute_location (ETableItem *eti,
eti->grabbed_row = grabbed_row;
}
+/**
+ * e_table_item_compute_mouse_over:
+ * Similar to e_table_item_compute_location, only here recalculating
+ * the position inside the item too.
+ **/
+void
+e_table_item_compute_mouse_over (ETableItem *eti,
+ int x,
+ int y,
+ int *row,
+ int *col)
+{
+ double realx, realy;
+ /* Save the grabbed row but make sure that we don't get flawed
+ results because the cursor is grabbed. */
+ int grabbed_row = eti->grabbed_row;
+ eti->grabbed_row = -1;
+
+ realx = x;
+ realy = y;
+
+ gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (eti), &realx, &realy);
+
+ if (!find_cell (eti, (int)realx, (int)realy, col, row, NULL, NULL)) {
+ *row = -1;
+ *col = -1;
+ }
+
+ eti->grabbed_row = grabbed_row;
+}
+
void
e_table_item_get_cell_geometry (ETableItem *eti,
int *row,
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index 39a5533837..ef3f4a542a 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -214,6 +214,11 @@ void e_table_item_compute_location (ETableItem *eti,
int *y,
int *row,
int *col);
+void e_table_item_compute_mouse_over (ETableItem *eti,
+ int x,
+ int y,
+ int *row,
+ int *col);
void e_table_item_get_cell_geometry (ETableItem *eti,
int *row,
int *col,
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 6ee1a93cbd..c260199ecb 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -2414,6 +2414,24 @@ e_table_get_cell_geometry (ETable *table,
}
/**
+ * e_table_get_mouse_over_cell:
+ * Similar to e_table_get_cell_at, only here we recalculate x,y relatively to each item.
+ **/
+void
+e_table_get_mouse_over_cell (ETable *table, int x, int y, int *row, int *col)
+{
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (E_IS_TABLE (table));
+
+ x += GTK_LAYOUT (table->table_canvas)->hadjustment->value;
+ y += GTK_LAYOUT (table->table_canvas)->vadjustment->value;
+
+ y -= E_TABLE_HEADER_ITEM (table->header_item)->height;
+
+ e_table_group_compute_mouse_over (table->group, x, y, row, col);
+}
+
+/**
* e_table_get_selection_model:
* @table: The #ETable to query
*
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index acfbc0d879..1dd873e04e 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -283,6 +283,7 @@ void e_table_get_cell_at (ETable *table,
int y,
int *row_return,
int *col_return);
+void e_table_get_mouse_over_cell (ETable *table, int x, int y, int *row, int *col);
void e_table_get_cell_geometry (ETable *table,
int row,
int col,