From 9e7367f27e11f313e0cdb401e196f1f98fa35101 Mon Sep 17 00:00:00 2001 From: Jose Aliste Date: Fri, 09 Jul 2010 07:42:46 +0000 Subject: [shell] Emit a DBus signal when window is closed --- (limited to 'shell') diff --git a/shell/ev-window.c b/shell/ev-window.c index fa7a16b..e79bf00 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -337,6 +337,9 @@ static void ev_window_media_player_key_pressed (EvWindow *windo const gchar *key, gpointer user_data); static void ev_window_update_max_min_scale (EvWindow *window); +#ifdef ENABLE_DBUS +static void ev_window_emit_closed (EvWindow *window); +#endif static guint ev_window_n_copies = 0; @@ -4866,6 +4869,7 @@ ev_window_dispose (GObject *object) #ifdef ENABLE_DBUS if (priv->dbus_object_id > 0) { + ev_window_emit_closed (window); g_dbus_connection_unregister_object (ev_application_get_dbus_connection (EV_APP), priv->dbus_object_id); priv->dbus_object_id = 0; @@ -6227,6 +6231,37 @@ ev_window_sync_source (EvWindow *window, } static void +ev_window_emit_closed (EvWindow *window) +{ + GDBusConnection *connection; + GError *error = NULL; + + if (window->priv->dbus_object_id <= 0) + return; + + connection = ev_application_get_dbus_connection (EV_APP); + if (!connection) + return; + + /* TODO: figure out if this is the last window and use + * g_dbus_connection_flush_sync() to make sure the signal + * is emitted. + */ + g_dbus_connection_emit_signal (connection, + NULL, + window->priv->dbus_object_path, + EV_WINDOW_DBUS_INTERFACE, + "Closed", + NULL, + &error); + if (error) { + g_printerr ("Failed to emit DBus signal Closed: %s\n", + error->message); + g_error_free (error); + } +} + +static void method_call_cb (GDBusConnection *connection, const gchar *sender, const gchar *object_path, @@ -6263,6 +6298,7 @@ static const char introspection_xml[] = "" "" "" + "" "" ""; -- cgit v0.9.1