diff options
| author | Patrick Storz <eduard.braun2@gmx.de> | 2019-06-30 14:29:03 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2019-07-03 19:49:06 +0000 |
| commit | 99ab4e91c23b0396bba708e68142176553372e45 (patch) | |
| tree | df0d1e6571ff23d42d19edbe357af465a9762a9a /src | |
| parent | Crashfix SIOX Trace (free memory properly) (diff) | |
| download | inkscape-99ab4e91c23b0396bba708e68142176553372e45.tar.gz inkscape-99ab4e91c23b0396bba708e68142176553372e45.zip | |
Group command line options in --help output
This implements a workaround for functionality that seems to be
missing in glib/gtk:
We add the group headers as additional option entries and modify
their short name to produce the desired output.
Diffstat (limited to 'src')
| -rw-r--r-- | src/inkscape-application.cpp | 99 | ||||
| -rw-r--r-- | src/inkscape-application.h | 2 |
2 files changed, 60 insertions, 41 deletions
diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp index 6a3b50c44..23bdb4e57 100644 --- a/src/inkscape-application.cpp +++ b/src/inkscape-application.cpp @@ -457,6 +457,13 @@ ConcreteInkscapeApplication<T>::get_instance() return instance; } +template<class T> +void +ConcreteInkscapeApplication<T>::_start_main_option_section(const Glib::ustring& section_name) +{ + this->add_main_option_entry(T::OPTION_TYPE_BOOL, Glib::ustring("\b\b \n") + section_name + ":"); +} + // Note: We tried using Gio::APPLICATION_CAN_OVERRIDE_APP_ID instead of // Gio::APPLICATION_NON_UNIQUE. The advantages of this is that copy/paste between windows would be // more reliable and that we wouldn't have multiple Inkscape instance writing to the preferences @@ -500,72 +507,82 @@ ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication() // Note: OPTION_TYPE_FILENAME => std::string, OPTION_TYPE_STRING => Glib::ustring. // Actions + _start_main_option_section(_("Actions")); this->add_main_option_entry(T::OPTION_TYPE_STRING, "actions", 'a', N_("Actions (with optional arguments), semi-colon separated."), N_("ACTION(:ARG)[;ACTION(:ARG)]*")); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "action-list", '\0', N_("Actions: List available actions."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "action-list", '\0', N_("List available actions."), ""); // Query - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "version", 'V', N_("Print: Inkscape version."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "extension-directory", 'x', N_("Print: Extensions directory."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "verb-list", '\0', N_("Print: List verbs."), ""); + _start_main_option_section(_("Query")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "version", 'V', N_("Inkscape version."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "extension-directory", 'x', N_("Extensions directory."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "verb-list", '\0', N_("List verbs."), ""); // Interface - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "with-gui", 'g', N_("GUI: With graphical interface."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "without-gui", 'z', N_("GUI: Console only."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "batch-process", '\0', N_("GUI: Close window after processing actions (needed as some verbs require GUI)."), ""); + _start_main_option_section(_("Interface")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "with-gui", 'g', N_("With graphical interface."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "without-gui", 'z', N_("Console only."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "batch-process", '\0', N_("Close window after processing actions (needed as some verbs require GUI)."), ""); // Open/Import - this->add_main_option_entry(T::OPTION_TYPE_INT, "pdf-page", '\0', N_("Open: PDF page to import"), N_("PAGE")); + _start_main_option_section(_("Open/Import")); + this->add_main_option_entry(T::OPTION_TYPE_INT, "pdf-page", '\0', N_("PDF page to import"), N_("PAGE")); this->add_main_option_entry(T::OPTION_TYPE_BOOL, "pdf-poppler", '\0', N_("Use poppler when importing via commandline"), ""); - this->add_main_option_entry(T::OPTION_TYPE_STRING, "convert-dpi-method", '\0', N_("Open: Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document]."), "[...]"); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "convert-dpi-method", '\0', N_("Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document]."), "[...]"); this->add_main_option_entry(T::OPTION_TYPE_BOOL, "no-convert-text-baseline-spacing", 0, N_("Open: Do not fix pre-0.92 document's text baseline spacing on opening."), ""); // Query - Geometry - this->add_main_option_entry(T::OPTION_TYPE_STRING, "query-id", 'I', N_("Query: ID(s) of object(s) to be queried."), N_("OBJECT-ID[,OBJECT-ID]*")); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-all", 'S', N_("Query: Print bounding boxes of all objects."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-x", 'X', N_("Query: X coordinate of drawing or object (if specified by --query-id)."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-y", 'Y', N_("Query: Y coordinate of drawing or object (if specified by --query-id)."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-width", 'W', N_("Query: Width of drawing or object (if specified by --query-id)."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-height", 'H', N_("Query: Height of drawing or object (if specified by --query-id)."), ""); + _start_main_option_section(_("Query - Geometry")); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "query-id", 'I', N_("ID(s) of object(s) to be queried."), N_("OBJECT-ID[,OBJECT-ID]*")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-all", 'S', N_("Print bounding boxes of all objects."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-x", 'X', N_("X coordinate of drawing or object (if specified by --query-id)."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-y", 'Y', N_("Y coordinate of drawing or object (if specified by --query-id)."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-width", 'W', N_("Width of drawing or object (if specified by --query-id)."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "query-height", 'H', N_("Height of drawing or object (if specified by --query-id)."), ""); // Processing - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "vacuum-defs", '\0', N_("Process: Remove unused definitions from the <defs> section(s) of document."), ""); - this->add_main_option_entry(T::OPTION_TYPE_STRING, "select", '\0', N_("Process: Select objects: comma separated list of IDs."), N_("OBJECT-ID[,OBJECT-ID]*")); - this->add_main_option_entry(T::OPTION_TYPE_STRING, "verb", '\0', N_("Process: Verb(s) to call when Inkscape opens."), N_("VERB-ID[;VERB-ID]*")); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "shell", '\0', N_("Process: Start Inkscape in interactive shell mode."), ""); - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "pipe", 'p', N_("Process: Read file from pipe."), ""); + _start_main_option_section(_("Processing")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "vacuum-defs", '\0', N_("Remove unused definitions from the <defs> section(s) of document."), ""); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "select", '\0', N_("Select objects: comma separated list of IDs."), N_("OBJECT-ID[,OBJECT-ID]*")); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "verb", '\0', N_("Verb(s) to call when Inkscape opens."), N_("VERB-ID[;VERB-ID]*")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "shell", '\0', N_("Start Inkscape in interactive shell mode."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "pipe", 'p', N_("Read file from pipe."), ""); // Export - File and File Type + _start_main_option_section(_("Export")); this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-type", '\0', N_("Export: File type:[svg,png,ps,psf,tex,emf,wmf,xaml]"), "[...]"); this->add_main_option_entry(T::OPTION_TYPE_FILENAME, "export-file", 'o', N_("Export: File name"), N_("EXPORT-FILENAME")); this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-overwrite", '\0', N_("Export: Overwrite input file."), ""); // BSP // B = PNG, S = SVG, P = PS/EPS/PDF // Export - Geometry - this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-area", 'a', N_("Export: Area to export in SVG user units."), N_("x0:y0:x1:y1")); // BSP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-drawing", 'D', N_("Export: Area to export is drawing (not page)."), ""); // BSP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-page", 'C', N_("Export: Area to export is page."), ""); // BSP - this->add_main_option_entry(T::OPTION_TYPE_INT, "export-margin", '\0', N_("Export: Margin around export area: units of page size for SVG, mm for PS/EPS/PDF."), ""); // xSP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-snap", '\0', N_("Export: Snap the bitmap export area outwards to the nearest integer values."), ""); // Bxx - this->add_main_option_entry(T::OPTION_TYPE_INT, "export-width", 'w', N_("Export: Bitmap width in pixels (overrides --export-dpi)."), N_("WIDTH")); // Bxx - this->add_main_option_entry(T::OPTION_TYPE_INT, "export-height", 'h', N_("Export: Bitmap height in pixels (overrides --export-dpi)."), N_("HEIGHT")); // Bxx + _start_main_option_section(_("Export - Geometry")); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-area", 'a', N_("Area to export in SVG user units."), N_("x0:y0:x1:y1")); // BSP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-drawing", 'D', N_("Area to export is drawing (not page)."), ""); // BSP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-page", 'C', N_("Area to export is page."), ""); // BSP + this->add_main_option_entry(T::OPTION_TYPE_INT, "export-margin", '\0', N_("Margin around export area: units of page size for SVG, mm for PS/EPS/PDF."), ""); // xSP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-area-snap", '\0', N_("Snap the bitmap export area outwards to the nearest integer values."), ""); // Bxx + this->add_main_option_entry(T::OPTION_TYPE_INT, "export-width", 'w', N_("Bitmap width in pixels (overrides --export-dpi)."), N_("WIDTH")); // Bxx + this->add_main_option_entry(T::OPTION_TYPE_INT, "export-height", 'h', N_("Bitmap height in pixels (overrides --export-dpi)."), N_("HEIGHT")); // Bxx // Export - Options - this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-id", 'i', N_("Export: ID(s) of object(s) to export."), N_("OBJECT-ID[;OBJECT-ID]*")); // BSP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-id-only", 'j', N_("Export: Hide all objects except object with ID selected by export-id."), ""); // BSx - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-plain-svg", 'l', N_("Export: Remove items in the Inkscape namespace."), ""); // xSx - this->add_main_option_entry(T::OPTION_TYPE_INT, "export-dpi", 'd', N_("Export: Resolution for rasterization bitmaps and filters (default is 96)."), N_("DPI")); // BxP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-ignore-filters", '\0', N_("Export: Render objects without filters instead of rasterizing. (PS/EPS/PDF)"), ""); // xxP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-text-to-path", 'T', N_("Export: Convert text to paths. (PS/EPS/PDF/SVG)."), ""); // xxP - this->add_main_option_entry(T::OPTION_TYPE_INT, "export-ps-level", '\0', N_("Export: Postscript level (2 or 3). Default is 3."), N_("PS-Level")); // xxP - this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-pdf-version", '\0', N_("Export: PDF version (1.4 or 1.5)"), N_("PDF-VERSION")); // xxP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-latex", '\0', N_("Export: Export text separately to LaTeX file (PS/EPS/PDF). Include via \\input{file.tex}"), ""); // xxP - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-use-hints", 't', N_("Export: Use stored filename and DPI hints when exporting object selected by --export-id."), ""); // Bxx - this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-background", 'b', N_("Export: Background color for exported bitmaps (any SVG color string)."), N_("COLOR")); // Bxx - this->add_main_option_entry(T::OPTION_TYPE_DOUBLE, "export-background-opacity", 'y', N_("Export: Background opacity for exported bitmaps (either 0.0 to 1.0 or 1 to 255)."), N_("VALUE")); // Bxx + _start_main_option_section(_("Export - Options")); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-id", 'i', N_("ID(s) of object(s) to export."), N_("OBJECT-ID[;OBJECT-ID]*")); // BSP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-id-only", 'j', N_("Hide all objects except object with ID selected by export-id."), ""); // BSx + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-plain-svg", 'l', N_("Remove items in the Inkscape namespace."), ""); // xSx + this->add_main_option_entry(T::OPTION_TYPE_INT, "export-dpi", 'd', N_("Resolution for rasterization bitmaps and filters (default is 96)."), N_("DPI")); // BxP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-ignore-filters", '\0', N_("Render objects without filters instead of rasterizing. (PS/EPS/PDF)"), ""); // xxP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-text-to-path", 'T', N_("Convert text to paths. (PS/EPS/PDF/SVG)."), ""); // xxP + this->add_main_option_entry(T::OPTION_TYPE_INT, "export-ps-level", '\0', N_("Postscript level (2 or 3). Default is 3."), N_("PS-Level")); // xxP + this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-pdf-version", '\0', N_("PDF version (1.4 or 1.5)"), N_("PDF-VERSION")); // xxP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-latex", '\0', N_("Export text separately to LaTeX file (PS/EPS/PDF). Include via \\input{file.tex}"), ""); // xxP + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "export-use-hints", 't', N_("Use stored filename and DPI hints when exporting object selected by --export-id."), ""); // Bxx + this->add_main_option_entry(T::OPTION_TYPE_STRING, "export-background", 'b', N_("Background color for exported bitmaps (any SVG color string)."), N_("COLOR")); // Bxx + this->add_main_option_entry(T::OPTION_TYPE_DOUBLE, "export-background-opacity", 'y', N_("Background opacity for exported bitmaps (either 0.0 to 1.0 or 1 to 255)."), N_("VALUE")); // Bxx #ifdef WITH_DBUS - this->add_main_option_entry(T::OPTION_TYPE_BOOL, "dbus-listen", '\0', N_("D-Bus: Enter a listening loop for D-Bus messages in console mode."), ""); - this->add_main_option_entry(T::OPTION_TYPE_STRING, "dbus-name", '\0', N_("D-Bus: Specify the D-Bus name (default is 'org.inkscape')."), N_("BUS-NAME")); + _start_main_option_section(_("D-Bus")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "dbus-listen", '\0', N_("Enter a listening loop for D-Bus messages in console mode."), ""); + this->add_main_option_entry(T::OPTION_TYPE_STRING, "dbus-name", '\0', N_("Specify the D-Bus name (default is 'org.inkscape')."), N_("BUS-NAME")); #endif // WITH_DBUS Gio::Application::signal_handle_local_options().connect(sigc::mem_fun(*this, &InkscapeApplication::on_handle_local_options)); diff --git a/src/inkscape-application.h b/src/inkscape-application.h index a952db235..b51407aa3 100644 --- a/src/inkscape-application.h +++ b/src/inkscape-application.h @@ -152,6 +152,8 @@ private: void shell(); void shell2(); + void _start_main_option_section(const Glib::ustring& section_name); + Glib::RefPtr<Gtk::Builder> _builder; }; |
