Destroy the tooltip if we're the owner when we're destroyed. Also, keep a

2001-07-07  Christopher James Lahey  <clahey@ximian.com>

	* 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
This commit is contained in:
Christopher James Lahey
2001-07-07 22:21:12 +00:00
committed by Chris Lahey
parent c7fac300f3
commit 23bb03e993
3 changed files with 24 additions and 1 deletions

View File

@ -139,6 +139,8 @@ e_canvas_destroy (GtkObject *object)
canvas->toplevel = NULL;
}
e_canvas_hide_tooltip(canvas);
if ((GTK_OBJECT_CLASS (parent_class))->destroy)
(*(GTK_OBJECT_CLASS (parent_class))->destroy) (object);
}

View File

@ -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;

View File

@ -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 */