~ubuntu-branches/ubuntu/wily/almanah/wily

« back to all changes in this revision

Viewing changes to debian/patches/encrypt_database

  • Committer: Package Import Robot
  • Author(s): Angel Abad
  • Date: 2013-12-02 13:21:08 UTC
  • mfrom: (10.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20131202132108-sfv3084bowgmzq09
Tags: 0.11.0-1
* Imported Upstream version 0.11.0
* debian/control: Update Homepage field.
* debian/patches/:
  - encrypt_database: Removed, applied upstream
  - spellchecking_error: Removed, applied upstream
  - desktop_keywords: Removed, applied upstream
* Bump Standards-Version to 3.9.5 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Subject: Almanah doesn't encrypt the database when the application close
2
 
Author: Alvaro Peña <alvaropg@gmail.com>
3
 
Orirgin: upstream, https://git.gnome.org/browse/almanah/commit/?id=0e4fb167c6eb478e0bcdb1cce5dd18f36f3f2656
4
 
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=695117
5
 
Reviewed-by: Angel Abad <angel@debian.org>
6
 
 
7
 
--- a/src/application.c
8
 
+++ b/src/application.c
9
 
@@ -40,7 +40,7 @@
10
 
 static void startup (GApplication *application);
11
 
 static void activate (GApplication *application);
12
 
 static gint handle_command_line (GApplication *application, GApplicationCommandLine *command_line);
13
 
-static void quit_main_loop (GApplication *application);
14
 
+static void window_removed (GtkApplication *application, GtkWindow *window);
15
 
 
16
 
 static void almanah_application_init_actions (AlmanahApplication *self);
17
 
 
18
 
@@ -87,6 +87,7 @@
19
 
 {
20
 
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
21
 
        GApplicationClass *gapplication_class = G_APPLICATION_CLASS (klass);
22
 
+       GtkApplicationClass *gtkapplication_class = GTK_APPLICATION_CLASS (klass);
23
 
 
24
 
        g_type_class_add_private (klass, sizeof (AlmanahApplicationPrivate));
25
 
 
26
 
@@ -98,7 +99,8 @@
27
 
        gapplication_class->startup = startup;
28
 
        gapplication_class->activate = activate;
29
 
        gapplication_class->command_line = handle_command_line;
30
 
-       gapplication_class->quit_mainloop = quit_main_loop;
31
 
+
32
 
+       gtkapplication_class->window_removed = window_removed;
33
 
 
34
 
        g_object_class_install_property (gobject_class, PROP_DEBUG,
35
 
                                         g_param_spec_boolean ("debug",
36
 
@@ -356,7 +358,7 @@
37
 
 }
38
 
 
39
 
 static void
40
 
-storage_manager_disconnected_cb (AlmanahStorageManager *self, const gchar *gpgme_error_message, const gchar *warning_message, GApplication *application)
41
 
+storage_manager_disconnected_cb (AlmanahStorageManager *self, const gchar *gpgme_error_message, const gchar *warning_message, GtkApplication *application)
42
 
 {
43
 
        if (gpgme_error_message != NULL || warning_message != NULL) {
44
 
                GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
45
 
@@ -373,21 +375,28 @@
46
 
                gtk_widget_destroy (dialog);
47
 
        }
48
 
 
49
 
-       /* Chain up to the parent class */
50
 
-       G_APPLICATION_CLASS (almanah_application_parent_class)->quit_mainloop (application);
51
 
+       /* Allow the end of the applaction */
52
 
+       g_application_release (G_APPLICATION (application));
53
 
 }
54
 
 
55
 
 static void
56
 
-quit_main_loop (GApplication *application)
57
 
+window_removed (GtkApplication *application, GtkWindow *window)
58
 
 {
59
 
-       AlmanahApplicationPrivate *priv = ALMANAH_APPLICATION (application)->priv;
60
 
+       /* This would normally result in the end of the application, but we need to close the database connection first
61
 
+          to prevent an unencrypted database in the filesystem, and we don't want a bug like that.
62
 
+          So, we append a reference to the application when the user close the main window. When the application disconnect
63
 
+          from the database, allowing the encryption if necessary, we remove this reference with g_application_release.
64
 
+          See: https://bugzilla.gnome.org/show_bug.cgi?id=695117 */
65
 
+       if (ALMANAH_IS_MAIN_WINDOW (window)) {
66
 
+               AlmanahApplicationPrivate *priv = ALMANAH_APPLICATION (application)->priv;
67
 
 
68
 
-       /* This would normally result in gtk_main_quit() being called, but we need to close the database connection first. */
69
 
-       g_signal_connect (priv->storage_manager, "disconnected", (GCallback) storage_manager_disconnected_cb, application);
70
 
-       almanah_storage_manager_disconnect (priv->storage_manager, NULL);
71
 
+               g_application_hold (G_APPLICATION (application));
72
 
+
73
 
+               g_signal_connect (priv->storage_manager, "disconnected", (GCallback) storage_manager_disconnected_cb, application);
74
 
+               almanah_storage_manager_disconnect (priv->storage_manager, NULL);
75
 
+       }
76
 
 
77
 
-       /* Quitting is actually done in storage_manager_disconnected_cb, which is called once
78
 
-        * the storage manager has encrypted the DB and disconnected from it. */
79
 
+       GTK_APPLICATION_CLASS (almanah_application_parent_class)->window_removed (application, window);
80
 
 }
81
 
 
82
 
 static void