comparison src/gtkconv.c @ 11664:38bbb0f15453

[gaim-migrate @ 13949] "This patch updates the colors of the tabs correctly. I have removed the tab-highlighting stuff from the core to the UI." Sadrul Habib Chowdhury committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 14 Oct 2005 11:30:37 +0000
parents 516cefa2d27d
children ae9d9e2add8e
comparison
equal deleted inserted replaced
11663:03db7f366ae1 11664:38bbb0f15453
125 static gboolean tab_complete(GaimConversation *conv); 125 static gboolean tab_complete(GaimConversation *conv);
126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); 126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type);
127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); 127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state);
128 static void update_typing_icon(GaimGtkConversation *gtkconv); 128 static void update_typing_icon(GaimGtkConversation *gtkconv);
129 static char *item_factory_translate_func (const char *path, gpointer func_data); 129 static char *item_factory_translate_func (const char *path, gpointer func_data);
130 gboolean gaim_gtkconv_has_focus(GaimConversation *conv);
130 131
131 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { 132 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) {
132 static GdkColor col; 133 static GdkColor col;
133 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); 134 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml);
134 float scale; 135 float scale;
1599 static void 1600 static void
1600 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) 1601 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward)
1601 { 1602 {
1602 GaimGtkConversation *next_gtkconv = NULL; 1603 GaimGtkConversation *next_gtkconv = NULL;
1603 GaimGtkWindow *win; 1604 GaimGtkWindow *win;
1604 GList *l;
1605 int index, i, total, found = 0; 1605 int index, i, total, found = 0;
1606 1606
1607 win = gtkconv->win; 1607 win = gtkconv->win;
1608 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); 1608 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont);
1609 total = gaim_gtk_conv_window_get_gtkconv_count(win); 1609 total = gaim_gtk_conv_window_get_gtkconv_count(win);
1613 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); 1613 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i));
1614 forward ? i++ : i--) { 1614 forward ? i++ : i--) {
1615 if (i == -1) { 1615 if (i == -1) {
1616 break; 1616 break;
1617 } 1617 }
1618 for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) { 1618
1619 GaimConversation *c = l->data; 1619 if (next_gtkconv->unseen_state > 0)
1620 if (gaim_conversation_get_unseen(c) > 0) 1620 found = 1;
1621 {
1622 found = 1;
1623 break;
1624 }
1625 }
1626 } 1621 }
1627 1622
1628 if (!found) { 1623 if (!found) {
1629 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ 1624 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */
1630 for (i = forward ? 0 : total - 1; 1625 for (i = forward ? 0 : total - 1;
1631 !found && (forward ? i < index : i >= 0) && 1626 !found && (forward ? i < index : i >= 0) &&
1632 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); 1627 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i));
1633 forward ? i++ : i--) { 1628 forward ? i++ : i--) {
1634 for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) { 1629
1635 GaimConversation *c = l->data; 1630 if (next_gtkconv->unseen_state > 0)
1636 if (gaim_conversation_get_unseen(c) > 0) { 1631 found = 1;
1637 found = 1;
1638 break;
1639 }
1640 }
1641 } 1632 }
1642 1633
1643 if (!found) { 1634 if (!found) {
1644 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ 1635 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */
1645 if (forward) { 1636 if (forward) {
4259 g_free(new_message); 4250 g_free(new_message);
4260 } 4251 }
4261 4252
4262 if(sml_attrib) 4253 if(sml_attrib)
4263 g_free(sml_attrib); 4254 g_free(sml_attrib);
4255
4256 /* Tab highlighting stuff */
4257 if (!gaim_gtkconv_has_focus(conv))
4258 {
4259 GaimUnseenState unseen = GAIM_UNSEEN_NONE;
4260
4261 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK ||
4262 gtkconv->unseen_state == GAIM_UNSEEN_NICK)
4263 unseen = GAIM_UNSEEN_NICK;
4264 else if ((((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) ||
4265 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) &&
4266 gtkconv->unseen_state != GAIM_UNSEEN_TEXT)
4267 unseen = GAIM_UNSEEN_EVENT;
4268 else
4269 unseen = GAIM_UNSEEN_TEXT;
4270
4271 gtkconv_set_unseen(gtkconv, unseen);
4272 }
4264 } 4273 }
4265 4274
4266 static void 4275 static void
4267 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *aliases) 4276 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *aliases)
4268 { 4277 {
4912 } 4921 }
4913 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) 4922 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED)
4914 { 4923 {
4915 strcpy(color, "#D1940C"); 4924 strcpy(color, "#D1940C");
4916 } 4925 }
4917 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) 4926 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK)
4918 { 4927 {
4919 strcpy(color, "#0D4E91"); 4928 strcpy(color, "#0D4E91");
4920 } 4929 }
4921 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) 4930 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT)
4922 { 4931 {
4923 strcpy(color, "#DF421E"); 4932 strcpy(color, "#DF421E");
4924 } 4933 }
4925 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_EVENT) 4934 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT)
4926 { 4935 {
4927 strcpy(color, "#868272"); 4936 strcpy(color, "#868272");
4928 } 4937 }
4929 4938
4930 if (*color != '\0') 4939 if (*color != '\0')
5660 5669
5661 static gboolean 5670 static gboolean
5662 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) 5671 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
5663 { 5672 {
5664 GaimGtkWindow *win = d; 5673 GaimGtkWindow *win = d;
5665 GList *l, *j; 5674 GList *l;
5666 5675
5667 /* If there are unread messages then show a warning dialog */ 5676 /* If there are unread messages then show a warning dialog */
5668 for (l = gaim_gtk_conv_window_get_gtkconvs(win); 5677 for (l = gaim_gtk_conv_window_get_gtkconvs(win);
5669 l != NULL; l = l->next) 5678 l != NULL; l = l->next)
5670 { 5679 {
5671 GaimGtkConversation *gtkconv = l->data; 5680 GaimGtkConversation *gtkconv = l->data;
5672 5681 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM &&
5673 for (j = gtkconv->convs; j != NULL; j = j->next) { 5682 gtkconv->unseen_state == GAIM_UNSEEN_TEXT)
5674 GaimConversation *conv = j->data; 5683 {
5675 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && 5684 build_warn_close_dialog(win);
5676 gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) 5685 gtk_widget_show_all(warn_close_dialog);
5677 { 5686
5678 build_warn_close_dialog(win); 5687 return TRUE;
5679 gtk_widget_show_all(warn_close_dialog);
5680
5681 return TRUE;
5682 }
5683 } 5688 }
5684 } 5689 }
5685 5690
5686 gaim_gtk_conv_window_destroy(win); 5691 gaim_gtk_conv_window_destroy(win);
5687 5692
5689 } 5694 }
5690 5695
5691 static void 5696 static void
5692 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) 5697 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state)
5693 { 5698 {
5694 GList *l; 5699 gtkconv->unseen_state = state;
5695 5700
5696 for (l = gtkconv->convs; l != NULL; l = l->next) 5701 gaim_gtkconv_updated(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN);
5697 gaim_conversation_set_unseen(l->data, state);
5698 } 5702 }
5699 /* 5703 /*
5700 * When a conversation window is focused, we know the user 5704 * When a conversation window is focused, we know the user
5701 * has looked at it so we know there are no longer unseen 5705 * has looked at it so we know there are no longer unseen
5702 * messages. 5706 * messages.