summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-05-14 01:49:13 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-05-14 01:49:13 +0000
commit8b5ac2ae58d3857d98b4e6d12b95be8430a1ca50 (patch)
tree4f33be9a9c63a682f461661085bd7fa35c33eb67 /src
parentInkview: Some more refactoring (diff)
downloadinkscape-8b5ac2ae58d3857d98b4e6d12b95be8430a1ca50.tar.gz
inkscape-8b5ac2ae58d3857d98b4e6d12b95be8430a1ca50.zip
Inkview: Finally implement the -t or --timer option after we dragged it around for over 10 years without implementation
(bzr r15690.1.10)
Diffstat (limited to 'src')
-rw-r--r--src/inkview.cpp3
-rw-r--r--src/svg-view-slideshow.cpp35
-rw-r--r--src/svg-view-slideshow.h5
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 <glibmm/main.h>
+
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/image.h>
@@ -44,15 +46,14 @@
-SPSlideShow::SPSlideShow(std::vector<Glib::ustring> 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<Glib::ustring> 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<Glib::ustring> 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<Glib::ustring> const &slides);
- void set_timer(int timer) {_timer = timer;}
+ SPSlideShow(std::vector<Glib::ustring> const &slides,
+ int timer);
private:
std::vector<Glib::ustring> _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);