aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-29 17:05:19 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-29 17:36:09 +0800
commitbba82eedbef0a2e3ea30ef924d64c85a7a105ad4 (patch)
treee3f803b9f281bce50bb0ca215574e28bfe650370
parent8ad9151c1f7228436492e992158346e2bc808122 (diff)
downloadgsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar.gz
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar.bz2
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar.lz
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar.xz
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.tar.zst
gsoc2013-empathy-bba82eedbef0a2e3ea30ef924d64c85a7a105ad4.zip
Add a timer stopping the proccess after a while if idling
There is no point to keep it around when not needed.
-rw-r--r--src/empathy-av.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/empathy-av.c b/src/empathy-av.c
index f86999cba..cb0e82b1b 100644
--- a/src/empathy-av.c
+++ b/src/empathy-av.c
@@ -38,6 +38,56 @@
#include <gst/gst.h>
+/* Exit after $TIMEOUT seconds if not displaying any call window */
+#define TIMEOUT 60
+
+static guint nb_windows = 0;
+static guint timeout_id = 0;
+
+static gboolean
+timeout_cb (gpointer data)
+{
+ DEBUG ("Timing out; exiting");
+
+ gtk_main_quit ();
+ return FALSE;
+}
+
+static void
+start_timer (void)
+{
+ if (timeout_id != 0)
+ return;
+
+ DEBUG ("Start timer");
+
+ timeout_id = g_timeout_add_seconds (TIMEOUT, timeout_cb, NULL);
+}
+
+static void
+stop_timer (void)
+{
+ if (timeout_id == 0)
+ return;
+
+ DEBUG ("Stop timer");
+
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+}
+
+static void
+call_window_destroy_cb (EmpathyCallWindow *window,
+ gpointer user_data)
+{
+ nb_windows--;
+
+ if (nb_windows > 0)
+ return;
+
+ start_timer ();
+}
+
static void
new_call_handler_cb (EmpathyCallFactory *factory,
EmpathyCallHandler *handler,
@@ -46,7 +96,16 @@ new_call_handler_cb (EmpathyCallFactory *factory,
{
EmpathyCallWindow *window;
+ DEBUG ("Create a new call window");
+
window = empathy_call_window_new (handler);
+
+ nb_windows++;
+ stop_timer ();
+
+ g_signal_connect (window, "destroy",
+ G_CALLBACK (call_window_destroy_cb), NULL);
+
gtk_widget_show (GTK_WIDGET (window));
}
@@ -107,6 +166,8 @@ main (int argc,
return EXIT_FAILURE;
}
+ start_timer ();
+
gtk_main ();
g_object_unref (call_factory);