cvsimport
[fvwm-themes.git] / scripts / FvwmScript-ImageBrowser
blobf8c31daf32758bccfaf8cb971a5e016335ca9d8c
1 # This script is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16 #-----------------------------------------------------------------------------
17 # This fvwm-themes "module" is a modification of FvwmScript-FileBrowser
18 # from fvwm (in fact rewrote from scratch ...)
19 #     Copyright 2000, Olivier Chapuis
20 #-----------------------------------------------------------------------------
22 # Note : the mode list is not yet supported!
24 WindowTitle {Image Browser}
25 WindowSize 650 430              # Taille
26 Font            -adobe-helvetica-bold-r-*-*-12-*
28 Init
29 Begin
30     # Name of the "utile" perl script
31     Set $PerlUtile={fvwm-themes-script }
33     # Arguments
34     Set $LsOptions = {1F}
35     Set $hidden = {}
36     Set $Type = {}
37     Set $Mode = {browser}
38     Set $i = 1
39     Set $ARG = (GetScriptArgument $i)
40     Set $Launched = 1
42     While $ARG <> {} Do
43     Begin
44         Set $j = (Add $i 1)
45         If $ARG == {--dir} Then
46             Set $Directory = (GetScriptArgument $j)
47         If $ARG == {--mode} Then
48             Set $Mode = (GetScriptArgument $j)
49         If $ARG == {--ls-options} Then
50             Set $LsOptions = $LsOptions (GetScriptArgument $j)
51         If $ARG == {--text-colorset} Then
52             Set $TextColorset = (GetScriptArgument $j)
53         If $ARG == {--icon-colorset} Then
54             Set $ICON_COLORSET = (GetScriptArgument $j)
55         If $ARG == {--list-title} Then
56             Set $ListTitle = (GetScriptArgument $j)
57         If $ARG == {--launched} Then
58             Set $Launched = (GetScriptArgument $j)
59         Set $i = (Add $i 2)
60         Set $ARG = (GetScriptArgument $i)
61     End
63 #    If $Launched == 1 Then
64 #       Do {Style "FvwmScript-IconBrowser" StaysOnTop, NoHandles}
65 #    Else
66 #       Do {Style "FvwmScript-IconBrowser" StaysPut, NoHandles}
68     If $TextColorset <> {} Then
69     Begin
70         ChangeColorset 5 $TextColorset
71         ChangeColorset 7 $TextColorset
72     End
73     If $ICON_COLORSET <> {} Then
74     Begin
75         ChangeColorset 8 $ICON_COLORSET
76     End
78     If $Mode == {list} Then
79     Begin
80         Set $UpdateList = 1
81         HideWidget 5
82         HideWidget 4
83         HideWidget 6
84         HideWidget 11
85         HideWidget 12
86         ChangeTitle 20 $ListTitle
87         Set $Type = {file}
88     End
89     
90     If $Mode == {browser} Then
91     Begin
92         Set $UpdateList = 1
93         Set $CMD={cd } $Directory{; pwd}
94         Set $Directory=(GetOutput $CMD 1 -1)
95         ChangeTitle 7 $List
96         ChangeTitle 5 $Directory
97         ChangeTitle 9 {}
98         HideWidget 20
99     End
103 PeriodicTasks
104 Begin
105     If $UpdateValue == 1 Then
106     Begin
107         Set $UpdateValue = 0
108         Set $CMD = $PerlUtile {--dirs="}$Directory{" --ls --ls-opt=-"}$LsOptions $hidden{" --item=}$Value{ --type="}$Type{"}
109         Set $TheItem = (GetOutput $CMD 1 -1)
110         Set $CMD = {if [ -d "}$Directory {/} $TheItem{" ]; then echo 1; else echo 0; fi}
111         Set $test = (GetOutput $CMD 1 -1)
112         If $test == 1 Then
113         Begin
114             Set $UpdateList = 1
115             Set $Directory = $Directory {/} $TheItem
116             Set $CMD={cd } $Directory{; pwd}
117             Set $Directory=(GetOutput $CMD 1 -1)
118             ChangeTitle 5 $Directory
119             ChangeTitle 9 {}
120             ChangeIcon 8 mini/empty.xpm
121         End
122         Else
123         Begin
124             ChangeTitle 9 $TheItem
125             Set $Icon = $Directory {/} $TheItem
126             Set $Fit = (GetValue 50)
127             If $Fit == 1 Then
128             Begin
129                 Do {Echo I:}$Icon
130                 Set $cmd = {rm -f /tmp/ft-ib.xpm; convert -geometry "365x335>" }$Icon{ /tmp/ft-ib.xpm}
131                 Set $dummy = (GetOutput $cmd 1 -1)
132                 Set $tmp = {/tmp/ft-ib.xpm}
133                 ChangeIcon 8 $tmp
134             End
135             Else
136                 ChangeIcon 8 $Icon
137         End
138     End
140     If $UpdateList == 1 Then
141     Begin
142         Set $UpdateList = 0
143         Set $GetListCmd= $PerlUtile {--dirs="}$Directory{" --ls --ls-opt="-}$LsOptions $hidden{" --type="}$Type{"}
144         Set $List = (GetOutput $GetListCmd 1 -1)
145         ChangeTitle 7 $List
146         ChangeTitle 5 $Directory
147         ChangeTitle 9 {}
148         ChangeIcon 8 mini/empty.xpm
149         ChangeValue 7 0
150     End
154 Widget 1
155 Property
156  Size 80 20
157  Position 80 390
158  Type PushButton
159  Flags NoReliefString
160  Title {OK}
161 Main
162  Case message of
163  SingleClic :
164  Begin
165     If $Launched == 1 Then
166     Begin
167         If $Mode == {list} Then
168             SendToScript (GetScriptFather) (GetTitle 9)
169         Else
170             SendToScript (GetScriptFather) $Directory {/} (GetTitle 9)
171     End
172     Quit
173   End
176 Widget 2
177 Property
178  Size 80 20
179  Position 490 390
180  Type PushButton
181  Flags NoReliefString
182  Title {Cancel}
183 Main
184  Case message of
185  SingleClic :
186  Begin
187     If $Launched == 1 Then
188         SendToScript (GetScriptFather) {Cancel}
189     Quit
190   End
193 Widget 3
194 Property
195  Position 5 4
196  Size 270 370
197  Type Rectangle
198 Main
199  Case message of
200   SingleClic :
201   Begin
202   End
205 Widget 4
206 Property
207  Position 10 25
208  Type PushButton
209  Flags NoReliefString
210  Title {Path:}
211 Main
212  Case message of
213   SingleClic :
214   Begin
215     Set $Directory = (GetTitle 5)
216     Set $UpdateList = 1
217   End
220 Widget 5
221 Property
222  Position 65 25
223  Size 205 20
224  Font -*-fixed-medium-r-semicondensed-*-13-*
225  Type TextField
226  Flags NoReliefString
227  Title {}
228 Main
229  Case message of
230   SingleClic :
231   Begin
232   End
235 Widget 20
236 Property
237  Position 20 45
238  Size 320 20
239  Type ItemDraw
240  Flags NoReliefString
241  Title {All Applications in Path}
242 Main
243  Case message of
244  SingleClic :
245  Begin
246  End
249 Widget 6
250 Property
251  Position 10 62
252  Size 50 18
253  Flags NoReliefString
254  Title {up}
255  #Icon up.xpm
256  Type PushButton
257 Main
258  Case message of
259   SingleClic :
260   Begin
261     Set $CMD={cd } $Directory {; cd ../; pwd}
262     Set $Directory=(GetOutput $CMD 1 -1)
263     Set $UpdateList = 1
264   End
267 Widget 11
268 Property
269  Position 75 62
270  Size 35 18
271  Flags NoReliefString
272  Title {home}
273  #Icon home.xpm
274  Type PushButton
275 Main
276  Case message of
277   SingleClic :
278   Begin
279     Set $Directory={~/}
280     Set $CMD={cd } $Directory{; pwd}
281     Set $Directory=(GetOutput $CMD 1 -1)
282     Set $UpdateList = 1
283   End
286 Widget 12
287 Property
288  Position 140 67
289  Type CheckBox
290  Font -*-fixed-medium-r-semicondensed-*-13-*
291  Flags NoReliefString
292  Title {Show hidden files}
293 Main
294  Case message of
295  SingleClic :
296  Begin
297     If (GetValue 12) == 1 Then
298         Set $hidden={A}
299     Else
300         Set $hidden={ }
301     Set $UpdateList = 1   
302  End
305 Widget 7
306 Property
307  Position 10 105
308  Size 260 230
309  Type List
310  Font -*-fixed-medium-r-semicondensed-*-13-*
311  Flags NoReliefString
312  Title {}
313 Main
314  Case message of
315  SingleClic :
316  Begin
317     Set $Value = (GetValue 7)
318     Set $UpdateValue = 1
319  End
322 Widget 8
323 Property
324  Position 280 5
325  Size 365 335
326  Type ItemDraw
327  Icon mini/empty.xpm
328 Main
329  Case message of
330   SingleClic :
331   Begin
332   End
335 Widget 81
336 Property
337  Position 279 4
338  Size 367 337
339  Type Rectangle
340 Main
341  Case message of
342   SingleClic :
343   Begin
344   End
347 Widget 9
348 Property
349  Position 10 345
350  Size 260 20
351  Type ItemDraw
352  Flags NoReliefString
353  Title {}
354 Main
355  Case message of
356   SingleClic :
357   Begin
358   End
361 Widget 50
362 Property
363  Position 280 352
364  Type ItemDraw
365  Flags NoReliefString
366  Type CheckBox
367  Title {Fit image in window (365x335) and convert}
368 Main
369  Case message of
370   SingleClic :
371   Begin
372     Set $UpdateValue = 1
373   End