summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-11-01 19:27:57 +0000
committerMartin Owens <doctormo@gmail.com>2019-11-01 23:08:03 +0000
commita1253803f469ff6be714ec7ce2837286e719939d (patch)
treea0909acf5d2d74353e0a655c3afbfe9b1ef45d2f
parentfix #497 don't set 'd' style property (diff)
downloadinkscape-a1253803f469ff6be714ec7ce2837286e719939d.tar.gz
inkscape-a1253803f469ff6be714ec7ce2837286e719939d.zip
Remove OCAL
-rw-r--r--share/ui/menus.xml2
-rw-r--r--src/file.cpp207
-rw-r--r--src/file.h31
-rw-r--r--src/preferences-skeleton.h3
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp12
-rw-r--r--src/ui/dialog/inkscape-preferences.h5
-rw-r--r--src/ui/dialog/ocaldialogs.cpp1213
-rw-r--r--src/ui/dialog/ocaldialogs.h500
-rw-r--r--src/verbs.cpp10
-rw-r--r--src/verbs.h2
11 files changed, 1 insertions, 1986 deletions
diff --git a/share/ui/menus.xml b/share/ui/menus.xml
index c7c96bee2..d59d9675a 100644
--- a/share/ui/menus.xml
+++ b/share/ui/menus.xml
@@ -16,8 +16,6 @@
<separator/>
<verb verb-id="FileImport" />
<verb verb-id="DialogExport" />
- <verb verb-id="FileImportFromOCAL" />
- <!--verb verb-id="FileExportToOCAL" /-->
<separator/>
<verb verb-id="FilePrint" />
<separator/>
diff --git a/src/file.cpp b/src/file.cpp
index 57ad8b54c..471b55cad 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -69,7 +69,7 @@
#include "style.h"
#include "ui/dialog/font-substitution.h"
-#include "ui/dialog/ocaldialogs.h"
+#include "ui/dialog/filedialog.h"
#include "ui/interface.h"
#include "ui/tools/tool-base.h"
#include "widgets/desktop-widget.h"
@@ -1270,211 +1270,6 @@ sp_file_import(Gtk::Window &parentWindow)
return;
}
-
-/*######################
-## E X P O R T T O O C A L
-######################*/
-
-/**
- * Display an Export dialog, export as the selected type if OK pressed
- */
-/*
-bool
-sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
-{
-
- 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 bool gotSuccess = false;
-
- Inkscape::XML::Node *repr = doc->getReprRoot();
- (void)repr;
-
- if (!doc->uri && !doc->isModifiedSinceSave())
- return false;
-
- // Get the default extension name
- Glib::ustring default_extension = "org.inkscape.output.svg.inkscape";
- char formatBuf[256];
-
- Glib::ustring filename_extension = ".svg";
- selectionType = Inkscape::Extension::db.get(default_extension.c_str());
-
- 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
- Inkscape::UI::Dialog::OCAL:ExportDialog *exportDialogInstance =
- new Inkscape::UI::Dialog::OCAL:ExportDialog
- parentWindow,
- Inkscape::UI::Dialog::EXPORT_TYPES,
- (char const *) _("Select file to export to")
- );
-
- success = exportDialogInstance->show();
- if (!success) {
- delete exportDialogInstance;
- return success;
- }
-
- fileName = exportDialogInstance->getFilename();
-
- delete exportDialogInstance;
- exportDialogInstance = NULL;;
-
- fileName.append(filename_extension.c_str());
- 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, Inkscape::Extension::FILE_SAVE_METHOD_EXPORT);
-
- if (!success){
- gchar *text = g_strdup_printf(_("Error saving a temporary copy"));
- sp_ui_error_dialog(text);
-
- return success;
- }
-
- // Start submission now
-
- // Create the uri
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring uri = "dav://";
- Glib::ustring username = prefs->getString("/options/ocalusername/str");
- Glib::ustring password = prefs->getString("/options/ocalpassword/str");
- if (username.empty() || password.empty())
- {
- Inkscape::UI::Dialog::FileExportToOCALPasswordDialog *exportPasswordDialogInstance = NULL;
- if(!gotSuccess)
- {
- exportPasswordDialogInstance = new Inkscape::UI::Dialog::FileExportToOCALPasswordDialog(
- parentWindow,
- (char const *) _("Open Clip Art Login"));
- success = exportPasswordDialogInstance->show();
- if (!success) {
- delete exportPasswordDialogInstance;
- return success;
- }
- }
- username = exportPasswordDialogInstance->getUsername();
- password = exportPasswordDialogInstance->getPassword();
-
- delete exportPasswordDialogInstance;
- exportPasswordDialogInstance = NULL;
- }
- uri.append(username);
- uri.append(":");
- uri.append(password);
- uri.append("@");
- uri.append(prefs->getString("/options/ocalurl/str"));
- uri.append("/dav.php/");
- uri.append(Glib::path_get_basename(fileName));
-
- // Save as a remote file using the dav protocol.
- success = file_save_remote(doc, uri, selectionType, FALSE, FALSE);
- remove(fileName.c_str());
- if (!success)
- {
- gchar *text = g_strdup_printf(_("Error exporting the document. Verify if the server name, username and password are correct, if the server has support for webdav and verify if you didn't forget to choose a license."));
- sp_ui_error_dialog(text);
- }
- else
- gotSuccess = true;
-
- return success;
-}
-*/
-/**
- * Export the current document to OCAL
- */
-/*
-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..."));
-}
-*/
-
-/*######################
-## I M P O R T F R O M O C A L
-######################*/
-
-Inkscape::UI::Dialog::OCAL::ImportDialog* import_ocal_dialog = nullptr;
-
-/**
- * Display an ImportFromOcal Dialog, and the selected document from OCAL
- */
-void on_import_from_ocal_response(Glib::ustring filename)
-{
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
-
- if (!filename.empty()) {
- Inkscape::Extension::Extension *selection = import_ocal_dialog->get_selection_type();
- file_import(doc, filename, selection);
- }
-}
-
-void
-sp_file_import_from_ocal(Gtk::Window &parent_window)
-{
- static Glib::ustring import_path;
-
- SPDocument *doc = SP_ACTIVE_DOCUMENT;
- if (!doc)
- return;
-
- if (import_ocal_dialog == nullptr) {
- import_ocal_dialog = new
- Inkscape::UI::Dialog::OCAL::ImportDialog(
- parent_window,
- Inkscape::UI::Dialog::IMPORT_TYPES,
- (char const *)_("Import Clip Art"));
-
- import_ocal_dialog->signal_response().connect(
- sigc::ptr_fun(&on_import_from_ocal_response));
- }
-
- import_ocal_dialog->show_all();
-}
-
/*######################
## P R I N T
######################*/
diff --git a/src/file.h b/src/file.h
index c6353ad99..67597688e 100644
--- a/src/file.h
+++ b/src/file.h
@@ -142,37 +142,6 @@ SPObject* file_import(SPDocument *in_doc, const Glib::ustring &uri,
/*######################
-## 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);
-
-
-/*######################
-## I M P O R T F R O M O C A L
-######################*/
-
-/**
- * Import a document from OCAL
- */
-void on_import_from_ocal_response(Glib::ustring filename);
-
-/**
- * Import a document from OCAL
- */
-void sp_file_import_from_ocal (Gtk::Window &parentWindow );
-
-
-/*######################
## P R I N T
######################*/
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 4d2a10de3..abf568221 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -319,9 +319,6 @@ R"=====(
<group id="showfiltersinfobox" value="1" />
<group id="startmode" outline="0"/>
<group id="outlinemode" value="0"/>
- <group id="ocalurl" str="openclipart.org"/>
- <group id="ocalusername" str=""/>
- <group id="ocalpassword" str=""/>
<group id="wireframecolors"
onlight="0x000000ff"
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index cae637bfb..c25c04adf 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -130,7 +130,6 @@ set(ui_SRC
dialog/object-attributes.cpp
dialog/object-properties.cpp
dialog/objects.cpp
- dialog/ocaldialogs.cpp
dialog/polar-arrange-tab.cpp
dialog/print-colors-preview-dialog.cpp
dialog/print.cpp
@@ -297,7 +296,6 @@ set(ui_SRC
dialog/object-attributes.h
dialog/object-properties.h
dialog/objects.h
- dialog/ocaldialogs.h
dialog/panel-dialog.h
dialog/polar-arrange-tab.h
dialog/print-colors-preview-dialog.h
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index cd9396e98..1815ddaea 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1720,18 +1720,6 @@ void InkscapePreferences::initPageIO()
// -----------
this->AddPage(_page_autosave, _("Autosave"), iter_io, PREFS_PAGE_IO_AUTOSAVE);
-
- // Open Clip Art options
- _importexport_ocal_url.init("/options/ocalurl/str", true, g_strdup_printf("openclipart.org"));
- _page_openclipart.add_line( false, _("Open Clip Art Library _Server Name:"), _importexport_ocal_url, "",
- _("The server name of the Open Clip Art Library webdav server; it's used by the Import and Export to OCAL function"), true);
- _importexport_ocal_username.init("/options/ocalusername/str", true);
- _page_openclipart.add_line( false, _("Open Clip Art Library _Username:"), _importexport_ocal_username, "",
- _("The username used to log into Open Clip Art Library"), true);
- _importexport_ocal_password.init("/options/ocalpassword/str", false);
- _page_openclipart.add_line( false, _("Open Clip Art Library _Password:"), _importexport_ocal_password, "",
- _("The password used to log into Open Clip Art Library"), true);
- this->AddPage(_page_openclipart, _("Open Clip Art"), iter_io, PREFS_PAGE_IO_OPENCLIPART);
}
void InkscapePreferences::initPageBehavior()
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 2475339f6..8bda1c1ab 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -176,7 +176,6 @@ protected:
UI::Widget::DialogPage _page_svgexport;
UI::Widget::DialogPage _page_cms;
UI::Widget::DialogPage _page_autosave;
- UI::Widget::DialogPage _page_openclipart;
UI::Widget::DialogPage _page_rendering;
UI::Widget::DialogPage _page_system;
@@ -486,10 +485,6 @@ protected:
UI::Widget::PrefCheckButton _svgexport_remove_marker_context_paint;
- UI::Widget::PrefEntryButtonHBox _importexport_ocal_url;
- UI::Widget::PrefEntry _importexport_ocal_username;
- UI::Widget::PrefEntry _importexport_ocal_password;
-
/*
* Keyboard shortcut members
*/
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
deleted file mode 100644
index 32bcb88c1..000000000
--- a/src/ui/dialog/ocaldialogs.cpp
+++ /dev/null
@@ -1,1213 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/**
- * @file
- * Open Clip Art Library integration dialogs - implementation.
- */
-/* Authors:
- * Bruno Dilly
- * Other dudes from The Inkscape Organization
- * Andrew Higginson
- *
- * Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#include "ocaldialogs.h"
-
-#include "filedialogimpl-gtkmm.h"
-#include "io/sys.h"
-#include "path-prefix.h"
-#include "preferences.h"
-#include "ui/icon-loader.h"
-
-#include <gtkmm/notebook.h>
-#include <gtkmm/spinner.h>
-#include <gdkmm/general.h>
-#include <libxml/tree.h>
-
-#include <glibmm/i18n.h>
-#include <glibmm/miscutils.h>
-#include <glibmm/markup.h>
-#include <glibmm/convert.h>
-#include <glibmm/fileutils.h>
-#include <glibmm/main.h>
-
-#include "ui/icon-names.h"
-
-namespace Inkscape
-{
-namespace UI
-{
-namespace Dialog
-{
-namespace OCAL
-{
-
-//########################################################################
-//# F I L E E X P O R T T O O C A L
-//########################################################################
-
-/**
- * Callback for fileNameEntry widget
- */
-/*
-void ExportDialog::fileNameEntryChangedCallback()
-{
- if (!fileNameEntry)
- return;
-
- Glib::ustring fileName = fileNameEntry->get_text();
- if (!Glib::get_charset()) //If we are not utf8
- fileName = Glib::filename_to_utf8(fileName);
-
- myFilename = fileName;
- response(Gtk::RESPONSE_OK);
-}
-*/
-/**
- * Constructor
- */
-/*
-ExportDialog::ExportDialog(Gtk::Window &parentWindow,
- FileDialogType fileTypes,
- const Glib::ustring &title) :
- FileDialogBase(title, parentWindow)
-{
-*/
- /*
- * Start Taking the vertical Box and putting a Label
- * and a Entry to take the filename
- * Later put the extension selection and checkbox (?)
- */
- /* Initialize to Autodetect */
-/*
- extension = NULL;
-*/
- /* No filename to start out with */
-/*
- myFilename = "";
-*/
- /* Set our dialog type (save, export, etc...)*/
-/*
- dialogType = fileTypes;
- Gtk::VBox *vbox = get_vbox();
-
- Gtk::Label *fileLabel = new Gtk::Label(_("File"));
-
- fileNameEntry = new Gtk::Entry();
- fileNameEntry->set_text(myFilename);
- fileNameEntry->set_max_length(252); // I am giving the extension approach.
- fileBox.pack_start(*fileLabel);
- fileBox.pack_start(*fileNameEntry, Gtk::PACK_EXPAND_WIDGET, 3);
- vbox->pack_start(fileBox);
-
- //Let's do some customization
- fileNameEntry = NULL;
- Gtk::Container *cont = get_toplevel();
- std::vector<Gtk::Entry *> entries;
- findEntryWidgets(cont, entries);
- if (entries.size() >=1 )
- {
- //Catch when user hits [return] on the text field
- fileNameEntry = entries[0];
- fileNameEntry->signal_activate().connect(
- sigc::mem_fun(*this, &ExportDialog::fileNameEntryChangedCallback) );
- }
-
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK));
-
- show_all_children();
-}
-*/
-/**
- * Destructor
- */
-/*
-ExportDialog::~ExportDialog()
-{
-}
-*/
-/**
- * Show this dialog modally. Return true if user hits [OK]
- */
-/*
-bool
-ExportDialog::show()
-{
- set_modal (TRUE); //Window
- sp_transientize(GTK_WIDGET(gobj())); //Make transient
- gint b = run(); //Dialog
- hide();
-
- if (b == Gtk::RESPONSE_OK)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-*/
-/**
- * Get the file name chosen by the user. Valid after an [OK]
- */
-/*
-Glib::ustring
-ExportDialog::get_filename()
-{
- myFilename = fileNameEntry->get_text();
- if (!Glib::get_charset()) //If we are not utf8
- myFilename = Glib::filename_to_utf8(myFilename);
-
- return myFilename;
-}
-
-
-void
-ExportDialog::change_title(const Glib::ustring& title)
-{
- this->set_title(title);
-}
-*/
-
-//########################################################################
-//# F I L E E X P O R T T O O C A L P A S S W O R D
-//########################################################################
-
-
-/**
- * Constructor
- */
-/*
-ExportPasswordDialog::ExportPasswordDialog(Gtk::Window &parentWindow,
- const Glib::ustring &title) : FileDialogBase(title, parentWindow)
-{
-*/
- /*
- * Start Taking the vertical Box and putting 2 Labels
- * and 2 Entries to take the username and password
- */
- /* No username and password to start out with */
-/*
- myUsername = "";
- myPassword = "";
-
- Gtk::VBox *vbox = get_vbox();
-
- Gtk::Label *userLabel = new Gtk::Label(_("Username:"));
- Gtk::Label *passLabel = new Gtk::Label(_("Password:"));
-
- usernameEntry = new Gtk::Entry();
- usernameEntry->set_text(myUsername);
- usernameEntry->set_max_length(255);
-
- passwordEntry = new Gtk::Entry();
- passwordEntry->set_text(myPassword);
- passwordEntry->set_max_length(255);
- passwordEntry->set_invisible_char('*');
- passwordEntry->set_visibility(false);
- passwordEntry->set_activates_default(true);
-
- userBox.pack_start(*userLabel);
- userBox.pack_start(*usernameEntry, Gtk::PACK_EXPAND_WIDGET, 3);
- vbox->pack_start(userBox);
-
- passBox.pack_start(*passLabel);
- passBox.pack_start(*passwordEntry, Gtk::PACK_EXPAND_WIDGET, 3);
- vbox->pack_start(passBox);
-
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- set_default(*add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK));
-
- show_all_children();
-}
-*/
-
-/**
- * Destructor
- */
-/*
-ExportPasswordDialog::~ExportPasswordDialog()
-{
-}
-*/
-/**
- * Show this dialog modally. Return true if user hits [OK]
- */
-/*
-bool
-ExportPasswordDialog::show()
-{
- set_modal (TRUE); //Window
- sp_transientize(GTK_WIDGET(gobj())); //Make transient
- gint b = run(); //Dialog
- hide();
-
- if (b == Gtk::RESPONSE_OK)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-*/
-/**
- * Get the username. Valid after an [OK]
- */
-/*
-Glib::ustring
-ExportPasswordDialog::getUsername()
-{
- myUsername = usernameEntry->get_text();
- return myUsername;
-}
-*/
-/**
- * Get the password. Valid after an [OK]
- */
-/*
-Glib::ustring
-ExportPasswordDialog::getPassword()
-{
- myPassword = passwordEntry->get_text();
- return myPassword;
-}
-
-void
-ExportPasswordDialog::change_title(const Glib::ustring& title)
-{
- this->set_title(title);
-}
-*/
-
-//#########################################################################
-//### F I L E I M P O R T F R O M O C A L
-//#########################################################################
-
-WrapLabel::WrapLabel() : Gtk::Label()
-{
- signal_size_allocate().connect(sigc::mem_fun(*this, &WrapLabel::_on_size_allocate));
-}
-
-void WrapLabel::_on_size_allocate(Gtk::Allocation& allocation)
-{
- set_size_request(allocation.get_width(), -1);
-}
-
-
-LoadingBox::LoadingBox() : Gtk::EventBox()
-{
- set_visible_window(false);
- draw_spinner = false;
- spinner_step = 0;
-
- signal_draw().connect(sigc::mem_fun(*this, &LoadingBox::_on_draw), false);
-}
-
-bool LoadingBox::_on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
-{
- // Draw shadow
- int x = get_allocation().get_x();
- int y = get_allocation().get_y();
- int width = get_allocation().get_width();
- int height = get_allocation().get_height();
-
- get_style_context()->render_frame(cr, x, y, width, height);
-
- if (draw_spinner) {
- int spinner_size = 16;
- int spinner_x = x + (width - spinner_size) / 2;
- int spinner_y = y + (height - spinner_size) / 2;
-
- get_style_context()->render_activity(cr, spinner_x, spinner_y, spinner_size, spinner_size);
- }
-
- return false;
-}
-
-void LoadingBox::start()
-{
- // Timeout hasn't been stopped, so must be disconnected
- if ((draw_spinner != false) && timeout) {
- timeout.disconnect();
- }
-
- draw_spinner = true;
- timeout = Glib::signal_timeout().connect(sigc::mem_fun(*this, &LoadingBox::on_timeout), 80);
-}
-
-void LoadingBox::stop()
-{
- draw_spinner = false;
-}
-
-bool LoadingBox::on_timeout() {
- if (draw_spinner) {
-
- if (spinner_step == 11) {
- spinner_step = 0;
- } else {
- spinner_step ++;
- }
-
- queue_draw();
- return true;
- }
- return false;
-}
-
-PreviewWidget::PreviewWidget() : Gtk::VBox(false, 12)
-{
- box_loading = new LoadingBox();
- image = new Gtk::Image();
-
- label_title = new WrapLabel();
- label_description = new WrapLabel();
- label_time = new WrapLabel();
-
- pack_start(*box_loading, false, false);
- pack_start(*image, false, false);
- pack_start(*label_title, false, false);
- pack_start(*label_description, false, false);
- pack_start(*label_time, false, false);
-
- label_title->set_line_wrap(true);
- label_title->set_line_wrap_mode(Pango::WRAP_WORD_CHAR);
- label_title->set_justify(Gtk::JUSTIFY_CENTER);
- label_description->set_line_wrap(true);
- label_description->set_line_wrap_mode(Pango::WRAP_WORD_CHAR);
- label_description->set_justify(Gtk::JUSTIFY_CENTER);
- label_time->set_line_wrap(true);
- label_time->set_line_wrap_mode(Pango::WRAP_WORD_CHAR);
- label_time->set_justify(Gtk::JUSTIFY_CENTER);
-
- box_loading->set_no_show_all(true);
- image->set_no_show_all(true);
- label_title->set_size_request(90, -1);
- label_description->set_size_request(90, -1);
- label_time->set_size_request(90, -1);
- box_loading->set_size_request(90, 90);
- set_border_width(12);
-
- signal_draw().connect(sigc::mem_fun(*this, &PreviewWidget::_on_draw), false);
-
- clear();
-}
-
-void PreviewWidget::set_metadata(Glib::ustring description, Glib::ustring creator,
- Glib::ustring time)
-{
- label_title->set_markup(g_markup_printf_escaped("<b>%s</b>", description.c_str()));
- label_description->set_markup(g_markup_printf_escaped("%s", creator.c_str()));
- label_time->set_markup(g_markup_printf_escaped("<small>%s</small>", time.c_str()));
-
- show_box_loading();
-}
-
-void PreviewWidget::show_box_loading()
-{
- box_loading->show();
- box_loading->start();
-}
-
-void PreviewWidget::hide_box_loading()
-{
- box_loading->hide();
- box_loading->stop();
-}
-
-void PreviewWidget::set_image(std::string path)
-{
- image->set(path);
- hide_box_loading();
- image->show();
-}
-
-void PreviewWidget::clear()
-{
- label_title->set_markup("");
- label_description->set_markup("");
- label_time->set_markup("");
-
- box_loading->hide();
- image->hide();
-}
-
-bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
-{
- // Draw background
- int x = get_allocation().get_x();
- int y = get_allocation().get_y();
- int width = get_allocation().get_width();
- int height = get_allocation().get_height();
-
- Gdk::RGBA background_fill;
- get_style_context()->lookup_color("base_color", background_fill);
- cr->rectangle(x, y, width, height);
- Gdk::Cairo::set_source_rgba(cr, background_fill);
-
- cr->fill();
-
- return false;
-}
-
-StatusWidget::StatusWidget() : Gtk::HBox(false, 6)
-{
- image = sp_get_icon_image("dialog-error", Gtk::ICON_SIZE_MENU);
- spinner = new Gtk::Spinner();
- label = new Gtk::Label();
-
- image->set_no_show_all(true);
- spinner->set_no_show_all(true);
- label->set_no_show_all(true);
-
- pack_start(*image, false, false);
- pack_start(*spinner, false, false);
- pack_start(*label, false, false);
-}
-
-void StatusWidget::clear()
-{
- spinner->hide();
- image->hide();
- label->hide();
-}
-
-void StatusWidget::set_info(Glib::ustring text)
-{
- spinner->hide();
- image->show();
- label->show();
- image = sp_get_icon_image("dialog-information", Gtk::ICON_SIZE_MENU);
- label->set_text(text);
-}
-
-void StatusWidget::set_error(Glib::ustring text)
-{
- spinner->hide();
- image->show();
- label->show();
- image = sp_get_icon_image("dialog-error", Gtk::ICON_SIZE_MENU);
- label->set_text(text);
-}
-
-void StatusWidget::start_process(Glib::ustring text)
-{
- image->hide();
- spinner->show();
- label->show();
- label->set_text(text);
- spinner->start();
- show_all();
-}
-
-void StatusWidget::end_process()
-{
- spinner->stop();
- spinner->hide();
- label->hide();
- clear();
-}
-
-BaseBox::BaseBox() : Gtk::EventBox()
-{
- signal_draw().connect(sigc::mem_fun(*this, &BaseBox::_on_draw), false);
- set_visible_window(false);
-}
-
-bool BaseBox::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
-{
- // Draw background and shadow
- int x = get_allocation().get_x();
- int y = get_allocation().get_y();
- int width = get_allocation().get_width();
- int height = get_allocation().get_height();
-
- Gdk::RGBA background_fill;
- get_style_context()->lookup_color("base_color", background_fill);
- cr->rectangle(x, y, width, height);
- Gdk::Cairo::set_source_rgba(cr, background_fill);
- cr->fill();
- get_style_context()->render_frame(cr, x, y, width, height);
-
- return false;
-}
-
-LogoArea::LogoArea() : Gtk::EventBox()
-{
- // Try to load the OCAL logo, but if the file is not found, degrade gracefully
- try {
- std::string logo_path = Glib::build_filename(INKSCAPE_PIXMAPSDIR, "OCAL.png");
- logo_mask = Cairo::ImageSurface::create_from_png(logo_path);
- draw_logo = true;
- } catch(Cairo::logic_error) {
- logo_mask = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 1,1);
- draw_logo = false;
- }
-
- signal_draw().connect(sigc::mem_fun(*this, &LogoArea::_on_draw));
- set_visible_window(false);
-}
-
-bool LogoArea::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
-{
- if (draw_logo) {
- int x = get_allocation().get_x();
- int y = get_allocation().get_y();
- int width = get_allocation().get_width();
- int height = get_allocation().get_height();
- int x_logo = x + (width - 220) / 2;
- int y_logo = y + (height - 76) / 2;
-
- // Draw logo, we mask [read fill] it with grey
- Gdk::RGBA logo_fill("grey");
- Gdk::Cairo::set_source_rgba(cr, logo_fill);
-
- cr->mask(logo_mask, x_logo, y_logo);
- }
-
- return false;
-}
-
-SearchResultList::SearchResultList(guint columns_count) : ListViewText(columns_count)
-{
- set_headers_visible(false);
- set_column_title(RESULTS_COLUMN_MARKUP, _("Clipart found"));
-
- Gtk::CellRenderer* cr_markup = get_column_cell_renderer(RESULTS_COLUMN_MARKUP);
- cr_markup->set_property("ellipsize", Pango::ELLIPSIZE_END);
- get_column(RESULTS_COLUMN_MARKUP)->clear_attributes(*cr_markup);
- get_column(RESULTS_COLUMN_MARKUP)->add_attribute(*cr_markup,
- "markup", RESULTS_COLUMN_MARKUP);
-
- // Hide all columns except for the MARKUP column
- for (int i = 0; i < RESULTS_COLUMN_LENGTH; i++) {
- if (i != RESULTS_COLUMN_MARKUP) {
- get_column(i)->set_visible(false);
- }
- }
-}
-
-void ImportDialog::on_list_results_selection_changed()
-{
- std::vector<Gtk::TreeModel::Path> pathlist;
- pathlist = list_results->get_selection()->get_selected_rows();
- std::vector<int> posArray(1);
-
- // If nothing is selected, then return
- if (((int) pathlist.size()) < 1) {
- return;
- }
- int row = pathlist[0][0];
-
- Glib::ustring guid = list_results->get_text(row, RESULTS_COLUMN_GUID);
-
- bool item_selected = (!guid.empty());
- button_import->set_sensitive(item_selected);
-}
-
-
-void ImportDialog::on_button_import_clicked() {
- std::vector<Gtk::TreeModel::Path> pathlist;
- pathlist = list_results->get_selection()->get_selected_rows();
- std::vector<int> posArray(1);
-
- // If nothing is selected, then return
- if (((int) pathlist.size()) < 1) {
- return;
- }
- int row = pathlist[0][0];
-
- button_import->set_sensitive(false);
- button_close->hide();
- button_cancel->show();
- widget_status->start_process(_("Downloading image..."));
- download_resource(TYPE_IMAGE, row);
-}
-
-/*
- * Callback for cursor change
- */
-void ImportDialog::on_list_results_cursor_changed()
-{
- std::vector<Gtk::TreeModel::Path> pathlist;
- pathlist = list_results->get_selection()->get_selected_rows();
- std::vector<int> posArray(1);
-
- // If nothing is selected, then return
- if (((int) pathlist.size()) < 1) {
- return;
- }
- int row = pathlist[0][0];
-
- if (downloading_thumbnail) {
- cancellable_thumbnail->cancel();
- cancelled_thumbnail = true;
- }
-
- update_preview(row);
- downloading_thumbnail = true;
- download_resource(TYPE_THUMBNAIL, row);
-}
-void ImportDialog::update_preview(int row)
-{
- Glib::ustring description = list_results->get_text(row, RESULTS_COLUMN_DESCRIPTION);
- Glib::ustring creator = list_results->get_text(row, RESULTS_COLUMN_CREATOR);
- Glib::ustring date = list_results->get_text(row, RESULTS_COLUMN_DATE);
-
- preview_files->clear();
- preview_files->set_metadata(description, creator, date);
-}
-
-
-std::string ImportDialog::get_temporary_dir(ResourceType type)
-{
- std::string ocal_tmp_dir = Glib::build_filename(Glib::get_tmp_dir(),
- "openclipart");
-
- if (type == TYPE_THUMBNAIL) {
- return Glib::build_filename(ocal_tmp_dir, "thumbnails");
- } else {
- return Glib::build_filename(ocal_tmp_dir, "images");
- }
-}
-
-void ImportDialog::create_temporary_dirs()
-{
- // Make sure the temporary directories exists, if not, create them
- std::string ocal_tmp_thumbnail_dir = get_temporary_dir(TYPE_THUMBNAIL);
- std::string ocal_tmp_image_dir = get_temporary_dir(TYPE_IMAGE);
-
- if (!Glib::file_test(ocal_tmp_thumbnail_dir, Glib::FILE_TEST_EXISTS)) {
- Glib::RefPtr<Gio::File> directory = Gio::File::create_for_path(ocal_tmp_thumbnail_dir);
- directory->make_directory_with_parents();
- }
-
- if (!Glib::file_test(ocal_tmp_image_dir, Glib::FILE_TEST_EXISTS)) {
- Glib::RefPtr<Gio::File> directory = Gio::File::create_for_path(ocal_tmp_image_dir);
- directory->make_directory_with_parents();
- }
-}
-
-void ImportDialog::download_resource(ResourceType type, int row)
-{
- // Get Temporary Directory
- std::string ocal_tmp_dir = get_temporary_dir(type);
-
- // Make a unique filename for the clipart, in the form 'GUID.extension'
- Glib::ustring guid = list_results->get_text(row, RESULTS_COLUMN_GUID);
- Glib::ustring original_filename;
-
- if (type == TYPE_IMAGE) {
- original_filename = list_results->get_text(row, RESULTS_COLUMN_FILENAME);
- } else {
- original_filename = list_results->get_text(row, RESULTS_COLUMN_THUMBNAIL_FILENAME);
- }
- Glib::ustring extension = Inkscape::IO::get_file_extension(original_filename);
-
- Glib::ustring filename = Glib::ustring::compose("%1%2", guid, extension);
- std::string path = Glib::build_filename(ocal_tmp_dir, filename.c_str());
- Glib::RefPtr<Gio::File> file_local = Gio::File::create_for_path(path);
-
- // If the file has already been downloaded, use it
- if (Glib::file_test(path, Glib::FILE_TEST_EXISTS)) {
- if (type == TYPE_IMAGE) {
- on_image_downloaded(path, true);
- } else {
- on_thumbnail_downloaded(path, true);
- }
- return;
- }
-
- // Get Remote File URL and get the respective cancellable object
- Glib::ustring url;
- Glib::RefPtr<Gio::Cancellable> cancellable;
-
- if (type == TYPE_IMAGE) {
- url = list_results->get_text(row, RESULTS_COLUMN_URL);
- cancellable_image = Gio::Cancellable::create();
- cancellable = cancellable_image;
- } else {
- url = list_results->get_text(row, RESULTS_COLUMN_THUMBNAIL_URL);
- cancellable_thumbnail = Gio::Cancellable::create();
- cancellable = cancellable_thumbnail;
- }
-
- Glib::RefPtr<Gio::File> file_remote = Gio::File::create_for_uri(url);
-
- // Download it asynchronously
- file_remote->copy_async(file_local,
- sigc::bind<Glib::RefPtr<Gio::File>, Glib::ustring, ResourceType>(
- sigc::mem_fun(*this, &ImportDialog::on_resource_downloaded),
- file_remote, path, type), cancellable,
- Gio::FILE_COPY_OVERWRITE);
-}
-
-void ImportDialog::on_resource_downloaded(const Glib::RefPtr<Gio::AsyncResult>& result,
- Glib::RefPtr<Gio::File> file_remote, Glib::ustring path, ResourceType resource)
-{
- bool success;
-
- try {
- success = file_remote->copy_finish(result);
- } catch(Glib::Error) {
- success = false;
- }
-
- if (resource == TYPE_IMAGE) {
- on_image_downloaded(path, success);
- } else {
- on_thumbnail_downloaded(path, success);
- }
-}
-
-void ImportDialog::on_image_downloaded(Glib::ustring path, bool success)
-{
- button_import->set_sensitive(true);
- button_close->show();
- button_cancel->hide();
-
- // If anything went wrong, show an error message if the user didn't do it
- if (!success && !cancelled_image) {
- widget_status->set_error(_("Could not download image"));
- }
- if (!success) {
- widget_status->clear();
- return;
- }
-
- try {
- widget_status->clear();
- m_signal_response.emit(path);
- widget_status->set_info(_("Clipart downloaded successfully"));
- } catch(Glib::Error) {
- // success = false; //has no effect, value not returned
- }
-
- cancelled_image = false;
-}
-
-void ImportDialog::on_thumbnail_downloaded(Glib::ustring path, bool success)
-{
- downloading_thumbnail = false;
-
- // If anything went wrong, show an error message if the user didn't do it
- if (!success && !cancelled_thumbnail) {
- widget_status->set_error(_("Could not download thumbnail file"));
- return;
- }
- if (!success) {
- widget_status->clear();
- return;
- }
-
- try {
- widget_status->clear();
- preview_files->set_image(path);
- } catch(Glib::Error) {
- // success = false; //has no effect, value not returned
- }
-
- cancelled_thumbnail = false;
-}
-
-/*
- * Callback for row activated
- */
-void ImportDialog::on_list_results_row_activated(const Gtk::TreeModel::Path& /*path*/,
- Gtk::TreeViewColumn* /*column*/)
-{
- on_list_results_cursor_changed();
- button_import->signal_clicked();
-}
-
-/**
- * Prints the names of the all the xml elements
- * that are siblings or children of a given xml node
- */
-void SearchResultList::populate_from_xml(xmlNode * a_node)
-{
- guint row_num = 0;
-
- for (xmlNode *cur_node = a_node; cur_node; cur_node = cur_node->next) {
-
- // Get items information
- if (strcmp(reinterpret_cast<const char*>(cur_node->name), "rss")) // Avoid the root
- if (cur_node->type == XML_ELEMENT_NODE &&
- (cur_node->parent->name && !strcmp(reinterpret_cast<const char*>(cur_node->parent->name), "item")))
- {
- if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "title"))
- {
- row_num = append("");
- xmlChar *xml_title = xmlNodeGetContent(cur_node);
- char* title = reinterpret_cast<char*>(xml_title);
-
- set_text(row_num, RESULTS_COLUMN_TITLE, title);
- xmlFree(title);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "pubDate"))
- {
- xmlChar *xml_date = xmlNodeGetContent(cur_node);
- char* date = reinterpret_cast<char*>(xml_date);
-
- set_text(row_num, RESULTS_COLUMN_DATE, date);
- xmlFree(xml_date);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "creator"))
- {
- xmlChar *xml_creator = xmlNodeGetContent(cur_node);
- char* creator = reinterpret_cast<char*>(xml_creator);
-
- set_text(row_num, RESULTS_COLUMN_CREATOR, creator);
- xmlFree(xml_creator);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "description"))
- {
- xmlChar *xml_description = xmlNodeGetContent(cur_node);
- //char* final_description;
- char* stripped_description = g_strstrip(reinterpret_cast<char*>(xml_description));
-
- if (!strcmp(stripped_description, "")) {
- stripped_description = _("No description");
- }
-
- //GRegex* regex = g_regex_new(g_regex_escape_string(stripped_description, -1));
- //final_description = g_regex_replace_literal(regex, "\n", -1, 0, " ");
-
- set_text(row_num, RESULTS_COLUMN_DESCRIPTION, stripped_description);
- xmlFree(xml_description);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "enclosure"))
- {
- xmlChar *xml_url = xmlGetProp(cur_node, reinterpret_cast<xmlChar const*>("url"));
- char* url = reinterpret_cast<char*>(xml_url);
- char* filename = g_path_get_basename(url);
-
- set_text(row_num, RESULTS_COLUMN_URL, url);
- set_text(row_num, RESULTS_COLUMN_FILENAME, filename);
- xmlFree(xml_url);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "thumbnail"))
- {
- xmlChar *xml_thumbnail_url = xmlGetProp(cur_node, reinterpret_cast<xmlChar const*>("url"));
- char* thumbnail_url = reinterpret_cast<char*>(xml_thumbnail_url);
- char* thumbnail_filename = g_path_get_basename(thumbnail_url);
-
- set_text(row_num, RESULTS_COLUMN_THUMBNAIL_URL, thumbnail_url);
- set_text(row_num, RESULTS_COLUMN_THUMBNAIL_FILENAME, thumbnail_filename);
- xmlFree(xml_thumbnail_url);
- }
- else if (!strcmp(reinterpret_cast<const char*>(cur_node->name), "guid"))
- {
- xmlChar *xml_guid = xmlNodeGetContent(cur_node);
- char* guid_url = reinterpret_cast<char*>(xml_guid);
- char* guid = g_path_get_basename(guid_url);
-
- set_text(row_num, RESULTS_COLUMN_GUID, guid);
- xmlFree(xml_guid);
- }
- }
- populate_from_xml(cur_node->children);
- }
-}
-
-/**
- * Callback for user input into entry_search
- */
-void ImportDialog::on_button_search_clicked()
-{
- on_entry_search_activated();
-}
-
-void ImportDialog::on_button_close_clicked()
-{
- hide();
-}
-
-void ImportDialog::on_button_cancel_clicked()
-{
- cancellable_image->cancel();
- cancelled_image = true;
-}
-
-/**
- * Callback for user input into entry_search
- */
-void ImportDialog::on_entry_search_activated()
-{
- preview_files->clear();
- widget_status->start_process(_("Searching clipart..."));
-
- notebook_content->set_current_page(NOTEBOOK_PAGE_LOGO);
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- Glib::ustring search_keywords = entry_search->get_text();
-
- // Create the URI to the OCAL RSS feed
- Glib::ustring xml_uri = Glib::ustring::compose("http://%1/media/feed/rss/%2",
- prefs->getString("/options/ocalurl/str"), search_keywords);
- // If we are not UTF8
- if (!Glib::get_charset()) {
- xml_uri = Glib::filename_to_utf8(xml_uri);
- }
-
- // Open the RSS feed
- Glib::RefPtr<Gio::File> xml_file = Gio::File::create_for_uri(xml_uri);
- xml_file->load_contents_async(
- sigc::bind<Glib::RefPtr<Gio::File> , Glib::ustring>(
- sigc::mem_fun(*this, &ImportDialog::on_xml_file_read),
- xml_file, xml_uri)
- );
-}
-
-void ImportDialog::on_xml_file_read(const Glib::RefPtr<Gio::AsyncResult>& result,
- Glib::RefPtr<Gio::File> xml_file, Glib::ustring xml_uri)
-{
- widget_status->end_process();
-
- bool success;
- char* data;
- gsize length;
-
- try {
- success = xml_file->load_contents_finish(result, data, length);
- } catch(Glib::Error &e) {
- success = false;
- g_warning("ImportDialog::on_xml_file_read():\n\tFailed to retrieve '%s'\n\t%s",
- xml_uri.c_str(), e.what().c_str());
- }
- if (!success) {
- widget_status->set_error(_("Could not connect to the Open Clip Art Library"));
- return;
- }
-
- // Create the resulting xml document tree
- // Initialize libxml and test mistakes between compiled and shared library used
- LIBXML_TEST_VERSION
- xmlDoc *doc = nullptr;
- xmlNode *root_element = nullptr;
-
- int parse_options = XML_PARSE_RECOVER + XML_PARSE_NOWARNING + XML_PARSE_NOERROR; // do not use XML_PARSE_NOENT ! see bug lp:1025185
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool allowNetAccess = prefs->getBool("/options/externalresources/xml/allow_net_access", false);
- if (!allowNetAccess) {
- parse_options |= XML_PARSE_NONET;
- }
-
- doc = xmlReadMemory(data, (int) length, xml_uri.c_str(), nullptr, parse_options);
-
- if (doc == nullptr) {
- // If nothing is returned, no results could be found
- if (length == 0) {
- notebook_content->set_current_page(NOTEBOOK_PAGE_NOT_FOUND);
- update_label_no_search_results();
- } else {
- widget_status->set_error(_("Could not parse search results"));
- }
- return;
- }
-
- // Get the root element node
- root_element = xmlDocGetRootElement(doc);
-
- // Clear and populate the list_results
- list_results->clear_items();
- list_results->populate_from_xml(root_element);
-
- // Populate the MARKUP column with the title & description of the clipart
- for (guint i = 0; i < list_results->size(); i++) {
- Glib::ustring title = list_results->get_text(i, RESULTS_COLUMN_TITLE);
- Glib::ustring description = list_results->get_text(i, RESULTS_COLUMN_DESCRIPTION);
- char* markup = g_markup_printf_escaped("<b>%s</b>\n<span size=\"small\">%s</span>",
- title.c_str(), description.c_str());
- list_results->set_text(i, RESULTS_COLUMN_MARKUP, markup);
- }
- notebook_content->set_current_page(NOTEBOOK_PAGE_RESULTS);
-
- // free the document
- xmlFreeDoc(doc);
-}
-
-
-void ImportDialog::update_label_no_search_results()
-{
- Glib::ustring keywords = Glib::Markup::escape_text(entry_search->get_text());
-
- Glib::ustring msg_one = Glib::ustring::compose(
- _("No clipart named <b>%1</b> was found."),
- keywords);
- Glib::ustring msg_two = _("Please make sure all keywords are spelled correctly,"
- " or try again with different keywords.");
-
- auto markup = Glib::ustring::compose(
- "<span size=\"large\">%1</span>\n<span>%2</span>",
- msg_one, msg_two);
-
- label_not_found->set_markup(markup);
-}
-
-/**
- * Constructor. Not called directly. Use the factory.
- */
-ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types,
- const Glib::ustring &title) :
- FileDialogBase(title, parent_window)
-{
- // Initialize to Autodetect
- extension = nullptr;
- // No filename to start out with
- Glib::ustring search_keywords = "";
-
- dialogType = file_types;
-
- // Creation
- auto vbox = new Gtk::VBox(false, 0);
- auto hbuttonbox_bottom = new Gtk::ButtonBox();
- auto hbox_bottom = new Gtk::HBox(false, 12);
- BaseBox *basebox_logo = new BaseBox();
- BaseBox *basebox_no_search_results = new BaseBox();
- label_not_found = new Gtk::Label();
- label_description = new Gtk::Label();
- entry_search = new Gtk::SearchEntry();
- button_search = new Gtk::Button(_("Search"));
-
- auto hbuttonbox_search = new Gtk::ButtonBox();
-
- Gtk::ScrolledWindow* scrolledwindow_preview = new Gtk::ScrolledWindow();
- preview_files = new PreviewWidget();
- /// Add the buttons in the bottom of the dialog
- button_cancel = new Gtk::Button(_("_Cancel"), true);
- button_close = new Gtk::Button(_("Close"));
- button_import = new Gtk::Button(_("Import"));
- list_results = new SearchResultList(RESULTS_COLUMN_LENGTH);
- drawingarea_logo = new LogoArea();
- notebook_content = new Gtk::Notebook();
- widget_status = new StatusWidget();
-
- downloading_thumbnail = false;
- cancelled_thumbnail = false;
- cancelled_image = false;
-
- // Packing
- add(*vbox);
- vbox->pack_start(hbox_tags, false, false);
- vbox->pack_start(hbox_files, true, true);
- vbox->pack_start(*hbox_bottom, false, false);
- basebox_logo->add(*drawingarea_logo);
- basebox_no_search_results->add(*label_not_found);
- hbox_bottom->pack_start(*widget_status, true, true);
- hbox_bottom->pack_start(*hbuttonbox_bottom, true, true);
- hbuttonbox_bottom->pack_start(*button_cancel, false, false);
- hbuttonbox_bottom->pack_start(*button_close, false, false);
- hbuttonbox_bottom->pack_start(*button_import, false, false);
- hbuttonbox_search->pack_start(*button_search, false, false);
- hbox_tags.pack_start(*entry_search, true, true);
- hbox_tags.pack_start(*hbuttonbox_search, false, false);
- hbox_files.pack_start(*notebook_content, true, true);
- scrolledwindow_preview->add(*preview_files);
- hbox_files.pack_start(*scrolledwindow_preview, true, true);
-
- notebook_content->insert_page(*basebox_logo, NOTEBOOK_PAGE_LOGO);
- notebook_content->insert_page(scrolledwindow_list, NOTEBOOK_PAGE_RESULTS);
- notebook_content->insert_page(*basebox_no_search_results, NOTEBOOK_PAGE_NOT_FOUND);
-
- // Properties
- set_border_width(12);
- set_default_size(480, 330);
- vbox->set_spacing(12);
- hbuttonbox_bottom->set_spacing(6);
- hbuttonbox_bottom->set_layout(Gtk::BUTTONBOX_END);
- button_import->set_sensitive(false);
- entry_search->set_max_length(255);
- hbox_tags.set_spacing(6);
- preview_files->clear();
- notebook_content->set_current_page(NOTEBOOK_PAGE_LOGO);
- /// Add the listview inside a ScrolledWindow
- scrolledwindow_list.add(*list_results);
- scrolledwindow_list.set_shadow_type(Gtk::SHADOW_IN);
- /// Only show the scrollbars when they are necessary
- scrolledwindow_list.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- preview_files->set_size_request(120, -1);
- hbox_files.set_spacing(12);
- label_not_found->set_line_wrap(true);
- label_not_found->set_line_wrap_mode(Pango::WRAP_WORD);
- label_not_found->set_justify(Gtk::JUSTIFY_CENTER);
- label_not_found->set_size_request(260, -1);
- scrolledwindow_preview->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
- notebook_content->set_show_tabs(false);
- notebook_content->set_show_border(false);
- button_cancel->set_no_show_all(true);
- button_close->set_no_show_all(true);
- button_close->show();
- button_cancel->hide();
-
- // Signals
- entry_search->signal_activate().connect(
- sigc::mem_fun(*this, &ImportDialog::on_entry_search_activated));
- button_import->signal_clicked().connect(
- sigc::mem_fun(*this, &ImportDialog::on_button_import_clicked));
- button_close->signal_clicked().connect(
- sigc::mem_fun(*this, &ImportDialog::on_button_close_clicked));
- button_cancel->signal_clicked().connect(
- sigc::mem_fun(*this, &ImportDialog::on_button_cancel_clicked));
- button_search->signal_clicked().connect(
- sigc::mem_fun(*this, &ImportDialog::on_button_search_clicked));
- list_results->signal_cursor_changed().connect(
- sigc::mem_fun(*this, &ImportDialog::on_list_results_cursor_changed));
- list_results->signal_row_activated().connect(
- sigc::mem_fun(*this, &ImportDialog::on_list_results_row_activated));
- list_results->get_selection()->signal_changed().connect(
- sigc::mem_fun(*this, &ImportDialog::on_list_results_selection_changed));
-
- show_all_children();
- entry_search->grab_focus();
-
- // Create the temporary directories that will be needed later
- create_temporary_dirs();
-}
-
-/**
- * Destructor
- */
-ImportDialog::~ImportDialog()
-{
- // free the global variables that may have been allocated by the parser
- xmlCleanupParser();
-}
-
-/**
- * Get the file extension type that was selected by the user. Valid after an [OK]
- */
-Inkscape::Extension::Extension *
-ImportDialog::get_selection_type()
-{
- return extension;
-}
-
-ImportDialog::type_signal_response ImportDialog::signal_response()
-{
- return m_signal_response;
-}
-
-
-} //namespace OCAL
-} //namespace Dialog
-} //namespace UI
-} //namespace Inkscape
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
deleted file mode 100644
index 8d2694095..000000000
--- a/src/ui/dialog/ocaldialogs.h
+++ /dev/null
@@ -1,500 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/** @file
- * @brief Open Clip Art Library integration dialogs
- */
-/* Authors:
- * Bruno Dilly <bruno.dilly@gmail.com>
- * Inkscape Guys
- * Andrew Higginson
- *
- * Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#ifndef __OCAL_DIALOG_H__
-#define __OCAL_DIALOG_H__
-
-// Gtkmm includes
-#include <gtkmm/box.h>
-#include <gtkmm/eventbox.h>
-#include <gtkmm/listviewtext.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/searchentry.h>
-#include <gtkmm/window.h>
-
-#include <cairomm/refptr.h>
-
-#include <giomm/file.h>
-
-//Inkscape includes
-#include "ui/dialog/filedialog.h"
-#include "ui/dialog-events.h"
-
-struct _xmlNode;
-typedef _xmlNode xmlNode;
-
-namespace Gtk {
-class Notebook;
-class Spinner;
-}
-
-namespace Inkscape
-{
-namespace UI
-{
-namespace Dialog
-{
-
-class SVGPreview;
-
-namespace OCAL
-{
-/*#########################################################################
-### F I L E D I A L O G O C A L B A S E C L A S S
-#########################################################################*/
-
-/**
- * This class is the base implementation for export to OCAL.
- */
-class FileDialogBase : public Gtk::Window
-{
-public:
-
- /**
- * Constructor
- */
- FileDialogBase(const Glib::ustring &title, Gtk::Window& /*parent*/) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
- {
- set_title(title);
- sp_transientize(GTK_WIDGET(gobj()));
-
- // Allow shrinking of window so labels wrap correctly
- set_resizable(true);
-
- Gdk::Geometry geom;
- geom.min_width = 480;
- geom.min_height = 320;
-
- set_geometry_hints(*this, geom, Gdk::HINT_MIN_SIZE);
- }
-
- /*
- * Destructor
- */
- ~FileDialogBase() override
- = default;
-
-protected:
- void cleanup( bool showConfirmed );
-
- /**
- * What type of 'open' are we? (open, import, place, etc)
- */
- FileDialogType dialogType;
-};
-
-
-
-
-//########################################################################
-//# F I L E E X P O R T T O O C A L
-//########################################################################
-
-
-/**
- * Our implementation of the ExportDialog interface.
- */
-/*
-class ExportDialog : public FileDialogBase
-{
-
-public:
-*/
- /**
- * Constructor
- * @param fileTypes one of FileDialogTypes
- * @param title the title of the dialog
- * @param key a list of file types from which the user can select
- */
-/*
- ExportDialog(Gtk::Window& parentWindow,
- FileDialogType fileTypes,
- const Glib::ustring &title);
-*/
- /**
- * Destructor.
- * Perform any necessary cleanups.
- */
-/*
- ~ExportDialog();
-*/
- /**
- * Show an SaveAs file selector.
- * @return the selected path if user selected one, else NULL
- */
-/*
- bool show();
-
- Glib::ustring getFilename();
-
- Glib::ustring myFilename;
-*/
- /**
- * Change the window title.
- */
-/*
- void change_title(const Glib::ustring& title);
-
-private:
-*/
- /**
- * Fix to allow the user to type the file name
- */
-/*
- Gtk::Entry *fileNameEntry;
-*/
- /**
- * Data mirror of the combo box
- */
-/*
- std::vector<FileType> fileTypes;
-
- // Child widgets
- Gtk::HBox childBox;
- Gtk::VBox checksBox;
- Gtk::HBox fileBox;
-*/
- /**
- * The extension to use to write this file
- */
-/*
- Inkscape::Extension::Extension *extension;
-*/
- /**
- * Callback for user input into fileNameEntry
- */
-/*
- void fileNameEntryChangedCallback();
-*/
- /**
- * List of known file extensions.
- */
-/*
- std::set<Glib::ustring> knownExtensions;
-
-}; //ExportDialog
-*/
-
-//########################################################################
-//# F I L E E X P O R T T O O C A L P A S S W O R D
-//########################################################################
-
-
-/**
- * Our implementation of the ExportPasswordDialog interface.
- */
-/*
-class ExportPasswordDialog : public FileDialogBase
-{
-
-public:
-*/
- /**
- * Constructor
- * @param title the title of the dialog
- */
-/*
- ExportPasswordDialog(Gtk::Window& parentWindow,
- const Glib::ustring &title);
-*/
- /**
- * Destructor.
- * Perform any necessary cleanups.
- */
-/*
- ~ExportPasswordDialog();
-*/
-
- /**
- * Show 2 entry to input username and password.
- */
-/*
- bool show();
-
- Glib::ustring getUsername();
- Glib::ustring getPassword();
-*/
- /**
- * Change the window title.
- */
-/*
- void change_title(const Glib::ustring& title);
-
- Glib::ustring myUsername;
- Glib::ustring myPassword;
-
-private:
-*/
- /**
- * Fix to allow the user to type the file name
- */
-/*
- Gtk::Entry *usernameEntry;
- Gtk::Entry *passwordEntry;
-
- // Child widgets
- Gtk::VBox entriesBox;
- Gtk::HBox userBox;
- Gtk::HBox passBox;
-
-}; //ExportPasswordDialog
-*/
-
-
-//#########################################################################
-//### F I L E I M P O R T F R O M O C A L
-//#########################################################################
-
-class WrapLabel : public Gtk::Label
-{
-public:
- WrapLabel();
-
-private:
- void _on_size_allocate(Gtk::Allocation& allocation);
-};
-
-class LoadingBox : public Gtk::EventBox
-{
-public:
- LoadingBox();
-
- void start();
- void stop();
-
-private:
- unsigned int spinner_step;
- sigc::connection timeout;
- bool draw_spinner;
-
- bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
- bool on_timeout();
-};
-
-class PreviewWidget : public Gtk::VBox
-{
-public:
- PreviewWidget();
-
- void set_metadata(Glib::ustring description, Glib::ustring creator, Glib::ustring time);
- void show_box_loading();
- void hide_box_loading();
- void set_image(std::string path);
- void clear();
-
-private:
- LoadingBox* box_loading;
- Gtk::Image* image;
-
- WrapLabel* label_title;
- WrapLabel* label_description;
- WrapLabel* label_time;
-
- bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
-};
-
-/**
- * A Widget that contains an status icon and a message
- */
-class StatusWidget : public Gtk::HBox
-{
-public:
- StatusWidget();
-
- void clear();
- void set_error(Glib::ustring text);
- void set_info(Glib::ustring text);
- void start_process(Glib::ustring text);
- void end_process();
-
- Gtk::Spinner* spinner;
- Gtk::Image* image;
- Gtk::Label* label;
-};
-
-/**
- * A box which paints an overlay of the OCAL logo
- */
-class LogoArea : public Gtk::EventBox
-{
-public:
- LogoArea();
-private:
- bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
- bool draw_logo;
- Cairo::RefPtr<Cairo::ImageSurface> logo_mask;
-};
-
-/**
- * A box filled with the Base colour from the user's GTK theme, and a border
- */
-class BaseBox : public Gtk::EventBox
-{
-public:
- BaseBox();
-private:
- bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
-};
-
-enum {
- RESULTS_COLUMN_MARKUP,
- RESULTS_COLUMN_TITLE,
- RESULTS_COLUMN_DESCRIPTION,
- RESULTS_COLUMN_CREATOR,
- RESULTS_COLUMN_DATE,
- RESULTS_COLUMN_FILENAME,
- RESULTS_COLUMN_THUMBNAIL_FILENAME,
- RESULTS_COLUMN_URL,
- RESULTS_COLUMN_THUMBNAIL_URL,
- RESULTS_COLUMN_GUID,
- RESULTS_COLUMN_LENGTH,
-};
-
-enum {
- NOTEBOOK_PAGE_LOGO,
- NOTEBOOK_PAGE_RESULTS,
- NOTEBOOK_PAGE_NOT_FOUND,
-};
-
-enum ResourceType {
- TYPE_THUMBNAIL,
- TYPE_IMAGE,
-};
-
-/**
- * The TreeView which holds the search results
- */
-class SearchResultList : public Gtk::ListViewText
-{
-public:
- SearchResultList(guint columns_count);
- void populate_from_xml(xmlNode* a_node);
-};
-
-/**
- * The Import Dialog
- */
-class ImportDialog : public FileDialogBase
-{
-public:
- /**
- * Constructor
- * @param path the directory where to start searching
- * @param fileTypes one of FileDialogTypes
- * @param title the title of the dialog
- */
- ImportDialog(Gtk::Window& parent_window, FileDialogType file_types,
- const Glib::ustring &title);
-
- /**
- * Destructor.
- * Perform any necessary cleanups.
- */
- ~ImportDialog() override;
-
- /**
- * Show an OpenFile file selector.
- * @return the selected path if user selected one, else NULL
- */
- bool show();
-
- /**
- * Return the 'key' (filetype) of the selection, if any
- * @return a pointer to a string if successful (which must
- * be later freed with g_free(), else NULL.
- */
- Inkscape::Extension::Extension *get_selection_type();
-
- typedef sigc::signal<void, Glib::ustring> type_signal_response;
- type_signal_response signal_response();
-
-protected:
- type_signal_response m_signal_response;
-
-private:
- Glib::ustring filename_image;
- Glib::ustring filename_thumbnail;
- Gtk::SearchEntry *entry_search;
-
- LogoArea *drawingarea_logo;
- SearchResultList *list_results;
- PreviewWidget *preview_files;
- Gtk::Label *label_not_found;
- Gtk::Label *label_description;
- Gtk::Button *button_search;
- Gtk::Button *button_import;
- Gtk::Button *button_close;
- Gtk::Button *button_cancel;
- StatusWidget *widget_status;
-
- // Child widgets
- Gtk::Notebook *notebook_content;
- Gtk::HBox hbox_tags;
- Gtk::HBox hbox_files;
- Gtk::ScrolledWindow scrolledwindow_list;
- Glib::RefPtr<Gtk::TreeSelection> selection;
-
- Glib::RefPtr<Gio::Cancellable> cancellable_image;
- Glib::RefPtr<Gio::Cancellable> cancellable_thumbnail;
- bool downloading_thumbnail;
- bool cancelled_thumbnail;
- bool cancelled_image;
-
- void update_label_no_search_results();
- void update_preview(int row);
- void on_list_results_cursor_changed();
-
- void download_resource(ResourceType type, int row);
- void on_resource_downloaded(const Glib::RefPtr<Gio::AsyncResult>& result,
- Glib::RefPtr<Gio::File> file_remote, Glib::ustring path, ResourceType resource);
- void on_image_downloaded(Glib::ustring path, bool success);
- void on_thumbnail_downloaded(Glib::ustring path, bool success);
- void on_list_results_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
- void on_button_import_clicked();
- void on_button_close_clicked();
- void on_button_cancel_clicked();
- void on_button_search_clicked();
- void on_entry_search_activated();
- void on_list_results_selection_changed();
- void on_xml_file_read(const Glib::RefPtr<Gio::AsyncResult>& result,
- Glib::RefPtr<Gio::File> xml_file, Glib::ustring xml_uri);
- void create_temporary_dirs();
- std::string get_temporary_dir(ResourceType type);
-
-
- /**
- * The extension to use to write this file
- */
- Inkscape::Extension::Extension *extension;
-
-}; //ImportDialog
-
-
-} //namespace OCAL
-} //namespace Dialog
-} //namespace UI
-} //namespace Inkscape
-
-
-#endif /* __OCAL_DIALOG_H__ */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 49ee61aab..63c5295f8 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -874,12 +874,6 @@ void FileVerb::perform(SPAction *action, void *data)
// case SP_VERB_FILE_EXPORT:
// sp_file_export_dialog(*parent);
// 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;
case SP_VERB_FILE_NEXT_DESKTOP:
INKSCAPE.switch_desktops_next();
break;
@@ -2538,10 +2532,6 @@ Verb *Verb::_base_verbs[] = {
N_("Import a bitmap or SVG image into this document"), INKSCAPE_ICON("document-import")),
// new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."), N_("Export this document or a
// selection as a bitmap image"), INKSCAPE_ICON("document-export")),
- new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import Clip Art..."),
- N_("Import clipart from Open Clip Art Library"), INKSCAPE_ICON("document-import-ocal")),
- // new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"),
- // N_("Export this document to Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL),
new FileVerb(SP_VERB_FILE_NEXT_DESKTOP, "NextWindow", N_("N_ext Window"), N_("Switch to the next document window"),
INKSCAPE_ICON("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 67920499d..fe9fc0601 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -56,8 +56,6 @@ enum {
SP_VERB_FILE_VACUUM,
SP_VERB_FILE_IMPORT,
// SP_VERB_FILE_EXPORT,
- 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,