diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 1073132182ea365c78d5417841ab713a27049443..dc176fe943c8a30ba9b16b66a808d2a3467d7724 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -51,6 +51,7 @@ #include "assistant.h" #include "accountlist.h" #include "accountlistconfigdialog.h" +#include "messaging/message_tab.h" #include "dbus.h" #include "actions.h" @@ -147,18 +148,16 @@ voice_mail_cb(DBusGProxy *proxy UNUSED, const gchar *accountID, guint nb, static void incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar *callID UNUSED, - const gchar *from, const gchar *msg, void *foo UNUSED) + const gchar *from UNUSED, const gchar *msg, void *foo UNUSED) { // do not display message if instant messaging is disabled if (eel_gconf_key_exists(INSTANT_MESSAGING_ENABLED) && !eel_gconf_get_integer(INSTANT_MESSAGING_ENABLED)) return; - gchar *id; callable_obj_t *call = calllist_get_call(current_calls_tab, callID); if (call) { - id = call->_callID; new_text_message(call,msg); } else { conference_obj_t *conf = conferencelist_get(current_calls_tab, callID); @@ -167,7 +166,6 @@ incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar *callID UNUSED, return; } - id = conf->_confID; new_text_message(conf,msg); } } @@ -358,6 +356,7 @@ conference_removed_cb(DBusGProxy *proxy UNUSED, const gchar *confID, // remove all participants for this conference for (GSList *p = c->participant_list; p; p = g_slist_next(p)) { callable_obj_t *call = calllist_get_call(current_calls_tab, p->data); + /*TODO elepage(2012) implement unmerging of IM here*/ } conferencelist_remove(current_calls_tab, c->_confID); diff --git a/gnome/src/messaging/message_tab.c b/gnome/src/messaging/message_tab.c index 01ba738f7630086c8a9fb057fb4f700b878b928b..8fe2ed9778ae91afd56217fa890568a01bed30e3 100644 --- a/gnome/src/messaging/message_tab.c +++ b/gnome/src/messaging/message_tab.c @@ -43,25 +43,7 @@ GtkWidget *get_tab_box() return tab_box; } -void new_text_message(gchar* call_id, char* message) -{ - message_tab *tab = g_hash_table_lookup(tabs,call_id); - if (!tab) - tab = create_messaging_tab(call_id,call_id); - append_message(tab,"Peer",message); -} -void replace_markup_tag(GtkTextBuffer* text_buffer, GtkTextIter* start) -{ - GtkTextIter start_match,end_match; - while ( gtk_text_iter_forward_search(start, "<b>", GTK_TEXT_SEARCH_TEXT_ONLY | GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, NULL) ) { - gtk_text_iter_forward_search(start, "</b>", GTK_TEXT_SEARCH_TEXT_ONLY | GTK_TEXT_SEARCH_VISIBLE_ONLY, &end_match, &end_match, NULL); - gtk_text_buffer_apply_tag_by_name(text_buffer, "b", &start_match, &end_match); - int offset = gtk_text_iter_get_offset(&end_match); - gtk_text_buffer_get_iter_at_offset(text_buffer, start, offset); - } -} - -void append_message(message_tab* self, gchar* name, gchar* message) +void append_message(message_tab* self, gchar* name, const gchar* message) { GtkTextIter current_end,new_end; gtk_text_buffer_get_end_iter(self->buffer, ¤t_end); @@ -69,7 +51,7 @@ void append_message(message_tab* self, gchar* name, gchar* message) gtk_text_buffer_insert(self->buffer, ¤t_end, ": ", -1); gtk_text_buffer_get_end_iter(self->buffer, ¤t_end); - for (int i=0;i<strlen(name)+2;i++){ + for (unsigned int i=0;i<strlen(name)+2;i++){ if (!gtk_text_iter_backward_char(¤t_end)) break; } @@ -82,16 +64,34 @@ void append_message(message_tab* self, gchar* name, gchar* message) gtk_text_view_scroll_to_iter(self->view,&new_end,FALSE,0,0,FALSE); } -static gboolean on_enter(GtkEntry *entry, gpointer user_data) +void new_text_message(callable_obj_t* call, const gchar* message) +{ + message_tab *tab = g_hash_table_lookup(tabs,call->_callID); + if (!tab) + tab = create_messaging_tab(call,call->_callID); + append_message(tab,"Peer",message); +} +void replace_markup_tag(GtkTextBuffer* text_buffer, GtkTextIter* start) +{ + GtkTextIter start_match,end_match; + while ( gtk_text_iter_forward_search(start, "<b>", GTK_TEXT_SEARCH_TEXT_ONLY | GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, NULL) ) { + gtk_text_iter_forward_search(start, "</b>", GTK_TEXT_SEARCH_TEXT_ONLY | GTK_TEXT_SEARCH_VISIBLE_ONLY, &end_match, &end_match, NULL); + gtk_text_buffer_apply_tag_by_name(text_buffer, "b", &start_match, &end_match); + int offset = gtk_text_iter_get_offset(&end_match); + gtk_text_buffer_get_iter_at_offset(text_buffer, start, offset); + } +} + +static void on_enter(GtkEntry *entry, gpointer user_data) { message_tab *tab = (message_tab*)user_data; - append_message(tab,"Me",gtk_entry_get_text(entry)); + append_message(tab,(gchar*)"Me",gtk_entry_get_text(entry)); dbus_send_text_message(tab->call_id,gtk_entry_get_text(entry)); gtk_entry_set_text(entry,""); } //conference_obj_t -message_tab* create_messaging_tab(callable_obj_t* call,const char* title) +message_tab* create_messaging_tab(callable_obj_t* call,const gchar* title) { message_tab *tab = g_hash_table_lookup(tabs,call->_callID); if (tab) { @@ -107,10 +107,9 @@ message_tab* create_messaging_tab(callable_obj_t* call,const char* title) GtkWidget *scoll_area = gtk_scrolled_window_new(NULL,NULL); GtkWidget *text_box_widget = gtk_text_view_new_with_buffer(text_buffer); - gtk_text_view_set_editable(text_box_widget,FALSE); - gtk_text_view_set_wrap_mode(text_box_widget,GTK_WRAP_CHAR); + gtk_text_view_set_editable(GTK_TEXT_VIEW(text_box_widget),FALSE); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_box_widget),GTK_WRAP_CHAR); - gtk_container_add(scoll_area,text_box_widget); gtk_box_pack_start(GTK_BOX(vbox), scoll_area, TRUE, TRUE, 0); GtkWidget *line_edit = gtk_entry_new(); @@ -120,19 +119,20 @@ message_tab* create_messaging_tab(callable_obj_t* call,const char* title) self->widget = vbox; self->call_id = call->_callID; - self->title = title; + self->title = malloc(strlen(title) * sizeof(gchar*)); + strcpy(self->title,title); self->buffer = text_buffer; self->entry = line_edit; - self->view = text_box_widget; - - GtkWidget *tab_label = gtk_label_new(call->_peer_number); + self->view = GTK_TEXT_VIEW(text_box_widget); gchar* label_text; if (strcmp(call->_display_name,"")) label_text = call->_display_name; else label_text = call->_peer_number; - int ret = gtk_notebook_append_page(GTK_NOTEBOOK(get_tab_box()),vbox,tab_label); + GtkWidget *tab_label = gtk_label_new(label_text); + + gtk_notebook_append_page(GTK_NOTEBOOK(get_tab_box()),vbox,tab_label); gtk_widget_show (vbox); gtk_widget_show (scoll_area); gtk_widget_show (text_box_widget); diff --git a/gnome/src/messaging/message_tab.h b/gnome/src/messaging/message_tab.h index 577e561af09bdb87ea57678a7d11352715e92d30..1bc312642bcb20856424e68f705b164029c8b593 100644 --- a/gnome/src/messaging/message_tab.h +++ b/gnome/src/messaging/message_tab.h @@ -47,9 +47,8 @@ typedef struct { GtkWidget* entry; } message_tab; -// void add_message_box(ClutterActor* stage, const char* author, const char* message); -message_tab* create_messaging_tab(callable_obj_t* call,const char* title); +message_tab* create_messaging_tab(callable_obj_t* call,const gchar* title); GtkWidget *get_tab_box(); -void new_text_message(gchar* call_id, char* message); +void new_text_message(callable_obj_t* call, const gchar* message); #endif \ No newline at end of file diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c index 5f6f62028efe30f4efa241646253e4b1cba8da7c..518feded404d35fee095409fa1b2d55d6d7b3294 100644 --- a/gnome/src/uimanager.c +++ b/gnome/src/uimanager.c @@ -63,6 +63,8 @@ #include "account_schema.h" #include "config/accountlistconfigdialog.h" +#include "messaging/message_tab.h" + #include <sys/stat.h> #include <sliders.h>