forked from mirrors/linphone-iphone
gtk: update badge count when marking some messages read
This commit is contained in:
parent
af1070f04c
commit
3a5838fd3d
4 changed files with 24 additions and 17 deletions
12
gtk/chat.c
12
gtk/chat.c
|
|
@ -81,6 +81,12 @@ char *linphone_gtk_message_storage_get_db_file(const char *filename){
|
|||
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) {
|
||||
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);
|
||||
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);
|
||||
from=g_object_get_data(G_OBJECT(w),"from_message");
|
||||
if (from){
|
||||
|
|
@ -280,7 +286,7 @@ void linphone_gtk_compose_text(void) {
|
|||
LinphoneChatRoom *cr=g_object_get_data(G_OBJECT(w),"cr");
|
||||
if (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));
|
||||
}
|
||||
}
|
||||
|
|
@ -394,7 +400,7 @@ static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent
|
|||
}
|
||||
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));
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -190,18 +190,18 @@ void linphone_gtk_friend_list_update_button_display(GtkTreeView *friendlist){
|
|||
int nbmsg=0;
|
||||
GtkTreePath *selected_path = NULL;
|
||||
GtkTreePath *hovered_row = (GtkTreePath *)g_object_get_data(G_OBJECT(friendlist), "hovered_row");
|
||||
|
||||
|
||||
if (gtk_tree_selection_get_selected(select, &model, &selected_iter)){
|
||||
selected_path = gtk_tree_model_get_path(model, &selected_iter);
|
||||
}
|
||||
|
||||
|
||||
if (gtk_tree_model_get_iter_first(model,&iter)) {
|
||||
do{
|
||||
const char *icon_name = NULL;
|
||||
gboolean show_chat_button = FALSE;
|
||||
gboolean show_call_button = FALSE;
|
||||
GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
|
||||
|
||||
|
||||
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
|
||||
nbmsg=linphone_chat_room_get_unread_messages_count(cr);
|
||||
is_composing=linphone_chat_room_is_remote_composing(cr);
|
||||
|
|
@ -217,7 +217,7 @@ void linphone_gtk_friend_list_update_button_display(GtkTreeView *friendlist){
|
|||
icon_name = "linphone-chat-nothing";
|
||||
}
|
||||
}
|
||||
if ((selected_path && gtk_tree_path_compare(path, selected_path) == 0)
|
||||
if ((selected_path && gtk_tree_path_compare(path, selected_path) == 0)
|
||||
|| (hovered_row && gtk_tree_path_compare(path, hovered_row) == 0)){
|
||||
show_chat_button = TRUE;
|
||||
show_call_button = TRUE;
|
||||
|
|
@ -225,7 +225,7 @@ void linphone_gtk_friend_list_update_button_display(GtkTreeView *friendlist){
|
|||
gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_CHAT,icon_name,
|
||||
FRIEND_CHAT_BUTTON_VISIBLE, show_chat_button, -1);
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, FRIEND_CALL_BUTTON_VISIBLE, show_call_button, -1);
|
||||
|
||||
|
||||
gtk_tree_path_free(path);
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
|
|
@ -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)){
|
||||
cr=g_object_get_data(G_OBJECT(chat_view),"cr");
|
||||
if(cr!=NULL){
|
||||
linphone_chat_room_mark_as_read(cr);
|
||||
linphone_gtk_mark_chat_read(cr);
|
||||
linphone_gtk_show_friends();
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
|
|||
} else {
|
||||
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));
|
||||
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ void linphone_gtk_contact_clicked(GtkTreeSelection *selection){
|
|||
GtkWidget *mw = linphone_gtk_get_main_window();
|
||||
GtkWidget *edit_button = linphone_gtk_get_widget(mw, "edit_button");
|
||||
GtkWidget *remove_button = linphone_gtk_get_widget(mw, "remove_button");
|
||||
|
||||
|
||||
linphone_gtk_set_selection_to_uri_bar(friendlist);
|
||||
linphone_gtk_friend_list_update_button_display(friendlist);
|
||||
if(gtk_tree_selection_get_selected(selection, NULL, NULL)) {
|
||||
|
|
@ -605,7 +605,7 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
|
|||
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store),FRIEND_NAME,friend_sort,NULL,NULL);
|
||||
gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(linphone_gtk_contact_clicked), NULL);
|
||||
|
||||
|
||||
g_object_set_data(G_OBJECT(friendlist), "friendlist_initialized", (gpointer)TRUE);
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +734,7 @@ void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){
|
|||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"allow_presence")),
|
||||
linphone_friend_get_inc_subscribe_policy(lf)==LinphoneSPAccept);
|
||||
g_object_set_data(G_OBJECT(w),"friend_ref",(gpointer)lf);
|
||||
|
||||
|
||||
gtk_widget_show(w);
|
||||
}
|
||||
|
||||
|
|
@ -917,10 +917,10 @@ gboolean linphone_gtk_contact_list_button_pressed(GtkTreeView *friendlist, GdkEv
|
|||
GtkTreePath *path;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(friendlist);
|
||||
|
||||
|
||||
gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, event->x, event->y, &x_bin, &y_bin);
|
||||
gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, &column, NULL, NULL);
|
||||
|
||||
|
||||
if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
|
||||
if(path) gtk_tree_selection_select_path(selection, path);
|
||||
ret = linphone_gtk_popup_contact_menu(GTK_WIDGET(friendlist), event);
|
||||
|
|
|
|||
|
|
@ -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_enable_auto_answer(GtkToggleButton *checkbox, gpointer user_data);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_gtk_mark_chat_read(LinphoneChatRoom *cr);
|
||||
#ifdef __APPLE__
|
||||
LINPHONE_PUBLIC void linphone_gtk_update_badge_count();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#import "linphone.h"
|
||||
|
||||
int unread_messages_count() {
|
||||
|
||||
static int unread_messages_count() {
|
||||
LinphoneCore* lc = linphone_gtk_get_core();
|
||||
int count = 0;
|
||||
const MSList *rooms = linphone_core_get_chat_rooms(lc);
|
||||
|
|
@ -34,7 +35,6 @@ int unread_messages_count() {
|
|||
}
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue