diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-04-15 22:18:02 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-04-15 22:18:02 +0800 |
commit | 655592d3a8ee26b96142ef09fdf0cd1a8eb776ed (patch) | |
tree | 19081e1b5323b7b126c8e41b4ee54945088be251 /widgets/misc | |
parent | 9c91a37ee139de657d2ac341d246f93e186e6332 (diff) | |
download | gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar.gz gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar.bz2 gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar.lz gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar.xz gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.tar.zst gsoc2013-evolution-655592d3a8ee26b96142ef09fdf0cd1a8eb776ed.zip |
Use e_canvas_hide_tooltip and e_canvas_popup_tooltip. Set bold on the
2001-04-15 Christopher James Lahey <clahey@ximian.com>
* gal/e-text/e-text.c (tooltip_event): Use e_canvas_hide_tooltip
and e_canvas_popup_tooltip. Set bold on the tooltip.
* gal/widgets/e-canvas.c, gal/widgets/e-canvas.h: Added
e_canvas_popup_tooltip and e_canvas_hide_tooltip.
svn path=/trunk/; revision=9323
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-canvas.c | 55 | ||||
-rw-r--r-- | widgets/misc/e-canvas.h | 8 |
2 files changed, 63 insertions, 0 deletions
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c index 91fbca29b8..e48c6bb821 100644 --- a/widgets/misc/e-canvas.c +++ b/widgets/misc/e-canvas.c @@ -31,6 +31,10 @@ static void e_canvas_unrealize (GtkWidget *widget); static gint e_canvas_key (GtkWidget *widget, GdkEventKey *event); +static gint e_canvas_visibility (GtkWidget *widget, + GdkEventVisibility *event, + ECanvas *canvas); + static gint e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event); static gint e_canvas_focus_out (GtkWidget *widget, @@ -114,6 +118,7 @@ e_canvas_init (ECanvas *canvas) canvas->cursor = NULL; canvas->ic = NULL; canvas->ic_attr = NULL; + canvas->tooltip_window = NULL; } static void @@ -124,6 +129,16 @@ e_canvas_destroy (GtkObject *object) if (canvas->idle_id) g_source_remove(canvas->idle_id); + if (canvas->toplevel) { + if (canvas->visibility_notify_id) + gtk_signal_disconnect (GTK_OBJECT(canvas->toplevel), + canvas->visibility_notify_id); + canvas->visibility_notify_id = 0; + + gtk_object_unref(GTK_OBJECT(canvas->toplevel)); + canvas->toplevel = NULL; + } + if ((GTK_OBJECT_CLASS (parent_class))->destroy) (*(GTK_OBJECT_CLASS (parent_class))->destroy) (object); } @@ -284,6 +299,18 @@ e_canvas_key (GtkWidget *widget, GdkEventKey *event) return emit_event (canvas, &full_event); } +/* Key event handler for the canvas */ +static gint +e_canvas_visibility (GtkWidget *widget, GdkEventVisibility *event, ECanvas *canvas) +{ + if (! canvas->visibility_first) { + e_canvas_hide_tooltip(canvas); + } + canvas->visibility_first = FALSE; + + return FALSE; +} + /** * e_canvas_item_grab_focus: @@ -703,3 +730,31 @@ e_canvas_item_remove_selection (GnomeCanvasItem *item, gpointer id) } } } + +void e_canvas_popup_tooltip (ECanvas *canvas, GtkWidget *widget, int x, int y) +{ + if (canvas->tooltip_window && canvas->tooltip_window != widget) { + e_canvas_hide_tooltip(canvas); + } + canvas->tooltip_window = widget; + canvas->visibility_first = TRUE; + if (canvas->toplevel == NULL) { + canvas->toplevel = gtk_widget_get_toplevel (GTK_WIDGET(canvas)); + if (canvas->toplevel) { + gtk_widget_add_events(canvas->toplevel, GDK_VISIBILITY_NOTIFY_MASK); + gtk_object_ref(GTK_OBJECT(canvas->toplevel)); + canvas->visibility_notify_id = + gtk_signal_connect (GTK_OBJECT (canvas->toplevel), "visibility_notify_event", + GTK_SIGNAL_FUNC (e_canvas_visibility), canvas); + } + } + gtk_widget_popup (widget, x, y); +} + +void e_canvas_hide_tooltip (ECanvas *canvas) +{ + if (canvas->tooltip_window) { + gtk_widget_destroy (canvas->tooltip_window); + canvas->tooltip_window = NULL; + } +} diff --git a/widgets/misc/e-canvas.h b/widgets/misc/e-canvas.h index 212fda7c2f..820dcddc2e 100644 --- a/widgets/misc/e-canvas.h +++ b/widgets/misc/e-canvas.h @@ -79,6 +79,11 @@ struct _ECanvas GList *selection; ECanvasSelectionInfo *cursor; + GtkWidget *tooltip_window; + int visibility_notify_id; + GtkWidget *toplevel; + guint visibility_first : 1; + /* Input context for dead key support */ GdkIC *ic; GdkICAttr *ic_attr; @@ -113,6 +118,9 @@ void e_canvas_item_remove_selection (GnomeCanvasItem *item, gpointer id); /* Not implemented yet. */ void e_canvas_item_set_cursor_end (GnomeCanvasItem *item, gpointer id); +void e_canvas_popup_tooltip (ECanvas *canvas, GtkWidget *widget, int x, int y); +void e_canvas_hide_tooltip (ECanvas *canvas); + #ifdef __cplusplus } #endif /* __cplusplus */ |