aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);