Commit 3bd93005 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files

[ #13333] Make new chat widget work

parent 4ad7a7fd
......@@ -163,6 +163,7 @@ incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar *callID UNUSED,
if (call) {
widget = &call->_im_widget;
id = call->_callID;
new_text_message(call->_callID,msg);
} else {
conference_obj_t *conf = conferencelist_get(current_calls_tab, callID);
if (!conf) {
......@@ -172,11 +173,13 @@ incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar *callID UNUSED,
widget = &conf->_im_widget;
id = conf->_confID;
new_text_message(conf->_confID,msg);
}
if (!*widget)
*widget = im_widget_display(id);
im_widget_add_message(IM_WIDGET(*widget), from, msg, 0);
}
......
......@@ -62,11 +62,6 @@
#include <sys/stat.h>
#include <gtk/gtk.h>
/*TODO elepage REMOVE*/
#include <clutter/clutter.h>
#include <clutter-gtk/clutter-gtk.h>
/*TODO END elepage REMOVE*/
#include <gdk/gdkkeysyms.h>
/** Local variables */
......@@ -281,7 +276,7 @@ create_main_window()
// gtk_widget_show (text_box_widget2);
create_messaging_tab("test","test2");
// create_messaging_tab("test","test2");
// ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; /* Black */
// gtk_clutter_init(NULL,NULL);
// GtkWidget *clutter_widget = gtk_clutter_embed_new ();
......
......@@ -4,10 +4,8 @@ noinst_LTLIBRARIES = libmessaging.la
libmessaging_la_SOURCES = message_tab.c message_tab.h
libmessaging_la_LDFLAGS = @CLUTTER_LDFLAGS@ @CLUTTERGTK_LDFLAGS@
libmessaging_la_LDFLAGS =
libmessaging_la_LIBADD = @CLUTTER_LIBS@ \
@GTK_LIBS@ @GLIB_LIBS@ @CLUTTERGTK_LIBS@
libmessaging_la_LIBADD = @GTK_LIBS@ @GLIB_LIBS@
libmessaging_la_CFLAGS = @CLUTTER_CFLAGS@ \
@GTK_CFLAGS@ @GLIB_CFLAGS@ @CLUTTERGTK_CFLAGS@ @DBUSGLIB_CFLAGS@
libmessaging_la_CFLAGS = @GTK_CFLAGS@ @GLIB_CFLAGS@ @DBUSGLIB_CFLAGS@
......@@ -48,9 +48,12 @@ GtkWidget *get_tab_box()
return tab_box;
}
void add_message(message_tab *self, char* message)
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)
{
......@@ -70,7 +73,7 @@ void append_message(message_tab* self, gchar* name, gchar* message)
gtk_text_buffer_insert(self->buffer, &current_end, "\n\n", -1);
gtk_text_buffer_insert(self->buffer, &current_end, name, -1);
gtk_text_buffer_insert(self->buffer, &current_end, ": ", -1);
gtk_text_buffer_get_end_iter(self->buffer, &current_end);
for (int i=0;i<strlen(name)+2;i++){
if (!gtk_text_iter_backward_char(&current_end))
......@@ -87,27 +90,30 @@ static gboolean on_enter(GtkEntry *entry, gpointer user_data)
{
message_tab *tab = (message_tab*)user_data;
append_message(tab,"Me",gtk_entry_get_text(entry));
dbus_send_text_message(tab->call_id,gtk_entry_get_text(entry));
gtk_entry_set_text(entry,"");
// dbus_send_text_message(user_data->call_id,gtk_entry_get_text(entry));
}
message_tab* create_messaging_tab(const char* call_id,const char* title)
{
message_tab *tab = g_hash_table_lookup(tabs,call_id);
if (tab) {
return tab;
}
message_tab *self = g_new0(message_tab, 1);
GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
GtkTextBuffer *text_buffer = gtk_text_buffer_new(NULL);
gtk_text_buffer_create_tag(text_buffer, "b", "weight", PANGO_WEIGHT_BOLD,NULL);
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_widget_show (text_box_widget);
gtk_container_add(scoll_area,text_box_widget);
gtk_box_pack_start(GTK_BOX(vbox), scoll_area, TRUE, TRUE, 0);
......@@ -131,7 +137,14 @@ message_tab* create_messaging_tab(const char* call_id,const char* title)
append_message(self,"test_name","message blah blah blah");
append_message(self,"other_name","sajfhasdjkh fsdjkafh kasdh kahjk hfkjasdhfjkasd hfasdkjfh asdjk fhsdjkfh asdjkfh asdjkfhsdjkfha fhfhsdkajh fasdjkfh ahfkasdjfhasdkfhsdjkafh jh sdkfhasdkjhfajksdfhkasdjfh hsjk fhsdkfhkasdjfh");
gtk_notebook_append_page(get_tab_box(),vbox,NULL);
printf("\n\n\nusing widget %d\n",GTK_NOTEBOOK(get_tab_box()));
int ret = gtk_notebook_append_page(GTK_NOTEBOOK(get_tab_box()),vbox,NULL);
gtk_widget_show (vbox);
gtk_widget_show (scoll_area);
gtk_widget_show (text_box_widget);
gtk_widget_show (line_edit);
printf("ret %d\n",ret);
if (!tabs) {
tabs = g_hash_table_new(NULL,g_str_equal);
}
......
......@@ -35,8 +35,6 @@
#ifndef __MESSAGING_H__
#define __MESSAGING_H__
// #include <clutter/clutter.h>
// #include <clutter-gtk/clutter-gtk.h>
#include <gtk/gtk.h>
typedef struct {
......@@ -50,5 +48,6 @@ typedef struct {
// void add_message_box(ClutterActor* stage, const char* author, const char* message);
message_tab* create_messaging_tab(const char* call_id,const char* title);
GtkWidget *get_tab_box();
void new_text_message(gchar* call_id, char* message);
#endif
\ No newline at end of file
......@@ -652,12 +652,14 @@ call_im(void* foo UNUSED)
if (selectedCall) {
if (!selectedCall->_im_widget)
selectedCall->_im_widget = im_widget_display(selectedCall->_callID);
create_messaging_tab(selectedCall->_callID,"test");
} else
WARN("Sorry. Instant messaging is not allowed outside a call\n");
} else {
if (selectedConf) {
if (!selectedConf->_im_widget)
selectedConf->_im_widget = im_widget_display(selectedConf->_confID);
create_messaging_tab(selectedConf->_confID,"test");
} else
WARN("Sorry. Instant messaging is not allowed outside a call\n");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment