[bijiben] Timeout : emit signal if apps quit



commit 73df4cc8e363c5b5fcff439dbfb53073d552cfb7
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Sun Nov 18 23:31:21 2012 +0100

    Timeout : emit signal if apps quit

 src/libbiji/biji-note-obj.c |    3 ---
 src/libbiji/biji-timeout.c  |   10 +++++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index a0e7d30..43229dc 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -825,13 +825,10 @@ biji_note_obj_is_opened (BijiNoteObj *note)
   return BIJI_IS_WEBKIT_EDITOR (note->priv->editor);
 }
 
-/* Saving there might be no good. Untill better it ensures
- * note is saved when app quit. */
 static void
 _biji_note_obj_close (BijiNoteObj *note)
 {
   note->priv->editor = NULL;
-  on_save_timeout (note);
 }
 
 GtkWidget *
diff --git a/src/libbiji/biji-timeout.c b/src/libbiji/biji-timeout.c
index 66aad86..bd3a3d4 100644
--- a/src/libbiji/biji-timeout.c
+++ b/src/libbiji/biji-timeout.c
@@ -19,6 +19,8 @@
  *     Ported from gnote
  */
 
+#include <gio/gio.h>
+
 #include "biji-timeout.h"
 
 /* Signal */
@@ -33,6 +35,7 @@ static guint biji_time_signals [BIJI_TIME_SIGNALS] = { 0 };
 struct _BijiTimeoutPrivate
 {
   guint timeout_id;
+  guint quit;
 };
 
 #define BIJI_TIMEOUT_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BIJI_TYPE_TIMEOUT, BijiTimeoutPrivate))
@@ -45,7 +48,8 @@ biji_timeout_init (BijiTimeout *self)
   BijiTimeoutPrivate *priv = BIJI_TIMEOUT_GET_PRIVATE(self);
   self->priv = priv;
 
-  self->priv->timeout_id = 0;
+  priv->timeout_id = 0;
+  priv->quit = 0;
 }
 
 static void
@@ -117,4 +121,8 @@ biji_timeout_reset (BijiTimeout *self, guint millis)
 
   self->priv->timeout_id = g_timeout_add (
        millis, (GSourceFunc) biji_timeout_callback, self);
+
+  /* Ensure to perform timeout if main loop ends */
+  self->priv->quit = g_signal_connect_swapped (g_application_get_default(), "shutdown",
+                                               G_CALLBACK (biji_timeout_expired), self);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]