From f3d225e830fd102d33d644f1b6f1f3a6174113c6 Mon Sep 17 00:00:00 2001 From: bdilly Date: Wed, 8 Aug 2007 05:47:10 +0000 Subject: [PATCH] export to ocal bug fix --- src/file.cpp | 55 +++++++++++++++++++--------- src/file.h | 17 +++++++++ src/menus-skeleton.h | 1 + src/ui/icons.cpp | 6 --- src/ui/stock-items.cpp | 1 + src/ui/stock.cpp | 1 + src/ui/stock.h | 1 + src/ui/widget/preferences-widget.cpp | 3 +- src/ui/widget/preferences-widget.h | 2 +- src/verbs.cpp | 6 ++- src/verbs.h | 3 +- 11 files changed, 68 insertions(+), 28 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index d697a7d78..d5f0c6f6e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -499,6 +499,7 @@ sp_file_vacuum() * This 'save' function called by the others below * It was divided in file_save_local and file_save_remote * to support remote saving too. + * Now file_save is calling only local saving, but it will be solved. * * \param official whether to set :output_module and :modified in the * document; is true for normal save, false for temporary saves @@ -512,18 +513,18 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, #ifdef WITH_GNOME_VFS - if (gnome_vfs_initialized() && !gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri.c_str()))) { - // Use VFS for this - bool success = file_save_remote(doc, uri, key, saveas, official); - if (!success) { - g_warning("Error: Could not save file '%s' with VFS\n", uri.c_str()); - return false; - } - else - return true; - } - else - return file_save_local(parentWindow, doc, uri, key, saveas, official); +// if (gnome_vfs_initialized() && !gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri.c_str()))) { +// // Use VFS for this +// bool success = file_save_remote(doc, uri, key, saveas, official); +// if (!success) { +// g_warning("Error: Could not save file '%s' with VFS\n", uri.c_str()); +// return false; +// } +// else +// return true; +// } +// else + return file_save_local(parentWindow, doc, uri, key, saveas, official); #else return file_save_local(parentWindow, doc, uri, key, saveas, official); @@ -567,7 +568,9 @@ file_save_local(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring #ifdef WITH_GNOME_VFS - +/* + * Used only for remote saving using VFS and a specific uri. Gets the file at the /tmp. + */ bool file_save_remote(SPDocument *doc, const Glib::ustring &uri, Inkscape::Extension::Extension *key, bool saveas, bool official) @@ -1316,9 +1319,9 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow) } uri.append(prefs_get_string_attribute("options.ocalurl", "str")); uri.append(Glib::path_get_basename(fileName)); - - success = file_save(parentWindow, doc, uri, selectionType, FALSE, FALSE); - remove(fileName.c_str()); + // Save as a remote file using the dav protocol. + success = file_save_remote(doc, uri, selectionType, FALSE, FALSE); + //remove(fileName.c_str()); if (!success) g_warning( "Error exporting the document." ); @@ -1336,10 +1339,28 @@ sp_file_export_to_ocal(Gtk::Window &parentWindow) bool success = sp_file_export_to_ocal_dialog(parentWindow); if (success) SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Document exported...")); - +} + +/*###################### +## I M P O R T F R O M O C A L +######################*/ + +/** + * Import a document from OCAL + */ +void +sp_file_import_from_ocal(Gtk::Window &parentWindow) +{ + // Try to execute the new code and return; + if (!SP_ACTIVE_DOCUMENT) + return; + //bool success = sp_file_import_from_ocal_dialog(parentWindow); + //if (success) + // SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Document imported...")); } + /*###################### ## P R I N T ######################*/ diff --git a/src/file.h b/src/file.h index 33210fabd..c5a854922 100644 --- a/src/file.h +++ b/src/file.h @@ -168,6 +168,23 @@ void sp_file_export_to_ocal (Gtk::Window &parentWindow ); bool sp_file_export_to_ocal_dialog (void *widget); +/*###################### +## I M P O R T F R O M O C A L +######################*/ + +/** + * Import a document from OCAL + */ +void sp_file_import_from_ocal (Gtk::Window &parentWindow ); + + +/** + * Import a document from OCAL + */ +//bool sp_file_import_from_ocal_dialog (void *widget); + + + /*###################### ## P R I N T diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 900232303..cdf725232 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -29,6 +29,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" /* These are ugly, but what needs to happen here is allowing users diff --git a/src/ui/icons.cpp b/src/ui/icons.cpp index f7f66d574..f24dad66b 100644 --- a/src/ui/icons.cpp +++ b/src/ui/icons.cpp @@ -57,12 +57,6 @@ init() src.set_filename(get_icon_path("export.svg")); _export.add_source(src); icons->add(Stock::EXPORT, _export); - // Export to OCAL - Gtk::IconSet _export_to_ocal; - src.set_icon_name("ExportToOCAL"); - src.set_filename(get_icon_path("export_to_ocal.svg")); - _export_to_ocal.add_source(src); - icons->add(Stock::EXPORTTOOCAL, _export_to_ocal); // Vacuum Defs Gtk::IconSet _vacuum_defs; src.set_icon_name("VacuumDefs"); diff --git a/src/ui/stock-items.cpp b/src/ui/stock-items.cpp index 503d05991..6ac6042d4 100644 --- a/src/ui/stock-items.cpp +++ b/src/ui/stock-items.cpp @@ -33,6 +33,7 @@ init() add(Gtk::StockItem(SAVE_AS, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(IMPORT, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(EXPORT, _("PLACEHOLDER, do not translate"))); + add(Gtk::StockItem(IMPORTFROMOCAL, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(EXPORTTOOCAL, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(PRINT, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(PRINT_PREVIEW, _("PLACEHOLDER, do not translate"))); diff --git a/src/ui/stock.cpp b/src/ui/stock.cpp index 6d4c7b391..f0ec456b1 100644 --- a/src/ui/stock.cpp +++ b/src/ui/stock.cpp @@ -19,6 +19,7 @@ namespace Stock { Gtk::StockID const OPEN_RECENT("open-recent"); Gtk::StockID const IMPORT("import"); Gtk::StockID const EXPORT("export"); +Gtk::StockID const IMPORTFROMOCAL("import_from_ocal"); Gtk::StockID const EXPORTTOOCAL("export_to_ocal"); Gtk::StockID const VACUUM_DEFS("vacuum-defs"); // Edit menu diff --git a/src/ui/stock.h b/src/ui/stock.h index 4069115a7..ad99a3c05 100644 --- a/src/ui/stock.h +++ b/src/ui/stock.h @@ -22,6 +22,7 @@ namespace Stock { extern Gtk::StockID const OPEN_RECENT; extern Gtk::StockID const IMPORT; extern Gtk::StockID const EXPORT; +extern Gtk::StockID const IMPORTFROMOCAL; extern Gtk::StockID const EXPORTTOOCAL; extern Gtk::StockID const VACUUM_DEFS; // Edit menu diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index a6302aa9d..e1671e5b1 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -277,13 +277,12 @@ void PrefEntry::init(const std::string& prefs_path, const std::string& attr, this->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())); } -void PrefEntry::on_activate() +void PrefEntry::on_changed() { if (this->is_visible()) //only take action if user changed value { prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_text().c_str()); } - return; } } // namespace Widget diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 5b6402883..4ed0a35aa 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -97,7 +97,7 @@ public: protected: std::string _prefs_path; std::string _attr; - void on_activate(); + void on_changed(); }; class DialogPage : public Gtk::Table diff --git a/src/verbs.cpp b/src/verbs.cpp index 38ce87e59..897f11369 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -833,6 +833,9 @@ FileVerb::perform(SPAction *action, void *data, void *pdata) case SP_VERB_FILE_EXPORT: sp_file_export_dialog(NULL); break; + case SP_VERB_FILE_IMPORT_FROM_OCAL: + sp_file_import_from_ocal(*parent); + break; case SP_VERB_FILE_EXPORT_TO_OCAL: sp_file_export_to_ocal(*parent); break; @@ -2147,7 +2150,8 @@ Verb *Verb::_base_verbs[] = { N_("Import a bitmap or SVG image into this document"), "file_import"), new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."), N_("Export this document or a selection as a bitmap image"), "file_export"), - new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("_Export To OCAL"), N_("_Export this document to Open Clip Art Library"), "file_export_to_ocal"), + new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import From OCAL"), N_("Import a document from Open Clip Art Library"), NULL), + new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To OCAL"), N_("Export this document to Open Clip Art Library"), NULL), new FileVerb(SP_VERB_FILE_NEXT_DESKTOP, "NextWindow", N_("N_ext Window"), N_("Switch to the next document window"), "window_next"), new FileVerb(SP_VERB_FILE_PREV_DESKTOP, "PrevWindow", N_("P_revious Window"), diff --git a/src/verbs.h b/src/verbs.h index b86a84ee5..ec21ac068 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -41,7 +41,8 @@ enum { SP_VERB_FILE_PRINT_PREVIEW, SP_VERB_FILE_IMPORT, SP_VERB_FILE_EXPORT, - SP_VERB_FILE_EXPORT_TO_OCAL, /**< Export the file to Open ClipArt Library */ + SP_VERB_FILE_IMPORT_FROM_OCAL, /**< Import the file from Open Clip Art Library */ + SP_VERB_FILE_EXPORT_TO_OCAL, /**< Export the file to Open Clip Art Library */ SP_VERB_FILE_NEXT_DESKTOP, SP_VERB_FILE_PREV_DESKTOP, SP_VERB_FILE_CLOSE_VIEW, -- 2.30.2