| 158 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); |
159 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); |
| 159 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); |
160 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); |
| 160 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); |
161 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); |
| 161 static gboolean pidgin_userlist_motion_cb (GtkWidget *w, GdkEventMotion *event, PidginConversation *gtkconv); |
162 static gboolean pidgin_userlist_motion_cb (GtkWidget *w, GdkEventMotion *event, PidginConversation *gtkconv); |
| 162 static void pidgin_conv_leave_cb (GtkWidget *w, GdkEventCrossing *e, PidginConversation *gtkconv); |
163 static void pidgin_conv_leave_cb (GtkWidget *w, GdkEventCrossing *e, PidginConversation *gtkconv); |
| |
164 static void hide_conv(PidginConversation *gtkconv, gboolean closetimer); |
| 163 |
165 |
| 164 static void pidgin_conv_set_position_size(PidginWindow *win, int x, int y, |
166 static void pidgin_conv_set_position_size(PidginWindow *win, int x, int y, |
| 165 int width, int height); |
167 int width, int height); |
| 166 |
168 |
| 167 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { |
169 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { |
| 205 /************************************************************************** |
207 /************************************************************************** |
| 206 * Callbacks |
208 * Callbacks |
| 207 **************************************************************************/ |
209 **************************************************************************/ |
| 208 |
210 |
| 209 static gboolean |
211 static gboolean |
| 210 close_conv_cb(GtkWidget *w, GdkEventButton *event, PidginConversation *gtkconv) |
212 close_this_sucker(gpointer data) |
| 211 { |
213 { |
| |
214 PidginConversation *gtkconv = data; |
| 212 GList *list = g_list_copy(gtkconv->convs); |
215 GList *list = g_list_copy(gtkconv->convs); |
| 213 |
|
| 214 g_list_foreach(list, (GFunc)purple_conversation_destroy, NULL); |
216 g_list_foreach(list, (GFunc)purple_conversation_destroy, NULL); |
| 215 g_list_free(list); |
217 g_list_free(list); |
| |
218 return FALSE; |
| |
219 } |
| |
220 |
| |
221 static gboolean |
| |
222 close_conv_cb(GtkWidget *w, GdkEventButton *event, PidginConversation *gtkconv) |
| |
223 { |
| |
224 /* We are going to destroy the conversations immediately only if the 'close immediately' |
| |
225 * preference is selected. Otherwise, close the conversation after a reasonable timeout |
| |
226 * (I am going to consider 10 minutes as a 'reasonable timeout' here. |
| |
227 * For chats, close immediately if the chat is not in the buddylist, or if the chat is |
| |
228 * not marked 'Persistent' */ |
| |
229 PurpleConversation *conv = gtkconv->active_conv; |
| |
230 PurpleAccount *account = purple_conversation_get_account(conv); |
| |
231 const char *name = purple_conversation_get_name(conv); |
| |
232 |
| |
233 switch (purple_conversation_get_type(conv)) { |
| |
234 case PURPLE_CONV_TYPE_IM: |
| |
235 { |
| |
236 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately")) |
| |
237 close_this_sucker(gtkconv); |
| |
238 else |
| |
239 hide_conv(gtkconv, TRUE); |
| |
240 break; |
| |
241 } |
| |
242 case PURPLE_CONV_TYPE_CHAT: |
| |
243 { |
| |
244 PurpleChat *chat = purple_blist_find_chat(account, name); |
| |
245 if (!chat || |
| |
246 !purple_blist_node_get_bool(&chat->node, "gtk-persistent")) |
| |
247 close_this_sucker(gtkconv); |
| |
248 else |
| |
249 hide_conv(gtkconv, FALSE); |
| |
250 break; |
| |
251 } |
| |
252 default: |
| |
253 ; |
| |
254 } |
| 216 |
255 |
| 217 return TRUE; |
256 return TRUE; |
| 218 } |
257 } |
| 219 |
258 |
| 220 static gboolean |
259 static gboolean |
| 1312 conv = pidgin_conv_window_get_active_conversation(win); |
1351 conv = pidgin_conv_window_get_active_conversation(win); |
| 1313 |
1352 |
| 1314 add_remove_cb(NULL, PIDGIN_CONVERSATION(conv)); |
1353 add_remove_cb(NULL, PIDGIN_CONVERSATION(conv)); |
| 1315 } |
1354 } |
| 1316 |
1355 |
| 1317 #if 0 |
1356 static gboolean |
| 1318 static void |
1357 close_already(gpointer data) |
| 1319 menu_hide_conv_cb(gpointer data, guint action, GtkWidget *widget) |
1358 { |
| 1320 { |
1359 purple_conversation_destroy(data); |
| 1321 PidginWindow *win = data; |
1360 return FALSE; |
| 1322 PidginConversation *gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
1361 } |
| 1323 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); |
1362 |
| |
1363 static void |
| |
1364 hide_conv(PidginConversation *gtkconv, gboolean closetimer) |
| |
1365 { |
| |
1366 GList *list; |
| |
1367 |
| 1324 purple_signal_emit(pidgin_conversations_get_handle(), |
1368 purple_signal_emit(pidgin_conversations_get_handle(), |
| 1325 "conversation-hiding", gtkconv); |
1369 "conversation-hiding", gtkconv); |
| 1326 purple_conversation_set_ui_ops(conv, NULL); |
1370 |
| 1327 } |
1371 for (list = g_list_copy(gtkconv->convs); list; list = g_list_delete_link(list, list)) { |
| 1328 #endif |
1372 PurpleConversation *conv = list->data; |
| |
1373 if (closetimer) { |
| |
1374 guint timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); |
| |
1375 if (timer) |
| |
1376 purple_timeout_remove(timer); |
| |
1377 timer = purple_timeout_add_seconds(CLOSE_CONV_TIMEOUT_SECS, close_already, conv); |
| |
1378 purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(timer)); |
| |
1379 } |
| |
1380 purple_conversation_set_ui_ops(conv, NULL); |
| |
1381 } |
| |
1382 } |
| 1329 |
1383 |
| 1330 static void |
1384 static void |
| 1331 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
1385 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
| 1332 { |
1386 { |
| 1333 PidginWindow *win = data; |
1387 PidginWindow *win = data; |
| 2338 } |
2392 } |
| 2339 |
2393 |
| 2340 return get_prpl_icon_list(account); |
2394 return get_prpl_icon_list(account); |
| 2341 } |
2395 } |
| 2342 |
2396 |
| 2343 GdkPixbuf * |
2397 static GdkPixbuf * |
| 2344 pidgin_conv_get_tab_icon(PurpleConversation *conv, gboolean small_icon) |
2398 pidgin_conv_get_icon(PurpleConversation *conv, GtkWidget *parent, const char *icon_size) |
| 2345 { |
2399 { |
| 2346 PurpleAccount *account = NULL; |
2400 PurpleAccount *account = NULL; |
| 2347 const char *name = NULL; |
2401 const char *name = NULL; |
| 2348 GdkPixbuf *status = NULL; |
2402 GdkPixbuf *status = NULL; |
| 2349 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
2403 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
| 2350 const char *icon_size = small_icon ? PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC : PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL; |
2404 g_return_val_if_fail(conv != NULL, NULL); |
| 2351 g_return_val_if_fail(conv != NULL, NULL); |
2405 |
| 2352 |
2406 account = purple_conversation_get_account(conv); |
| 2353 account = purple_conversation_get_account(conv); |
2407 name = purple_conversation_get_name(conv); |
| 2354 name = purple_conversation_get_name(conv); |
2408 |
| 2355 |
2409 g_return_val_if_fail(account != NULL, NULL); |
| 2356 g_return_val_if_fail(account != NULL, NULL); |
2410 g_return_val_if_fail(name != NULL, NULL); |
| 2357 g_return_val_if_fail(name != NULL, NULL); |
2411 |
| 2358 |
2412 /* Use the buddy icon, if possible */ |
| 2359 /* Use the buddy icon, if possible */ |
2413 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
| 2360 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
2414 PurpleBuddy *b = purple_find_buddy(account, name); |
| 2361 PurpleBuddy *b = purple_find_buddy(account, name); |
2415 if (b != NULL) { |
| 2362 if (b != NULL) { |
|
| 2363 PurplePresence *p = purple_buddy_get_presence(b); |
2416 PurplePresence *p = purple_buddy_get_presence(b); |
| 2364 /* I hate this hack. It fixes a bug where the pending message icon |
2417 /* I hate this hack. It fixes a bug where the pending message icon |
| 2365 * displays in the conv tab even though it shouldn't. |
2418 * displays in the conv tab even though it shouldn't. |
| 2366 * A better solution would be great. */ |
2419 * A better solution would be great. */ |
| 2367 if (ops && ops->update) |
2420 if (ops && ops->update) |
| 2368 ops->update(NULL, (PurpleBlistNode*)b); |
2421 ops->update(NULL, (PurpleBlistNode*)b); |
| 2369 |
2422 |
| 2370 /* XXX Seanegan: We really need a util function to return a pixbuf for a Presence to avoid all this switching */ |
2423 /* XXX Seanegan: We really need a util function to return a pixbuf for a Presence to avoid all this switching */ |
| 2371 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) |
2424 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) |
| 2372 status = pidgin_create_status_icon(PURPLE_STATUS_AWAY, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2425 status = pidgin_create_status_icon(PURPLE_STATUS_AWAY, parent, icon_size); |
| 2373 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_EXTENDED_AWAY)) |
2426 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_EXTENDED_AWAY)) |
| 2374 status = pidgin_create_status_icon(PURPLE_STATUS_EXTENDED_AWAY, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2427 status = pidgin_create_status_icon(PURPLE_STATUS_EXTENDED_AWAY, parent, icon_size); |
| 2375 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_OFFLINE)) |
2428 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_OFFLINE)) |
| 2376 status = pidgin_create_status_icon(PURPLE_STATUS_OFFLINE, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2429 status = pidgin_create_status_icon(PURPLE_STATUS_OFFLINE, parent, icon_size); |
| 2377 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AVAILABLE)) |
2430 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AVAILABLE)) |
| 2378 status = pidgin_create_status_icon(PURPLE_STATUS_AVAILABLE, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2431 status = pidgin_create_status_icon(PURPLE_STATUS_AVAILABLE, parent, icon_size); |
| 2379 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_INVISIBLE)) |
2432 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_INVISIBLE)) |
| 2380 status = pidgin_create_status_icon(PURPLE_STATUS_INVISIBLE, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2433 status = pidgin_create_status_icon(PURPLE_STATUS_INVISIBLE, parent, icon_size); |
| 2381 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) |
2434 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) |
| 2382 status = pidgin_create_status_icon(PURPLE_STATUS_UNAVAILABLE, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
2435 status = pidgin_create_status_icon(PURPLE_STATUS_UNAVAILABLE, parent, icon_size); |
| 2383 } |
2436 } |
| 2384 } |
2437 } |
| 2385 |
2438 |
| 2386 /* If they don't have a buddy icon, then use the PRPL icon */ |
2439 /* If they don't have a buddy icon, then use the PRPL icon */ |
| 2387 if (status == NULL) { |
2440 if (status == NULL) { |
| 2388 GtkIconSize size = gtk_icon_size_from_name(icon_size); |
2441 GtkIconSize size = gtk_icon_size_from_name(icon_size); |
| 2389 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
2442 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
| 2390 status = gtk_widget_render_icon (PIDGIN_CONVERSATION(conv)->icon, PIDGIN_STOCK_STATUS_PERSON, |
2443 status = gtk_widget_render_icon (parent, PIDGIN_STOCK_STATUS_PERSON, |
| 2391 size, "GtkWidget"); |
2444 size, "GtkWidget"); |
| 2392 } else { |
2445 } else { |
| 2393 status = gtk_widget_render_icon (PIDGIN_CONVERSATION(conv)->icon, PIDGIN_STOCK_STATUS_CHAT, |
2446 status = gtk_widget_render_icon (parent, PIDGIN_STOCK_STATUS_CHAT, |
| 2394 size, "GtkWidget"); |
2447 size, "GtkWidget"); |
| 2395 } |
2448 } |
| 2396 } |
2449 } |
| 2397 return status; |
2450 return status; |
| |
2451 } |
| |
2452 |
| |
2453 GdkPixbuf * |
| |
2454 pidgin_conv_get_tab_icon(PurpleConversation *conv, gboolean small_icon) |
| |
2455 { |
| |
2456 const char *icon_size = small_icon ? PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC : PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL; |
| |
2457 return pidgin_conv_get_icon(conv, PIDGIN_CONVERSATION(conv)->icon, icon_size); |
| 2398 } |
2458 } |
| 2399 |
2459 |
| 2400 |
2460 |
| 2401 static void |
2461 static void |
| 2402 update_tab_icon(PurpleConversation *conv) |
2462 update_tab_icon(PurpleConversation *conv) |
| 2829 for (l = convs; l != NULL ; l = l->next) { |
2893 for (l = convs; l != NULL ; l = l->next) { |
| 2830 PurpleConversation *conv = (PurpleConversation*)l->data; |
2894 PurpleConversation *conv = (PurpleConversation*)l->data; |
| 2831 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
2895 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
| 2832 |
2896 |
| 2833 GtkWidget *icon = gtk_image_new(); |
2897 GtkWidget *icon = gtk_image_new(); |
| 2834 GdkPixbuf *pbuf = pidgin_conv_get_tab_icon(conv, TRUE); |
2898 GdkPixbuf *pbuf = pidgin_conv_get_icon(conv, icon, PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC); |
| 2835 GtkWidget *item; |
2899 GtkWidget *item; |
| 2836 gchar *text = g_strdup_printf("%s (%d)", |
2900 gchar *text = g_strdup_printf("%s (%d)", |
| 2837 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
2901 gtkconv ? gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)) : purple_conversation_get_name(conv), |
| 2838 gtkconv->unseen_count); |
2902 gtkconv ? gtkconv->unseen_count : GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"))); |
| 2839 |
2903 |
| 2840 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
2904 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
| 2841 g_object_unref(pbuf); |
2905 g_object_unref(pbuf); |
| 2842 |
2906 |
| 2843 item = gtk_image_menu_item_new_with_label(text); |
2907 item = gtk_image_menu_item_new_with_label(text); |
| 5039 |
5106 |
| 5040 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
5107 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
| 5041 G_CALLBACK(gtk_widget_grab_focus), |
5108 G_CALLBACK(gtk_widget_grab_focus), |
| 5042 gtkconv->entry); |
5109 gtkconv->entry); |
| 5043 |
5110 |
| 5044 if (hidden) |
5111 pidgin_conv_placement_place(gtkconv); |
| 5045 pidgin_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
|
| 5046 else |
|
| 5047 pidgin_conv_placement_place(gtkconv); |
|
| 5048 |
5112 |
| 5049 if (nick_colors == NULL) { |
5113 if (nick_colors == NULL) { |
| 5050 nbr_nick_colors = NUM_NICK_COLORS; |
5114 nbr_nick_colors = NUM_NICK_COLORS; |
| 5051 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
5115 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
| 5052 } |
5116 } |
| 5053 } |
5117 } |
| 5054 |
5118 |
| |
5119 #if 0 |
| 5055 static void |
5120 static void |
| 5056 pidgin_conv_new_hidden(PurpleConversation *conv) |
5121 pidgin_conv_new_hidden(PurpleConversation *conv) |
| 5057 { |
5122 { |
| 5058 private_gtkconv_new(conv, TRUE); |
5123 private_gtkconv_new(conv, TRUE); |
| 5059 } |
5124 } |
| |
5125 #endif |
| 5060 |
5126 |
| 5061 void |
5127 void |
| 5062 pidgin_conv_new(PurpleConversation *conv) |
5128 pidgin_conv_new(PurpleConversation *conv) |
| 5063 { |
5129 { |
| 5064 private_gtkconv_new(conv, FALSE); |
5130 private_gtkconv_new(conv, FALSE); |
| 5071 PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops(); |
5137 PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops(); |
| 5072 if (conv != NULL) |
5138 if (conv != NULL) |
| 5073 return; |
5139 return; |
| 5074 |
5140 |
| 5075 /* create hidden conv if hide_new pref is always */ |
5141 /* create hidden conv if hide_new pref is always */ |
| 5076 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) |
5142 /* or if hide_new pref is away and account is away */ |
| 5077 { |
5143 if ((strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) || |
| 5078 ui_ops->create_conversation = pidgin_conv_new_hidden; |
5144 (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away") == 0 && |
| 5079 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); |
5145 !purple_status_is_available(purple_account_get_active_status(account)))) { |
| 5080 ui_ops->create_conversation = pidgin_conv_new; |
5146 if (!conv) { |
| |
5147 ui_ops->create_conversation = NULL; |
| |
5148 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); |
| |
5149 purple_conversation_set_ui_ops(conv, NULL); |
| |
5150 ui_ops->create_conversation = pidgin_conv_new; |
| |
5151 } |
| |
5152 } else { |
| |
5153 /* new message for an IM */ |
| |
5154 if (conv && conv->type == PURPLE_CONV_TYPE_IM) |
| |
5155 pidgin_conv_attach_to_conversation(conv); |
| |
5156 } |
| |
5157 } |
| |
5158 |
| |
5159 static void |
| |
5160 pidgin_conv_destroy(PurpleConversation *conv) |
| |
5161 { |
| |
5162 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
| |
5163 |
| |
5164 if (!gtkconv) |
| 5081 return; |
5165 return; |
| 5082 } |
|
| 5083 |
|
| 5084 /* create hidden conv if hide_new pref is away and account is away */ |
|
| 5085 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away") == 0 && |
|
| 5086 !purple_status_is_available(purple_account_get_active_status(account))) |
|
| 5087 { |
|
| 5088 ui_ops->create_conversation = pidgin_conv_new_hidden; |
|
| 5089 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); |
|
| 5090 ui_ops->create_conversation = pidgin_conv_new; |
|
| 5091 return; |
|
| 5092 } |
|
| 5093 } |
|
| 5094 |
|
| 5095 static void |
|
| 5096 pidgin_conv_destroy(PurpleConversation *conv) |
|
| 5097 { |
|
| 5098 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
|
| 5099 |
5166 |
| 5100 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
5167 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
| 5101 /* Don't destroy ourselves until all our convos are gone */ |
5168 /* Don't destroy ourselves until all our convos are gone */ |
| 5102 if (gtkconv->convs) { |
5169 if (gtkconv->convs) { |
| 5103 /* Make sure the destroyed conversation is not the active one */ |
5170 /* Make sure the destroyed conversation is not the active one */ |
| 7064 |
7144 |
| 7065 static void |
7145 static void |
| 7066 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, |
7146 account_status_changed_cb(PurpleAccount *account, PurpleStatus *oldstatus, |
| 7067 PurpleStatus *newstatus) |
7147 PurpleStatus *newstatus) |
| 7068 { |
7148 { |
| |
7149 #if 0 |
| 7069 GList *l; |
7150 GList *l; |
| 7070 PurpleConversation *conv = NULL; |
7151 PurpleConversation *conv = NULL; |
| 7071 PidginConversation *gtkconv; |
7152 PidginConversation *gtkconv; |
| 7072 |
7153 |
| 7073 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")!=0) |
7154 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")!=0) |
| 7074 return; |
7155 return; |
| 7075 |
7156 |
| 7076 if(purple_status_is_available(oldstatus) || !purple_status_is_available(newstatus)) |
7157 if(purple_status_is_available(oldstatus) || !purple_status_is_available(newstatus)) |
| 7077 return; |
7158 return; |
| 7078 |
7159 #endif |
| 7079 while ((l = hidden_convwin->gtkconvs) != NULL) |
|
| 7080 { |
|
| 7081 gtkconv = l->data; |
|
| 7082 |
|
| 7083 conv = gtkconv->active_conv; |
|
| 7084 |
|
| 7085 while(l && !purple_status_is_available( |
|
| 7086 purple_account_get_active_status( |
|
| 7087 purple_conversation_get_account(conv)))) |
|
| 7088 l = l->next; |
|
| 7089 if (!l) |
|
| 7090 break; |
|
| 7091 |
|
| 7092 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
|
| 7093 pidgin_conv_placement_place(gtkconv); |
|
| 7094 |
|
| 7095 /* TODO: do we need to do anything for any other conversations that are in the same gtkconv here? |
|
| 7096 * I'm a little concerned that not doing so will cause the "pending" indicator in the gtkblist not to be cleared. -DAA*/ |
|
| 7097 purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); |
|
| 7098 } |
|
| 7099 } |
7160 } |
| 7100 |
7161 |
| 7101 static void |
7162 static void |
| 7102 hide_new_pref_cb(const char *name, PurplePrefType type, |
7163 hide_new_pref_cb(const char *name, PurplePrefType type, |
| 7103 gconstpointer value, gpointer data) |
7164 gconstpointer value, gpointer data) |
| 7104 { |
7165 { |
| 7105 GList *l; |
7166 GList *l; |
| 7106 PurpleConversation *conv = NULL; |
|
| 7107 PidginConversation *gtkconv; |
|
| 7108 gboolean when_away = FALSE; |
7167 gboolean when_away = FALSE; |
| 7109 |
|
| 7110 if(!hidden_convwin) |
|
| 7111 return; |
|
| 7112 |
7168 |
| 7113 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always")==0) |
7169 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always")==0) |
| 7114 return; |
7170 return; |
| 7115 |
7171 |
| 7116 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")==0) |
7172 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "away")==0) |
| 7117 when_away = TRUE; |
7173 when_away = TRUE; |
| 7118 |
7174 |
| 7119 while ((l = hidden_convwin->gtkconvs) != NULL) |
7175 for (l = purple_get_conversations(); l; l = l->next) |
| 7120 { |
7176 { |
| 7121 gtkconv = l->data; |
7177 PurpleConversation *conv = l->data; |
| 7122 |
7178 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
| 7123 conv = gtkconv->active_conv; |
7179 if (gtkconv) |
| 7124 |
7180 continue; |
| 7125 if(when_away && !purple_status_is_available( |
7181 if(when_away && !purple_status_is_available( |
| 7126 purple_account_get_active_status( |
7182 purple_account_get_active_status( |
| 7127 purple_conversation_get_account(conv)))) |
7183 purple_conversation_get_account(conv)))) |
| 7128 continue; |
7184 continue; |
| 7129 |
7185 pidgin_conv_attach_to_conversation(conv); |
| 7130 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
|
| 7131 pidgin_conv_placement_place(gtkconv); |
|
| 7132 } |
7186 } |
| 7133 } |
7187 } |
| 7134 |
7188 |
| 7135 |
7189 |
| 7136 static void |
7190 static void |
| 7331 |
7389 |
| 7332 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) |
7390 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) |
| 7333 { |
7391 { |
| 7334 GList *list; |
7392 GList *list; |
| 7335 PidginConversation *gtkconv; |
7393 PidginConversation *gtkconv; |
| |
7394 int timer; |
| 7336 |
7395 |
| 7337 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
7396 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
| 7338 return FALSE; |
7397 return FALSE; |
| 7339 |
7398 |
| |
7399 purple_conversation_set_data(conv, "unseen-count", NULL); |
| 7340 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); |
7400 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); |
| 7341 private_gtkconv_new(conv, FALSE); |
7401 private_gtkconv_new(conv, FALSE); |
| 7342 gtkconv = PIDGIN_CONVERSATION(conv); |
7402 gtkconv = PIDGIN_CONVERSATION(conv); |
| 7343 |
7403 |
| 7344 list = purple_conversation_get_message_history(conv); |
7404 list = purple_conversation_get_message_history(conv); |
| 7345 if (list) { |
7405 if (list) { |
| 7346 list = g_list_last(list); |
7406 gtkconv->attach.when = ((PurpleConvMessage*)(list->data))->when; |
| 7347 gtkconv->attach.current = list; |
7407 gtkconv->attach.current = g_list_last(list); |
| 7348 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
7408 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
| 7349 } else { |
7409 } else { |
| 7350 purple_signal_emit(pidgin_conversations_get_handle(), |
7410 purple_signal_emit(pidgin_conversations_get_handle(), |
| 7351 "conversation-displayed", gtkconv); |
7411 "conversation-displayed", gtkconv); |
| 7352 } |
7412 } |
| 7353 |
7413 |
| 7354 if (conv->type == PURPLE_CONV_TYPE_CHAT) { |
7414 if (conv->type == PURPLE_CONV_TYPE_CHAT) { |
| 7355 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7415 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
| 7356 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); |
7416 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); |
| 7357 } |
7417 } |
| |
7418 |
| |
7419 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); |
| |
7420 if (timer) |
| |
7421 purple_timeout_remove(timer); |
| 7358 |
7422 |
| 7359 return TRUE; |
7423 return TRUE; |
| 7360 } |
7424 } |
| 7361 |
7425 |
| 7362 void * |
7426 void * |
| 7620 purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", handle, |
7682 purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", handle, |
| 7621 PURPLE_CALLBACK(update_chat_topic), NULL); |
7683 PURPLE_CALLBACK(update_chat_topic), NULL); |
| 7622 purple_signal_connect_priority(purple_conversations_get_handle(), "conversation-updated", handle, |
7684 purple_signal_connect_priority(purple_conversations_get_handle(), "conversation-updated", handle, |
| 7623 PURPLE_CALLBACK(pidgin_conv_updated), NULL, |
7685 PURPLE_CALLBACK(pidgin_conv_updated), NULL, |
| 7624 PURPLE_SIGNAL_PRIORITY_LOWEST); |
7686 PURPLE_SIGNAL_PRIORITY_LOWEST); |
| |
7687 purple_signal_connect(purple_conversations_get_handle(), "wrote-im-msg", handle, |
| |
7688 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL); |
| |
7689 purple_signal_connect(purple_conversations_get_handle(), "wrote-chat-msg", handle, |
| |
7690 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL); |
| 7625 } |
7691 } |
| 7626 |
7692 |
| 7627 void |
7693 void |
| 7628 pidgin_conversations_uninit(void) |
7694 pidgin_conversations_uninit(void) |
| 7629 { |
7695 { |
| 7630 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); |
7696 purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle()); |
| 7631 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); |
7697 purple_signals_disconnect_by_handle(pidgin_conversations_get_handle()); |
| 7632 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); |
7698 purple_signals_unregister_by_instance(pidgin_conversations_get_handle()); |
| 7633 pidgin_conv_window_destroy(hidden_convwin); |
|
| 7634 hidden_convwin=NULL; |
|
| 7635 } |
7699 } |
| 7636 |
7700 |
| 7637 |
7701 |
| 7638 |
7702 |
| 7639 |
7703 |