[almanah: 5/5] Merge branch 'Version_0_10_1'



commit f532dcad9ff4e04cffc1263d07ae71e1cd496985
Merge: dd6190a 91eae05
Author: Álvaro Peña <alvaropg gmail com>
Date:   Mon Mar 11 12:20:49 2013 +0100

    Merge branch 'Version_0_10_1'
    
    Conflicts:
        NEWS
        configure.ac

 NEWS              |    6 ++++++
 src/application.c |   35 ++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)
---
diff --cc NEWS
index c1824d4,fae2aa5..fda9abd
--- a/NEWS
+++ b/NEWS
@@@ -1,34 -1,9 +1,40 @@@
 +Overview of changes from Almanah 0.10.0 to Almanah 0.10.8
 +=========================================================
 +
 +This is a development release for testing purpose in the road to 0.11, so use carefully.
 +
 +Major changes:
 +* Main window redesign, see https://live.gnome.org/Almanah_Diary/Design#New_Design
 +* Tagging support
 +* Port to GMenu
 +* Dropped the libedataserverui dependency and embed the ECellRendererColor and ESourceSelector widgets 
(Thanks to Matthew Barnes)
 +* Hide the title bar in maximized windows
 +* Updated GtkSpell 3 support
 +* Updated EDS dependency to 3.5.91 (Thanks to Philip Withnall)
 +
 +Bugs fixed:
 +* Bug 677209 - The CalendarWindow dropdown doesn't displayed in the correct place
 +* Bug 680845 - Translatable strings for the time in the events list
 +
 +Update translations:
 +* cs (Marek Černocký)
 +* es (Daniel Mustieles)
 +* gl (Fran Diéguez)
 +* hu (Balázs Úr)
 +* id (Andika Triwidada)
 +* lv (Rūdolfs Mazurs)
 +* pl (Piotr Drąg)
 +* pt_BR (Rafael Ferreira)
 +* ru (Yuri Myasoedov)
 +* sl (Andrej Žnidaršič and Matej Urbančič)
 +* sr (Мирослав Николић)
 +
+ Overview of changes from Almanah 0.10.0 to Almanah 0.10.1
+ ========================================================
+ 
+ Bug fixed:
+ * Bug 695117 - Almanah doesn't encrypt the database when the application close (see 
https://bugzilla.gnome.org/show_bug.cgi?id=695117)
+ 
  Overview of changes from Almanah 0.9.0 to Almanah 0.10.0
  ========================================================
  
