comparison finch/gntconv.c @ 19114:6de2e9ba0930

merge of '2970edca111b3535ae0703e3c866ad1c3b87df94' and 'a2b508e8680ac3f20965226a5dd83f7e2a3b15bb'
author Eric Polino <aluink@pidgin.im>
date Sun, 24 Jun 2007 02:56:09 +0000
parents ebc2288d9253
children b25cb0775be3
comparison
equal deleted inserted replaced
19102:7f26e5b98b15 19114:6de2e9ba0930
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 24 */
25 #include <string.h> 25 #include <string.h>
26 26
27 #include "finch.h"
28
27 #include <cmds.h> 29 #include <cmds.h>
28 #include <idle.h> 30 #include <idle.h>
29 #include <prefs.h> 31 #include <prefs.h>
30 #include <util.h> 32 #include <util.h>
31 33
32 #include "finch.h"
33 #include "gntaccount.h" 34 #include "gntaccount.h"
34 #include "gntblist.h" 35 #include "gntblist.h"
35 #include "gntconv.h" 36 #include "gntconv.h"
36 #include "gntdebug.h" 37 #include "gntdebug.h"
37 #include "gntplugin.h" 38 #include "gntplugin.h"
438 char *name = gnt_tree_get_selection_data(GNT_TREE(widget)); 439 char *name = gnt_tree_get_selection_data(GNT_TREE(widget));
439 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); 440 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
440 } 441 }
441 442
442 static void 443 static void
444 gained_focus_cb(GntWindow *window, FinchConv *fc)
445 {
446 GList *iter;
447 for (iter = fc->list; iter; iter = iter->next) {
448 purple_conversation_set_data(iter->data, "unseen-count", 0);
449 purple_conversation_update(iter->data, PURPLE_CONV_UPDATE_UNSEEN);
450 }
451 }
452
453 static void
443 finch_create_conversation(PurpleConversation *conv) 454 finch_create_conversation(PurpleConversation *conv)
444 { 455 {
445 FinchConv *ggc = conv->ui_data; 456 FinchConv *ggc = conv->ui_data;
446 char *title; 457 char *title;
447 PurpleConversationType type; 458 PurpleConversationType type;
472 483
473 ggc->window = gnt_vwindow_new(FALSE); 484 ggc->window = gnt_vwindow_new(FALSE);
474 gnt_box_set_title(GNT_BOX(ggc->window), title); 485 gnt_box_set_title(GNT_BOX(ggc->window), title);
475 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); 486 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE);
476 gnt_box_set_pad(GNT_BOX(ggc->window), 0); 487 gnt_box_set_pad(GNT_BOX(ggc->window), 0);
477 gnt_widget_set_name(ggc->window, "conversation-window"); 488
489 switch(conv->type){
490 case PURPLE_CONV_TYPE_UNKNOWN:
491 gnt_widget_set_name(ggc->window, "conversation-window-unknown" );
492 break;
493 case PURPLE_CONV_TYPE_IM:
494 gnt_widget_set_name(ggc->window, "conversation-window-im" );
495 break;
496 case PURPLE_CONV_TYPE_CHAT:
497 gnt_widget_set_name(ggc->window, "conversation-window-chat" );
498 break;
499 case PURPLE_CONV_TYPE_MISC:
500 gnt_widget_set_name(ggc->window, "conversation-window-misc" );
501 break;
502 case PURPLE_CONV_TYPE_ANY:
503 gnt_widget_set_name(ggc->window, "conversation-window-any" );
504 break;
505 }
478 506
479 gg_create_menu(ggc); 507 gg_create_menu(ggc);
480 508
481 ggc->tv = gnt_text_view_new(); 509 ggc->tv = gnt_text_view_new();
482 gnt_widget_set_name(ggc->tv, "conversation-window-textview"); 510 gnt_widget_set_name(ggc->tv, "conversation-window-textview");
527 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); 555 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc);
528 } 556 }
529 557
530 g_free(title); 558 g_free(title);
531 gnt_box_give_focus_to_child(GNT_BOX(ggc->window), ggc->entry); 559 gnt_box_give_focus_to_child(GNT_BOX(ggc->window), ggc->entry);
560 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc);
532 } 561 }
533 562
534 static void 563 static void
535 finch_destroy_conversation(PurpleConversation *conv) 564 finch_destroy_conversation(PurpleConversation *conv)
536 { 565 {
620 if (pos <= 1) 649 if (pos <= 1)
621 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); 650 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
622 651
623 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) 652 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR))
624 gnt_widget_set_urgent(ggconv->tv); 653 gnt_widget_set_urgent(ggconv->tv);
654 if (flags & PURPLE_MESSAGE_RECV && !gnt_widget_has_focus(ggconv->window)) {
655 int count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"));
656 purple_conversation_set_data(conv, "unseen-count", GINT_TO_POINTER(count + 1));
657 purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN);
658 }
625 } 659 }
626 660
627 static void 661 static void
628 finch_write_chat(PurpleConversation *conv, const char *who, const char *message, 662 finch_write_chat(PurpleConversation *conv, const char *who, const char *message,
629 PurpleMessageFlags flags, time_t mtime) 663 PurpleMessageFlags flags, time_t mtime)