Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Gimp 3.0 Plug-in (group_selected_layers)
#12
(11-17-2024, 05:07 AM)Newman Wrote: Plug-in: group-selected-layers
Description: nests all currently selected layers inside a new group layer.  

UPDATED VERSION addressing most of the changes suggested (again many thanks, Ofnuts). 


Anymore feedback still very much welcome


Now tested and working on version 3.0.0-RC1+git
More details in code comments


Commit history here: https://github.com/newinput/gimp3_plug-i...ted_layers  

For do_set_i18n() you can return (False, None, None)

|code]
for drawable in n_drawables:
          if drawable not in selected_layers and (Gimp.Item.is_layer(drawable) or Gimp.Item.is_group_layer(drawable)):
              selected_layers.append(drawable)
[/code]
Since
  • I doubt that a layer/group appears twice in n_layers 
  • GroupLayer is  a subclass of Layer, so any GroupLayer is a Layer
you can simplify the test, and to be "pythonic" use a one-line comprehension:
Code:
selected_layers=[drawable for drawable in n_drawables if drawable.is_group()]

Code:
if len(selected_layers) == 0:
can be replaced by
Code:
if not selected_layers:
because in python, when used as tests, None and empty objects (strings, list, dictionaries...) are "falsy" ("truthy" otherwise), so if somevariable tests if somevariable has usable contents.

Your "messages" are  a soup of "\n". (and IMHO they are too long anyway). If you want a clean message, investigate using triple quoting:

Code:
Gimp.message('''
This message appears exactly
as you
type it!''')
Reply


Messages In This Thread
RE: My Gimp 3.0 Plug-in (group_selected_layers) - by Ofnuts - 11-17-2024, 09:26 AM

Forum Jump: