From 1c8797563cc134190fe424f8fdb6b2f8ed7d9275 Mon Sep 17 00:00:00 2001 From: bdilly Date: Mon, 6 Aug 2007 18:32:13 +0000 Subject: [PATCH] adds export to ocal feature without dialog window --- share/icons/icons.svg | 17729 +++++++++++++++++++---- src/file.cpp | 268 + src/file.h | 33 + src/menus-skeleton.h | 1 + src/preferences-skeleton.h | 3 + src/ui/dialog/inkscape-preferences.cpp | 7 + src/ui/dialog/inkscape-preferences.h | 4 + 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 | 22 +- src/ui/widget/preferences-widget.h | 14 +- src/verbs.cpp | 4 + src/verbs.h | 1 + 15 files changed, 15496 insertions(+), 2599 deletions(-) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 89e480bf3..50d84944f 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -1,2600 +1,15135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Created with Inkscape + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Created with Inkscape http://www.inkscape.org/ -image/svg+xml - - - - -Inkscape Developers - - - - -Inkscape Developers - - -Icon Sheet - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -a - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + image/svg+xml + + + + + Inkscape Developers + + + + + Inkscape Developers + + + Icon Sheet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/file.cpp b/src/file.cpp index 436cd0ee0..d697a7d78 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -7,6 +7,7 @@ * Lauris Kaplinski * Chema Celorio * bulia byak + * Bruno Dilly * * Copyright (C) 2006 Johan Engelen * Copyright (C) 1999-2005 Authors @@ -64,6 +65,10 @@ #include "inkscape.h" #include "uri.h" +#ifdef WITH_GNOME_VFS +# include +#endif + #ifdef WITH_INKBOARD #include "jabber_whiteboard/session-manager.h" #endif @@ -492,6 +497,8 @@ 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. * * \param official whether to set :output_module and :modified in the * document; is true for normal save, false for temporary saves @@ -503,6 +510,31 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, if (!doc || uri.size()<1) //Safety check return false; +#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); +#else + + return file_save_local(parentWindow, doc, uri, key, saveas, official); + +#endif +} + +bool +file_save_local(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, + Inkscape::Extension::Extension *key, bool saveas, bool official) +{ try { Inkscape::Extension::save(key, doc, uri.c_str(), false, @@ -533,6 +565,92 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, +#ifdef WITH_GNOME_VFS + + +bool +file_save_remote(SPDocument *doc, const Glib::ustring &uri, + Inkscape::Extension::Extension *key, bool saveas, bool official) +{ + +#define BUF_SIZE 8192 + gnome_vfs_init(); + + GnomeVFSHandle *from_handle = NULL; + GnomeVFSHandle *to_handle = NULL; + GnomeVFSFileSize bytes_read; + GnomeVFSFileSize bytes_written; + GnomeVFSResult result; + guint8 buffer[8192]; + + gchar* uri_local = g_filename_from_utf8( uri.c_str(), -1, NULL, NULL, NULL); + + if ( uri_local == NULL ) { + g_warning( "Error converting filename to locale encoding."); + } + + // Gets the temp file name. + Glib::ustring fileName = Glib::get_tmp_dir (); + fileName.append(G_DIR_SEPARATOR_S); + fileName.append((gnome_vfs_uri_extract_short_name(gnome_vfs_uri_new(uri_local)))); + + // Open the temp file to send. + result = gnome_vfs_open (&from_handle, fileName.c_str(), GNOME_VFS_OPEN_READ); + + if (result != GNOME_VFS_OK) { + g_warning("Could not find the temp saving."); + return false; + } + + + result = gnome_vfs_open (&to_handle, uri_local, GNOME_VFS_OPEN_WRITE); + + + if (result == GNOME_VFS_ERROR_NOT_FOUND){ + result = gnome_vfs_create (&to_handle, uri_local, GNOME_VFS_OPEN_WRITE, FALSE, GNOME_VFS_PERM_USER_ALL); + } + + if (result != GNOME_VFS_OK) { + g_warning("file creating: %s", gnome_vfs_result_to_string(result)); + return false; + } + + ///g_warning("file_save_remote: temp dir: %s",fileName.c_str()); + + while (1) { + + result = gnome_vfs_read (from_handle, buffer, 8192, &bytes_read); + //g_warning("bytes lidos: %d",bytes_read); + + if ((result == GNOME_VFS_ERROR_EOF) &&(!bytes_read)){ + result = gnome_vfs_close (from_handle); + result = gnome_vfs_close (to_handle); + return true; + } + + //g_warning("while: %s", gnome_vfs_result_to_string(result)); + + if (result != GNOME_VFS_OK) { + g_warning("%s", gnome_vfs_result_to_string(result)); + return false; + } + //g_warning("%s",buffer); + result = gnome_vfs_write (to_handle, buffer, bytes_read, &bytes_written); + //g_warning("escritos: %d",bytes_written); + if (result != GNOME_VFS_OK) { + g_warning("%s", gnome_vfs_result_to_string(result)); + return false; + } + + + if (bytes_read != bytes_written){ + return false; + } + + } + return true; +} +#endif /** @@ -1072,6 +1190,156 @@ sp_file_export_dialog(void *widget) #endif +/*###################### +## E X P O R T T O O C A L +######################*/ + + +/** + * Export the current document to OCAL + */ + + +/** + * Display an Export dialog, export as the selected type if OK pressed + */ +bool +sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow) +{ + //# temp hack for 'doc' until we can switch to this dialog + + if (!SP_ACTIVE_DOCUMENT) + return false; + + SPDocument *doc = SP_ACTIVE_DOCUMENT; + + Glib::ustring export_path; + Glib::ustring export_loc; + Glib::ustring fileName; + Inkscape::Extension::Extension *selectionType; + + bool success = false; + + static Inkscape::UI::Dialog::FileExportDialog *exportDialogInstance = NULL; + + Inkscape::XML::Node *repr = sp_document_repr_root(doc); + // Verify whether the document is saved, so save this as temporary + + char *str = (char *) repr->attribute("sodipodi:modified"); + if ((!doc->uri) && (!str)) + return false; + + + Inkscape::Extension::Output *extension; + + //# Get the default extension name + Glib::ustring default_extension; + char *attr = (char *)repr->attribute("inkscape:output_extension"); + if (!attr) + attr = (char *)prefs_get_string_attribute("dialogs.save_as", "default"); + if (attr) + default_extension = attr; + + char formatBuf[256]; + + Glib::ustring filename_extension = ".svg"; + extension = dynamic_cast + (Inkscape::Extension::db.get(default_extension.c_str())); + if (extension) + filename_extension = extension->get_extension(); + + export_path = Glib::get_tmp_dir (); + + export_loc = export_path; + export_loc.append(G_DIR_SEPARATOR_S); + snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str()); + export_loc.append(formatBuf); + + // convert save_loc from utf-8 to locale + // is this needed any more, now that everything is handled in + // Inkscape::IO? + Glib::ustring export_path_local = Glib::filename_from_utf8(export_path); + if ( export_path_local.size() > 0) + export_path = export_path_local; + + //# Show the Export To OCAL dialog + // MADE A CHANGE TO SUBMIT CHANGES. IN THE FUTURE WILL CALL FileExportToOCALDialog + if (!exportDialogInstance) + exportDialogInstance = Inkscape::UI::Dialog::FileExportDialog::create( + parentWindow, + export_path, + Inkscape::UI::Dialog::EXPORT_TYPES, + (char const *) _("Select file to export to"), + default_extension + ); + + success = exportDialogInstance->show(); + if (!success) + return success; + + fileName = exportDialogInstance->getFilename(); + + selectionType = exportDialogInstance->getSelectionType(); + + if (fileName.size() > 0) { + Glib::ustring newFileName = Glib::filename_to_utf8(fileName); + + if ( newFileName.size()>0 ) + fileName = newFileName; + else + g_warning( "Error converting save filename to UTF-8." ); + } + Glib::ustring filePath = export_path; + filePath.append(G_DIR_SEPARATOR_S); + filePath.append(Glib::path_get_basename(fileName)); + + fileName = filePath; + + success = file_save(parentWindow, doc, filePath, selectionType, FALSE, FALSE); + + if (!success){ + g_warning( "Error saving a temporary copy." ); + return success; + } + + /* Start now the submition */ + + // Create the uri + Glib::ustring uri = "dav://"; + char *username = (char *)prefs_get_string_attribute("options.ocalusername", "str"); + char *password = (char *)prefs_get_string_attribute("options.ocalpassword", "str"); + if ((username != NULL) && (password != NULL)){ + uri.append(username); + uri.append(":"); + uri.append(password); + uri.append("@"); + } + 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()); + if (!success) + g_warning( "Error exporting the document." ); + + return success; +} + + +void +sp_file_export_to_ocal(Gtk::Window &parentWindow) +{ + + // Try to execute the new code and return; + if (!SP_ACTIVE_DOCUMENT) + return; + bool success = sp_file_export_to_ocal_dialog(parentWindow); + if (success) + SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Document exported...")); + + +} + /*###################### ## P R I N T ######################*/ diff --git a/src/file.h b/src/file.h index 9bff1ca12..33210fabd 100644 --- a/src/file.h +++ b/src/file.h @@ -79,6 +79,23 @@ void sp_file_revert_dialog (); ## S A V E ######################*/ +/* + * Added to make only the local savings. + */ + +bool file_save_local(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, + Inkscape::Extension::Extension *key, bool saveas, bool official); + + +/* + * Added to make only the remote savings. + */ + +bool file_save_remote(SPDocument *doc, const Glib::ustring &uri, + Inkscape::Extension::Extension *key, bool saveas, bool official); + + + /** * */ @@ -135,6 +152,22 @@ void file_import(SPDocument *in_doc, const Glib::ustring &uri, bool sp_file_export_dialog (void *widget); +/*###################### +## E X P O R T T O O C A L +######################*/ + +/** + * Export the current document to OCAL + */ +void sp_file_export_to_ocal (Gtk::Window &parentWindow ); + + +/** + * Export the current document to OCAL + */ +bool sp_file_export_to_ocal_dialog (void *widget); + + /*###################### ## P R I N T diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 17494332d..900232303 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" /* These are ugly, but what needs to happen here is allowing users to use the native PS support if they are using another print driver. diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 57dca4583..0ad7bc157 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -213,6 +213,9 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" " + * Bruno Dilly * * Copyright (C) 2004-2007 Authors * @@ -621,6 +622,12 @@ void InkscapePreferences::initPageMisc() _misc_overs_bitmap.set_size_request(_sb_width); _misc_overs_bitmap.init("options.bitmapoversample", "value", labels, values, num_items, 1); _page_misc.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false); + _misc_ocal_url.init("options.ocalurl", "str", true); + _page_misc.add_line( false, _("Open Clip Art Library URL:"), _misc_ocal_url, "", _("The url of the Open Clip Art Library webdav server. It's used by the Export to OCAL function."), true); + _misc_ocal_username.init("options.ocalusername", "str", true); + _page_misc.add_line( false, _("Open Clip Art Library Username:"), _misc_ocal_username, "", _("The username used to log into Open Clip Art Library."), true); + _misc_ocal_password.init("options.ocalpassword", "str", false); + _page_misc.add_line( false, _("Open Clip Art Library Password:"), _misc_ocal_password, "", _("The password used to log into Open Clip Art Library."), true); this->AddPage(_page_misc, _("Misc"), PREFS_PAGE_MISC); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index fc3adb20a..c1999f946 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -5,6 +5,7 @@ * Carl Hetherington * Marco Scholten * Johan Engelen + * Bruno Dilly * * Copyright (C) 2004-2007 Authors * @@ -154,6 +155,9 @@ protected: PrefCheckButton _misc_imp_bitmap, _misc_comment, _misc_scripts; PrefCheckButton _misc_small_toolbar; PrefCombo _misc_overs_bitmap; + PrefEntry _misc_ocal_url; + PrefEntry _misc_ocal_username; + PrefEntry _misc_ocal_password; int _max_dialog_width; int _max_dialog_height; diff --git a/src/ui/icons.cpp b/src/ui/icons.cpp index f24dad66b..f7f66d574 100644 --- a/src/ui/icons.cpp +++ b/src/ui/icons.cpp @@ -57,6 +57,12 @@ 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 09e2a894d..503d05991 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(EXPORTTOOCAL, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(PRINT, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(PRINT_PREVIEW, _("PLACEHOLDER, do not translate"))); add(Gtk::StockItem(VACUUM_DEFS, _("PLACEHOLDER, do not translate"))); diff --git a/src/ui/stock.cpp b/src/ui/stock.cpp index 03e491340..6d4c7b391 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 EXPORTTOOCAL("export_to_ocal"); Gtk::StockID const VACUUM_DEFS("vacuum-defs"); // Edit menu Gtk::StockID const UNDO_HISTORY("undo-history"); diff --git a/src/ui/stock.h b/src/ui/stock.h index 733edacdb..4069115a7 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 EXPORTTOOCAL; extern Gtk::StockID const VACUUM_DEFS; // Edit menu extern Gtk::StockID const UNDO_HISTORY; diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 00d8b5a26..a6302aa9d 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -3,8 +3,9 @@ * * Authors: * Marco Scholten + * Bruno Dilly * - * Copyright (C) 2004, 2006 Authors + * Copyright (C) 2004, 2006, 2007 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -266,6 +267,25 @@ void PrefCombo::on_changed() } } +void PrefEntry::init(const std::string& prefs_path, const std::string& attr, + bool visibility) +{ + _prefs_path = prefs_path; + _attr = attr; + this->set_invisible_char('*'); + this->set_visibility(visibility); + this->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())); +} + +void PrefEntry::on_activate() +{ + 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 } // namespace UI } // namespace Inkscape diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 361d737a8..5b6402883 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -3,8 +3,9 @@ * * Authors: * Marco Scholten + * Bruno Dilly * - * Copyright (C) 2004, 2006 Authors + * Copyright (C) 2004, 2006, 2007 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -88,6 +89,17 @@ protected: void on_changed(); }; +class PrefEntry : public Gtk::Entry +{ +public: + void init(const std::string& prefs_path, const std::string& attr, + bool mask); +protected: + std::string _prefs_path; + std::string _attr; + void on_activate(); +}; + class DialogPage : public Gtk::Table { public: diff --git a/src/verbs.cpp b/src/verbs.cpp index 41d6fcdcc..38ce87e59 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_EXPORT_TO_OCAL: + sp_file_export_to_ocal(*parent); + break; case SP_VERB_FILE_NEXT_DESKTOP: inkscape_switch_desktops_next(); break; @@ -2144,6 +2147,7 @@ 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_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 aa589e36d..b86a84ee5 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -41,6 +41,7 @@ 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_NEXT_DESKTOP, SP_VERB_FILE_PREV_DESKTOP, SP_VERB_FILE_CLOSE_VIEW, -- 2.30.2