diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-05-01 19:12:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-01 19:12:01 +0200 |
| commit | eb64c88a8bf9c8fe66c33a5309d28e526b994d25 (patch) | |
| tree | 0260975a708a4212edd50a5c3cd1f04f4dca7a8d | |
| parent | 0c825d21631d467104cb65c61e15c39c46481e9e (diff) | |
Fix select elements extension (#2875)
* fix dbus issue
* add bean stitch repeats
* add tartan
* add autosatin underlay
---------
Co-authored-by: rejbasket
| -rw-r--r-- | dbus/select_elements.py | 15 | ||||
| -rw-r--r-- | lib/extensions/select_elements.py | 42 | ||||
| -rw-r--r-- | templates/select_elements.xml | 3 |
3 files changed, 41 insertions, 19 deletions
diff --git a/dbus/select_elements.py b/dbus/select_elements.py index ad016751..564de8a3 100644 --- a/dbus/select_elements.py +++ b/dbus/select_elements.py @@ -22,20 +22,7 @@ class DBusActions: except BaseException: exit() - proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None, - 'org.freedesktop.DBus', - '/org/freedesktop/DBus', - 'org.freedesktop.DBus', None) - names_list = proxy.call_sync('ListNames', None, Gio.DBusCallFlags.NO_AUTO_START, 500, None) - - # names_list is a GVariant, must unpack - names = names_list.unpack()[0] - - # Look for Inkscape; names is a tuple. - for name in names: - if ('org.inkscape.Inkscape' in name): - break - + name = 'org.inkscape.Inkscape' appGroupName = "/org/inkscape/Inkscape" self.applicationGroup = Gio.DBusActionGroup.get( bus, diff --git a/lib/extensions/select_elements.py b/lib/extensions/select_elements.py index a8fac466..c1b948a3 100644 --- a/lib/extensions/select_elements.py +++ b/lib/extensions/select_elements.py @@ -23,6 +23,7 @@ class SelectElements(InkstitchExtension): pars.add_argument("--select-running-stitch", type=Boolean, dest="running", default=False) pars.add_argument("--running-stitch-condition", type=str, dest="running_stitch_condition", default="all") + pars.add_argument("--bean-stitch-repeats", type=str, dest="bean_stitch_repeats", default='0') pars.add_argument("--select-ripples", type=Boolean, dest="ripples", default=False) pars.add_argument("--select-zigzag", type=Boolean, dest="zigzag", default=False) pars.add_argument("--select-manual", type=Boolean, dest="manual", default=False) @@ -39,6 +40,7 @@ class SelectElements(InkstitchExtension): pars.add_argument("--select-meander-fill", type=Boolean, dest="meander", default=False) pars.add_argument("--select-circular-fill", type=Boolean, dest="circular", default=False) pars.add_argument("--select-linear-gradient-fill", type=Boolean, dest="linear_gradient", default=False) + pars.add_argument("--select-tartan-fill", type=Boolean, dest="tartan_fill", default=False) pars.add_argument("--select-legacy-fill", type=Boolean, dest="legacy", default=False) pars.add_argument("--fill-underlay", type=str, dest="fill_underlay", default="all") pars.add_argument("--select-clone", type=Boolean, dest="clone", default=False) @@ -49,12 +51,32 @@ class SelectElements(InkstitchExtension): py_path, file_path = self._get_paths() id_list = self._get_id_list() - with subprocess.Popen( + if sys.platform == "linux": + # Pyinstaller fix for gnome document view not opening. + lenv = dict(os.environ) + lp_key = 'LD_LIBRARY_PATH' + lp_orig = lenv.get(lp_key + '_ORIG') + if lp_orig is not None: + lenv[lp_key] = lp_orig # restore the original, unmodified value + else: + lenv.pop(lp_key, None) + + with subprocess.Popen( [py_path, 'select_elements.py', id_list], cwd=file_path, stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) as proc: - proc.wait() + stderr=subprocess.DEVNULL, + env=lenv + ) as proc: + proc.wait() + else: + with subprocess.Popen( + [py_path, 'select_elements.py', id_list], + cwd=file_path, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) as proc: + proc.wait() def _get_paths(self): file_path = get_bundled_dir("dbus") @@ -107,7 +129,7 @@ class SelectElements(InkstitchExtension): def _select_stroke(self, element): select = False method = element.stroke_method - if self.options.running and method == 'running_stitch' and self._running_condition(element): + if self.options.running and method == 'running_stitch' and self._running_condition(element) and self._bean_stitch_repeats(element): select = True if self.options.ripples and method == 'ripple_stitch': select = True @@ -134,15 +156,25 @@ class SelectElements(InkstitchExtension): select = True elif self.options.linear_gradient and method == 'linear_gradient_fill': select = True + elif self.options.tartan_fill and method == 'tartan_fill': + select = True elif self.options.legacy and method == 'legacy_fill': select = True return select def _running_condition(self, element): element_id = element.node.get_id() or '' - conditions = {'all': True, 'autorun-top': element_id.startswith('autorun'), 'autorun-underpath': element_id.startswith('underpath')} + conditions = { + 'all': True, + 'autorun-top': element_id.startswith('autorun'), + 'autorun-underpath': element_id.startswith('underpath'), + 'autosatin-underpath': element_id.startswith('autosatinrun')} return conditions[self.options.running_stitch_condition] + def _bean_stitch_repeats(self, element): + repeats = element.node.get('inkstitch:bean_stitch_repeats', '0') + return repeats == self.options.bean_stitch_repeats + def _select_fill_underlay(self, element): underlay = {'all': True, 'no': not element.fill_underlay, 'yes': element.fill_underlay} return underlay[self.options.fill_underlay] diff --git a/templates/select_elements.xml b/templates/select_elements.xml index 095fb18e..4d8823e5 100644 --- a/templates/select_elements.xml +++ b/templates/select_elements.xml @@ -16,7 +16,9 @@ <option value="all">No restriction</option> <option value="autorun-top">Auto-Run Top Stitching</option> <option value="autorun-underpath">Auto-Run Underpath</option> + <option value="autosatin-underpath">Auto-Satin Underpath</option> </param> + <param indent="3" name="bean-stitch-repeats" type="string" gui-text="Bean stitch repeats">0</param> <param indent="1" name="select-ripples" type="boolean" gui-text="Ripples">false</param> <param indent="1" name="select-zigzag" type="boolean" gui-text="ZigZag Stitch">false</param> <param indent="1" name="select-manual" type="boolean" gui-text="Manual Stitch">false</param> @@ -57,6 +59,7 @@ <param indent="1" name="select-guided-fill" type="boolean" gui-text="Guided Fill">false</param> <param indent="1" name="select-linear-gradient-fill" type="boolean" gui-text="Linear Gradient Fill">false</param> <param indent="1" name="select-meander-fill" type="boolean" gui-text="Meander Fill">false</param> + <param indent="1" name="select-tartan-fill" type="boolean" gui-text="Tartan Fill">false</param> <param indent="1" name="select-legacy-fill" type="boolean" gui-text="Legacy Fill">false</param> <param indent="1" name="fill-underlay" type="optiongroup" appearance="combo" gui-text="Underlay" gui-description="Only select fills with this underlay"> |
