aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2007-05-10 02:06:22 +0800
committerxclaesse <xclaesse@4ee84921-47dd-4033-b63a-18d7a039a3e4>2007-05-10 02:06:22 +0800
commit53875e71dcc04b1197d97e654f43293c74557d92 (patch)
treea919b4247c9b3a80cb0089d9c26cbb22b2f9952e /src
parent50549ef5a4df1be5877e340c0fd86453532b8088 (diff)
downloadgsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar.gz
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar.bz2
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar.lz
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar.xz
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.tar.zst
gsoc2013-empathy-53875e71dcc04b1197d97e654f43293c74557d92.zip
[darcs-to-svn @ Ctr+Enter adds a new line in and empathy-chat exits 5sec after the last chat was closed]
git-svn-id: svn+ssh://svn.gnome.org/svn/empathy/trunk@39 4ee84921-47dd-4033-b63a-18d7a039a3e4
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-main.c62
-rw-r--r--src/empathy-main.c2
2 files changed, 63 insertions, 1 deletions
diff --git a/src/empathy-chat-main.c b/src/empathy-chat-main.c
index 91dd510b4..9b961d554 100644
--- a/src/empathy-chat-main.c
+++ b/src/empathy-chat-main.c
@@ -33,14 +33,68 @@
#include <libmissioncontrol/mc-account.h>
#include <libempathy/gossip-contact.h>
+#include <libempathy/gossip-debug.h>
#include <libempathy/empathy-chandler.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy-gtk/gossip-private-chat.h>
+#define DEBUG_DOMAIN "ChatMain"
+
#define BUS_NAME "org.gnome.Empathy.Chat"
#define OBJECT_PATH "/org/freedesktop/Telepathy/ChannelHandler"
+/* Time to wait before exit, in seconds */
+#define EXIT_TIMEOUT 5
+
+
+static guint chat_count = 0;
+static guint exit_timeout = 0;
+
+
+static gboolean
+exit_timeout_cb (gpointer user_data)
+{
+ gossip_debug (DEBUG_DOMAIN, "Timeout, exiting");
+
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+exit_timeout_start (void)
+{
+ if (exit_timeout) {
+ return;
+ }
+
+ exit_timeout = g_timeout_add (EXIT_TIMEOUT * 1000,
+ (GSourceFunc) exit_timeout_cb,
+ NULL);
+}
+
+static void
+exit_timeout_stop (void)
+{
+ if (exit_timeout) {
+ gossip_debug (DEBUG_DOMAIN, "Exit timeout canceled");
+ g_source_remove (exit_timeout);
+ exit_timeout = 0;
+ }
+}
+
+static void
+chat_finalized_cb (gpointer user_data,
+ GossipChat *chat)
+{
+ chat_count--;
+ if (chat_count == 0) {
+ gossip_debug (DEBUG_DOMAIN, "No more chat, start exit timeout");
+ exit_timeout_start ();
+ }
+}
+
static void
new_channel_cb (EmpathyChandler *chandler,
TpConn *tp_conn,
@@ -63,6 +117,13 @@ new_channel_cb (EmpathyChandler *chandler,
contact = empathy_contact_list_get_from_handle (list, tp_chan->handle);
chat = gossip_private_chat_new_with_channel (contact, tp_chan);
+ g_object_weak_ref (G_OBJECT (chat),
+ (GWeakNotify) chat_finalized_cb,
+ NULL);
+
+ exit_timeout_stop ();
+ chat_count++;
+
gossip_chat_present (GOSSIP_CHAT (chat));
g_object_unref (mc);
@@ -80,6 +141,7 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
+ exit_timeout_start ();
chandler = empathy_chandler_new (BUS_NAME, OBJECT_PATH);
g_signal_connect (chandler, "new-channel",
diff --git a/src/empathy-main.c b/src/empathy-main.c
index afa1e119e..077e1a6b6 100644
--- a/src/empathy-main.c
+++ b/src/empathy-main.c
@@ -41,7 +41,7 @@
#include "empathy-filter.h"
-#define DEBUG_DOMAIN "Empathy"
+#define DEBUG_DOMAIN "EmpathyMain"
static void error_cb (MissionControl *mc,
GError *error,