[glom/feature_backup2: 3/6] Add Save Backup menu item.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/feature_backup2: 3/6] Add Save Backup menu item.
- Date: Sun, 4 Jul 2010 13:43:19 +0000 (UTC)
commit fe44b0bd4f46c8a981e08544e3a4ed5aee1413f9
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jul 1 12:30:34 2010 +0200
Add Save Backup menu item.
* glom/libglom/connectionpool_backends/backend.[h|cc]:
* glom/libglom/connectionpool_backends/posgres.[h|cc]:
* glom/libglom/connectionpool_backends/sqlite.[h|cc]: Added save_backup()
virtual method, using pg_dump for PostgreSQL.
* glom/libglom/connectionpool.[h|cc]: Add save_backup() here, calling the
backend.
* glom/application.cc: Add a Developer/Export Backup menu item, to use
this feature. This also saves the .glom file.
ChangeLog | 13 +++++++++++++
glom/application.cc | 34 ++++++++++++++++++++++++++++------
glom/libglom/connectionpool.cc | 2 +-
3 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9331b69..3262e33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2010-07-01 Murray Cumming <murrayc murrayc com>
+ Add Save Backup menu item.
+
+ * glom/libglom/connectionpool_backends/backend.[h|cc]:
+ * glom/libglom/connectionpool_backends/posgres.[h|cc]:
+ * glom/libglom/connectionpool_backends/sqlite.[h|cc]: Added save_backup()
+ virtual method, using pg_dump for PostgreSQL.
+ * glom/libglom/connectionpool.[h|cc]: Add save_backup() here, calling the
+ backend.
+ * glom/application.cc: Add a Developer/Export Backup menu item, to use
+ this feature. This also saves the .glom file.
+
+2010-07-01 Murray Cumming <murrayc murrayc com>
+
Spawn functions: Catch some exceptions.
* glom/libglom/spawn_with_feedback.cc():
diff --git a/glom/application.cc b/glom/application.cc
index 7261fb7..1235575 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -2487,6 +2487,7 @@ void Application::on_menu_developer_active_platform_maemo()
void Application::on_menu_developer_export_backup()
{
+ // Ask the user to choose a new directory name. This actually creates the directory:
Gtk::FileChooserDialog dialog(*this, _("Save Backup"), Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
@@ -2494,13 +2495,34 @@ void Application::on_menu_developer_export_backup()
if(result != Gtk::RESPONSE_ACCEPT)
return;
- const std::string& filepath_output = dialog.get_filename() + G_DIR_SEPARATOR + "backup";
- if(filepath_output.empty())
+ const std::string& path_dir = dialog.get_filename();
+ if(path_dir.empty())
return;
-
- ConnectionPool* connection_pool = ConnectionPool::get_instance();
- const bool saved = connection_pool->save_backup(ConnectionPool::SlotProgress() /* TODO */, filepath_output);
- std::cout << "debug: saved=" << saved << std::endl;
+
+ //Save a copy of the document there:
+ Document* document = dynamic_cast<Document*>(get_document());
+ if(!document)
+ return;
+
+ const std::string& filepath_document = Glib::build_filename(path_dir, "backup.glom");
+ document->set_allow_autosave(false); //Prevent saving while we modify the document:
+ const Glib::ustring fileuri_old = document->get_file_uri();
+ document->set_file_uri(Glib::filename_to_uri(filepath_document), true); //true = enforce file extension;
+ bool saved = document->save();
+ document->set_file_uri(fileuri_old);
+ document->set_allow_autosave(true);
+
+ if(saved)
+ {
+ //Save a backup of the data there:
+ const std::string& filepath_output = Glib::build_filename(path_dir, "backup");
+
+ ConnectionPool* connection_pool = ConnectionPool::get_instance();
+ saved = connection_pool->save_backup(ConnectionPool::SlotProgress() /* TODO */, filepath_output);
+ }
+
+ if(!saved)
+ ui_warning(_("Export Backup failed."), _("There was an error while exporting the backup."));
}
void Application::on_menu_developer_show_layout_toolbar()
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 210639b..6027de5 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -589,7 +589,7 @@ bool ConnectionPool::startup(const SlotProgress& slot_progress, bool network_sha
//If we crash while running (unlikely, hopefully), then try to cleanup.
//Comment this out if you want to see the backtrace in a debugger.
- previous_sig_handler = signal(SIGSEGV, &on_linux_signal);
+ //previous_sig_handler = signal(SIGSEGV, &on_linux_signal);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]