gtk: update badge count when marking some messages read

This commit is contained in:
Gautier Pelloux-Prayer 2015-12-23 11:48:30 +01:00
parent af1070f04c
commit 3a5838fd3d
4 changed files with 24 additions and 17 deletions

View file

@ -81,6 +81,12 @@ char *linphone_gtk_message_storage_get_db_file(const char *filename){
return db_file; return db_file;
} }
void linphone_gtk_mark_chat_read(LinphoneChatRoom *cr) {
linphone_chat_room_mark_as_read(cr);
#ifdef __APPLE__
linphone_gtk_update_badge_count();
#endif
}
void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) { void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
GtkWidget *main_window=linphone_gtk_get_main_window (); GtkWidget *main_window=linphone_gtk_get_main_window ();
@ -91,7 +97,7 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
g_return_if_fail(w!=NULL); g_return_if_fail(w!=NULL);
gtk_notebook_remove_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),w)); gtk_notebook_remove_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),w));
linphone_chat_room_mark_as_read(cr); linphone_gtk_mark_chat_read(cr);
g_object_set_data(G_OBJECT(friendlist),"chatview",NULL); g_object_set_data(G_OBJECT(friendlist),"chatview",NULL);
from=g_object_get_data(G_OBJECT(w),"from_message"); from=g_object_get_data(G_OBJECT(w),"from_message");
if (from){ if (from){
@ -280,7 +286,7 @@ void linphone_gtk_compose_text(void) {
LinphoneChatRoom *cr=g_object_get_data(G_OBJECT(w),"cr"); LinphoneChatRoom *cr=g_object_get_data(G_OBJECT(w),"cr");
if (cr) { if (cr) {
linphone_chat_room_compose(cr); linphone_chat_room_compose(cr);
linphone_chat_room_mark_as_read(cr); linphone_gtk_mark_chat_read(cr);
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist)); linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
} }
} }
@ -394,7 +400,7 @@ static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent
} }
g_free(uri); g_free(uri);
linphone_chat_room_mark_as_read(chat_room); linphone_gtk_mark_chat_read(chat_room);
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist)); linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
return TRUE; return TRUE;

View file

@ -308,7 +308,7 @@ void linphone_gtk_notebook_tab_select(GtkNotebook *notebook,GtkWidget *page,guin
if(gtk_notebook_page_num(notebook,page)==gtk_notebook_page_num(notebook,chat_view)){ if(gtk_notebook_page_num(notebook,page)==gtk_notebook_page_num(notebook,chat_view)){
cr=g_object_get_data(G_OBJECT(chat_view),"cr"); cr=g_object_get_data(G_OBJECT(chat_view),"cr");
if(cr!=NULL){ if(cr!=NULL){
linphone_chat_room_mark_as_read(cr); linphone_gtk_mark_chat_read(cr);
linphone_gtk_show_friends(); linphone_gtk_show_friends();
} }
} }
@ -346,7 +346,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
} else { } else {
linphone_gtk_load_chatroom(cr,uri,page); linphone_gtk_load_chatroom(cr,uri,page);
} }
linphone_chat_room_mark_as_read(cr); linphone_gtk_mark_chat_read(cr);
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page)); gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry")); g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
} }

View file

@ -361,6 +361,7 @@ LINPHONE_PUBLIC gboolean linphone_gtk_auto_answer_enabled(void);
LINPHONE_PUBLIC void linphone_gtk_update_status_bar_icons(void); LINPHONE_PUBLIC void linphone_gtk_update_status_bar_icons(void);
LINPHONE_PUBLIC void linphone_gtk_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data); LINPHONE_PUBLIC void linphone_gtk_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data);
LINPHONE_PUBLIC void linphone_gtk_mark_chat_read(LinphoneChatRoom *cr);
#ifdef __APPLE__ #ifdef __APPLE__
LINPHONE_PUBLIC void linphone_gtk_update_badge_count(); LINPHONE_PUBLIC void linphone_gtk_update_badge_count();
#endif #endif

View file

@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "linphone.h" #import "linphone.h"
int unread_messages_count() {
static int unread_messages_count() {
LinphoneCore* lc = linphone_gtk_get_core(); LinphoneCore* lc = linphone_gtk_get_core();
int count = 0; int count = 0;
const MSList *rooms = linphone_core_get_chat_rooms(lc); const MSList *rooms = linphone_core_get_chat_rooms(lc);
@ -34,7 +35,6 @@ int unread_messages_count() {
} }
item = item->next; item = item->next;
} }
return count; return count;
} }