evolution r37275 - in trunk: calendar calendar/gui widgets/table



Author: mcrha
Date: Mon Feb 16 11:00:23 2009
New Revision: 37275
URL: http://svn.gnome.org/viewvc/evolution?rev=37275&view=rev

Log:
2009-02-16  Milan Crha  <mcrha redhat com>

	** Fix for bug #550114

	* widgets/table/e-table-group.h:
	* widgets/table/e-table-group.c:
	* widgets/table/e-table-group-container.c:
	* widgets/table/e-table-group-leaf.c:
	Replaced 'compute_mouse_over' with 'get_mouse_over', now works
	with cached values 'motion_row', 'motion_col'.
	* widgets/table/e-table.c: (e_table_get_mouse_over_cell):
	Mouse position not required anymore, remove it too then.

	* calendar/gui/e-calendar-table.h: (ec_query_tooltip):
	* calendar/gui/e-calendar-table.c: (ec_query_tooltip): Offer it to others too.
	* calendar/gui/e-calendar-table.c: (query_tooltip_cb): Use above funtion.
	Show proper tooltip in table with grouping columns.
	* calendar/gui/e-memo-table.c: (query_tooltip_cb), (e_memo_table_init):
	Show tooltips in memo view too.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/e-calendar-table.c
   trunk/calendar/gui/e-calendar-table.h
   trunk/calendar/gui/e-memo-table.c
   trunk/widgets/table/ChangeLog
   trunk/widgets/table/e-table-group-container.c
   trunk/widgets/table/e-table-group-leaf.c
   trunk/widgets/table/e-table-group.c
   trunk/widgets/table/e-table-group.h
   trunk/widgets/table/e-table.c
   trunk/widgets/table/e-table.h

Modified: trunk/calendar/gui/e-calendar-table.c
==============================================================================
--- trunk/calendar/gui/e-calendar-table.c	(original)
+++ trunk/calendar/gui/e-calendar-table.c	Mon Feb 16 11:00:23 2009
@@ -276,10 +276,9 @@
                                      buff, buff_len);
 }
 
-static gboolean
-query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+gboolean
+ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkWidget *etable_wgt, ECalModel *model)
 {
-	ECalendarTable *cal_table;
 	ECalModelComponent *comp;
 	int row = -1, col = -1;
 	GtkWidget *box, *l, *w;
@@ -302,13 +301,13 @@
 		return FALSE;
 
 	g_return_val_if_fail (widget != NULL, FALSE);
-	g_return_val_if_fail (E_IS_CALENDAR_TABLE (user_data), FALSE);
 	g_return_val_if_fail (tooltip != NULL, FALSE);
+	g_return_val_if_fail (E_IS_TABLE (etable_wgt), FALSE);
+	g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
 
-	cal_table = E_CALENDAR_TABLE (user_data);
+	etable = E_TABLE (etable_wgt);
 
-	etable = e_calendar_table_get_table (cal_table);
-	e_table_get_mouse_over_cell (etable, x, y, &row, &col);
+	e_table_get_mouse_over_cell (etable, &row, &col);
 	if (row == -1 || !etable)
 		return FALSE;
 
@@ -317,7 +316,7 @@
 	if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter))
 		row = e_sorter_sorted_to_model (esm->sorter, row);
 
-	comp = e_cal_model_get_component_at (cal_table->model, row);
+	comp = e_cal_model_get_component_at (model, row);
 	if (!comp || !comp->icalcomp)
 		return FALSE;
 
@@ -386,7 +385,7 @@
 	e_cal_component_get_dtstart (new_comp, &dtstart);
 	e_cal_component_get_due (new_comp, &dtdue);
 
-	default_zone = e_cal_model_get_timezone  (cal_table->model);
+	default_zone = e_cal_model_get_timezone  (model);
 
 	if (dtstart.tzid) {
 		zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (new_comp), dtstart.tzid);
@@ -476,6 +475,18 @@
 	return TRUE;
 }
 
+static gboolean
+query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+{
+	ECalendarTable *cal_table;
+
+	g_return_val_if_fail (E_IS_CALENDAR_TABLE (user_data), FALSE);
+
+	cal_table = E_CALENDAR_TABLE (user_data);
+
+	return ec_query_tooltip (widget, x, y, keyboard_mode, tooltip, GTK_WIDGET (e_calendar_table_get_table (cal_table)), cal_table->model);
+}
+
 static void
 e_calendar_table_init (ECalendarTable *cal_table)
 {

Modified: trunk/calendar/gui/e-calendar-table.h
==============================================================================
--- trunk/calendar/gui/e-calendar-table.h	(original)
+++ trunk/calendar/gui/e-calendar-table.h	Mon Feb 16 11:00:23 2009
@@ -116,6 +116,8 @@
 
 void e_calendar_table_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed);
 
+gboolean ec_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkWidget *etable_wgt, ECalModel *model);
+
 G_END_DECLS
 
 #endif /* _E_CALENDAR_TABLE_H_ */

Modified: trunk/calendar/gui/e-memo-table.c
==============================================================================
--- trunk/calendar/gui/e-memo-table.c	(original)
+++ trunk/calendar/gui/e-memo-table.c	Mon Feb 16 11:00:23 2009
@@ -57,6 +57,7 @@
 #include <e-util/e-icon-factory.h>
 #include <e-util/e-util-private.h>
 #include "e-cal-popup.h"
+#include "e-calendar-table.h"
 
 enum TargetType{
 	TARGET_TYPE_VCALENDAR
@@ -181,6 +182,18 @@
 	g_signal_emit (memo_table, signals[USER_CREATED], 0);
 }
 
+static gboolean
+query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+{
+	EMemoTable *memo_table;
+
+	g_return_val_if_fail (E_IS_MEMO_TABLE (user_data), FALSE);
+
+	memo_table = E_MEMO_TABLE (user_data);
+
+	return ec_query_tooltip (widget, x, y, keyboard_mode, tooltip, GTK_WIDGET (e_memo_table_get_table (memo_table)), memo_table->model);
+}
+
 static void
 e_memo_table_init (EMemoTable *memo_table)
 {
@@ -272,6 +285,8 @@
 	g_signal_connect (e_table, "right_click", G_CALLBACK (e_memo_table_on_right_click), memo_table);
 	g_signal_connect (e_table, "key_press", G_CALLBACK (e_memo_table_on_key_press), memo_table);
 	g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_memo_table_on_popup_menu), memo_table);
+	g_signal_connect (e_table, "query-tooltip", G_CALLBACK (query_tooltip_cb), memo_table);
+	gtk_widget_set_has_tooltip (GTK_WIDGET (e_table), TRUE);
 
 	a11y = gtk_widget_get_accessible (GTK_WIDGET(e_table));
 	if (a11y)

Modified: trunk/widgets/table/e-table-group-container.c
==============================================================================
--- trunk/widgets/table/e-table-group-container.c	(original)
+++ trunk/widgets/table/e-table-group-container.c	Mon Feb 16 11:00:23 2009
@@ -688,7 +688,7 @@
 }
 
 static void
-etgc_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+etgc_get_mouse_over (ETableGroup *etg, int *row, int *col)
 {
 	ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
 
@@ -697,18 +697,23 @@
 	if (col)
 		*col = -1;
 
-	x -= GROUP_INDENT;
-	y -= TITLE_HEIGHT;
-
-	if (x >= 0 && y >= 0 && etgc->children) {
+	if (etgc->children) {
+		int row_plus = 0;
 		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))
+			e_table_group_get_mouse_over (child, row, col);
+
+			if ((!row || *row != -1) && (!col || *col != -1)) {
+				if (row)
+					*row += row_plus;
 				return;
+			}
+
+			row_plus += e_table_group_row_count (child);
 		}
 	}
 }
@@ -914,7 +919,7 @@
 	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_mouse_over = etgc_get_mouse_over;
 	e_group_class->get_cell_geometry = etgc_get_cell_geometry;
 
 	g_object_class_install_property (object_class, PROP_TABLE_ALTERNATING_ROW_COLORS,

Modified: trunk/widgets/table/e-table-group-leaf.c
==============================================================================
--- trunk/widgets/table/e-table-group-leaf.c	(original)
+++ trunk/widgets/table/e-table-group-leaf.c	Mon Feb 16 11:00:23 2009
@@ -408,11 +408,16 @@
 }
 
 static void
-etgl_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+etgl_get_mouse_over (ETableGroup *etg, int *row, int *col)
 {
 	ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg);
 
-	e_table_item_compute_mouse_over (etgl->item, x, y, row, col);
+	if (etgl->item && etgl->item->motion_row > -1 && etgl->item->motion_col > -1) {
+		if (row)
+			*row = etgl->item->motion_row;
+		if (col)
+			*col = etgl->item->motion_col;
+	}
 }
 
 static void
@@ -573,7 +578,7 @@
 	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_mouse_over = etgl_get_mouse_over;
 	e_group_class->get_cell_geometry = etgl_get_cell_geometry;
 
 	g_object_class_install_property (object_class, PROP_TABLE_ALTERNATING_ROW_COLORS,

Modified: trunk/widgets/table/e-table-group.c
==============================================================================
--- trunk/widgets/table/e-table-group.c	(original)
+++ trunk/widgets/table/e-table-group.c	Mon Feb 16 11:00:23 2009
@@ -382,13 +382,13 @@
 }
 
 void
-e_table_group_compute_mouse_over (ETableGroup *etg, int x, int y, int *row, int *col)
+e_table_group_get_mouse_over (ETableGroup *etg, 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);
+	g_return_if_fail (ETG_CLASS (etg)->get_mouse_over != NULL);
+	ETG_CLASS (etg)->get_mouse_over (etg, row, col);
 }
 
 /**
@@ -648,7 +648,7 @@
 	klass->get_focus = etg_get_focus;
 	klass->get_printable = NULL;
 	klass->compute_location = NULL;
-	klass->compute_mouse_over = NULL;
+	klass->get_mouse_over = NULL;
 	klass->get_cell_geometry = NULL;
 
 	etg_signals [CURSOR_CHANGE] =

Modified: trunk/widgets/table/e-table-group.h
==============================================================================
--- trunk/widgets/table/e-table-group.h	(original)
+++ trunk/widgets/table/e-table-group.h	Mon Feb 16 11:00:23 2009
@@ -90,7 +90,7 @@
 	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_mouse_over)        (ETableGroup *etg, int *row, int *col);
 	void        (*get_cell_geometry)     (ETableGroup *etg, int *row, int *col, int *x, int *y, int *width, int *height);
 
 } ETableGroupClass;
@@ -123,9 +123,7 @@
 					       int               *y,
 					       int               *row,
 					       int               *col);
-void          e_table_group_compute_mouse_over(ETableGroup       *etg,
-					       int                x,
-					       int                y,
+void          e_table_group_get_mouse_over(ETableGroup       *etg,
 					       int               *row,
 					       int               *col);
 void          e_table_group_get_cell_geometry (ETableGroup       *etg,

Modified: trunk/widgets/table/e-table.c
==============================================================================
--- trunk/widgets/table/e-table.c	(original)
+++ trunk/widgets/table/e-table.c	Mon Feb 16 11:00:23 2009
@@ -2416,20 +2416,18 @@
 
 /**
  * e_table_get_mouse_over_cell:
- * Similar to e_table_get_cell_at, only here we recalculate x,y relatively to each item.
+ * Similar to e_table_get_cell_at, only here we check based on the mouse motion information in the group.
  **/
 void
-e_table_get_mouse_over_cell (ETable *table, int x, int y, int *row, int *col)
+e_table_get_mouse_over_cell (ETable *table, 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;
+	if (!table->group)
+		return;
 
-	y -= E_TABLE_HEADER_ITEM (table->header_item)->height;
-
-	e_table_group_compute_mouse_over (table->group, x, y, row, col);
+	e_table_group_get_mouse_over (table->group, row, col);
 }
 
 /**

Modified: trunk/widgets/table/e-table.h
==============================================================================
--- trunk/widgets/table/e-table.h	(original)
+++ trunk/widgets/table/e-table.h	Mon Feb 16 11:00:23 2009
@@ -282,7 +282,7 @@
 						    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_mouse_over_cell (ETable *table, int *row, int *col);
 void             e_table_get_cell_geometry         (ETable               *table,
 						    int                   row,
 						    int                   col,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]