summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-04-08 13:47:33 +0000
committerjabiertxof <info@marker.es>2016-04-08 13:47:33 +0000
commit1106ff9eeb561af9216563e3eb7422088fac4cf5 (patch)
tree8dc88ec1211b985e18c86835196d45e124d8cfe4 /src/extension
parentupdate to trunk (diff)
parentBug #1552765 fixed Break Apart dont handle well stroke with in documents diff... (diff)
downloadinkscape-1106ff9eeb561af9216563e3eb7422088fac4cf5.tar.gz
inkscape-1106ff9eeb561af9216563e3eb7422088fac4cf5.zip
update to trunk
(bzr r13645.1.125)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/document-interface.cpp2
-rw-r--r--src/extension/implementation/implementation.h24
-rw-r--r--src/extension/implementation/script.cpp62
-rw-r--r--src/extension/implementation/script.h45
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/cdr-input.cpp171
-rw-r--r--src/extension/internal/vsd-input.cpp183
-rw-r--r--src/extension/output.cpp3
8 files changed, 237 insertions, 255 deletions
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index d64bdbc5c..121a49a25 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -1,7 +1,7 @@
/*
* This is where the implementation of the DBus based document API lives.
* All the methods in here (except in the helper section) are
- * designed to be called remotly via DBus. application-interface.cpp
+ * designed to be called remotely via DBus. application-interface.cpp
* has the methods used to connect to the bus and get a document instance.
*
* Documentation for these methods is in document-interface.xml
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index f6f933aaf..1232ae0c8 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -18,7 +18,7 @@
#include <2geom/forward.h>
namespace Gtk {
- class Widget;
+ class Widget;
}
class SPDocument;
@@ -33,7 +33,7 @@ class View;
} // namespace UI
namespace XML {
- class Node;
+ class Node;
} // namespace XML
namespace Extension {
@@ -51,18 +51,18 @@ namespace Implementation {
*/
class ImplementationDocumentCache {
- /**
+ /**
* The document that this instance is working on.
*/
- Inkscape::UI::View::View * _view;
+ Inkscape::UI::View::View * _view;
public:
- ImplementationDocumentCache (Inkscape::UI::View::View * view) :
- _view(view)
- {
- return;
- };
- virtual ~ImplementationDocumentCache ( ) { return; };
- Inkscape::UI::View::View const * view ( ) { return _view; };
+ ImplementationDocumentCache (Inkscape::UI::View::View * view) :
+ _view(view)
+ {
+ return;
+ };
+ virtual ~ImplementationDocumentCache ( ) { return; };
+ Inkscape::UI::View::View const * view ( ) { return _view; };
};
/**
@@ -116,7 +116,7 @@ public:
// ----- Effect functions -----
/** Find out information about the file. */
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View *view,
+ Inkscape::UI::View::View *view,
sigc::signal<void> *changeSignal,
ImplementationDocumentCache *docCache);
virtual void effect(Inkscape::Extension::Effect * /*module*/,
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 4cb0c9b73..9aaf4b952 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -152,7 +152,7 @@ Script::Script() :
}
/**
- * brief Destructor
+ * \brief Destructor
*/
Script::~Script()
{
@@ -232,11 +232,7 @@ bool Script::check_existence(const std::string &command)
//Don't search when it is an absolute path. */
if (Glib::path_is_absolute(command)) {
- if (Glib::file_test(command, Glib::FILE_TEST_EXISTS)) {
- return true;
- } else {
- return false;
- }
+ return Glib::file_test(command, Glib::FILE_TEST_EXISTS);
}
// First search in the current directory
@@ -280,9 +276,9 @@ bool Script::check_existence(const std::string &command)
/**
\return none
- \brief This function 'loads' an extention, basically it determines
- the full command for the extention and stores that.
- \param module The extention to be loaded.
+ \brief This function 'loads' an extension, basically it determines
+ the full command for the extension and stores that.
+ \param module The extension to be loaded.
The most difficult part about this function is finding the actual
command through all of the Reprs. Basically it is hidden down a
@@ -292,7 +288,7 @@ bool Script::check_existence(const std::string &command)
At that point all of the loops are exited, and there is an
if statement to make sure they didn't exit because of not finding
- the command. If that's the case, the extention doesn't get loaded
+ the command. If that's the case, the extension doesn't get loaded
and should error out at a higher level.
*/
@@ -545,17 +541,17 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
/**
\return none
- \brief This function uses an extention to save a document. It first
+ \brief This function uses an extension to save a document. It first
creates an SVG file of the document, and then runs it through
the script.
- \param module Extention to be used
+ \param module Extension to be used
\param doc Document to be saved
\param filename The name to save the final file as
\return false in case of any failure writing the file, otherwise true
Well, at some point people need to save - it is really what makes
the entire application useful. And, it is possible that someone
- would want to use an extetion for this, so we need a function to
+ would want to use an extension for this, so we need a function to
do that eh?
First things first, the document is saved to a temporary file that
@@ -563,7 +559,7 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
ink_ext_ as a prefix. Don't worry, this file gets deleted at the
end of the function.
- After we have the SVG file, then extention_execute is called with
+ After we have the SVG file, then Script::execute is called with
the temporary file name and the final output filename. This should
put the output of the script into the final output file. We then
delete the temporary file.
@@ -1123,7 +1119,45 @@ int Script::execute (const std::list<std::string> &in_command,
}
+void Script::file_listener::init(int fd, Glib::RefPtr<Glib::MainLoop> main) {
+ _channel = Glib::IOChannel::create_from_fd(fd);
+ _channel->set_encoding();
+ _conn = main->get_context()->signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
+ _main_loop = main;
+
+ return;
+}
+bool Script::file_listener::read(Glib::IOCondition condition) {
+ if (condition != Glib::IO_IN) {
+ _main_loop->quit();
+ return false;
+ }
+
+ Glib::IOStatus status;
+ Glib::ustring out;
+ status = _channel->read_line(out);
+ _string += out;
+
+ if (status != Glib::IO_STATUS_NORMAL) {
+ _main_loop->quit();
+ _dead = true;
+ return false;
+ }
+
+ return true;
+}
+
+bool Script::file_listener::toFile(const Glib::ustring &name) {
+ try {
+ Glib::RefPtr<Glib::IOChannel> stdout_file = Glib::IOChannel::create_from_file(name, "w");
+ stdout_file->set_encoding();
+ stdout_file->write(_string);
+ } catch (Glib::FileError &e) {
+ return false;
+ }
+ return true;
+}
} // namespace Implementation
} // namespace Extension
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 4cf33c989..684719895 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -85,49 +85,10 @@ private:
};
bool isDead () { return _dead; }
-
- // TODO move these definitions into script.cpp
- void init (int fd, Glib::RefPtr<Glib::MainLoop> main) {
- _channel = Glib::IOChannel::create_from_fd(fd);
- _channel->set_encoding();
- _conn = main->get_context()->signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
- _main_loop = main;
-
- return;
- };
-
- bool read (Glib::IOCondition condition) {
- if (condition != Glib::IO_IN) {
- _main_loop->quit();
- return false;
- }
-
- Glib::IOStatus status;
- Glib::ustring out;
- status = _channel->read_line(out);
- _string += out;
-
- if (status != Glib::IO_STATUS_NORMAL) {
- _main_loop->quit();
- _dead = true;
- return false;
- }
-
- return true;
- };
-
+ void init(int fd, Glib::RefPtr<Glib::MainLoop> main);
+ bool read(Glib::IOCondition condition);
Glib::ustring string (void) { return _string; };
-
- bool toFile (const Glib::ustring &name) {
- try {
- Glib::RefPtr<Glib::IOChannel> stdout_file = Glib::IOChannel::create_from_file(name, "w");
- stdout_file->set_encoding();
- stdout_file->write(_string);
- } catch (Glib::FileError &e) {
- return false;
- }
- return true;
- };
+ bool toFile(const Glib::ustring &name);
};
int execute (const std::list<std::string> &in_command,
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index c16a5a899..af7af2cb1 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -1,6 +1,6 @@
/*
* This is what gets executed to initialize all of the modules. For
- * the internal modules this invovles executing their initialization
+ * the internal modules this involves executing their initialization
* functions, for external ones it involves reading their .spmodule
* files and bringing them into Sodipodi.
*
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index f4789a08f..a26af2078 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -41,28 +41,18 @@
#endif
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
#include "util/units.h"
@@ -82,108 +72,99 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
CdrImportDialog::~CdrImportDialog() {}
@@ -193,7 +174,7 @@ bool CdrImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -209,22 +190,34 @@ void CdrImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void CdrImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void CdrImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void CdrImportDialog::_setPreviewPage(unsigned page)
+void CdrImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 7fd0d363b..a3d4aad37 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -40,33 +40,24 @@
typedef libvisio::VSDStringVector RVNGStringVector;
#endif
-
#include <gtkmm/alignment.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scale.h>
+#include <gtkmm/spinbutton.h>
#include "extension/system.h"
#include "extension/input.h"
-#include "document.h"
+#include "document.h"
#include "document-private.h"
-#include "document-undo.h"
#include "inkscape.h"
-#include "util/units.h"
#include "ui/dialog-events.h"
-#include <gtk/gtk.h>
-#include "ui/widget/spinbutton.h"
-#include "ui/widget/frame.h"
#include <glibmm/i18n.h>
-#include <gdkmm/general.h>
-
-#include "svg-view.h"
#include "svg-view-widget.h"
+
+#include "util/units.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -82,108 +73,101 @@ public:
void getImportSettings(Inkscape::XML::Node *prefs);
private:
- void _setPreviewPage(unsigned page);
+ void _setPreviewPage();
// Signal handlers
-#if !WITH_GTKMM_3_0
- bool _onExposePreview(GdkEventExpose *event);
-#endif
-
void _onPageNumberChanged();
+ void _onSpinButtonPress(GdkEventButton* button_event);
+ void _onSpinButtonRelease(GdkEventButton* button_event);
+ class Gtk::VBox * vbox1;
+ class Gtk::Widget * _previewArea;
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
- class Gtk::VBox * vbox1;
- class Gtk::VBox * vbox2;
- class Gtk::Widget * _previewArea;
+ class Gtk::SpinButton * _pageNumberSpin;
- const std::vector<RVNGString> &_vec; // Document to be imported
- unsigned _current_page; // Current selected page
- int _preview_width, _preview_height; // Size of the preview area
+ const std::vector<RVNGString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ bool _spinning; // whether SpinButton is pressed (i.e. we're "spinning")
};
VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec)
- : _vec(vec), _current_page(1)
+ : _vec(vec), _current_page(1), _spinning(false)
{
int num_pages = _vec.size();
if ( num_pages <= 1 )
return;
- cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- // Page number
+
+ // Dialog settings
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+
+ // Preview area
+ _previewArea = Gtk::manage(new class Gtk::VBox());
+ vbox1 = Gtk::manage(new class Gtk::VBox());
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+ this->get_content_area()->pack_start(*vbox1);
#else
- Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ this->get_vbox()->pack_start(*vbox1);
#endif
- _labelTotalPages = Gtk::manage(new class Gtk::Label());
- gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- _labelTotalPages->set_label(label_text);
- g_free(label_text);
- vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
-
- vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- cancelbutton->set_can_focus();
- cancelbutton->set_can_default();
- cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- okbutton->set_can_focus();
- okbutton->set_can_default();
- okbutton->set_relief(Gtk::RELIEF_NORMAL);
- this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+
+ // CONTROLS
+
+ // Buttons
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+
+ // Labels
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
- _pageNumberSpin->set_can_focus();
- _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- _pageNumberSpin->set_numeric(true);
- _pageNumberSpin->set_digits(0);
- _pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ // Adjustment + spinner
#if WITH_GTKMM_3_0
- this->get_content_area()->set_homogeneous(false);
- this->get_content_area()->set_spacing(0);
- this->get_content_area()->pack_start(*vbox2);
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0));
#else
- this->get_vbox()->set_homogeneous(false);
- this->get_vbox()->set_spacing(0);
- this->get_vbox()->pack_start(*vbox2);
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0));
#endif
- this->set_title(_("Page Selector"));
- this->set_modal(true);
- sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
- this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- this->set_resizable(true);
- this->property_destroy_with_parent().set_value(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_wrap(false);
+
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
this->get_action_area()->add(*_labelSelect);
- this->add_action_widget(*_pageNumberSpin, -7);
+ this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT);
this->get_action_area()->add(*_labelTotalPages);
- this->add_action_widget(*cancelbutton, -6);
- this->add_action_widget(*okbutton, -5);
- cancelbutton->show();
- okbutton->show();
- _labelSelect->show();
- _pageNumberSpin->show();
- _labelTotalPages->show();
- vbox1->show();
- _previewArea->show();
- vbox2->show();
+ this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL);
+ this->add_action_widget(*okbutton, Gtk::RESPONSE_OK);
+
+ // Show all widgets in dialog
+ this->show_all();
// Connect signals
- _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+ _pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonPress));
+ _pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonRelease));
+
+ _setPreviewPage();
}
VsdImportDialog::~VsdImportDialog() {}
@@ -193,7 +177,7 @@ bool VsdImportDialog::showDialog()
show();
gint b = run();
hide();
- if ( b == Gtk::RESPONSE_OK ) {
+ if (b == Gtk::RESPONSE_OK || b == Gtk::RESPONSE_ACCEPT) {
return TRUE;
} else {
return FALSE;
@@ -209,22 +193,34 @@ void VsdImportDialog::_onPageNumberChanged()
{
unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
_current_page = CLAMP(page, 1U, _vec.size());
- _setPreviewPage(_current_page);
+ _setPreviewPage();
+}
+
+void VsdImportDialog::_onSpinButtonPress(GdkEventButton* /*button_event*/)
+{
+ _spinning = true;
+}
+
+void VsdImportDialog::_onSpinButtonRelease(GdkEventButton* /*button_event*/)
+{
+ _spinning = false;
+ _setPreviewPage();
}
/**
* \brief Renders the given page's thumbnail
*/
-void VsdImportDialog::_setPreviewPage(unsigned page)
+void VsdImportDialog::_setPreviewPage()
{
- SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ if (_spinning) {
+ return;
+ }
+
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
std::swap(_previewArea, tmpPreviewArea);
- if (tmpPreviewArea) {
- _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- delete tmpPreviewArea;
- }
- vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ delete tmpPreviewArea;
+ vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0);
_previewArea->show_now();
}
@@ -282,12 +278,11 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
-
+
// Set viewBox if it doesn't exist
- if (!doc->getRoot()->viewBox_set) {
+ if (doc && !doc->getRoot()->viewBox_set) {
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
}
-
return doc;
}
diff --git a/src/extension/output.cpp b/src/extension/output.cpp
index 8de5583c7..83f0fed2f 100644
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
@@ -192,8 +192,7 @@ Output::prefs (void)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
/**