comparison src/gtkconv.c @ 6392:e9974608b319

[gaim-migrate @ 6897] deryni absolutely rocks. Amazing guy. We now have these beautiful protocol icons on tabs that update to reflect status. Away, grey on idle, even the sign on/off doors. Wow. This will no doubt be known as the highlight of 0.67. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 06 Aug 2003 11:38:57 +0000
parents 8f94cce8faa5
children 2a4b93b57518
comparison
equal deleted inserted replaced
6391:4b2d8d7d0118 6392:e9974608b319
3814 GtkWidget *tab_cont; 3814 GtkWidget *tab_cont;
3815 GtkWidget *tabby; 3815 GtkWidget *tabby;
3816 gboolean new_ui; 3816 gboolean new_ui;
3817 GaimConversationType conv_type; 3817 GaimConversationType conv_type;
3818 const char *name; 3818 const char *name;
3819 struct buddy *b = NULL;
3820 GaimAccount *account;
3819 3821
3820 name = gaim_conversation_get_name(conv); 3822 name = gaim_conversation_get_name(conv);
3821 conv_type = gaim_conversation_get_type(conv); 3823 conv_type = gaim_conversation_get_type(conv);
3822 gtkwin = GAIM_GTK_WINDOW(win); 3824 gtkwin = GAIM_GTK_WINDOW(win);
3823 3825
3950 _("Close conversation"), NULL); 3952 _("Close conversation"), NULL);
3951 3953
3952 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", 3954 g_signal_connect(G_OBJECT(gtkconv->close), "clicked",
3953 G_CALLBACK(close_conv_cb), conv); 3955 G_CALLBACK(close_conv_cb), conv);
3954 3956
3957 /* Status icon. */
3958 account = gaim_conversation_get_account(conv);
3959 b = gaim_find_buddy(account, name);
3960 if (b != NULL)
3961 gtkconv->icon = gtk_image_new_from_pixbuf(
3962 gaim_gtk_blist_get_status_icon((GaimBlistNode *)b,
3963 GAIM_STATUS_ICON_SMALL));
3964 else
3965 gtkconv->icon = gtk_image_new();
3966
3955 /* Tab label. */ 3967 /* Tab label. */
3956 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); 3968 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv));
3957 #if 0 3969 #if 0
3958 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); 3970 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5);
3959 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); 3971 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0);
3960 #endif 3972 #endif
3961 3973
3962 3974
3963 /* Pack it all together. */ 3975 /* Pack it all together. */
3976 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0);
3977 if (gaim_prefs_get_bool("/gaim/gtk/conversations/icons_on_tabs"))
3978 gtk_widget_show_all(gtkconv->icon);
3979
3964 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); 3980 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0);
3965 gtk_widget_show(gtkconv->tab_label); 3981 gtk_widget_show(gtkconv->tab_label);
3982
3966 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); 3983 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0);
3967
3968 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) 3984 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs"))
3969 gtk_widget_show_all(gtkconv->close); 3985 gtk_widget_show_all(gtkconv->close);
3970 3986
3971 gtk_widget_show(tabby); 3987 gtk_widget_show(tabby);
3972 3988
4752 if(conv == gaim_window_get_active_conversation(win)) 4768 if(conv == gaim_window_get_active_conversation(win))
4753 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); 4769 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title);
4754 } 4770 }
4755 4771
4756 static void 4772 static void
4773 update_tab_icon(GaimConversation *conv)
4774 {
4775 GaimGtkConversation *gtkconv;
4776 GaimAccount *account;
4777 const char *name;
4778 struct buddy *b;
4779
4780 gtkconv = GAIM_GTK_CONVERSATION(conv);
4781 name = gaim_conversation_get_name(conv);
4782 account = gaim_conversation_get_account(conv);
4783 b = gaim_find_buddy(account, name);
4784
4785 if (b != NULL)
4786 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon),
4787 gaim_gtk_blist_get_status_icon((GaimBlistNode *)b,
4788 GAIM_STATUS_ICON_SMALL));
4789 else {
4790 g_object_unref(gtkconv->icon);
4791 gtkconv->icon = gtk_image_new();
4792 }
4793 }
4794
4795 static void
4757 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) 4796 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type)
4758 { 4797 {
4759 GaimWindow *win; 4798 GaimWindow *win;
4760 GaimGtkWindow *gtkwin; 4799 GaimGtkWindow *gtkwin;
4761 GaimGtkConversation *gtkconv; 4800 GaimGtkConversation *gtkconv;
4838 } 4877 }
4839 else if (type == GAIM_CONV_ACCOUNT_ONLINE || 4878 else if (type == GAIM_CONV_ACCOUNT_ONLINE ||
4840 type == GAIM_CONV_ACCOUNT_OFFLINE) { 4879 type == GAIM_CONV_ACCOUNT_OFFLINE) {
4841 4880
4842 generate_send_as_items(win, NULL); 4881 generate_send_as_items(win, NULL);
4882 if (gaim_prefs_get_bool("/gaim/gtk/conversations/icons_on_tabs"))
4883 update_tab_icon(conv);
4884 }
4885 else if (type == GAIM_CONV_UPDATE_AWAY) {
4886 if (gaim_prefs_get_bool("/gaim/gtk/conversations/icons_on_tabs"))
4887 update_tab_icon(conv);
4843 } 4888 }
4844 else if(type == GAIM_CONV_UPDATE_ADD || 4889 else if(type == GAIM_CONV_UPDATE_ADD ||
4845 type == GAIM_CONV_UPDATE_REMOVE) { 4890 type == GAIM_CONV_UPDATE_REMOVE) {
4846 4891
4847 update_convo_add_button(conv); 4892 update_convo_add_button(conv);
5489 5534
5490 return page_num; 5535 return page_num;
5491 } 5536 }
5492 5537
5493 static void 5538 static void
5539 icons_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value,
5540 gpointer data)
5541 {
5542 GList *l;
5543 GaimConversation *conv;
5544 GaimGtkConversation *gtkconv;
5545
5546 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
5547 conv = (GaimConversation *)l->data;
5548
5549 if (!GAIM_IS_GTK_CONVERSATION(conv))
5550 continue;
5551
5552 gtkconv = GAIM_GTK_CONVERSATION(conv);
5553
5554 if (value)
5555 gtk_widget_show(gtkconv->icon);
5556 else
5557 gtk_widget_hide(gtkconv->icon);
5558 }
5559 }
5560
5561 static void
5494 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value, 5562 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value,
5495 gpointer data) 5563 gpointer data)
5496 { 5564 {
5497 GList *l; 5565 GList *l;
5498 GaimConversation *conv; 5566 GaimConversation *conv;
5499 GaimGtkConversation *gtkconv; 5567 GaimGtkConversation *gtkconv;
5500 5568
5717 void 5785 void
5718 gaim_gtk_conversation_init(void) 5786 gaim_gtk_conversation_init(void)
5719 { 5787 {
5720 /* Conversations */ 5788 /* Conversations */
5721 gaim_prefs_add_none("/gaim/gtk/conversations"); 5789 gaim_prefs_add_none("/gaim/gtk/conversations");
5790 gaim_prefs_add_bool("/gaim/gtk/conversations/icons_on_tabs", TRUE);
5722 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); 5791 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE);
5723 gaim_prefs_add_bool("/gaim/gtk/conversations/ctrl_enter_sends", FALSE); 5792 gaim_prefs_add_bool("/gaim/gtk/conversations/ctrl_enter_sends", FALSE);
5724 gaim_prefs_add_bool("/gaim/gtk/conversations/enter_sends", TRUE); 5793 gaim_prefs_add_bool("/gaim/gtk/conversations/enter_sends", TRUE);
5725 gaim_prefs_add_bool("/gaim/gtk/conversations/escape_closes", FALSE); 5794 gaim_prefs_add_bool("/gaim/gtk/conversations/escape_closes", FALSE);
5726 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); 5795 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE);
5771 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); 5840 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410);
5772 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); 5841 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160);
5773 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); 5842 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50);
5774 5843
5775 /* Connect callbacks. */ 5844 /* Connect callbacks. */
5845 gaim_prefs_connect_callback("/gaim/gtk/conversations/icons_on_tabs",
5846 icons_on_tabs_pref_cb, NULL);
5776 gaim_prefs_connect_callback("/gaim/gtk/conversations/close_on_tabs", 5847 gaim_prefs_connect_callback("/gaim/gtk/conversations/close_on_tabs",
5777 close_on_tabs_pref_cb, NULL); 5848 close_on_tabs_pref_cb, NULL);
5778 gaim_prefs_connect_callback("/gaim/gtk/conversations/show_smileys", 5849 gaim_prefs_connect_callback("/gaim/gtk/conversations/show_smileys",
5779 show_smileys_pref_cb, NULL); 5850 show_smileys_pref_cb, NULL);
5780 gaim_prefs_connect_callback("/gaim/gtk/conversations/show_timestamps", 5851 gaim_prefs_connect_callback("/gaim/gtk/conversations/show_timestamps",