-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plugin_ShowLayer.py
86 lines (85 loc) · 2.82 KB
/
Plugin_ShowLayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
from gimpfu import *
import gimpfu
import re
import subprocess
import os
import inspect
layerSelected = []
def layerShow(image, bLayerActive,bVisible,bProgress):
def listGuiRun():
def fillList(L,ls):
for Layer in L.layers:
if pdb.gimp_item_is_group(Layer):
fillList(Layer,ls)
else:
if pdb.gimp_item_is_drawable(Layer):
ls.append([Layer.name])
import gtk
ls = gtk.ListStore(str)
fillList(image,ls)
scroll=gtk.ScrolledWindow()
tv = gtk.TreeView(ls)
col = gtk.TreeViewColumn("Layers", gtk.CellRendererText(), text=0)
tv.set_reorderable(True)
col.set_sort_column_id(0)
tv.append_column(col)
sel = tv.get_selection()
sel.set_mode(gtk.SELECTION_MULTIPLE)
dialog = gtk.Dialog("Selection Layers",None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,gtk.STOCK_OK, True))
dialog.resize(400, 400)
scroll.add_with_viewport(tv)
scroll.show()
dialog.vbox.pack_start(scroll)
tv.show()
response = dialog.run()
(model, pathlist) = sel.get_selected_rows()
dialog.destroy()
if not response==True:
return
for path in pathlist :
tree_iter = model.get_iter(path)
value = model.get_value(tree_iter,0)
layerSelected.append(value)
return
def doShow(group):
ll = group.layers
for layer in ll:
### recursion for nested groups ###
if (type(layer) == gimp.GroupLayer):
doShow(layer)
else:
if bProgress: pdb.gimp_progress_pulse()
if layer.name in layerSelected:
pdb.gimp_item_set_visible(layer, bVisible)
else:
pdb.gimp_item_set_visible(layer, not bVisible)
if bProgress: gimp.progress_init("Show/Hidden Layers")
if bLayerActive:
layerSelected.append( pdb.gimp_image_get_active_layer(image).name )
else:
listGuiRun()
pdb.gimp_image_undo_group_start(image)
doShow(image)
if bProgress: pdb.gimp_progress_end()
pdb.gimp_image_undo_group_end(image)
register(
"python_fu_ShowHiddenLayers",
"Show layers selected and hidden all",
"Nothing a",
"Anonymous a",
"1.1.0",
"2020",
"Show and hidden layers",
"RGB*, GRAY*",
[
(PF_IMAGE,"image","Input image", None),
(PF_TOGGLE, "bLayerActive", "Only Layer Active", False),
(PF_TOGGLE, "bVisible", "Selection is Visible", True),
(PF_TOGGLE, "bProgress", "Progress", True),
],
[],
layerShow,
menu="<Image>/Layer/Tools/"
)
main()