[empathy] Properly handle remote instances of empathy-av.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Properly handle remote instances of empathy-av.
- Date: Fri, 29 Oct 2010 16:35:54 +0000 (UTC)
commit 8857f63fb88c5b6cc3fed75143a9b58da439f583
Author: Travis Reitter <travis reitter collabora co uk>
Date: Fri Oct 22 13:03:55 2010 -0700
Properly handle remote instances of empathy-av.
Also cut out unncessary window counting that GApplication does for us.
Fixes bgo#632912.
src/empathy-av.c | 63 +++++++++++++++++------------------------------------
1 files changed, 20 insertions(+), 43 deletions(-)
---
diff --git a/src/empathy-av.c b/src/empathy-av.c
index 84aba71..ee6d441 100644
--- a/src/empathy-av.c
+++ b/src/empathy-av.c
@@ -44,41 +44,25 @@
#define EMPATHY_AV_DBUS_NAME "org.gnome.Empathy.AudioVideo"
static GtkApplication *app = NULL;
-static gboolean app_held = FALSE;
-static guint nb_windows = 0;
+static gboolean activated = FALSE;
static gboolean use_timer = TRUE;
static void
-start_timer (void)
-{
- if (!use_timer)
- return;
-
- DEBUG ("Start timer");
-
- if (app_held)
- g_application_release (G_APPLICATION (app));
-}
-
-static void
-stop_timer (void)
-{
- DEBUG ("Stop timer");
-
- g_application_hold (G_APPLICATION (app));
- app_held = TRUE;
-}
+new_call_handler_cb (EmpathyCallFactory *factory,
+ EmpathyCallHandler *handler,
+ gboolean outgoing,
+ gpointer user_data);
static void
-call_window_destroy_cb (EmpathyCallWindow *window,
- gpointer user_data)
+activate_cb (GApplication *application)
{
- nb_windows--;
-
- if (nb_windows > 0)
- return;
+ if (!use_timer && !activated)
+ {
+ /* keep a 'ref' to the application */
+ g_application_hold (G_APPLICATION (app));
- start_timer ();
+ activated = TRUE;
+ }
}
static void
@@ -93,11 +77,10 @@ new_call_handler_cb (EmpathyCallFactory *factory,
window = empathy_call_window_new (handler);
- nb_windows++;
- stop_timer ();
+ g_application_hold (G_APPLICATION (app));
- g_signal_connect (window, "destroy",
- G_CALLBACK (call_window_destroy_cb), NULL);
+ g_signal_connect_swapped (window, "destroy",
+ G_CALLBACK (g_application_release), app);
gtk_widget_show (GTK_WIDGET (window));
}
@@ -141,7 +124,8 @@ main (int argc,
gtk_window_set_default_icon_name ("empathy");
textdomain (GETTEXT_PACKAGE);
- app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_IS_SERVICE);
+ app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
#ifdef ENABLE_DEBUG
/* Set up debug sender */
@@ -158,9 +142,10 @@ main (int argc,
{
g_critical ("Failed to register Handler: %s", error->message);
g_error_free (error);
- return EXIT_FAILURE;
}
+ g_object_unref (call_factory);
+
if (g_getenv ("EMPATHY_PERSIST") != NULL)
{
DEBUG ("Disable timer");
@@ -171,15 +156,7 @@ main (int argc,
/* 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 ();
+ g_application_release (G_APPLICATION (app));
g_application_run (G_APPLICATION (app), argc, argv);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]