Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 19655:1729367f0a4f
Fix a crash when hovering over a buddy in the chat userlist and the account is disconnected.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 05 Sep 2007 23:51:16 +0000 |
parents | b4a4a0a09e0a |
children | 37429bc82307 |
comparison
equal
deleted
inserted
replaced
19653:941965d6fd88 | 19655:1729367f0a4f |
---|---|
4495 | 4495 |
4496 static gboolean | 4496 static gboolean |
4497 pidgin_conv_motion_cb (GtkWidget *infopane, GdkEventMotion *event, PidginConversation *gtkconv) | 4497 pidgin_conv_motion_cb (GtkWidget *infopane, GdkEventMotion *event, PidginConversation *gtkconv) |
4498 { | 4498 { |
4499 int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay"); | 4499 int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay"); |
4500 | 4500 |
4501 pidgin_blist_tooltip_destroy(); | 4501 pidgin_blist_tooltip_destroy(); |
4502 if (delay == 0) | 4502 if (delay == 0) |
4503 return FALSE; | 4503 return FALSE; |
4504 | 4504 |
4505 if (tooltip.timeout != 0) | 4505 if (tooltip.timeout != 0) |
4506 g_source_remove(tooltip.timeout); | 4506 g_source_remove(tooltip.timeout); |
4507 | 4507 |
4508 tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv); | 4508 tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv); |
4509 tooltip.gtkconv = gtkconv; | 4509 tooltip.gtkconv = gtkconv; |
4510 return FALSE; | 4510 return FALSE; |
4514 pidgin_userlist_tooltip_timeout(PidginConversation *gtkconv) | 4514 pidgin_userlist_tooltip_timeout(PidginConversation *gtkconv) |
4515 { | 4515 { |
4516 PurplePluginProtocolInfo *prpl_info; | 4516 PurplePluginProtocolInfo *prpl_info; |
4517 PurpleConversation *conv = gtkconv->active_conv; | 4517 PurpleConversation *conv = gtkconv->active_conv; |
4518 PidginChatPane *gtkchat; | 4518 PidginChatPane *gtkchat; |
4519 PurpleConnection *gc; | |
4520 PurpleBlistNode *node = NULL; | 4519 PurpleBlistNode *node = NULL; |
4521 PurpleAccount *account; | 4520 PurpleAccount *account; |
4522 GtkTreePath *path; | 4521 GtkTreePath *path; |
4523 GtkTreeIter iter; | 4522 GtkTreeIter iter; |
4524 GtkTreeModel *model; | 4523 GtkTreeModel *model; |
4526 gchar *who; | 4525 gchar *who; |
4527 int x, y; | 4526 int x, y; |
4528 | 4527 |
4529 gtkchat = gtkconv->u.chat; | 4528 gtkchat = gtkconv->u.chat; |
4530 account = purple_conversation_get_account(conv); | 4529 account = purple_conversation_get_account(conv); |
4531 gc = account->gc; | 4530 |
4532 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 4531 if (account->gc == NULL) |
4532 return FALSE; | |
4533 | |
4534 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4533 | 4535 |
4534 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 4536 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4535 | 4537 |
4536 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), | 4538 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
4537 tooltip.userlistx, tooltip.userlisty, &path, &column, &x, &y); | 4539 tooltip.userlistx, tooltip.userlisty, &path, &column, &x, &y); |
4541 | 4543 |
4542 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); | 4544 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
4543 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); | 4545 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
4544 | 4546 |
4545 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, who)); | 4547 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, who)); |
4546 if (node && prpl_info && (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) | 4548 if (node && prpl_info && (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) |
4547 pidgin_blist_draw_tooltip(node, gtkconv->infopane); | 4549 pidgin_blist_draw_tooltip(node, gtkconv->infopane); |
4548 | 4550 |
4549 g_free(who); | 4551 g_free(who); |
4550 gtk_tree_path_free(path); | 4552 gtk_tree_path_free(path); |
4551 | 4553 |
4552 | 4554 |
4553 return FALSE; | 4555 return FALSE; |
4554 } | 4556 } |
4555 | 4557 |
4556 static gboolean | 4558 static gboolean |
4557 pidgin_userlist_motion_cb (GtkWidget *w, GdkEventMotion *event, PidginConversation *gtkconv) | 4559 pidgin_userlist_motion_cb (GtkWidget *w, GdkEventMotion *event, PidginConversation *gtkconv) |
4558 { | 4560 { |
4559 PurpleConversation *conv; | 4561 PurpleConversation *conv; |
4562 PurpleAccount *account; | |
4560 int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay"); | 4563 int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay"); |
4561 | 4564 |
4562 pidgin_blist_tooltip_destroy(); | 4565 pidgin_blist_tooltip_destroy(); |
4563 if (delay == 0) | 4566 if (delay == 0) |
4564 return FALSE; | 4567 return FALSE; |
4565 | 4568 |
4566 if (tooltip.timeout != 0) | 4569 if (tooltip.timeout != 0) |
4567 g_source_remove(tooltip.timeout); | 4570 g_source_remove(tooltip.timeout); |
4568 | 4571 tooltip.timeout = 0; |
4572 | |
4569 conv = gtkconv->active_conv; | 4573 conv = gtkconv->active_conv; |
4574 account = purple_conversation_get_account(conv); | |
4575 | |
4576 if (account->gc == NULL) | |
4577 return FALSE; | |
4570 | 4578 |
4571 tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_userlist_tooltip_timeout, gtkconv); | 4579 tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_userlist_tooltip_timeout, gtkconv); |
4572 tooltip.gtkconv = gtkconv; | 4580 tooltip.gtkconv = gtkconv; |
4573 tooltip.userlistx = event->x; | 4581 tooltip.userlistx = event->x; |
4574 tooltip.userlisty = event->y; | 4582 tooltip.userlisty = event->y; |
4604 gtk_box_pack_start(GTK_BOX(vbox), event_box, FALSE, FALSE, 0); | 4612 gtk_box_pack_start(GTK_BOX(vbox), event_box, FALSE, FALSE, 0); |
4605 gtk_container_add(GTK_CONTAINER(event_box), gtkconv->infopane_hbox); | 4613 gtk_container_add(GTK_CONTAINER(event_box), gtkconv->infopane_hbox); |
4606 gtk_widget_show(gtkconv->infopane_hbox); | 4614 gtk_widget_show(gtkconv->infopane_hbox); |
4607 gtk_widget_add_events(event_box, | 4615 gtk_widget_add_events(event_box, |
4608 GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | 4616 GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); |
4609 g_signal_connect(G_OBJECT(event_box), "button_press_event", | 4617 g_signal_connect(G_OBJECT(event_box), "button-press-event", |
4610 G_CALLBACK(infopane_press_cb), gtkconv); | 4618 G_CALLBACK(infopane_press_cb), gtkconv); |
4611 | 4619 |
4612 g_signal_connect(G_OBJECT(event_box), "motion-notify-event", | 4620 g_signal_connect(G_OBJECT(event_box), "motion-notify-event", |
4613 G_CALLBACK(pidgin_conv_motion_cb), gtkconv); | 4621 G_CALLBACK(pidgin_conv_motion_cb), gtkconv); |
4614 g_signal_connect(G_OBJECT(event_box), "leave-notify-event", | 4622 g_signal_connect(G_OBJECT(event_box), "leave-notify-event", |