diff options
author | Travis Reitter <travis.reitter@collabora.co.uk> | 2010-10-22 05:37:01 +0800 |
---|---|---|
committer | Travis Reitter <travis.reitter@collabora.co.uk> | 2010-10-22 08:43:13 +0800 |
commit | 3c83182d654711d5f86b30ed8b7d3bf9af418d94 (patch) | |
tree | dcc4d3b76ef7dba7fea333f0ce0e2b921b4ba28a | |
parent | ca04b3480cf5a55767065324b29e5babb2039b37 (diff) | |
download | gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar.gz gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar.bz2 gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar.lz gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar.xz gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.tar.zst gsoc2013-empathy-3c83182d654711d5f86b30ed8b7d3bf9af418d94.zip |
Port the a/v app to new G/tkApplication.
Fixes bgo#632846.
-rw-r--r-- | 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 c937c2a44..84aba715b 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); |