From ace52f0b8ac77a8abd63facf02ef329b0aeedd0c Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Sun, 4 Mar 2018 23:18:09 +0000 Subject: Inkview: Split options code out --- src/CMakeLists.txt | 6 +++- src/inkview-options-group.cpp | 56 +++++++++++++++++++++++++++++++++++++ src/inkview-options-group.h | 35 +++++++++++++++++++++++ src/inkview.cpp | 65 +------------------------------------------ 4 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 src/inkview-options-group.cpp create mode 100644 src/inkview-options-group.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e6c49c88..44f64c56c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -294,7 +294,11 @@ set(inkscape_SRC # Setup the executable # ----------------------------------------------------------------------------- set(main_SRC main.cpp) -set(view_SRC inkview.cpp) +set(view_SRC + inkview.cpp + inkview-options-group.cpp + inkview-options-group.h +) if(WIN32) # Sources for the inkscape executable on Windows. diff --git a/src/inkview-options-group.cpp b/src/inkview-options-group.cpp new file mode 100644 index 000000000..7879c55e2 --- /dev/null +++ b/src/inkview-options-group.cpp @@ -0,0 +1,56 @@ +#include "inkview-options-group.h" + +#include + +InkviewOptionsGroup::InkviewOptionsGroup() + : Glib::OptionGroup(N_("Inkscape Options"), + N_("Default program options")) +{ + // Entry for the "fullscreen" option + Glib::OptionEntry entry_fullscreen; + entry_fullscreen.set_short_name('f'); + entry_fullscreen.set_long_name("fullscreen"); + entry_fullscreen.set_description(N_("Launch in fullscreen mode")); + add_entry(entry_fullscreen, fullscreen); + + // Entry for the "recursive" option + Glib::OptionEntry entry_recursive; + entry_recursive.set_short_name('r'); + entry_recursive.set_long_name("recursive"); + entry_recursive.set_description(N_("Search folders recursively")); + add_entry(entry_recursive, recursive); + + // 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); + + // 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…")); + + add_entry(entry_args, filenames); +} + +/* + 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/inkview-options-group.h b/src/inkview-options-group.h new file mode 100644 index 000000000..592caf1af --- /dev/null +++ b/src/inkview-options-group.h @@ -0,0 +1,35 @@ +#ifndef INKVIEW_OPTIONS_GROUP_H +#define INKVIEW_OPTIONS_GROUP_H + +#include + +/** + * \brief Set of command-line options for Inkview + */ +class InkviewOptionsGroup : public Glib::OptionGroup +{ +public: + // list of all input filenames; + // this list contains all arguments that are not recognized as an option (so needs to be checked) + Glib::OptionGroup::vecustrings filenames; + + bool fullscreen = false; // whether to launch in fullscreen mode + bool recursive = false; // whether to search folders for SVG files recursively + int timer = 0; // time (in seconds) after which the next image of the slideshow is automatically loaded + double scale = 1; // scale factor for images + // (currently only applied to the first image - others are resized to window dimensions) + + InkviewOptionsGroup(); +}; +#endif // INKVIEW_OPTIONS_GROUP_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 : diff --git a/src/inkview.cpp b/src/inkview.cpp index 5b27e9168..f3e5ccdfc 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -33,7 +33,6 @@ #include -#include #include #include "document.h" @@ -45,69 +44,7 @@ #include "inkgc/gc-core.h" #include "io/sys.h" #include "svg-view-slideshow.h" - - - - - -/** - * \brief Set of command-line options for Inkview - */ -class InkviewOptionsGroup : public Glib::OptionGroup -{ -public: - // list of all input filenames; - // this list contains all arguments that are not recognized as an option (so needs to be checked) - Glib::OptionGroup::vecustrings filenames; - - bool fullscreen = false; // whether to launch in fullscreen mode - bool recursive = false; // whether to search folders for SVG files recursively - int timer = 0; // time (in seconds) after which the next image of the slideshow is automatically loaded - double scale = 1; // scale factor for images - // (currently only applied to the first image - others are resized to window dimensions) - - InkviewOptionsGroup() : Glib::OptionGroup(N_("Inkscape Options"), - N_("Default program options")) - { - // Entry for the "fullscreen" option - Glib::OptionEntry entry_fullscreen; - entry_fullscreen.set_short_name('f'); - entry_fullscreen.set_long_name("fullscreen"); - entry_fullscreen.set_description(N_("Launch in fullscreen mode")); - add_entry(entry_fullscreen, fullscreen); - - // Entry for the "recursive" option - Glib::OptionEntry entry_recursive; - entry_recursive.set_short_name('r'); - entry_recursive.set_long_name("recursive"); - entry_recursive.set_description(N_("Search folders recursively")); - add_entry(entry_recursive, recursive); - - // 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); - - // 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…")); - - add_entry(entry_args, filenames); - } -}; - +#include "inkview-options-group.h" /** get a list of valid SVG files from a list of strings */ std::vector get_valid_files(std::vector filenames, bool recursive = false, bool first_iteration = false) -- cgit v1.2.3