Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 12175:a655bdeb561d
[gaim-migrate @ 14477]
SF Patch #1360582 from Casey Harkins (charkins)
"This patch adds an unseen_count field to gtkconvs which
obviously counts the number of unseen messages. It is
handled entirely within ...set_unseen() in gtkconv.c.
The code for filling the gtkblist menutray context menu
with unseen conversations is moved into gtkconv.c
because it will also be used by the docklet (avoiding
code duplication). I documented it in ChangeLog.API.
The context menu items and the tooltips faceprint added
now will show the message count as well."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 21 Nov 2005 00:43:20 +0000 |
parents | ffdd2ccf3a53 |
children | 762bb28154bf |
comparison
equal
deleted
inserted
replaced
12174:c7652a910308 | 12175:a655bdeb561d |
---|---|
2390 l = gaim_get_conversations(); | 2390 l = gaim_get_conversations(); |
2391 } | 2391 } |
2392 | 2392 |
2393 for(; l!=NULL; l=l->next) { | 2393 for(; l!=NULL; l=l->next) { |
2394 GaimConversation *conv = (GaimConversation*)l->data; | 2394 GaimConversation *conv = (GaimConversation*)l->data; |
2395 if(GAIM_IS_GTK_CONVERSATION(conv)) { | 2395 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
2396 if(GAIM_GTK_CONVERSATION(conv)->unseen_state>=min_state) { | 2396 return conv; |
2397 return conv; | |
2398 } | |
2399 } | |
2400 } | 2397 } |
2401 | 2398 |
2402 return NULL; | 2399 return NULL; |
2400 } | |
2401 | |
2402 static void | |
2403 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) | |
2404 { | |
2405 g_return_if_fail(conv != NULL); | |
2406 gaim_gtkconv_present_conversation(conv); | |
2407 } | |
2408 | |
2409 guint | |
2410 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, | |
2411 GaimConversationType type, | |
2412 GaimUnseenState min_state) | |
2413 { | |
2414 GList *l; | |
2415 guint ret = 0; | |
2416 | |
2417 g_return_val_if_fail(menu != NULL, 0); | |
2418 | |
2419 if (type == GAIM_CONV_TYPE_IM) { | |
2420 l = gaim_get_ims(); | |
2421 } else if (type == GAIM_CONV_TYPE_CHAT) { | |
2422 l = gaim_get_chats(); | |
2423 } else { | |
2424 l = gaim_get_conversations(); | |
2425 } | |
2426 | |
2427 for (; l != NULL ; l = l->next) { | |
2428 GaimConversation *conv = (GaimConversation*)l->data; | |
2429 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2430 | |
2431 if (gtkconv->unseen_state >= min_state) { | |
2432 GtkWidget *icon = gtk_image_new(); | |
2433 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); | |
2434 GtkWidget *item; | |
2435 gchar *text = g_strdup_printf("%s (%d)", | |
2436 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), | |
2437 gtkconv->unseen_count); | |
2438 | |
2439 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); | |
2440 g_object_unref(pbuf); | |
2441 | |
2442 item = gtk_image_menu_item_new_with_label(text); | |
2443 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); | |
2444 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); | |
2445 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
2446 g_free(text); | |
2447 ret++; | |
2448 } | |
2449 } | |
2450 | |
2451 return ret; | |
2403 } | 2452 } |
2404 | 2453 |
2405 GaimGtkWindow * | 2454 GaimGtkWindow * |
2406 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | 2455 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) |
2407 { | 2456 { |
3905 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | 3954 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); |
3906 | 3955 |
3907 /* Setup some initial variables. */ | 3956 /* Setup some initial variables. */ |
3908 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | 3957 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
3909 gtkconv->tooltips = gtk_tooltips_new(); | 3958 gtkconv->tooltips = gtk_tooltips_new(); |
3959 gtkconv->unseen_state = GAIM_UNSEEN_NONE; | |
3960 gtkconv->unseen_count = 0; | |
3910 | 3961 |
3911 if (conv_type == GAIM_CONV_TYPE_IM) { | 3962 if (conv_type == GAIM_CONV_TYPE_IM) { |
3912 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | 3963 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); |
3913 | 3964 |
3914 pane = setup_im_pane(gtkconv); | 3965 pane = setup_im_pane(gtkconv); |
5980 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | 6031 for (l = gaim_gtk_conv_window_get_gtkconvs(win); |
5981 l != NULL; l = l->next) | 6032 l != NULL; l = l->next) |
5982 { | 6033 { |
5983 GaimGtkConversation *gtkconv = l->data; | 6034 GaimGtkConversation *gtkconv = l->data; |
5984 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && | 6035 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
5985 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) | 6036 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
5986 { | 6037 { |
5987 build_warn_close_dialog(win); | 6038 build_warn_close_dialog(win); |
5988 gtk_widget_show_all(warn_close_dialog); | 6039 gtk_widget_show_all(warn_close_dialog); |
5989 | 6040 |
5990 return TRUE; | 6041 return TRUE; |
5997 } | 6048 } |
5998 | 6049 |
5999 static void | 6050 static void |
6000 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | 6051 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) |
6001 { | 6052 { |
6002 /* only allow NONE or higher priority unseen state */ | 6053 if (state == GAIM_UNSEEN_NONE) |
6003 if((state==GAIM_UNSEEN_NONE && gtkconv->unseen_state!=GAIM_UNSEEN_NONE) | 6054 { |
6004 || state > gtkconv->unseen_state) { | 6055 gtkconv->unseen_count = 0; |
6005 gtkconv->unseen_state = state; | 6056 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
6006 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); | 6057 } |
6007 } | 6058 else |
6059 { | |
6060 gtkconv->unseen_count++; | |
6061 | |
6062 if (state > gtkconv->unseen_state) | |
6063 gtkconv->unseen_state = state; | |
6064 } | |
6065 | |
6066 /* emit update signal to notify of count and possible unseen state change */ | |
6067 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); | |
6008 } | 6068 } |
6009 | 6069 |
6010 /* | 6070 /* |
6011 * When a conversation window is focused, we know the user | 6071 * When a conversation window is focused, we know the user |
6012 * has looked at it so we know there are no longer unseen | 6072 * has looked at it so we know there are no longer unseen |