Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 19227:ae0f058f604e
Fix a crash regarding tooltips on the infopane.
Steps to reproduce:
Open a conversation, move the mouse and place it over the infopane, close
the conversation window before the tooltip pops up.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 13 Aug 2007 06:22:08 +0000 |
parents | a0d45fa8ecfc |
children | 03d81500766d |
comparison
equal
deleted
inserted
replaced
19226:a0d45fa8ecfc | 19227:ae0f058f604e |
---|---|
4409 gtkchat->list = list; | 4409 gtkchat->list = list; |
4410 | 4410 |
4411 gtk_container_add(GTK_CONTAINER(sw), list); | 4411 gtk_container_add(GTK_CONTAINER(sw), list); |
4412 } | 4412 } |
4413 | 4413 |
4414 static int tooltip_timeout = 0; | 4414 /* Stuff used to display tooltips on the infopane */ |
4415 static struct { | |
4416 int timeout; | |
4417 PidginConversation *gtkconv; /* This is the Pidgin conversation that | |
4418 triggered the tooltip */ | |
4419 } tooltip; | |
4420 | |
4421 static void | |
4422 reset_tooltip() | |
4423 { | |
4424 if (tooltip.timeout != 0) { | |
4425 g_source_remove(tooltip.timeout); | |
4426 tooltip.timeout = 0; | |
4427 } | |
4428 tooltip.gtkconv = NULL; | |
4429 } | |
4415 | 4430 |
4416 static gboolean | 4431 static gboolean |
4417 pidgin_conv_tooltip_timeout(PidginConversation *gtkconv) | 4432 pidgin_conv_tooltip_timeout(PidginConversation *gtkconv) |
4418 { | 4433 { |
4419 PurpleBlistNode *node = NULL; | 4434 PurpleBlistNode *node = NULL; |
4420 PurpleConversation *conv = gtkconv->active_conv; | 4435 PurpleConversation *conv; |
4436 | |
4437 g_return_val_if_fail (tooltip.gtkconv == gtkconv, FALSE); | |
4438 | |
4439 conv = gtkconv->active_conv; | |
4421 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { | 4440 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
4422 node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name)); | 4441 node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name)); |
4423 } else { | 4442 } else { |
4424 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name)); | 4443 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name)); |
4425 } | 4444 } |
4431 | 4450 |
4432 static void | 4451 static void |
4433 pidgin_conv_leave_cb (GtkWidget *w, GdkEventCrossing *e, PidginConversation *gtkconv) | 4452 pidgin_conv_leave_cb (GtkWidget *w, GdkEventCrossing *e, PidginConversation *gtkconv) |
4434 { | 4453 { |
4435 pidgin_blist_tooltip_destroy(); | 4454 pidgin_blist_tooltip_destroy(); |
4436 if (tooltip_timeout) { | 4455 reset_tooltip(); |
4437 g_source_remove(tooltip_timeout); | |
4438 tooltip_timeout = 0; | |
4439 } | |
4440 } | 4456 } |
4441 | 4457 |
4442 static gboolean | 4458 static gboolean |
4443 pidgin_conv_motion_cb (GtkWidget *infopane, GdkEventMotion *event, PidginConversation *gtkconv) | 4459 pidgin_conv_motion_cb (GtkWidget *infopane, GdkEventMotion *event, PidginConversation *gtkconv) |
4444 { | 4460 { |
4446 | 4462 |
4447 pidgin_blist_tooltip_destroy(); | 4463 pidgin_blist_tooltip_destroy(); |
4448 if (delay == 0) | 4464 if (delay == 0) |
4449 return FALSE; | 4465 return FALSE; |
4450 | 4466 |
4451 if (tooltip_timeout != 0) | 4467 if (tooltip.timeout != 0) |
4452 g_source_remove(tooltip_timeout); | 4468 g_source_remove(tooltip.timeout); |
4453 | 4469 |
4454 tooltip_timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv); | 4470 tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv); |
4471 tooltip.gtkconv = gtkconv; | |
4455 return FALSE; | 4472 return FALSE; |
4456 } | 4473 } |
4457 | 4474 |
4458 static GtkWidget * | 4475 static GtkWidget * |
4459 setup_common_pane(PidginConversation *gtkconv) | 4476 setup_common_pane(PidginConversation *gtkconv) |
4982 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); | 4999 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4983 | 5000 |
4984 gtkconv->send_history = g_list_first(gtkconv->send_history); | 5001 gtkconv->send_history = g_list_first(gtkconv->send_history); |
4985 g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); | 5002 g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); |
4986 g_list_free(gtkconv->send_history); | 5003 g_list_free(gtkconv->send_history); |
5004 | |
5005 if (tooltip.gtkconv == gtkconv) | |
5006 reset_tooltip(); | |
4987 | 5007 |
4988 g_free(gtkconv); | 5008 g_free(gtkconv); |
4989 } | 5009 } |
4990 | 5010 |
4991 | 5011 |