Skip to content
Snippets Groups Projects
Commit e871887a authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3619] Fix first messsage display when instant message window pops

parent 920653fd
Branches
Tags
No related merge requests found
...@@ -130,10 +130,9 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const ...@@ -130,10 +130,9 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
/* First check if the call is valid */ /* First check if the call is valid */
if (c) { if (c) {
/* Make the instant messaging main window pops */ /* Make the instant messaging main window pops, add messages only if the main window exist.
im_widget_display (&c, msg); Elsewhere the message is displayed asynchronously*/
if (im_widget_display (&c, msg))
/* Display the message */
im_widget_add_message (c->_im_widget, get_peer_information (c), msg, 0); im_widget_add_message (c->_im_widget, get_peer_information (c), msg, 0);
} else { } else {
......
...@@ -38,26 +38,24 @@ ...@@ -38,26 +38,24 @@
static void static void
on_frame_loading_done (GObject *gobject, GParamSpec *pspec, gpointer user_data) on_frame_loading_done (GObject *gobject, GParamSpec *pspec, gpointer user_data)
{ {
IMWidget *im = IM_WIDGET (user_data);
callable_obj_t *c;
switch (webkit_web_frame_get_load_status (WEBKIT_WEB_FRAME (user_data))) { switch (webkit_web_frame_get_load_status (WEBKIT_WEB_FRAME (im->web_frame))) {
case WEBKIT_LOAD_PROVISIONAL: case WEBKIT_LOAD_PROVISIONAL:
DEBUG ("--------------------------------- loading provisional");
break;
case WEBKIT_LOAD_COMMITTED: case WEBKIT_LOAD_COMMITTED:
DEBUG ("--------------------------------- loading commited");
break; break;
case WEBKIT_LOAD_FINISHED: case WEBKIT_LOAD_FINISHED:
// im_widget_add_message(im, const gchar *from, const gchar *message, gint level c = calllist_get (current_calls, im->call_id);
DEBUG ("--------------------------------- loading finished"); im_widget_add_message (im, get_peer_information (c), im->first_message, 0);
g_free(im->first_message);
im->first_message = NULL;
DEBUG ("JavaScrip loading frame finished");
break; break;
case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
DEBUG ("--------------------------------- loading nonempty");
break;
case WEBKIT_LOAD_FAILED: case WEBKIT_LOAD_FAILED:
DEBUG ("--------------------------------- loading failed");
break; break;
default: default:
DEBUG ("--------------------------------- loading default");
} }
} }
...@@ -237,7 +235,7 @@ im_widget_init (IMWidget *im) ...@@ -237,7 +235,7 @@ im_widget_init (IMWidget *im)
im->js_global = JSContextGetGlobalObject (im->js_context); im->js_global = JSContextGetGlobalObject (im->js_context);
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (im->web_view), "file://" DATA_DIR "/webkit/im/im.html"); webkit_web_view_load_uri (WEBKIT_WEB_VIEW (im->web_view), "file://" DATA_DIR "/webkit/im/im.html");
g_signal_connect (G_OBJECT (im->web_frame), "notify", G_CALLBACK (on_frame_loading_done), im->web_frame); g_signal_connect (G_OBJECT (im->web_frame), "notify", G_CALLBACK (on_frame_loading_done), im);
} }
GtkWidget * GtkWidget *
...@@ -247,7 +245,7 @@ im_widget_new() ...@@ -247,7 +245,7 @@ im_widget_new()
} }
GtkWidget * GtkWidget *
im_widget_new_with_first_messaget (gchar *message) im_widget_new_with_first_message (gchar *message)
{ {
return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, NULL)); return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, NULL));
// return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, "first_message", message, NULL)); // return GTK_WIDGET (g_object_new (IM_WIDGET_TYPE, "first_message", message, NULL));
...@@ -301,7 +299,7 @@ im_widget_display (callable_obj_t **call, gchar *message) ...@@ -301,7 +299,7 @@ im_widget_display (callable_obj_t **call, gchar *message)
if (message) if (message)
im = IM_WIDGET (im_widget_new ()); im = IM_WIDGET (im_widget_new ());
else else
im = IM_WIDGET (im_widget_new ()); im = IM_WIDGET (im_widget_new_with_first_message (message));
/* Keep a reference on this object in the call struct */ /* Keep a reference on this object in the call struct */
tmp->_im_widget = im; tmp->_im_widget = im;
...@@ -316,6 +314,9 @@ im_widget_display (callable_obj_t **call, gchar *message) ...@@ -316,6 +314,9 @@ im_widget_display (callable_obj_t **call, gchar *message)
/* Add it to the main instant messaging window */ /* Add it to the main instant messaging window */
im_window_add (im); im_window_add (im);
/* Update the first message to appears at widget creation*/
im->first_message = g_strdup (message);
return FALSE; return FALSE;
} else { } else {
DEBUG ("im widget exists for this call\n"); DEBUG ("im widget exists for this call\n");
......
...@@ -74,7 +74,8 @@ struct _IMWidgetClass { ...@@ -74,7 +74,8 @@ struct _IMWidgetClass {
/*! @function /*! @function
@abstract Display the instant messaging interface for this call. If it has not been created yet, create it and attached it to the imWindow. @abstract Display the instant messaging interface for this call. If it has not been created yet, create it and attached it to the imWindow.
@param A reference on the call attached to the current IM widget @param A reference on the call attached to the current IM widget
@param The first message to be displayed @param The first message to be displayed, webkit's frames are loaded asynchronously
@return TRUE if window is already created, FALSE elsewhere
*/ */
gboolean im_widget_display (callable_obj_t**, gchar*); gboolean im_widget_display (callable_obj_t**, gchar*);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment