[empathy] Port the a/v app to new G/tkApplication.
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Port the a/v app to new G/tkApplication.
- Date: Fri, 22 Oct 2010 12:09:13 +0000 (UTC)
commit 3c83182d654711d5f86b30ed8b7d3bf9af418d94
Author: Travis Reitter <travis reitter collabora co uk>
Date: Thu Oct 21 14:37:01 2010 -0700
Port the a/v app to new G/tkApplication.
Fixes bgo#632846.
src/empathy-av.c | 41 +++++++++++++++++++----------------------
1 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/src/empathy-av.c b/src/empathy-av.c
index c937c2a..84aba71 100644
--- a/src/empathy-av.c
+++ b/src/empathy-av.c
@@ -43,43 +43,30 @@
#define EMPATHY_AV_DBUS_NAME "org.gnome.Empathy.AudioVideo"
+static GtkApplication *app = NULL;
+static gboolean app_held = FALSE;
static guint nb_windows = 0;
-static guint timeout_id = 0;
static gboolean use_timer = TRUE;
-static gboolean
-timeout_cb (gpointer data)
-{
- DEBUG ("Timing out; exiting");
-
- gtk_main_quit ();
- return FALSE;
-}
-
static void
start_timer (void)
{
if (!use_timer)
return;
- if (timeout_id != 0)
- return;
-
DEBUG ("Start timer");
- timeout_id = g_timeout_add_seconds (TIMEOUT, timeout_cb, NULL);
+ if (app_held)
+ g_application_release (G_APPLICATION (app));
}
static void
stop_timer (void)
{
- if (timeout_id == 0)
- return;
-
DEBUG ("Stop timer");
- g_source_remove (timeout_id);
- timeout_id = 0;
+ g_application_hold (G_APPLICATION (app));
+ app_held = TRUE;
}
static void
@@ -128,7 +115,6 @@ main (int argc,
#endif
EmpathyCallFactory *call_factory;
GError *error = NULL;
- GtkApplication *app;
/* Init */
g_thread_init (NULL);
@@ -155,7 +141,7 @@ main (int argc,
gtk_window_set_default_icon_name ("empathy");
textdomain (GETTEXT_PACKAGE);
- app = gtk_application_new (EMPATHY_AV_DBUS_NAME, &argc, &argv);
+ app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_IS_SERVICE);
#ifdef ENABLE_DEBUG
/* Set up debug sender */
@@ -182,9 +168,20 @@ main (int argc,
use_timer = FALSE;
}
+ /* the inactivity timeout can only be set while the application is held */
+ g_application_hold (G_APPLICATION (app));
+ g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
+ if (use_timer)
+ {
+ g_application_release (G_APPLICATION (app));
+ app_held = FALSE;
+ }
+ else
+ app_held = TRUE;
+
start_timer ();
- gtk_application_run (app);
+ g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
g_object_unref (call_factory);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]