[latexila] Document: warning when temporary location set



commit b605aedd82edbf068a3322934eff5ebf50e2fa6d
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Mon Aug 6 00:10:30 2012 +0200

    Document: warning when temporary location set
    
    With the possibility to save the file in a safer place.
    
    Fixes bug #681226:
    https://bugzilla.gnome.org/show_bug.cgi?id=681226
    
    Reported by: Michael Holtermann

 src/document.vala |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/document.vala b/src/document.vala
index 2b8e657..ebf28fe 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -606,6 +606,30 @@ public class Document : Gtk.SourceBuffer
         /* Set the location as 'tmp.tex' in the temporary directory */
         this.location = File.new_for_path (Path.build_filename (tmp_dir, "tmp.tex"));
 
+        /* Warn the user that the file can be lost */
+
+        TabInfoBar infobar = tab.add_message (
+            _("The file has a temporary location. The data can be lost after rebooting your computer."),
+            _("Do you want to save the file in a safer place?"),
+            MessageType.WARNING);
+
+        infobar.add_button (Stock.SAVE_AS, ResponseType.YES);
+        infobar.add_button (Stock.CANCEL, ResponseType.NO);
+
+        infobar.response.connect ((response_id) =>
+        {
+            if (response_id == ResponseType.YES)
+            {
+                unowned MainWindow? main_window =
+                    Utils.get_toplevel_window (tab) as MainWindow;
+
+                if (main_window != null)
+                    main_window.save_document (this, true);
+            }
+
+            infobar.destroy ();
+        });
+
         return true;
     }
 



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