empathy r2555 - trunk/src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r2555 - trunk/src
- Date: Tue, 3 Mar 2009 17:34:22 +0000 (UTC)
Author: xclaesse
Date: Tue Mar 3 17:34:22 2009
New Revision: 2555
URL: http://svn.gnome.org/viewvc/empathy?rev=2555&view=rev
Log:
Add timer and make all gtk calls in the main thread
Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>
Modified:
trunk/src/empathy-call-window.c
Modified: trunk/src/empathy-call-window.c
==============================================================================
--- trunk/src/empathy-call-window.c (original)
+++ trunk/src/empathy-call-window.c Tue Mar 3 17:34:22 2009
@@ -65,6 +65,8 @@
gboolean dispose_has_run;
EmpathyCallHandler *handler;
+ gboolean connected;
+
GtkWidget *video_output;
GtkWidget *video_preview;
GtkWidget *sidebar;
@@ -87,6 +89,9 @@
GladeXML *glade;
guint context_id;
+ GTimer *timer;
+ guint timer_id;
+
GMutex *lock;
};
@@ -413,6 +418,8 @@
G_CALLBACK (empathy_call_window_delete_cb), self);
empathy_call_window_status_message (self, _("Connecting..."));
+
+ priv->timer = g_timer_new ();
}
static void empathy_call_window_dispose (GObject *object);
@@ -511,6 +518,10 @@
g_object_unref (priv->video_tee);
priv->video_tee = NULL;
+ if (priv->timer_id != 0)
+ g_source_remove (priv->timer_id);
+ priv->timer_id = 0;
+
/* release any references held by the object here */
if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose)
G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
@@ -525,6 +536,8 @@
/* free any data held directly by the object here */
g_mutex_free (priv->lock);
+ g_timer_destroy (priv->timer);
+
G_OBJECT_CLASS (empathy_call_window_parent_class)->finalize (object);
}
@@ -554,6 +567,9 @@
EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ g_timer_stop (priv->timer);
+ g_source_remove (priv->timer_id);
+ priv->timer_id = 0;
empathy_call_window_status_message (self, _("Disconnected"));
gtk_widget_set_sensitive (priv->camera_button, FALSE);
@@ -614,35 +630,68 @@
return pad;
}
-/* Called from the streaming thread */
-static void
-empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
- GstPad *src, guint media_type, gpointer user_data)
+static gboolean
+empathy_call_window_update_timer (gpointer user_data)
{
EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
EmpathyCallWindowPriv *priv = GET_PRIV (self);
gchar *str;
- EmpathyTpCall *call;
- GstPad *pad;
+ gdouble time;
- g_mutex_lock (priv->lock);
+ time = g_timer_elapsed (priv->timer, NULL);
- g_object_get (priv->handler, "tp-call", &call, NULL);
+ /* Translators: number of minutes:seconds the caller has been connected */
+ str = g_strdup_printf (_("Connected -- %d:%02dm"), (int) time / 60,
+ (int) time % 60);
+ empathy_call_window_status_message (self, str);
+ g_free (str);
+
+ return TRUE;
+}
+
+static gboolean
+empathy_call_window_connected (gpointer user_data)
+{
+ EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+ EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ EmpathyTpCall *call;
- gdk_threads_enter ();
+ g_object_get (priv->handler, "tp-call", &call, NULL);
if (empathy_tp_call_has_dtmf (call))
gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
g_object_unref (call);
- /* Translators: number of minutes:seconds the caller has been connected */
- str = g_strdup_printf (_("Connected -- %d:%02dm"), 0, 0);
- empathy_call_window_status_message (self, str);
- g_free (str);
+ priv->timer_id = g_timeout_add_seconds (1,
+ empathy_call_window_update_timer, self);
+ empathy_call_window_update_timer (self);
gdk_threads_leave ();
+ return FALSE;
+}
+
+
+/* Called from the streaming thread */
+static void
+empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
+ GstPad *src, guint media_type, gpointer user_data)
+{
+ EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
+ EmpathyCallWindowPriv *priv = GET_PRIV (self);
+
+ GstPad *pad;
+
+ g_mutex_lock (priv->lock);
+
+ if (priv->connected == FALSE)
+ {
+ g_timer_start (priv->timer);
+ priv->timer_id = g_idle_add (empathy_call_window_connected, self);
+ priv->connected = TRUE;
+ }
+
switch (media_type)
{
case TP_MEDIA_STREAM_TYPE_AUDIO:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]