From c5f6ddd9b268dd6b5165a2353ee1a893075da91a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 18:56:35 +0200 Subject: Inkview: Fix loading files with non-ASCII characters in filename Fixed bugs: - https://launchpad.net/bugs/488997 (bzr r15690.1.1) --- src/inkview.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index b52d69825..1848cccd3 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -31,7 +31,6 @@ #endif #include -#include #include @@ -53,6 +52,8 @@ #include "document.h" #include "svg-view.h" #include "svg-view-widget.h" + +#include "io/sys.h" #include "util/units.h" #ifdef ENABLE_NLS #include "helper/gettext.h" @@ -289,10 +290,8 @@ int main (int argc, char **argv) for(auto file : filenames) { - struct stat st; - if (stat(file.c_str(), &st) - || !S_ISREG (st.st_mode) - || (st.st_size < 64)) { + if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) + { std::cerr << "could not open file " << file << std::endl; } else { auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); -- cgit v1.2.3 From 8c9ccd06ff0c11ec7728775ebedc4247d4e41234 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 19:21:17 +0200 Subject: Inkview: Print error in correct encoding. (bzr r15690.1.2) --- src/inkview.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 1848cccd3..3cca34d6c 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -246,10 +246,8 @@ private: #ifdef WIN32 // minimal print handler (just prints the string to stdout) -void g_print_no_convert(const gchar *buf) -{ - fputs(buf, stdout); -} +void g_print_no_convert(const gchar *buf) { fputs(buf, stdout); } +void g_printerr_no_convert(const gchar *buf) { fputs(buf, stderr); } #endif int main (int argc, char **argv) @@ -258,6 +256,7 @@ int main (int argc, char **argv) // Ugly hack to make g_print emit UTF-8 encoded characters. Otherwise glib will *always* // perform character conversion to the system's ANSI code page making UTF-8 output impossible. g_set_print_handler(g_print_no_convert); + g_set_printerr_handler(g_print_no_convert); #endif #ifdef ENABLE_NLS Inkscape::initialize_gettext(); @@ -290,9 +289,8 @@ int main (int argc, char **argv) for(auto file : filenames) { - if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) - { - std::cerr << "could not open file " << file << std::endl; + if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { + g_printerr("File does not exist: %s\n", file.c_str()); } else { auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); -- cgit v1.2.3 From d6170f0d771ce86df57dc90c9c9ac4d6f8845c7d Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 21:06:24 +0200 Subject: Inkview: Put checking for valid files in separate function (bzr r15690.1.3) --- src/inkview.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 3cca34d6c..0358fe917 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -244,6 +244,29 @@ private: }; +/** get a list of valid SVG files from a list of strings */ +std::vector get_valid_files(std::vector filenames) +{ + std::vector valid_files; + + for(auto file : filenames) + { + if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { + g_printerr("File does not exist: %s\n", file.c_str()); + } else { + auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); + + if(doc) + { + /* Append to list */ + valid_files.push_back(file); + } + } + } + + return valid_files; +} + #ifdef WIN32 // minimal print handler (just prints the string to stdout) void g_print_no_convert(const gchar *buf) { fputs(buf, stdout); } @@ -285,23 +308,7 @@ int main (int argc, char **argv) exit(EXIT_FAILURE); } - std::vector valid_files; - - for(auto file : filenames) - { - if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { - g_printerr("File does not exist: %s\n", file.c_str()); - } else { - auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); - - if(doc) - { - /* Append to list */ - valid_files.push_back(file); - } - } - } - + std::vector valid_files = get_valid_files(filenames); if(valid_files.empty()) { return 1; /* none of the slides loadable */ } -- cgit v1.2.3 From 5725bbcbd308cd7341da49947484dcce7df9eeb4 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 22:40:24 +0200 Subject: Inkview: Support folders as input. All .svg and .svgz files contained in the specified folder(s) will be opened. Note: Currently this is done non-recursively, but a command line option to make this recursive could be easily added in future (see "recursive" parameter of "get_valid_files()" function). (bzr r15690.1.4) --- src/inkview.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 0358fe917..f41e36cb1 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -46,8 +46,8 @@ #include "inkgc/gc-core.h" #include "preferences.h" +#include #include -#include #include "document.h" #include "svg-view.h" @@ -245,21 +245,36 @@ private: /** get a list of valid SVG files from a list of strings */ -std::vector get_valid_files(std::vector filenames) +std::vector get_valid_files(std::vector filenames, bool recursive = false) { std::vector valid_files; for(auto file : filenames) { if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { - g_printerr("File does not exist: %s\n", file.c_str()); + g_printerr("%s: %s\n", _("File or folder does not exist"), file.c_str()); } else { - auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); + if (Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_IS_DIR )) { + if (recursive) { + std::vector new_filenames; + Glib::Dir directory(file); + for (auto new_file: directory) { + Glib::ustring extension = new_file.substr( new_file.find_last_of(".") + 1 ); + if (!extension.compare("svg") || !extension.compare("svgz")) { + new_filenames.push_back(Glib::build_filename(file, new_file)); + } + } + std::vector new_files = get_valid_files(new_filenames); + valid_files.insert(valid_files.end(), new_files.begin(), new_files.end()); + } + } else { + auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); - if(doc) - { - /* Append to list */ - valid_files.push_back(file); + if(doc) + { + /* Append to list */ + valid_files.push_back(file); + } } } } @@ -308,7 +323,7 @@ int main (int argc, char **argv) exit(EXIT_FAILURE); } - std::vector valid_files = get_valid_files(filenames); + std::vector valid_files = get_valid_files(filenames, true); if(valid_files.empty()) { return 1; /* none of the slides loadable */ } -- cgit v1.2.3 From 1fead914d382ed1173d8bc4941c8ed270fe95b08 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 23:01:29 +0200 Subject: Inkview: Print warning if a file failed to load. (bzr r15690.1.5) --- src/inkview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index f41e36cb1..5ba896a40 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -269,11 +269,11 @@ std::vector get_valid_files(std::vector filenames, } } else { auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); - - if(doc) - { + if(doc) { /* Append to list */ valid_files.push_back(file); + } else { + g_printerr("%s: %s\n", _("Could not open file"), file.c_str()); } } } -- cgit v1.2.3 From b22b1218a3b22272e5c223959272fd22bb477548 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 23:16:17 +0200 Subject: Inkview: Show number of current slide and total number of slides in title (bzr r15690.1.6) --- src/inkview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 5ba896a40..897ecb3fb 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -93,7 +93,12 @@ public: /// Update the window title with current document name void update_title() { - set_title(_doc->getName()); + Glib::ustring title(_doc->getName()); + if (_slides.size() > 1) { + title += Glib::ustring::compose(" (%1/%2)", _current+1, _slides.size()); + } + + set_title(title); } SPSlideShow(std::vector const &slides); -- cgit v1.2.3 From b2280a117695f1205e549066f9a459b26cf89f8d Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 13 May 2017 23:27:16 +0200 Subject: Inkview: Title was not updated when using controls in control window. (bzr r15690.1.7) --- src/inkview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 897ecb3fb..f39dd4cf4 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -205,7 +205,6 @@ static int sp_svgview_main_key_press (GtkWidget */*widget*/, break; } - ss->update_title(); return TRUE; } @@ -429,6 +428,7 @@ void SPSlideShow::set_document(SPDocument *doc, reinterpret_cast(SP_VIEW_WIDGET_VIEW (_view))->setDocument (doc); _doc = doc; _current = current; + update_title(); } } -- cgit v1.2.3 From 030f2f1ebd1f776b45576079a1a4c2768553873a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 02:12:38 +0200 Subject: Inkview: Refactoring - move SPSlideShow to separate source file (bzr r15690.1.8) --- src/CMakeLists.txt | 2 + src/inkview.cpp | 330 +-------------------------------------------- src/svg-view-slideshow.cpp | 300 +++++++++++++++++++++++++++++++++++++++++ src/svg-view-slideshow.h | 91 +++++++++++++ 4 files changed, 398 insertions(+), 325 deletions(-) create mode 100644 src/svg-view-slideshow.cpp create mode 100644 src/svg-view-slideshow.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25a42a4a0..abe6c9758 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -260,6 +260,7 @@ set(inkscape_SRC snapper.cpp style-internal.cpp style.cpp + svg-view-slideshow.cpp svg-view-widget.cpp svg-view.cpp text-chemistry.cpp @@ -390,6 +391,7 @@ set(inkscape_SRC style-internal.h style.h svg-profile.h + svg-view-slideshow.h svg-view-widget.h svg-view.h syseq.h diff --git a/src/inkview.cpp b/src/inkview.cpp index f39dd4cf4..abb690619 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -25,188 +25,29 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include - - #include -#include -#include -#include #include #include -#include - -#include "inkgc/gc-core.h" -#include "preferences.h" #include #include #include "document.h" -#include "svg-view.h" -#include "svg-view-widget.h" - -#include "io/sys.h" -#include "util/units.h" +#include "inkscape.h" +#include "preferences.h" #ifdef ENABLE_NLS #include "helper/gettext.h" #endif +#include "inkgc/gc-core.h" +#include "io/sys.h" +#include "svg-view-slideshow.h" -#include "inkscape.h" - -#include "ui/icon-names.h" - -class SPSlideShow; - -static int sp_svgview_main_delete (GtkWidget *widget, - GdkEvent *event, - struct SPSlideShow *ss); - -static int sp_svgview_main_key_press (GtkWidget *widget, - GdkEventKey *event, - struct SPSlideShow *ss); - -/** - * The main application window for the slideshow - */ -class SPSlideShow : public Gtk::ApplicationWindow { -private: - std::vector _slides; ///< List of filenames for each slide - int _current; ///< Index of the currently displayed slide - SPDocument *_doc; ///< The currently displayed slide - int _timer; - GtkWidget *_view; - Gtk::Window *_ctrlwin; ///< Window containing slideshow control buttons - -public: - /// Current state of application (full-screen or windowed) - bool is_fullscreen; - - /// Update the window title with current document name - void update_title() - { - Glib::ustring title(_doc->getName()); - if (_slides.size() > 1) { - title += Glib::ustring::compose(" (%1/%2)", _current+1, _slides.size()); - } - - set_title(title); - } - - SPSlideShow(std::vector const &slides); - - void set_timer(int timer) {_timer = timer;} - void control_show(); - void show_next(); - void show_prev(); - void goto_first(); - void goto_last(); - - static int ctrlwin_delete (GtkWidget *widget, - GdkEvent *event, - void *data); -protected: - void waiting_cursor(); - void normal_cursor(); - void set_document(SPDocument *doc, - int current); -}; - -SPSlideShow::SPSlideShow(std::vector const &slides) - : - _slides(slides), - _current(0), - _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)), - _view(NULL), - is_fullscreen(false), - _timer(0), - _ctrlwin(NULL) -{ - update_title(); - - auto default_screen = Gdk::Screen::get_default(); - - set_default_size(MIN ((int)_doc->getWidth().value("px"), default_screen->get_width() - 64), - MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); - - g_signal_connect (G_OBJECT (gobj()), "delete_event", (GCallback) sp_svgview_main_delete, this); - g_signal_connect (G_OBJECT (gobj()), "key_press_event", (GCallback) sp_svgview_main_key_press, this); - - _doc->ensureUpToDate(); - _view = sp_svg_view_widget_new (_doc); - _doc->doUnref (); - SP_SVG_VIEW_WIDGET(_view)->setResize( false, _doc->getWidth().value("px"), _doc->getHeight().value("px") ); - gtk_widget_show (_view); - add(*Glib::wrap(_view)); - - show(); -} - - -static int sp_svgview_main_delete (GtkWidget */*widget*/, - GdkEvent */*event*/, - struct SPSlideShow */*ss*/) -{ - Gtk::Main::quit(); - return FALSE; -} - -static int sp_svgview_main_key_press (GtkWidget */*widget*/, - GdkEventKey *event, - struct SPSlideShow *ss) -{ - switch (event->keyval) { - case GDK_KEY_Up: - case GDK_KEY_Home: - ss->goto_first(); - break; - case GDK_KEY_Down: - case GDK_KEY_End: - ss->goto_last(); - break; - case GDK_KEY_F11: - if (ss->is_fullscreen) { - ss->unfullscreen(); - ss->is_fullscreen = false; - } else { - ss->fullscreen(); - ss->is_fullscreen = true; - } - break; - case GDK_KEY_Return: - ss->control_show(); - break; - case GDK_KEY_KP_Page_Down: - case GDK_KEY_Page_Down: - case GDK_KEY_Right: - case GDK_KEY_space: - ss->show_next(); - break; - case GDK_KEY_KP_Page_Up: - case GDK_KEY_Page_Up: - case GDK_KEY_Left: - case GDK_KEY_BackSpace: - ss->show_prev(); - break; - case GDK_KEY_Escape: - case GDK_KEY_q: - case GDK_KEY_Q: - Gtk::Main::quit(); - break; - default: - break; - } - - return TRUE; -} /// List of all input filenames static Glib::OptionGroup::vecustrings filenames; @@ -339,167 +180,6 @@ int main (int argc, char **argv) return 0; } -int SPSlideShow::ctrlwin_delete (GtkWidget */*widget*/, - GdkEvent */*event*/, - void *data) -{ - auto ss = reinterpret_cast(data); - if(ss->_ctrlwin) delete ss->_ctrlwin; - - ss->_ctrlwin = NULL; - return FALSE; -} - -/** - * @brief Show the control buttons (next, previous etc) for the application - */ -void SPSlideShow::control_show() -{ - if (!_ctrlwin) { - _ctrlwin = new Gtk::Window(); - _ctrlwin->set_resizable(false); - _ctrlwin->set_transient_for(*this); - g_signal_connect(G_OBJECT (_ctrlwin->gobj()), "key_press_event", (GCallback) sp_svgview_main_key_press, this); - g_signal_connect(G_OBJECT (_ctrlwin->gobj()), "delete_event", (GCallback) SPSlideShow::ctrlwin_delete, this); - auto t = Gtk::manage(new Gtk::ButtonBox()); - _ctrlwin->add(*t); - - auto btn_go_first = Gtk::manage(new Gtk::Button()); - auto img_go_first = Gtk::manage(new Gtk::Image()); - img_go_first->set_from_icon_name(INKSCAPE_ICON("go-first"), Gtk::ICON_SIZE_BUTTON); - btn_go_first->set_image(*img_go_first); - t->add(*btn_go_first); - btn_go_first->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_first)); - - auto btn_go_prev = Gtk::manage(new Gtk::Button()); - auto img_go_prev = Gtk::manage(new Gtk::Image()); - img_go_prev->set_from_icon_name(INKSCAPE_ICON("go-previous"), Gtk::ICON_SIZE_BUTTON); - btn_go_prev->set_image(*img_go_prev); - t->add(*btn_go_prev); - btn_go_prev->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_prev)); - - auto btn_go_next = Gtk::manage(new Gtk::Button()); - auto img_go_next = Gtk::manage(new Gtk::Image()); - img_go_next->set_from_icon_name(INKSCAPE_ICON("go-next"), Gtk::ICON_SIZE_BUTTON); - btn_go_next->set_image(*img_go_next); - t->add(*btn_go_next); - btn_go_next->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_next)); - - auto btn_go_last = Gtk::manage(new Gtk::Button()); - auto img_go_last = Gtk::manage(new Gtk::Image()); - img_go_last->set_from_icon_name(INKSCAPE_ICON("go-last"), Gtk::ICON_SIZE_BUTTON); - btn_go_last->set_image(*img_go_last); - t->add(*btn_go_last); - btn_go_last->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_last)); - - _ctrlwin->show_all(); - } else { - _ctrlwin->present(); - } -} - -void SPSlideShow::waiting_cursor() -{ - auto display = Gdk::Display::get_default(); - auto waiting = Gdk::Cursor::create(display, Gdk::WATCH); - get_window()->set_cursor(waiting); - - if (_ctrlwin) { - _ctrlwin->get_window()->set_cursor(waiting); - } - while(Gtk::Main::events_pending()) { - Gtk::Main::iteration(); - } -} - -void SPSlideShow::normal_cursor() -{ - get_window()->set_cursor(); - if (_ctrlwin) { - _ctrlwin->get_window()->set_cursor(); - } -} - -void SPSlideShow::set_document(SPDocument *doc, - int current) -{ - if (doc && doc != _doc) { - doc->ensureUpToDate(); - reinterpret_cast(SP_VIEW_WIDGET_VIEW (_view))->setDocument (doc); - _doc = doc; - _current = current; - update_title(); - } -} - -/** - * @brief Show the next file in the slideshow - */ -void SPSlideShow::show_next() -{ - waiting_cursor(); - - SPDocument *doc = NULL; - while (!doc && (_current < _slides.size() - 1)) { - doc = SPDocument::createNewDoc ((_slides[++_current]).c_str(), TRUE, false); - } - - set_document(doc, _current); - normal_cursor(); -} - -/** - * @brief Show the previous file in the slideshow - */ -void SPSlideShow::show_prev() -{ - waiting_cursor(); - - SPDocument *doc = NULL; - while (!doc && (_current > 0)) { - doc = SPDocument::createNewDoc ((_slides[--_current]).c_str(), TRUE, false); - } - - set_document(doc, _current); - normal_cursor(); -} - -/** - * @brief Switch to first slide in slideshow - */ -void SPSlideShow::goto_first() -{ - waiting_cursor(); - - SPDocument *doc = NULL; - int current = 0; - while ( !doc && (current < _slides.size() - 1)) { - doc = SPDocument::createNewDoc((_slides[current++]).c_str(), TRUE, false); - } - - set_document(doc, current - 1); - - normal_cursor(); -} - -/** - * @brief Switch to last slide in slideshow - */ -void SPSlideShow::goto_last() -{ - waiting_cursor(); - - SPDocument *doc = NULL; - int current = _slides.size() - 1; - while (!doc && (current >= 0)) { - doc = SPDocument::createNewDoc((_slides[current--]).c_str(), TRUE, false); - } - - set_document(doc, current + 1); - - normal_cursor(); -} - /* Local Variables: mode:c++ diff --git a/src/svg-view-slideshow.cpp b/src/svg-view-slideshow.cpp new file mode 100644 index 000000000..eebcd94df --- /dev/null +++ b/src/svg-view-slideshow.cpp @@ -0,0 +1,300 @@ +/* + * Inkscape - an ambitious vector drawing program + * + * Authors: + * Lauris Kaplinski + * Frank Felfe + * Davide Puricelli + * Mitsuru Oka + * Masatake YAMATO + * F.J.Franklin + * Michael Meeks + * Chema Celorio + * Pawel Palucha + * ... and various people who have worked with various projects + * Abhishek Sharma + * + * Copyright (C) 1999-2002 authors + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Inkscape authors: + * Johan Ceuppens + * + * Copyright (C) 2004 Inkscape authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include "document.h" +#include "ui/icon-names.h" +#include "util/units.h" + +#include "svg-view.h" +#include "svg-view-slideshow.h" +#include "svg-view-widget.h" + + + +SPSlideShow::SPSlideShow(std::vector const &slides) + : + _slides(slides), + _current(0), + _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)), + _view(NULL), + is_fullscreen(false), + _timer(0), + _ctrlwin(NULL) +{ + update_title(); + + auto default_screen = Gdk::Screen::get_default(); + + set_default_size(MIN ((int)_doc->getWidth().value("px"), default_screen->get_width() - 64), + MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); + + this->signal_key_press_event().connect(sigc::mem_fun(*this, &SPSlideShow::key_press), false); + this->signal_delete_event().connect(sigc::mem_fun(*this, &SPSlideShow::main_delete), false); + + _doc->ensureUpToDate(); + _view = sp_svg_view_widget_new (_doc); + _doc->doUnref (); + SP_SVG_VIEW_WIDGET(_view)->setResize( false, _doc->getWidth().value("px"), _doc->getHeight().value("px") ); + gtk_widget_show (_view); + add(*Glib::wrap(_view)); + + show(); +} + + + +/** + * @brief Show the control buttons (next, previous etc) for the application + */ +void SPSlideShow::control_show() +{ + if (!_ctrlwin) { + _ctrlwin = new Gtk::Window(); + _ctrlwin->set_resizable(false); + _ctrlwin->set_transient_for(*this); + + _ctrlwin->signal_key_press_event().connect(sigc::mem_fun(*this, &SPSlideShow::key_press), false); + _ctrlwin->signal_delete_event().connect(sigc::mem_fun(*this, &SPSlideShow::ctrlwin_delete), false); + + auto t = Gtk::manage(new Gtk::ButtonBox()); + _ctrlwin->add(*t); + + auto btn_go_first = Gtk::manage(new Gtk::Button()); + auto img_go_first = Gtk::manage(new Gtk::Image()); + img_go_first->set_from_icon_name(INKSCAPE_ICON("go-first"), Gtk::ICON_SIZE_BUTTON); + btn_go_first->set_image(*img_go_first); + t->add(*btn_go_first); + btn_go_first->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_first)); + + auto btn_go_prev = Gtk::manage(new Gtk::Button()); + auto img_go_prev = Gtk::manage(new Gtk::Image()); + img_go_prev->set_from_icon_name(INKSCAPE_ICON("go-previous"), Gtk::ICON_SIZE_BUTTON); + btn_go_prev->set_image(*img_go_prev); + t->add(*btn_go_prev); + btn_go_prev->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_prev)); + + auto btn_go_next = Gtk::manage(new Gtk::Button()); + auto img_go_next = Gtk::manage(new Gtk::Image()); + img_go_next->set_from_icon_name(INKSCAPE_ICON("go-next"), Gtk::ICON_SIZE_BUTTON); + btn_go_next->set_image(*img_go_next); + t->add(*btn_go_next); + btn_go_next->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_next)); + + auto btn_go_last = Gtk::manage(new Gtk::Button()); + auto img_go_last = Gtk::manage(new Gtk::Image()); + img_go_last->set_from_icon_name(INKSCAPE_ICON("go-last"), Gtk::ICON_SIZE_BUTTON); + btn_go_last->set_image(*img_go_last); + t->add(*btn_go_last); + btn_go_last->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_last)); + + _ctrlwin->show_all(); + } else { + _ctrlwin->present(); + } +} + +void SPSlideShow::waiting_cursor() +{ + auto display = Gdk::Display::get_default(); + auto waiting = Gdk::Cursor::create(display, Gdk::WATCH); + get_window()->set_cursor(waiting); + + if (_ctrlwin) { + _ctrlwin->get_window()->set_cursor(waiting); + } + while(Gtk::Main::events_pending()) { + Gtk::Main::iteration(); + } +} + +void SPSlideShow::normal_cursor() +{ + get_window()->set_cursor(); + if (_ctrlwin) { + _ctrlwin->get_window()->set_cursor(); + } +} + +void SPSlideShow::set_document(SPDocument *doc, + int current) +{ + if (doc && doc != _doc) { + doc->ensureUpToDate(); + reinterpret_cast(SP_VIEW_WIDGET_VIEW (_view))->setDocument (doc); + _doc = doc; + _current = current; + update_title(); + } +} + +/** + * @brief Show the next file in the slideshow + */ +void SPSlideShow::show_next() +{ + waiting_cursor(); + + SPDocument *doc = NULL; + while (!doc && (_current < _slides.size() - 1)) { + doc = SPDocument::createNewDoc ((_slides[++_current]).c_str(), TRUE, false); + } + + set_document(doc, _current); + normal_cursor(); +} + +/** + * @brief Show the previous file in the slideshow + */ +void SPSlideShow::show_prev() +{ + waiting_cursor(); + + SPDocument *doc = NULL; + while (!doc && (_current > 0)) { + doc = SPDocument::createNewDoc ((_slides[--_current]).c_str(), TRUE, false); + } + + set_document(doc, _current); + normal_cursor(); +} + +/** + * @brief Switch to first slide in slideshow + */ +void SPSlideShow::goto_first() +{ + waiting_cursor(); + + SPDocument *doc = NULL; + int current = 0; + while ( !doc && (current < _slides.size() - 1)) { + doc = SPDocument::createNewDoc((_slides[current++]).c_str(), TRUE, false); + } + + set_document(doc, current - 1); + + normal_cursor(); +} + +/** + * @brief Switch to last slide in slideshow + */ +void SPSlideShow::goto_last() +{ + waiting_cursor(); + + SPDocument *doc = NULL; + int current = _slides.size() - 1; + while (!doc && (current >= 0)) { + doc = SPDocument::createNewDoc((_slides[current--]).c_str(), TRUE, false); + } + + set_document(doc, current + 1); + + normal_cursor(); +} + +bool SPSlideShow::ctrlwin_delete (GdkEventAny */*event*/) +{ + if(_ctrlwin) delete _ctrlwin; + _ctrlwin = NULL; + return true; +} + +bool SPSlideShow::main_delete (GdkEventAny */*event*/) +{ + Gtk::Main::quit(); + return true; +} + +bool SPSlideShow::key_press(GdkEventKey* event) +{ + switch (event->keyval) { + case GDK_KEY_Up: + case GDK_KEY_Home: + goto_first(); + break; + case GDK_KEY_Down: + case GDK_KEY_End: + goto_last(); + break; + case GDK_KEY_F11: + if (is_fullscreen) { + unfullscreen(); + is_fullscreen = false; + } else { + fullscreen(); + is_fullscreen = true; + } + break; + case GDK_KEY_Return: + control_show(); + break; + case GDK_KEY_KP_Page_Down: + case GDK_KEY_Page_Down: + case GDK_KEY_Right: + case GDK_KEY_space: + show_next(); + break; + case GDK_KEY_KP_Page_Up: + case GDK_KEY_Page_Up: + case GDK_KEY_Left: + case GDK_KEY_BackSpace: + show_prev(); + break; + case GDK_KEY_Escape: + case GDK_KEY_q: + case GDK_KEY_Q: + Gtk::Main::quit(); + break; + default: + break; + } + return false; +} + +/* + 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/svg-view-slideshow.h b/src/svg-view-slideshow.h new file mode 100644 index 000000000..173e97e5b --- /dev/null +++ b/src/svg-view-slideshow.h @@ -0,0 +1,91 @@ +/* + * Inkscape - an ambitious vector drawing program + * + * Authors: + * Lauris Kaplinski + * Frank Felfe + * Davide Puricelli + * Mitsuru Oka + * Masatake YAMATO + * F.J.Franklin + * Michael Meeks + * Chema Celorio + * Pawel Palucha + * ... and various people who have worked with various projects + * Abhishek Sharma + * + * Copyright (C) 1999-2002 authors + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Inkscape authors: + * Johan Ceuppens + * + * Copyright (C) 2004 Inkscape authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +#ifndef SEEN_SP_SVG_SLIDESHOW_H +#define SEEN_SP_SVG_SLIDESHOW_H + +/** + * The main application window for the slideshow + */ +class SPSlideShow : public Gtk::ApplicationWindow { +public: + SPSlideShow(std::vector const &slides); + void set_timer(int timer) {_timer = timer;} + +private: + std::vector _slides; ///< List of filenames for each slide + int _current; ///< Index of the currently displayed slide + SPDocument *_doc; ///< The currently displayed slide + int _timer; + GtkWidget *_view; + Gtk::Window *_ctrlwin; ///< Window containing slideshow control buttons + + /// Current state of application (full-screen or windowed) + bool is_fullscreen; + + /// Update the window title with current document name + void update_title() + { + Glib::ustring title(_doc->getName()); + if (_slides.size() > 1) { + title += Glib::ustring::compose(" (%1/%2)", _current+1, _slides.size()); + } + + set_title(title); + } + + + void control_show(); + void show_next(); + void show_prev(); + void goto_first(); + void goto_last(); + + bool key_press (GdkEventKey *event); + bool main_delete (GdkEventAny *event); + bool ctrlwin_delete (GdkEventAny *event); + +protected: + void waiting_cursor(); + void normal_cursor(); + void set_document(SPDocument *doc, + int current); +}; + +#endif // SEEN_SP_SVG_SLIDESHOW_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 : -- cgit v1.2.3 From 9607306c03378d38b9ba67b7f0120593b7820826 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 02:41:40 +0200 Subject: Inkview: Some more refactoring (bzr r15690.1.9) --- src/inkview.cpp | 1 - src/svg-view-slideshow.cpp | 13 ++++++++++++- src/svg-view-slideshow.h | 16 +++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index abb690619..04d223091 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -29,7 +29,6 @@ # include "config.h" #endif -#include #include #include diff --git a/src/svg-view-slideshow.cpp b/src/svg-view-slideshow.cpp index eebcd94df..f9a392d3e 100644 --- a/src/svg-view-slideshow.cpp +++ b/src/svg-view-slideshow.cpp @@ -29,7 +29,6 @@ # include "config.h" #endif -#include #include #include #include @@ -149,6 +148,18 @@ void SPSlideShow::normal_cursor() } } + +/// Update the window title with current document name +void SPSlideShow::update_title() +{ + Glib::ustring title(_doc->getName()); + if (_slides.size() > 1) { + title += Glib::ustring::compose(" (%1/%2)", _current+1, _slides.size()); + } + + set_title(title); +} + void SPSlideShow::set_document(SPDocument *doc, int current) { diff --git a/src/svg-view-slideshow.h b/src/svg-view-slideshow.h index 173e97e5b..a44ef5b55 100644 --- a/src/svg-view-slideshow.h +++ b/src/svg-view-slideshow.h @@ -29,6 +29,8 @@ #ifndef SEEN_SP_SVG_SLIDESHOW_H #define SEEN_SP_SVG_SLIDESHOW_H +#include + /** * The main application window for the slideshow */ @@ -48,18 +50,6 @@ private: /// Current state of application (full-screen or windowed) bool is_fullscreen; - /// Update the window title with current document name - void update_title() - { - Glib::ustring title(_doc->getName()); - if (_slides.size() > 1) { - title += Glib::ustring::compose(" (%1/%2)", _current+1, _slides.size()); - } - - set_title(title); - } - - void control_show(); void show_next(); void show_prev(); @@ -70,7 +60,7 @@ private: bool main_delete (GdkEventAny *event); bool ctrlwin_delete (GdkEventAny *event); -protected: + void update_title(); void waiting_cursor(); void normal_cursor(); void set_document(SPDocument *doc, -- cgit v1.2.3 From 8b5ac2ae58d3857d98b4e6d12b95be8430a1ca50 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 03:49:13 +0200 Subject: Inkview: Finally implement the -t or --timer option after we dragged it around for over 10 years without implementation (bzr r15690.1.10) --- src/inkview.cpp | 3 +-- src/svg-view-slideshow.cpp | 35 ++++++++++++++++++++++++++--------- src/svg-view-slideshow.h | 5 +++-- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index 04d223091..bc4782b39 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -172,8 +172,7 @@ int main (int argc, char **argv) return 1; /* none of the slides loadable */ } - SPSlideShow ss(valid_files); - ss.set_timer(timer); + SPSlideShow ss(valid_files, timer); main_instance.run(); return 0; diff --git a/src/svg-view-slideshow.cpp b/src/svg-view-slideshow.cpp index f9a392d3e..00552130d 100644 --- a/src/svg-view-slideshow.cpp +++ b/src/svg-view-slideshow.cpp @@ -29,6 +29,8 @@ # include "config.h" #endif +#include + #include #include #include @@ -44,15 +46,14 @@ -SPSlideShow::SPSlideShow(std::vector const &slides) - : - _slides(slides), - _current(0), - _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)), - _view(NULL), - is_fullscreen(false), - _timer(0), - _ctrlwin(NULL) +SPSlideShow::SPSlideShow(std::vector const &slides, int timer) + : _slides(slides) + , _current(0) + , _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)) + , _timer(timer) + , _view(NULL) + , _ctrlwin(NULL) + , is_fullscreen(false) { update_title(); @@ -72,6 +73,10 @@ SPSlideShow::SPSlideShow(std::vector const &slides) add(*Glib::wrap(_view)); show(); + + if(_timer) { + Glib::signal_timeout().connect_seconds(sigc::mem_fun(*this, &timer_callback), _timer); + } } @@ -240,6 +245,18 @@ void SPSlideShow::goto_last() normal_cursor(); } +bool SPSlideShow::timer_callback() +{ + show_next(); + + // stop the timer if the last slide is reached + if (_current == _slides.size()-1) { + return false; + } else { + return true; + } +} + bool SPSlideShow::ctrlwin_delete (GdkEventAny */*event*/) { if(_ctrlwin) delete _ctrlwin; diff --git a/src/svg-view-slideshow.h b/src/svg-view-slideshow.h index a44ef5b55..3bab8f28f 100644 --- a/src/svg-view-slideshow.h +++ b/src/svg-view-slideshow.h @@ -36,8 +36,8 @@ */ class SPSlideShow : public Gtk::ApplicationWindow { public: - SPSlideShow(std::vector const &slides); - void set_timer(int timer) {_timer = timer;} + SPSlideShow(std::vector const &slides, + int timer); private: std::vector _slides; ///< List of filenames for each slide @@ -55,6 +55,7 @@ private: void show_prev(); void goto_first(); void goto_last(); + bool timer_callback(); bool key_press (GdkEventKey *event); bool main_delete (GdkEventAny *event); -- cgit v1.2.3 From f878665ef5fa1193157d436ce153c0a43c9ace94 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 04:13:34 +0200 Subject: Inkview: minor refactoring (bzr r15690.1.11) --- src/svg-view-slideshow.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/svg-view-slideshow.cpp b/src/svg-view-slideshow.cpp index 00552130d..a025eed9e 100644 --- a/src/svg-view-slideshow.cpp +++ b/src/svg-view-slideshow.cpp @@ -55,25 +55,22 @@ SPSlideShow::SPSlideShow(std::vector const &slides, int timer) , _ctrlwin(NULL) , is_fullscreen(false) { - update_title(); - + // setup initial document auto default_screen = Gdk::Screen::get_default(); - set_default_size(MIN ((int)_doc->getWidth().value("px"), default_screen->get_width() - 64), - MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); + MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); - this->signal_key_press_event().connect(sigc::mem_fun(*this, &SPSlideShow::key_press), false); - this->signal_delete_event().connect(sigc::mem_fun(*this, &SPSlideShow::main_delete), false); - - _doc->ensureUpToDate(); - _view = sp_svg_view_widget_new (_doc); - _doc->doUnref (); + _view = sp_svg_view_widget_new(_doc); SP_SVG_VIEW_WIDGET(_view)->setResize( false, _doc->getWidth().value("px"), _doc->getHeight().value("px") ); gtk_widget_show (_view); add(*Glib::wrap(_view)); - + + update_title(); show(); + // connect signals + this->signal_key_press_event().connect(sigc::mem_fun(*this, &SPSlideShow::key_press), false); + this->signal_delete_event().connect(sigc::mem_fun(*this, &SPSlideShow::main_delete), false); if(_timer) { Glib::signal_timeout().connect_seconds(sigc::mem_fun(*this, &timer_callback), _timer); } @@ -248,7 +245,7 @@ void SPSlideShow::goto_last() bool SPSlideShow::timer_callback() { show_next(); - + // stop the timer if the last slide is reached if (_current == _slides.size()-1) { return false; -- cgit v1.2.3 From 556ddf2fb4dd71d9677082cc9238b1c117aa2497 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 04:59:36 +0200 Subject: Inkview: refactor InkviewOptionsGroup and other minor refactoring (bzr r15690.1.12) --- src/inkview.cpp | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index bc4782b39..b4edfa22f 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -48,11 +48,7 @@ -/// List of all input filenames -static Glib::OptionGroup::vecustrings filenames; -/// Input timer option -static int timer = 0; /** * \brief Set of command-line options for Inkview @@ -60,14 +56,17 @@ static int timer = 0; class InkviewOptionsGroup : public Glib::OptionGroup { public: - InkviewOptionsGroup() - : - Glib::OptionGroup(N_("Inkscape Options"), - N_("Default program options")), - _entry_timer(), - _entry_args() + /// List of all input filenames + Glib::OptionGroup::vecustrings filenames; + + /// Input timer option + int timer = 0; + + InkviewOptionsGroup() : Glib::OptionGroup(N_("Inkscape Options"), + N_("Default program options")) { // Entry for the "timer" option + Glib::OptionEntry _entry_timer; _entry_timer.set_short_name('t'); _entry_timer.set_long_name("timer"); _entry_timer.set_arg_description(N_("NUM")); @@ -75,16 +74,13 @@ public: add_entry(_entry_timer, timer); // Entry for the remaining non-option arguments + Glib::OptionEntry _entry_args; _entry_args.set_short_name('\0'); _entry_args.set_long_name(G_OPTION_REMAINING); _entry_args.set_arg_description(N_("FILES …")); add_entry(_entry_args, filenames); } - -private: - Glib::OptionEntry _entry_timer; - Glib::OptionEntry _entry_args; }; @@ -122,7 +118,7 @@ std::vector get_valid_files(std::vector filenames, } } } - + return valid_files; } @@ -144,15 +140,15 @@ int main (int argc, char **argv) Inkscape::initialize_gettext(); #endif - Glib::OptionContext opt(N_("Open SVG files")); - opt.set_translation_domain(GETTEXT_PACKAGE); - - InkviewOptionsGroup grp; - grp.set_translation_domain(GETTEXT_PACKAGE); - - opt.set_main_group(grp); + Glib::OptionContext context(N_("Open SVG files")); + context.set_translation_domain(GETTEXT_PACKAGE); - Gtk::Main main_instance (argc, argv, opt); + InkviewOptionsGroup options; + options.set_translation_domain(GETTEXT_PACKAGE); + + context.set_main_group(options); + + Gtk::Main main_instance (argc, argv, context); LIBXML_TEST_VERSION @@ -161,18 +157,18 @@ int main (int argc, char **argv) Inkscape::Application::create(argv[0], true); - if(filenames.empty()) + if(options.filenames.empty()) { - g_print("%s", opt.get_help().c_str()); + g_print("%s", context.get_help().c_str()); exit(EXIT_FAILURE); } - std::vector valid_files = get_valid_files(filenames, true); + std::vector valid_files = get_valid_files(options.filenames, true); if(valid_files.empty()) { return 1; /* none of the slides loadable */ } - - SPSlideShow ss(valid_files, timer); + + SPSlideShow ss(valid_files, options.timer); main_instance.run(); return 0; -- cgit v1.2.3 From 32e1550bf1f16ade2bd14b833bc366dc12b50af5 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 05:46:43 +0200 Subject: Inkview: Add additional information to help output and update option description (bzr r15690.1.13) --- src/inkview.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index b4edfa22f..f1eb1cfc6 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -70,14 +70,13 @@ public: _entry_timer.set_short_name('t'); _entry_timer.set_long_name("timer"); _entry_timer.set_arg_description(N_("NUM")); - _entry_timer.set_description(N_("Reset timer:")); + _entry_timer.set_description(N_("Change image every NUM seconds")); add_entry(_entry_timer, timer); // Entry for the remaining non-option arguments Glib::OptionEntry _entry_args; - _entry_args.set_short_name('\0'); _entry_args.set_long_name(G_OPTION_REMAINING); - _entry_args.set_arg_description(N_("FILES …")); + _entry_args.set_arg_description(N_("FILES/FOLDERS …")); add_entry(_entry_args, filenames); } @@ -140,7 +139,13 @@ int main (int argc, char **argv) Inkscape::initialize_gettext(); #endif - Glib::OptionContext context(N_("Open SVG files")); + Glib::OptionContext context(N_("- display SVG files")); + context.set_summary(N_( + "Quickly browse through a collection of .svg(z) files\n" + "or show them as a slide show.")); + context.set_description(N_( + "Example:\n" + " inkview -t 3 file1.svg file2.svgz series*.svg more_files")); context.set_translation_domain(GETTEXT_PACKAGE); InkviewOptionsGroup options; -- cgit v1.2.3 From 1be23961b14fb409ee1a13fde6de676111587356 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 06:11:55 +0200 Subject: Inkview: add option -s or --scale to set a factor by witch to scale the displayed image Fixed bugs: - https://launchpad.net/bugs/1550897 (bzr r15690.1.14) --- src/inkview.cpp | 35 +++++++++++++++++++++++------------ src/svg-view-slideshow.cpp | 7 ++++--- src/svg-view-slideshow.h | 16 +++++++++------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index f1eb1cfc6..e50c76ab0 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -59,26 +59,37 @@ public: /// List of all input filenames Glib::OptionGroup::vecustrings filenames; - /// Input timer option + /// timer for the slideshow int timer = 0; + + /// scale factor for images (currently only applied to the first image - others are resized to window dimensions) + double scale = 1; InkviewOptionsGroup() : Glib::OptionGroup(N_("Inkscape Options"), N_("Default program options")) { // Entry for the "timer" option - Glib::OptionEntry _entry_timer; - _entry_timer.set_short_name('t'); - _entry_timer.set_long_name("timer"); - _entry_timer.set_arg_description(N_("NUM")); - _entry_timer.set_description(N_("Change image every NUM seconds")); - add_entry(_entry_timer, timer); + Glib::OptionEntry entry_timer; + entry_timer.set_short_name('t'); + entry_timer.set_long_name("timer"); + entry_timer.set_arg_description(N_("NUM")); + entry_timer.set_description(N_("Change image every NUM seconds")); + add_entry(entry_timer, timer); + + // Entry for the "scale" option + Glib::OptionEntry entry_scale; + entry_scale.set_short_name('s'); + entry_scale.set_long_name("scale"); + entry_scale.set_arg_description(N_("NUM")); + entry_scale.set_description(N_("Scale image by factor NUM")); + add_entry(entry_scale, scale); // Entry for the remaining non-option arguments - Glib::OptionEntry _entry_args; - _entry_args.set_long_name(G_OPTION_REMAINING); - _entry_args.set_arg_description(N_("FILES/FOLDERS …")); + Glib::OptionEntry entry_args; + entry_args.set_long_name(G_OPTION_REMAINING); + entry_args.set_arg_description(N_("FILES/FOLDERS …")); - add_entry(_entry_args, filenames); + add_entry(entry_args, filenames); } }; @@ -173,7 +184,7 @@ int main (int argc, char **argv) return 1; /* none of the slides loadable */ } - SPSlideShow ss(valid_files, options.timer); + SPSlideShow ss(valid_files, options.timer, options.scale); main_instance.run(); return 0; diff --git a/src/svg-view-slideshow.cpp b/src/svg-view-slideshow.cpp index a025eed9e..109b0fcab 100644 --- a/src/svg-view-slideshow.cpp +++ b/src/svg-view-slideshow.cpp @@ -46,19 +46,20 @@ -SPSlideShow::SPSlideShow(std::vector const &slides, int timer) +SPSlideShow::SPSlideShow(std::vector const &slides, int timer, double scale) : _slides(slides) , _current(0) , _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)) , _timer(timer) + , _scale(scale) , _view(NULL) , _ctrlwin(NULL) , is_fullscreen(false) { // setup initial document auto default_screen = Gdk::Screen::get_default(); - set_default_size(MIN ((int)_doc->getWidth().value("px"), default_screen->get_width() - 64), - MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); + set_default_size(MIN ((int)_doc->getWidth().value("px")*_scale, default_screen->get_width() - 64), + MIN ((int)_doc->getHeight().value("px")*_scale, default_screen->get_height() - 64)); _view = sp_svg_view_widget_new(_doc); SP_SVG_VIEW_WIDGET(_view)->setResize( false, _doc->getWidth().value("px"), _doc->getHeight().value("px") ); diff --git a/src/svg-view-slideshow.h b/src/svg-view-slideshow.h index 3bab8f28f..cfa0949a4 100644 --- a/src/svg-view-slideshow.h +++ b/src/svg-view-slideshow.h @@ -37,15 +37,17 @@ class SPSlideShow : public Gtk::ApplicationWindow { public: SPSlideShow(std::vector const &slides, - int timer); + int timer, + double scale); private: - std::vector _slides; ///< List of filenames for each slide - int _current; ///< Index of the currently displayed slide - SPDocument *_doc; ///< The currently displayed slide - int _timer; - GtkWidget *_view; - Gtk::Window *_ctrlwin; ///< Window containing slideshow control buttons + std::vector _slides; ///< list of filenames for each slide + int _current; ///< index of the currently displayed slide + SPDocument *_doc; ///< parsed SPDocument of the currently displayed slide + int _timer; ///< time after which slides are automatically changed (in seconds) + double _scale; ///< scale factor for images + GtkWidget *_view; ///< the canvas to which the images are drawn + Gtk::Window *_ctrlwin; ///< window containing slideshow control buttons /// Current state of application (full-screen or windowed) bool is_fullscreen; -- cgit v1.2.3 From 7ac22eb4ab56e0ddc1242b88cdb03a275631615a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 14 May 2017 06:38:05 +0200 Subject: Inkview: Don't crash when unknow command line option is specified (bzr r15690.1.15) --- src/inkview.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/inkview.cpp b/src/inkview.cpp index e50c76ab0..05d8cd1eb 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -164,7 +164,14 @@ int main (int argc, char **argv) context.set_main_group(options); - Gtk::Main main_instance (argc, argv, context); + Gtk::Main main_instance(true); + try { + context.parse(argc, argv); + } catch (const Glib::Error& ex) { + g_printerr("%s\n\n", ex.what().c_str()); + g_print("%s", context.get_help().c_str()); + exit(EXIT_FAILURE); + } LIBXML_TEST_VERSION -- cgit v1.2.3