aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-04-15 22:18:02 +0800
committerChris Lahey <clahey@src.gnome.org>2001-04-15 22:18:02 +0800
commit655592d3a8ee26b96142ef09fdf0cd1a8eb776ed (patch)
tree19081e1b5323b7b126c8e41b4ee54945088be251
parent9c91a37ee139de657d2ac341d246f93e186e6332 (diff)
downloadgsoc2013-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
-rw-r--r--widgets/misc/e-canvas.c55
-rw-r--r--widgets/misc/e-canvas.h8
-rw-r--r--widgets/text/e-text.c36
3 files changed, 79 insertions, 20 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 */
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 76fb2f4714..eb4e1d02bb 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -2664,18 +2664,12 @@ tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text)
gint ret_val = FALSE;
switch (event->type) {
case GDK_LEAVE_NOTIFY:
- if (text->tooltip_window) {
- gtk_widget_destroy (text->tooltip_window);
- text->tooltip_window = NULL;
- }
+ e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->type == GDK_BUTTON_RELEASE) {
- if (text->tooltip_window) {
- gtk_widget_destroy (text->tooltip_window);
- text->tooltip_window = NULL;
- }
+ e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
}
/* Forward events to the text item */
gtk_signal_emit_by_name (GTK_OBJECT (text), "event", event,
@@ -2708,12 +2702,13 @@ _do_tooltip (gpointer data)
double x1, x2, y1, y2;
#endif
GnomeCanvasItem *rect;
+ GtkWidget *tooltip_window; /* GtkWindow for displaying the tooltip */
text->tooltip_count = 0;
lines = text->lines;
- if (text->tooltip_window || text->editing || (!lines)) {
+ if (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas)->tooltip_window || text->editing || (!lines)) {
text->tooltip_timeout = 0;
return FALSE;
}
@@ -2739,12 +2734,12 @@ _do_tooltip (gpointer data)
pixel_origin.x -= (int) gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(text)->canvas))->value;
pixel_origin.y -= (int) gtk_layout_get_vadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(text)->canvas))->value;
- text->tooltip_window = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_container_set_border_width (GTK_CONTAINER (text->tooltip_window), 1);
+ tooltip_window = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_container_set_border_width (GTK_CONTAINER (tooltip_window), 1);
canvas = e_canvas_new ();
- gtk_container_add (GTK_CONTAINER (text->tooltip_window), canvas);
+ gtk_container_add (GTK_CONTAINER (tooltip_window), canvas);
/* Get the longest line length */
max_width = 0.0;
@@ -2770,6 +2765,7 @@ _do_tooltip (gpointer data)
tooltip_text = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
e_text_get_type (),
"anchor", GTK_ANCHOR_NW,
+ "bold", text->bold,
"font_e", text->font,
"text", text->text,
"editable", FALSE,
@@ -2867,18 +2863,21 @@ _do_tooltip (gpointer data)
"y2", (double) tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0),
NULL);
- gtk_widget_set_usize (text->tooltip_window,
+ gtk_widget_set_usize (tooltip_window,
tooltip_width + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0),
tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0));
gnome_canvas_set_scroll_region (GNOME_CANVAS(canvas), 0.0, 0.0,
tooltip_width + (text->draw_borders ? BORDER_INDENT * 2 : 0),
(double)tooltip_height + (text->draw_borders ? BORDER_INDENT * 2 : 0));
gtk_widget_show (canvas);
- gtk_widget_realize (text->tooltip_window);
- gtk_signal_connect (GTK_OBJECT(text->tooltip_window), "event",
+ gtk_widget_realize (tooltip_window);
+ gtk_signal_connect (GTK_OBJECT(tooltip_window), "event",
GTK_SIGNAL_FUNC(tooltip_event), text);
- gtk_widget_popup (text->tooltip_window, pixel_origin.x - 2 + tooltip_x, pixel_origin.y - 2 + tooltip_y);
+ e_canvas_popup_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas),
+ tooltip_window,
+ pixel_origin.x - 2 + tooltip_x,
+ pixel_origin.y - 2 + tooltip_y);
text->tooltip_timeout = 0;
return FALSE;
@@ -2994,10 +2993,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
gtk_timeout_remove (text->tooltip_timeout);
text->tooltip_timeout = 0;
}
- if (text->tooltip_window) {
- gtk_widget_destroy (text->tooltip_window);
- text->tooltip_window = NULL;
- }
+ e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
#if 0
if ((!text->editing)
&& text->editable