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
No related branches found
No related tags found
No related merge requests found
......@@ -130,10 +130,9 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
/* First check if the call is valid */
if (c) {
/* Make the instant messaging main window pops */
im_widget_display (&c, msg);
/* Display the message */
/* Make the instant messaging main window pops, add messages only if the main window exist.
Elsewhere the message is displayed asynchronously*/
if (im_widget_display (&c, msg))
im_widget_add_message (c->_im_widget, get_peer_information (c), msg, 0);
} else {
......
......@@ -38,26 +38,24 @@
static void
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:
DEBUG ("--------------------------------- loading provisional");
break;
case WEBKIT_LOAD_COMMITTED:
DEBUG ("--------------------------------- loading commited");
break;
case WEBKIT_LOAD_FINISHED:
// im_widget_add_message(im, const gchar *from, const gchar *message, gint level
DEBUG ("--------------------------------- loading finished");
c = calllist_get (current_calls, im->call_id);
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;
case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
DEBUG ("--------------------------------- loading nonempty");
break;
case WEBKIT_LOAD_FAILED:
DEBUG ("--------------------------------- loading failed");
break;
default:
DEBUG ("--------------------------------- loading default");
}
}
......@@ -237,7 +235,7 @@ im_widget_init (IMWidget *im)
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");
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 *
......@@ -247,7 +245,7 @@ im_widget_new()
}
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, "first_message", message, NULL));
......@@ -301,7 +299,7 @@ im_widget_display (callable_obj_t **call, gchar *message)
if (message)
im = IM_WIDGET (im_widget_new ());
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 */
tmp->_im_widget = im;
......@@ -316,6 +314,9 @@ im_widget_display (callable_obj_t **call, gchar *message)
/* Add it to the main instant messaging window */
im_window_add (im);
/* Update the first message to appears at widget creation*/
im->first_message = g_strdup (message);
return FALSE;
} else {
DEBUG ("im widget exists for this call\n");
......
......@@ -74,7 +74,8 @@ struct _IMWidgetClass {
/*! @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.
@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*);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment