gnumeric r17176 - in trunk: . src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17176 - in trunk: . src
- Date: Fri, 6 Mar 2009 00:05:35 +0000 (UTC)
Author: mortenw
Date: Fri Mar 6 00:05:34 2009
New Revision: 17176
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17176&view=rev
Log:
2009-03-05 Morten Welinder <terra gnome org>
* src/item-cursor.c (struct _ItemCursor): Track last (x,y) for
mouse.
(item_cursor_event): Set (x,y).
(item_cursor_tip_setlabel): Use (x,y) for position.
* src/item-grid.c (struct _ItemGrid): Track last (x,y) for mouse.
(cb_cursor_come_to_rest): Use last (x,y) to position the tip.
* src/gui-util.c (gnumeric_create_tooltip): Take a reference
widget instead of a GdkScreen. All callers changed.
(gnumeric_position_tooltip): Get position as argument instead of
asking where the mouse cursor is by the time we get here. All
callers changed.
Modified:
trunk/ChangeLog
trunk/src/gnm-pane.c
trunk/src/gui-util.c
trunk/src/gui-util.h
trunk/src/item-bar.c
trunk/src/item-cursor.c
trunk/src/item-grid.c
Modified: trunk/src/gnm-pane.c
==============================================================================
--- trunk/src/gnm-pane.c (original)
+++ trunk/src/gnm-pane.c Fri Mar 6 00:05:34 2009
@@ -1969,11 +1969,12 @@
g_return_if_fail (so != NULL);
if (pane->size_tip == NULL) {
+ GtkWidget *cw = GTK_WIDGET (pane);
GtkWidget *top;
int x, y;
- GdkScreen *screen = gtk_window_get_screen (wbcg_toplevel (scg_wbcg (scg)));
+ GdkScreen *screen = gtk_widget_get_screen (cw);
- pane->size_tip = gnumeric_create_tooltip (screen);
+ pane->size_tip = gnumeric_create_tooltip (cw);
top = gtk_widget_get_toplevel (pane->size_tip);
/* do not use gnumeric_position_tooltip because it places the tip
* too close to the mouse and generates LEAVE events */
Modified: trunk/src/gui-util.c
==============================================================================
--- trunk/src/gui-util.c (original)
+++ trunk/src/gui-util.c Fri Mar 6 00:05:34 2009
@@ -427,7 +427,7 @@
GtkWidget *
-gnumeric_create_tooltip (GdkScreen *screen)
+gnumeric_create_tooltip (GtkWidget *ref_widget)
{
GtkWidget *tip, *label, *frame;
static GtkRcStyle*rc_style = NULL;
@@ -443,7 +443,7 @@
}
tip = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_screen (GTK_WINDOW (tip), screen);
+ gtk_window_set_screen (GTK_WINDOW (tip), gtk_widget_get_screen (ref_widget));
if (rc_style != NULL)
gtk_widget_modify_style (tip, rc_style);
@@ -458,29 +458,26 @@
}
void
-gnumeric_position_tooltip (GtkWidget *tip, int horizontal)
+gnumeric_position_tooltip (GtkWidget *tip, int px, int py, gboolean horizontal)
{
GtkRequisition req;
- int x, y;
gtk_widget_size_request (tip, &req);
- gdk_window_get_pointer (gdk_screen_get_root_window (gtk_widget_get_screen (tip)),
- &x, &y, NULL);
if (horizontal){
- x -= req.width / 2;
- y -= req.height + 20;
+ px -= req.width / 2;
+ py -= req.height + 20;
} else {
- x -= req.width + 20;
- y -= req.height / 2;
+ px -= req.width + 20;
+ py -= req.height / 2;
}
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
+ if (px < 0)
+ px = 0;
+ if (py < 0)
+ py = 0;
- gtk_window_move (GTK_WINDOW (gtk_widget_get_toplevel (tip)), x, y);
+ gtk_window_move (GTK_WINDOW (gtk_widget_get_toplevel (tip)), px, py);
}
/**
Modified: trunk/src/gui-util.h
==============================================================================
--- trunk/src/gui-util.h (original)
+++ trunk/src/gui-util.h Fri Mar 6 00:05:34 2009
@@ -38,8 +38,9 @@
/*
* Pseudo-tool-tip support code.
*/
-void gnumeric_position_tooltip (GtkWidget *tip, int horizontal);
-GtkWidget *gnumeric_create_tooltip (GdkScreen *screen);
+void gnumeric_position_tooltip (GtkWidget *tip, int px, int py,
+ gboolean horizontal);
+GtkWidget *gnumeric_create_tooltip (GtkWidget *ref_widget);
GladeXML *gnm_glade_xml_new (GOCmdContext *cc, char const *gladefile,
char const *root, char const *domain);
Modified: trunk/src/item-bar.c
==============================================================================
--- trunk/src/item-bar.c (original)
+++ trunk/src/item-bar.c Fri Mar 6 00:05:34 2009
@@ -964,7 +964,10 @@
ib->colrow_resize_size = cri->size_pixels;
if (ib->tip == NULL) {
- ib->tip = gnumeric_create_tooltip (gdk_event_get_screen (e));
+ GtkWidget *cw = GTK_WIDGET (canvas);
+ int wx, wy;
+ gdk_window_get_origin (cw->window, &wx, &wy);
+ ib->tip = gnumeric_create_tooltip (cw);
colrow_tip_setlabel (ib, is_cols, ib->colrow_resize_size);
/* Position above the current point for both
* col and row headers. trying to put it
@@ -972,7 +975,10 @@
* the tip under the cursor which can have odd
* effects on the event stream. win32 was
* different from X. */
- gnumeric_position_tooltip (ib->tip, TRUE);
+ gnumeric_position_tooltip (ib->tip,
+ wx + e->button.x,
+ wy + e->button.y,
+ TRUE);
gtk_widget_show_all (gtk_widget_get_toplevel (ib->tip));
}
} else {
Modified: trunk/src/item-cursor.c
==============================================================================
--- trunk/src/item-cursor.c (original)
+++ trunk/src/item-cursor.c Fri Mar 6 00:05:34 2009
@@ -72,6 +72,7 @@
int base_x, base_y;
GnmRange autofill_src;
int autofill_hsize, autofill_vsize;
+ gint last_x, last_y;
/* cursor outline in canvas coords, the bounding box (Item::[xy][01])
* is slightly larger ) */
@@ -1061,9 +1062,13 @@
item_cursor_tip_setlabel (ItemCursor *ic, char const *text)
{
if (ic->tip == NULL) {
- GdkScreen *screen = gtk_window_get_screen (wbcg_toplevel (scg_wbcg (ic->scg)));
- ic->tip = gnumeric_create_tooltip (screen);
- gnumeric_position_tooltip (ic->tip, TRUE);
+ GtkWidget *cw = GTK_WIDGET (FOO_CANVAS_ITEM (ic)->canvas);
+ int wx, wy;
+ gdk_window_get_origin (cw->window, &wx, &wy);
+ ic->tip = gnumeric_create_tooltip (cw);
+ gnumeric_position_tooltip (ic->tip,
+ wx + ic->last_x,
+ wy + ic->last_y, TRUE);
gtk_widget_show_all (gtk_widget_get_toplevel (ic->tip));
}
@@ -1294,6 +1299,15 @@
break;
}
#endif
+ switch (event->type) {
+ case GDK_MOTION_NOTIFY:
+ ic->last_x = event->motion.x;
+ ic->last_y = event->motion.y;
+ break;
+ default:
+ ;
+ }
+
if (ic->style == ITEM_CURSOR_EXPR_RANGE)
return item_cursor_expr_range_event (item, event);
@@ -1413,6 +1427,9 @@
ic->last_tip_pos.col = -1;
ic->last_tip_pos.row = -1;
+ ic->last_x = 0;
+ ic->last_y = 0;
+
ic->style = ITEM_CURSOR_SELECTION;
ic->gc = NULL;
ic->state = 0;
Modified: trunk/src/item-grid.c
==============================================================================
--- trunk/src/item-grid.c (original)
+++ trunk/src/item-grid.c Fri Mar 6 00:05:34 2009
@@ -78,7 +78,7 @@
/* information for the cursor motion handler */
guint cursor_timer;
- double last_x, last_y;
+ gint last_x, last_y;
GnmHLink *cur_link; /* do not derference, just a pointer */
GtkWidget *tip;
guint tip_timer;
@@ -966,10 +966,14 @@
g_return_val_if_fail (link == ig->cur_link, FALSE);
if (ig->tip == NULL && strlen (tiptext) > 0) {
- GdkScreen *screen = gtk_window_get_screen (wbcg_toplevel (scg_wbcg (ig->scg)));
- ig->tip = gnumeric_create_tooltip (screen);
+ GtkWidget *cw = GTK_WIDGET (canvas);
+ int wx, wy;
+ gdk_window_get_origin (cw->window, &wx, &wy);
+ ig->tip = gnumeric_create_tooltip (cw);
+ gnumeric_position_tooltip (ig->tip,
+ wx + ig->last_x,
+ wy + ig->last_y, TRUE);
gtk_label_set_text (GTK_LABEL (ig->tip), tiptext);
- gnumeric_position_tooltip (ig->tip, TRUE);
gtk_widget_show_all (gtk_widget_get_toplevel (ig->tip));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]