diff --cc src/application.c
index 5b61563,9c2da75..45aa2bc
--- a/src/application.c
+++ b/src/application.c
@@@ -40,19 -36,8 +40,19 @@@ static void set_property (GObject *obje
  static void startup (GApplication *application);
  static void activate (GApplication *application);
  static gint handle_command_line (GApplication *application, GApplicationCommandLine *command_line);
- static void quit_main_loop (GApplication *application);
+ static void window_removed (GtkApplication *application, GtkWindow *window);
  
 +static void almanah_application_init_actions (AlmanahApplication *self);
 +
 +/* GMenu application actions */
 +static void action_search_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_preferences_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_import_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_export_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_print_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_about_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +static void action_quit_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data);
 +
  struct _AlmanahApplicationPrivate {
        gboolean debug;
  
@@@ -378,218 -317,25 +380,225 @@@ storage_manager_disconnected_cb (Almana
  }
  
  static void
- quit_main_loop (GApplication *application)
+ window_removed (GtkApplication *application, GtkWindow *window)
  {
-       AlmanahApplicationPrivate *priv = ALMANAH_APPLICATION (application)->priv;
- 
-       /* This would normally result in gtk_main_quit() being called, but we need to close the database 
connection first. */
-       g_signal_connect (priv->storage_manager, "disconnected", (GCallback) storage_manager_disconnected_cb, 
application);
-       almanah_storage_manager_disconnect (priv->storage_manager, NULL);
+       /* This would normally result in the end of the application, but we need to close the database 
connection first
+          to prevent an unencrypted database in the filesystem, and we don't want a bug like that.
+          So, we append a reference to the application when the user close the main window. When the 
application disconnect
+          from the database, allowing the encryption if necessary, we remove this reference with 
g_application_release.
+          See: https://bugzilla.gnome.org/show_bug.cgi?id=695117 */
+       if (ALMANAH_IS_MAIN_WINDOW (window)) {
+               AlmanahApplicationPrivate *priv = ALMANAH_APPLICATION (application)->priv;
+ 
+               g_application_hold (G_APPLICATION (application));
+ 
+               g_signal_connect (priv->storage_manager, "disconnected", (GCallback) 
storage_manager_disconnected_cb, application);
+               almanah_storage_manager_disconnect (priv->storage_manager, NULL);
+       }
  
-       /* Quitting is actually done in storage_manager_disconnected_cb, which is called once
-        * the storage manager has encrypted the DB and disconnected from it. */
+       GTK_APPLICATION_CLASS (almanah_application_parent_class)->window_removed (application, window);
  }
  
 +static void
 +almanah_application_init_actions (AlmanahApplication *self)
 +{
 +      GtkBuilder *builder;
 +      GError *error = NULL;
 +      const gchar *interface_filename = almanah_get_interface_app_menu_filename ();
 +
 +      g_action_map_add_action_entries (G_ACTION_MAP (self), app_entries, G_N_ELEMENTS (app_entries), self);
 +
 +      builder = gtk_builder_new ();
 +      if (gtk_builder_add_from_file (builder, interface_filename, &error) == FALSE) {
 +              /* Show an error */
 +              GtkWidget *dialog = gtk_message_dialog_new (NULL,
 +                                                          GTK_DIALOG_MODAL,
 +                                                          GTK_MESSAGE_ERROR,
 +                                                          GTK_BUTTONS_OK,
 +                                                          _("UI file \"%s\" could not be loaded"), 
interface_filename);
 +              gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 +              gtk_dialog_run (GTK_DIALOG (dialog));
 +              gtk_widget_destroy (dialog);
 +
 +              g_error_free (error);
 +              g_object_unref (builder);
 +
 +              exit (1);
 +      }
 +
 +      gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
 +      gtk_application_set_app_menu (GTK_APPLICATION (self), G_MENU_MODEL (gtk_builder_get_object (builder, 
"almanah_app_menu")));
 +
 +#ifndef ENABLE_ENCRYPTION
 +#ifndef ENABLE_SPELL_CHECKING
 +      /* Remove the "Preferences" entry from the menu */
 +      g_action_map_remove_action (G_ACTION_MAP (self), "preferences");
 +#endif /* !ENABLE_SPELL_CHECKING */
 +#endif /* !ENABLE_ENCRYPTION */
 +
 +      g_object_unref (builder);
 +}
 +
 +static void
 +action_search_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahApplication *application;
 +      AlmanahSearchDialog *dialog = almanah_search_dialog_new ();
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      gtk_window_set_application (GTK_WINDOW (dialog), GTK_APPLICATION (application));
 +      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (application->priv->main_window));
 +      gtk_widget_show (GTK_WIDGET (dialog));
 +      gtk_dialog_run (GTK_DIALOG (dialog));
 +
 +      gtk_widget_destroy (GTK_WIDGET (dialog));
 +}
 +
 +static void
 +action_preferences_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +#if defined(ENABLE_ENCRYPTION) || defined(ENABLE_SPELL_CHECKING)
 +      AlmanahApplication *application;
 +      GSettings *settings;
 +      AlmanahPreferencesDialog *dialog;
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      settings = almanah_application_dup_settings (application);
 +      dialog = almanah_preferences_dialog_new (settings);
 +      g_object_unref (settings);
 +
 +      gtk_widget_show_all (GTK_WIDGET (dialog));
 +      gtk_dialog_run (GTK_DIALOG (dialog));
 +
 +      gtk_widget_destroy (GTK_WIDGET (dialog));
 +#endif /* ENABLE_ENCRYPTION || ENABLE_SPELL_CHECKING */
 +}
 +
 +static void
 +action_import_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahApplication *application;
 +      AlmanahStorageManager *storage_manager;
 +      GtkWidget *dialog;
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      storage_manager = almanah_application_dup_storage_manager (application);
 +      dialog = GTK_WIDGET (almanah_import_export_dialog_new (storage_manager, TRUE));
 +      g_object_unref (storage_manager);
 +
 +      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (application->priv->main_window));
 +      gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 +
 +      /* The dialog destroys itself once done */
 +      gtk_widget_show_all (dialog);
 +}
 +
 +static void
 +action_export_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahApplication *application;
 +      AlmanahStorageManager *storage_manager;
 +      GtkWidget *dialog;
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      storage_manager = almanah_application_dup_storage_manager (application);
 +      dialog = GTK_WIDGET (almanah_import_export_dialog_new (storage_manager, FALSE));
 +      g_object_unref (storage_manager);
 +
 +      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (application->priv->main_window));
 +      gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 +
 +      /* The dialog destroys itself once done */
 +      gtk_widget_show_all (dialog);
 +}
 +
 +static void
 +action_print_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahApplication *application;
 +      AlmanahStorageManager *storage_manager;
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      storage_manager = almanah_application_dup_storage_manager (application);
 +      almanah_print_entries (FALSE, GTK_WINDOW (application->priv->main_window), 
&(application->priv->page_setup), &(application->priv->print_settings), storage_manager);
 +      g_object_unref (storage_manager);
 +}
 +
 +static void
 +action_about_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahApplication *application;
 +      AlmanahStorageManager *storage_manager;
 +      gchar *license, *description;
 +      guint entry_count;
 +
 +      const gchar *authors[] =
 +      {
 +              "Philip Withnall <philip tecnocode co uk>",
 +              NULL
 +      };
 +      const gchar *license_parts[] = {
 +              N_("Almanah is free software: you can redistribute it and/or modify "
 +                 "it under the terms of the GNU General Public License as published by "
 +                 "the Free Software Foundation, either version 3 of the License, or "
 +                 "(at your option) any later version."),
 +              N_("Almanah is distributed in the hope that it will be useful, "
 +                 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
 +                 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
 +                 "GNU General Public License for more details."),
 +              N_("You should have received a copy of the GNU General Public License "
 +                 "along with Almanah.  If not, see <http://www.gnu.org/licenses/>."),
 +      };
 +
 +      license = g_strjoin ("\n\n",
 +                        _(license_parts[0]),
 +                        _(license_parts[1]),
 +                        _(license_parts[2]),
 +                        NULL);
 +
 +      application = ALMANAH_APPLICATION (user_data);
 +      storage_manager = almanah_application_dup_storage_manager (application);
 +      almanah_storage_manager_get_statistics (storage_manager, &entry_count);
 +      g_object_unref (storage_manager);
 +
 +      description = g_strdup_printf (_("A helpful diary keeper, storing %u entries."), entry_count);
 +
 +      gtk_show_about_dialog (GTK_WINDOW (application->priv->main_window),
 +                              "version", VERSION,
 +                              "copyright", _("Copyright \xc2\xa9 2008-2009 Philip Withnall"),
 +                              "comments", description,
 +                              "authors", authors,
 +                              /* Translators: please include your names here to be credited for your hard 
work!
 +                               * Format:
 +                               * "Translator name 1 <translator email address>\n"
 +                               * "Translator name 2 <translator2 email address>"
 +                               */
 +                              "translator-credits", _("translator-credits"),
 +                              "logo-icon-name", "almanah",
 +                              "license", license,
 +                              "wrap-license", TRUE,
 +                              "website-label", _("Almanah Website"),
 +                              "website", "http://live.gnome.org/Almanah_Diary";,
 +                              NULL);
 +
 +      g_free (license);
 +      g_free (description);
 +}
 +
 +static void
 +action_quit_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
 +{
 +      AlmanahMainWindow *main_window;
 +
 +      main_window = ALMANAH_APPLICATION (user_data)->priv->main_window;
 +
 +      /* Hide the window to make things look faster */
 +      gtk_widget_hide (GTK_WIDGET (main_window));
 +
 +      almanah_main_window_save_current_entry (main_window, TRUE);
 +      gtk_widget_destroy (GTK_WIDGET (main_window));
 +}
 +
  AlmanahApplication *
  almanah_application_new (void)
  {


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