From 23bb03e9939cc86b68b546570edc7884d7a1b051 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 7 Jul 2001 22:21:12 +0000 Subject: Destroy the tooltip if we're the owner when we're destroyed. Also, keep a 2001-07-07 Christopher James Lahey * gal/e-text/e-text.c, gal/e-text/e-text.h (e_text_destroy): Destroy the tooltip if we're the owner when we're destroyed. Also, keep a reference to the text object in case we get a signal on the window after the text object is destroyed. * gal/widgets/e-canvas.c (e_canvas_destroy): Hide the tooltip if there is one when the canvas is destroyed. svn path=/trunk/; revision=10888 --- widgets/text/e-text.c | 21 ++++++++++++++++++++- widgets/text/e-text.h | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'widgets/text') diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index fadb390c4f..d838518d5f 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -354,7 +354,7 @@ e_text_init (EText *text) { text->model = e_text_model_new (); text->text = e_text_model_get_text (text->model); - + gtk_object_ref (GTK_OBJECT (text->model)); gtk_object_sink (GTK_OBJECT (text->model)); @@ -420,6 +420,7 @@ e_text_init (EText *text) text->tooltip_timeout = 0; text->tooltip_count = 0; + text->tooltip_owner = FALSE; text->dbl_timeout = 0; text->tpl_timeout = 0; @@ -445,6 +446,10 @@ e_text_destroy (GtkObject *object) text = E_TEXT (object); + if (text->tooltip_owner) { + e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas)); + } + if (text->model_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT (text->model), text->model_changed_signal_id); @@ -2682,6 +2687,9 @@ static gboolean tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text) { gint ret_val = FALSE; + if (GTK_OBJECT_DESTROYED (text)) { + return FALSE; + } switch (event->type) { case GDK_LEAVE_NOTIFY: e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas)); @@ -2703,6 +2711,13 @@ tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text) return ret_val; } +static void +tooltip_destroy(GtkWidget *tooltip, EText *text) +{ + text->tooltip_owner = FALSE; + gtk_object_unref (GTK_OBJECT (text)); +} + static gboolean _do_tooltip (gpointer data) { @@ -2883,11 +2898,15 @@ _do_tooltip (gpointer data) gtk_widget_realize (tooltip_window); gtk_signal_connect (GTK_OBJECT(tooltip_window), "event", GTK_SIGNAL_FUNC(tooltip_event), text); + gtk_signal_connect (GTK_OBJECT(tooltip_window), "destroy", + GTK_SIGNAL_FUNC(tooltip_destroy), text); + gtk_object_ref (GTK_OBJECT (text)); 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_owner = TRUE; text->tooltip_timeout = 0; return FALSE; diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h index dfb25d21b5..b3126bf291 100644 --- a/widgets/text/e-text.h +++ b/widgets/text/e-text.h @@ -206,6 +206,8 @@ struct _EText { guint bold : 1; guint strikeout : 1; + guint tooltip_owner : 1; + EFontStyle style; gchar *break_characters; /* Characters to optionally break after */ -- cgit v1.2.3