Update plainbow theme to use features in FVWM 2.5.25+
[fvwm-themes.git] / scripts / FvwmScript-Menus
blob790d3ff96c608554e81ea858474ec1c3c6e31a78
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 # Copyright 2000, Olivier Chapuis
18 #-----------------------------------------------------------------------------
21 WindowTitle {FVWM Themes Menus Editor}
22 WindowSize 650 405
23 Font            -adobe-helvetica-bold-r-*-*-12-*
24 #Flags NoReliefString
26 Init
27 Begin
29     # Arguments
30     Set $i = 1
31     Set $arg = (GetScriptArgument $i)
32     While $arg <> {} Do
33     Begin
34         Set $j = (Add $i 1)
35         If $arg == {--files} Then
36             Set $file = (GetScriptArgument $j)
37         If $arg == {--menus} Then
38             Set $Menu = (GetScriptArgument $j)
39         If $arg == {--images-dir} Then
40             Set $ImagesDir = (GetScriptArgument $j)
41         If $arg == {--text-colorset} Then
42             Set $TextColorset = (GetScriptArgument $j)
43         If $arg == {--icon-colorset} Then
44             Set $IconColorset = (GetScriptArgument $j)  
45         Set $i = (Add $i 2)
46         Set $arg = (GetScriptArgument $i)
47     End
48     
49     Set $cmd = {echo "$FT_DATADIR"}
50     Set $FtDataDir = (GetOutput $cmd 1 -1)
52     If $ImagesDir == {} Then
53     Begin
54         Set $ImagesDir=$FtDataDir{/images/menu/}
55     End
56     If $TextColorset <> {} Then
57     Begin
58         ChangeColorset 4 $TextColorset
59         ChangeColorset 22 $TextColorset
60         ChangeColorset 39 $TextColorset
61         ChangeColorset 44 $TextColorset
62         ChangeColorset 48 $TextColorset
63         ChangeColorset 51 $TextColorset
64         ChangeColorset 53 $TextColorset
65     End
66     If $IconColorset <> {} Then
67     Begin
68         ChangeColorset 41 $IconColorset
69     End
71     # found the FvwmScript pid
72     Set $cmd = {exec perl -e 'print getppid . "\n"'}
73     Set $pid = (GetOutput $cmd 1 -1)
75     # Run fvwm-themes-menuapp until the end of the script
76     Set $MenuFilesList={$FVWM_USERDIR/themes/personal/menus-extra}
77     Do {Exec fvwm-themes-menuapp --menu-files=}$MenuFilesList{ --com-mode --com-name=menuapp-}$pid{ &}
79     # to send fvwm-themes-com command
80     Set $SendMsgAndGet = {fvwm-themes-com --name menuapp-}$pid{ --lock-and-get --message=}
81     Set $SendMsg = {fvwm-themes-com --name menuapp-}$pid{  --message=}
82     Set $GetLine = {fvwm-themes-com --name menuapp-}$pid{  --get-buffer --line=}
83     
84     Set $MenuLevel = 0
85     If $Menu == {} Then
86     Begin
87         Set $UseRootMenusList = 1
88         Set $isRootMenu = 1
89         Set $cmd = $SendMsgAndGet{"root-menus-list"}
90         Set $RootMenus = (GetOutput $cmd 1 -1)
91         ChangeTitle 2 $RootMenus
92         HideWidget 3
93         Set $cmd = $SendMsgAndGet{"root-menu 1"}
94         Set $Menu = (GetOutput $cmd 1 -1)
95     End
96     Else
97     Begin
98         Set $cmd={echo "}$Menu{"| grep -e '|'}
99         Set $tmp = (GetOutput $cmd 1 -1)
100         If $tmp == {} Then
101         Begin
102             Set $t = {Menu } $Menu
103             HideWidget 1
104             HideWidget 2
105             ChangeTitle 3 $t
106             Set $UseRootMenusList = 0
107             Set $isRootMenu = 0
108         End
109         Else
110         Begin
111             Set $RootMenus = $Menu
112             ChangeTitle 2 $RootMenus
113             HideWidget 3
114             Set $MenuLevel = 0
115             Set $cmd={perl -e '$M="} $Menu {";$M=substr($M,0,index($M,"|")); print "$M\n";'}
116             Set $Menu = (GetOutput $cmd 1 -1)
117             Set $UseRootMenusList = 2
118             Set $isRootMenu = 1
119         End
121     End
122     #Do {Echo URM:}$UseRootMenusList{, RM:}$RootMenus{, M:}$Menu
124     # Get the menu list
125     Set $cmd = $SendMsgAndGet{"menu-items }$Menu{"}
126     Set $ItemsList = (GetOutput $cmd 1 -1)
127     Set $cmd = $SendMsgAndGet{"nbr-of-items }$Menu{"}
128     Set $NbrOfItems = (GetOutput $cmd 1 -1)
130     If $ItemList == 0 Then
131         Set $ItemsList = {}
133     ChangeTitle 4 $ItemsList
135     Set $t={Selected: }
136     ChangeTitle 5 $t
137     Set $t={Type: }
138     ChangeTitle 6 $t
139     Set $t={Action: }
140     ChangeTitle 7 $t
142     Set $t={Msg: Warning Message are displayed here}
143     ChangeTitle 16 $t
145     Set $Empty = {}
146     # Nbr of items in the selection
147     Set $SelNumber = O
148     Set $SelFont = {-adobe-helvetica-bold-r-*-*-12-*}
149     Set $ShadeFont = {-adobe-helvetica-medium-r-*-*-12-*}
150     Set $EditorType = {Separator}
151     Set $MenuIconBrowser = {}
152     Set $FileDirBrowser = {}
153     Set $FindItBrowser = {}
154     #
155     ChangeFont 13 $ShadeFont
156     ChangeFont 15 $ShadeFont
157     Set $tmp = 18
158     While $tmp <> 22 Do
159     Begin
160         ChangeFont $tmp $ShadeFont
161         Set $tmp = (Add $tmp 1)
162     End
163     Set $HideEditorWidgets = 0
164     Set $tmp = 36
165     While $tmp <> 54 Do
166     Begin
167         HideWidget $tmp
168         Set $tmp = (Add $tmp 1)
169     End
170     HideWidget 70
171     HideWidget 71
173     # Periodic Tasks command variables
174     Set $HideEditorWidgets = 0
175     Set $HideMainWidgets = 0
176     Set $ShowMainWidgets = 0
177     Set $EditMess = {No message}
178     Set $MenuListValueIsZero = 1
180     # number of possible items the lists minus one 
181     Set $NbrOfVisibleItems = 10
182     Set $NbrOfVisibleSelItems = 3
185 # ---------------------------------------------------------------------------
187 # Periodic Task
189 # ---------------------------------------------------------------------------
190 # Almost every thing is done in the Periodic Task 
192 PeriodicTasks
193 Begin
195 #--------------------------------------
196 # Hide/show, Hiding before Show
198     If $HideMainWidgets == 1 Then
199     Begin
200         Set $HideMainWidgets = 0
201         Set $tmp = 1
202         While $tmp <> 27 Do
203         Begin
204             HideWidget $tmp
205             Set $tmp = (Add $tmp 1)
206         End
207     End
209     If $HideEditorWidgets == 1 Then
210     Begin
211         Set $HideEditorWidgets = 0
212         Set $tmp = 36
213         While $tmp <> 54 Do
214         Begin
215             HideWidget $tmp
216             Set $tmp = (Add $tmp 1)
217         End
218         HideWidget 70
219         HideWidget 71
220     End
222     If $ShowMainWidgets == 1 Then
223     Begin
224         Set $ShowMainWidgets = 0
226         If $isRootMenu == 1 Then
227         Begin
228             ShowWidget 1
229             ShowWidget 2
230         End
231         Else
232             ShowWidget 3
234         Set $tmp = 4
235         While $tmp <> 27 Do
236         Begin
237             ShowWidget $tmp
238             Set $tmp = (Add $tmp 1)
239         End
240     End
242 #--------------------------------------
243 # "Message" from the command editor (OK), the menu is modified here!
245     If $EditMess <> {No message} Then
246     Begin
247         Set $Err = (GetOutput $EditMess 1 -1)
248         Set $EditMess = {No message}
249         #Do {Echo ErrEM:}$Err
250         If $Value == 0 Then
251             Set $Value = 1
252     End
254 #-------------------------------------
257     If $UpdateEditorWidgets == 1 Then
258     Begin
259         Set $UpdateEditorWidgets = 0
261         Set $lastWidget = 36
262         Set $hasTitle = 0
263         Set $isMenu = 0
265         If $EditorType == {Separator} Then
266         Begin
267             ChangeValue 37 1
268             Set $lastWidget = 37
269         End
270         If $EditorType == {X Application} Then
271         Begin
272             Set $lastWidget = 49
273             Set $ActionTitle = {Exec:       }
274             ChangeValue 37 2
275         End
276         If $EditorType == {Run in a Terminal} Then
277         Begin
278             Set $lastWidget = 48
279             ChangeValue 37 3
280             Set $ActionTitle = {Exec:       }
281             Set $hasTitle = 1
282         End
283         If $EditorType == {Tail File} Then
284         Begin
285             Set $lastWidget = 48
286             ChangeValue 37 4
287             Set $ActionTitle = {File:        }
288             Set $hasTitle = 1
289         End
290         If $EditorType == {Title} Then
291         Begin
292             Set $lastWidget = 42
293             ChangeValue 37 5
294         End
295         If $EditorType == {Fvwm Command} Then
296         Begin
297             ChangeValue 37 6
298             Set $ActionTitle = {Command:}
299             Set $lastWidget = 45
300         End
301         If $EditorType == {Sub Menu} Then
302         Begin
303             ChangeValue 37 7
304             Set $lastWidget = 44
305             Set $ActionTitle = {Menu:      }
306             Set $isMenu = 1
307         End
308         If $EditorType == {Menu} Then
309         Begin
310             ChangeValue 37 8
311             Set $lastWidget = 44
312             Set $ActionTitle = {Menu:      }
313             Set $isMenu = 1
314         End
316         ChangeTitle 43 $ActionTitle
318         If $hasTitle == {1} Then
319         Begin
320             Set $t = {Window Title:}
321             If $EditOrAdd == {E} Then
322                 ChangeTitle 48 $WindowTitle
323         End
324         Else
325         Begin
326             Set $t = {Working Dir:  }
327             If $EditOrAdd == {E} Then
328                 ChangeTitle 48 $WorkingDir
329         End
330         ChangeTitle 47 $t
332         Set $W = (Add $lastWidget 1)
333         Set $tmp = 36
334         While $tmp <> $W Do
335         Begin
336             ShowWidget $tmp
337             Set $tmp = (Add $tmp 1)
338         End
339         ShowWidget 70
340         ShowWidget 71
342         If $isMenu == {1} Then
343         Begin
344             Set $cmd = $SendMsgAndGet{"menus-list"}
345             Set $MenusList =(GetOutput $cmd 1 -1)
346             ChangeTitle 51 $MenusList
347             Set $tmp = 50
348             While $tmp <> 54 Do
349             Begin
350                 ShowWidget $tmp
351                 Set $tmp = (Add $tmp 1)
352             End
353         End
354     End
356 #--------------------------------------
357 # Click on OK or "Double Click" on a submenu in the list
359     If $OpenSubMenu == 1 Then
360     Begin
361         Set $OpenSubMenu = 0
362         Set $LevelMenu = (Add $LevelMenu 1)
363         If $UP <> {} Then
364         Begin
365                 Set $UP=$UP{ }$Menu
366         End
367         Else
368         Begin
369                 Set $UP=$Menu
370                 If $UseRootMenusList <> {0} Then
371                 Begin
372                     HideWidget 1
373                     HideWidget 2
374                     ShowWidget 3
375                     Set $isRootMenu = 0
376                 End
377         End
378         ChangeFont 15 $SelFont 
379         Set $Menu=$Action
380         Set $t = $UP{ }$Menu
381         Set $cmd={echo "}$t{"|sed -e 's/ /->/g'}
382         Set $t = (GetOutput $cmd 1 -1)
383         Set $t = {Menu: }$t
384         ChangeTitle 3 $t
385     
386         Set $UpdateItemsList = 1
387         Set $MenuListValueIsZero = 1
389     End
391 #--------------------------------------
394     If $UpdateItemsList == 1 Then
395     Begin
396         Set $UpdateItemsList = 0
397         Set $cmd=$SendMsgAndGet{"menu-items }$Menu{"}
398         Set $ItemsList = (GetOutput $cmd 1 -1)
399         If $ItemsList == 0 Then
400             Set $ItemsList = {}
401         ChangeTitle 4 $ItemsList
402         Set $cmd = $SendMsgAndGet{"nbr-of-items }$Menu{"}
403         Set $NbrOfItems = (GetOutput $cmd 1 -1)
404         If $Value == 0 Then
405             Set $MenuListValueIsZero = 1
406         #Do {Echo List updated}
407         Set $t={}
408         ChangeTitle 16 $t
409     End
411 #--------------------------------------
412 # Update the selected item in the list
414     If $UpdateTheItem == 1 Then
415     Begin
416         Set $UpdateTheItem = 0
417         If $Value == 0 Then
418         Begin
419             Set $Value = 1
420         End
421         ChangeValue 4 $Value
423         # Show the selected items!
424         # first visible item
425         Set $tmp = (GetMinValue 4)
426         # last visible item
427         Set $tmp1 = (Add $NbrOfVisibleItems $tmp)
428         If $Value < $tmp Then
429         Begin
430             ChangeMinValue 4 $Value
431             ChangeTitle 4 $ItemsList
432         End
433         If $Value > $tmp1 Then
434         Begin
435             Set $tmp1 = (Mult $tmp1 -1)
436             Set $tmp1 = (Add $Value $tmp1)
437             Set $tmp = (Add $tmp $tmp1)
438             ChangeMinValue 4 $tmp
439             ChangeTitle 4 $ItemsList
440         End
442         Set $cmd = $SendMsgAndGet{"item }$Menu{:}$Value{" --line=1}
444         Set $Name=(GetOutput $cmd 1 -1)
445         Set $t={Selected: }$Name
446         ChangeTitle 5 $t
448         Set $cmd = $GetLine{2}
449         Set $Type=(GetOutput $cmd 1 -1)
450         Set $t={Type: }$Type
451         ChangeTitle 6 $t
453         Set $cmd = $GetLine{3}
454         Set $Action=(GetOutput $cmd 1 -1)
455         Set $t={Action: }$Action
456         Set $ti=(StrCopy $t  1  40)
457         Set $tmp=(StrCopy $t  41  41)
458         If $tmp <> {} Then
459             Set $ti=$ti{ ...}
460         ChangeTitle 7 $ti
462         If $Type <> {} Then
463         Begin
464             ChangeFont 8 $SelFont 
465             ChangeFont 9 $SelFont 
466             ChangeFont 10 $SelFont 
467             ChangeFont 11 $SelFont 
468             ChangeFont 12 $SelFont 
469         End
470         If $Type == {Sub Menu} Then
471         Begin
472             ChangeFont 13 $SelFont
473         End
474         Else
475         Begin
476             ChangeFont 13 $ShadeFont
477         End
478         
479         Set $t={}
480         ChangeTitle 16 $t
482         Set $cmd = $GetLine{4}
483         Set $WorkingDir=(GetOutput $cmd 1 -1)
485         Set $cmd = $GetLine{5}
486         Set $WindowTitle=(GetOutput $cmd 1 -1)
488         Set $cmd = $GetLine{6 --clear-buffer}
489         Set $MenuIcon=(GetOutput $cmd 1 -1)
490         #Do {Echo The Item is updated}
491     End
493 #--------------------------------------
495     If $UpdateSelectionList == 1 Then
496     Begin
497         Set $UpdateSelectionList = 0
498         Set $cmd=$SendMsgAndGet{"selection-items"}
499         Set $SelectedList = (GetOutput $cmd 1 -1)
500         #ChangeTitle 22 $SelectedList
501         ChangeValue 22 $SelNumber
502         If $SelNumber == 0 Then
503         Begin
504             Set $tmp = 18
505             While $tmp <> 22 Do
506             Begin
507                 ChangeFont $tmp $ShadeFont
508                 Set $tmp = (Add $tmp 1)
509             End
510         End
511         Else
512         Begin
513             Set $tmp = 18
514             While $tmp <> 22 Do
515             Begin
516                 ChangeFont $tmp $SelFont
517                 Set $tmp = (Add $tmp 1)
518             End
519             Set $SelValue = (Add $SelValue -1)
520             If $SelNumber == $tmpSelValue Then
521             Begin
522                 ChangeValue 22 $SelNumber
523                 Set $SelValue = $SelNumber
524             End
525         End
527         # Show the selected items!
528         # first visible item
529         Set $tmp = (GetMinValue 22)
530         # last visible item
531         Set $tmp1 = (Add $NbrOfVisibleSelItems $tmp)
532         If $SelNumber < $tmp Then
533         Begin
534             ChangeMinValue 22 $SelValue
535         End
536         If $SelNumber > $tmp1 Then
537         Begin
538             Set $tmp1 = (Mult $tmp1 -1)
539             Set $tmp1 = (Add $SelNumber $tmp1)
540             Set $tmp = (Add $tmp $tmp1)
541             ChangeMinValue 22 $tmp
542         End
543         ChangeTitle 22 $SelectedList
545         Set $t={}
546         ChangeTitle 16 $t
547     End
549 #--------------------------------------
551     If $MenuListValueIsZero == 1 Then
552     Begin
553         Set $Value = 0
554         Set $MenuListValueIsZero = 0
555         ChangeValue 4 0
556         Set $t={Selected: }
557         ChangeTitle 5 $t
558         Set $t={Type: }
559         ChangeTitle 6 $t
560         Set $t={Action: }
561         ChangeTitle 7 $t
562         ChangeFont 8 $ShadeFont
563         ChangeFont 9 $ShadeFont
564         ChangeFont 10 $ShadeFont
565         ChangeFont 11 $ShadeFont
566         ChangeFont 12 $ShadeFont
567         ChangeFont 13 $ShadeFont
568     End
570 #--------------------------------------
571 # Communication with the Bowsers
572     
573     If $MenuIconBrowser <> {} Then
574     Begin
575         Set $MSG = (ReceivFromScript $MenuIconBrowser)
576         If $MSG <> {No message} Then
577         Begin
578             Set $MenuIconBrowser = {}
579             If $MSG <> {Cancel} Then 
580             Begin
581                 Set $EditorMenuIcon = $MSG
582                 ChangeIcon 41 $MSG
583             End
584         End
585     End
587     If $FileDirBrowser <> {} Then
588     Begin
589         Set $MSG = (ReceivFromScript $FileDirBrowser)
590         If $MSG <> {No message} Then
591         Begin
592             Set $FileDirBrowser = {}
593             If $MSG <> {Cancel} Then 
594             Begin
595                 ChangeTitle 48 $MSG
596             End
597         End
598     End
600     If $FindItBrowser <> {} Then
601     Begin
602         Set $MSG = (ReceivFromScript $FindItBrowser)
603         If $MSG <> {No message} Then
604         Begin
605             Set $FindItBrowser = {}
606             If $MSG <> {Cancel} Then 
607             Begin
608                 ChangeTitle 44 $MSG
609             End
610         End
611     End
615 # ---------------------------------------------------------------------------
617 # Now the widgets
619 # ---------------------------------------------------------------------------
621 #---------------------------------------------------------------------------
622 # Root Menus list or path to the MENU
624 Widget 1
625 Property
626     Flags NoReliefString
627     Position 200 10
628     Type ItemDraw
629     Title {Root Menus:}
630 Main
631 Case message of
632     SingleClic :
633     Begin
634     End
637 Widget 2
638 Property
639     Flags NoReliefString
640     Position 300 5
641     Type PopupMenu
642     Title {                                                }
643 Main
644  Case message of
645  SingleClic :
646  Begin
647     Set $RootValue = (GetValue 2)
648     Set $cmd = {perl -e '$M="}$RootMenus{"; $I=}$RootValue{;$I--; @A=split("\\|",$M); print $A[$I] . "\n"'}
649     Set $Menu = (GetOutput $cmd 1 -1)
651     Set $UpdateItemsList = 1
652     Set $MenuListValueIsZero = 1
654  End
658 # Menu path
659 Widget 3
660 Property
661     Flags NoReliefString
662     Size 630 20
663     Position 10 10
664     Type ItemDraw
665     Title {}
666 Main
667  Case message of
668   SingleClic :
669   Begin
670   End
673 #---------------------------------------------------------------------------
674 # Items List
676 Widget 4
677 Property
678     Flags NoReliefString
679     Position 20 40
680     Size 300 200
681     Type List
682     Title {}
683 Main
684  Case message of
685  SingleClic :
686  Begin
687     # Double click simulation hum ...
688     Set $tmpValue = (GetValue 4)
689     Set $t = 0
690     Set $t1 = 0
691     Set $t2 = 0
692     If $tmpValue == $Value Then
693         Set $t = 1
694     If $Type == {Sub Menu} Then
695         Set $t1 = 1
696     If $Type == {Menu} Then
697         Set $t1 = 1
698     If $Menu <> $Action Then
699         Set $t2 = 1
700     Set $t = (Mult $t $t1)
701     Set $t = (Mult $t $t2)
702     Set $Value = $tmpValue
703     If $t == 1 Then
704     Begin
705         Set $OpenSubMenu = 1      
706     End
707     Else
708     Begin
709         Set $UpdateTheItem = 1
710     End
712  End
715 #----------------------------------------------------------------------------
717 #Selected items
718 Widget 5
719 Property
720     Flags NoReliefString
721     Size 320 20
722     Position 330 50
723     Type ItemDraw
724     Title {}
725 Main
726  Case message of
727   SingleClic :
728   Begin
729   End
732 # Type of the item
733 Widget 6
734 Property
735     Flags NoReliefString
736     Size 320 20
737     Position 330 70
738     Type ItemDraw
739     Title {}
740 Main
741  Case message of
742   SingleClic :
743   Begin
744   End
747 # Action of the item
748 Widget 7
749 Property
750     Flags NoReliefString
751     Size 320 20
752     Position 330 90
753     Type ItemDraw
754     Title {}
755 Main
756  Case message of
757   SingleClic :
758   Begin
759   End
762 # -----------------------------------------------------------------------------
763 # "Files" buttons
765 # Edit
766 Widget 8
767 Property
768     Flags NoReliefString
769     Position 340 130
770     Type PushButton
771     Title {Edit}
772 Main
773  Case message of
774   SingleClic :
775   Begin
776     Set $EditorValue = (GetValue 4)
777     If $EditorValue == 0 Then
778     Begin
779         Set $t={Msg: You need to select an item!}
780         ChangeTitle 16 $t
781     End
782     Else
783     Begin
784         Set $EditOrAdd = {E}
785         Set $HideMainWidgets = 1
786         Set $EditorType = $Type
787         Set $EditorMenuIcon = $MenuIcon
788         ChangeValue 39 0
789         ChangeMinValue 39 0
790         ChangeMaxValue 39 0
791         ChangeTitle 39 $Name
792         ChangeIcon 41 $MenuIcon
793         ChangeMinValue 44 0
794         ChangeMaxValue 44 0
795         ChangeValue 44 0
796         ChangeTitle 44 $Action
797         ChangeMinValue 48 0
798         ChangeMaxValue 48 0
799         ChangeValue 48 0
800         Set $UpdateEditorWidgets = 1
801     End
802   End
805 Widget 9
806 Property
807     Flags NoReliefString
808     Position 400 130
809     Type PushButton
810     Title {Copy}
811 Main
812  Case message of
813  SingleClic :
814  Begin
815     Set $Value = (GetValue 4)
816     If $Value == 0 Then
817     Begin
818         Set $t={Msg: You need to select an item!}
819         ChangeTitle 16 $t
820     End
821     Else
822     Begin
823         Set $cmd=$SendMsgAndGet{"add-item-to-selection }$Menu{:}$Value{"}
824         Set $Err=(GetOutput $cmd 1 -1)
825         If $Err <> 0 Then
826         Begin
827             Set $SelNumber = (Add $SelNumber 1)
828             Set $UpdateSelectionList = 1
829         End
830     End
831  End
834 Widget 10
835 Property
836     Flags NoReliefString
837     Position 467 130
838     Type PushButton
839     Title {Cut}
840 Main
841  Case message of
842  SingleClic :
843  Begin
844     Set $Value = (GetValue 4)
845     If $Value == 0 Then
846     Begin
847         Set $t={Msg: You need to select an item!}
848         ChangeTitle 16 $t
849     End
850     Else
851     Begin
852         Set $cmd=$SendMsgAndGet{"add-item-to-selection }$Menu{:}$Value{"}
853         Set $Err=(GetOutput $cmd 1 -1)
854         If $Err <> 0 Then
855         Begin
856             Set $SelNumber = (Add $SelNumber 1)
857             Set $UpdateSelectionList = 1
858             Set $cmd=$SendMsgAndGet{"remove-item }$Menu{:}$Value{"}
859             Set $Err=(GetOutput $cmd 1 -1)
860             If $Err == {0} Then
861             Begin
862                 Set $t = {Msg: Impossible to Remove "}$Title{"}
863                 ChangeTitle 16 $t
864             End
865             Else
866             Begin
867                 If $Value == $NbrOfItems Then
868                     Set $Value = (Add $Value -1)
869                 Set $UpdateItemsList = 1
870                 Set $UpdateTheItem = 1
871             End
872         End
873     End 
874  End
877 # Move Up Push Button
878 Widget 11
879 Property
880     Flags NoReliefString
881     Position 524 130
882     Type PushButton
883     Title {Up }
884 Main
885  Case message of
886  SingleClic :
887  Begin
888     Set $Value = (GetValue 4)
889     If $Value == 0 Then
890     Begin
891         Set $t={Msg: You need to select an item!}
892         ChangeTitle 16 $t
893     End
894     Else
895     Begin
896         Set $cmd=$SendMsgAndGet{"move-up }$Menu{:}$Value{"}
897         Set $Err=(GetOutput $cmd 1 -1)
898         If $Err == {0} Then
899         Begin
900                 Set $t = {Msg: Impossible to Move Up "}$Name{"}
901                 ChangeTitle 16 $t
902         End
903         Else
904         Begin
905             Set $UpdateItemsList = 1
906             Set $Value =(Add $Value -1)
907             Set $UpdateTheItem = 1
908         End
909     End
910  End
913 # Move Down Push Button
914 Widget 12
915 Property
916     Flags NoReliefString
917     Position 581 130
918     Type PushButton
919     Title {Down}
920 Main
921  Case message of
922  SingleClic :
923  Begin
924     Set $Value = (GetValue 4)
925     If $Value == 0 Then
926     Begin
927         Set $t={Msg: You need to select an item!}
928         ChangeTitle 16 $t
929     End
930     Else
931     Begin
932         Set $cmd=$SendMsgAndGet{"move-down }$Menu{:}$Value{"}
933         Set $Err=(GetOutput $cmd 1 -1)
934         If $Err == {0} Then
935         Begin
936                 Set $t = {Msg: Impossible to Move Down "}$Name{"}
937                 ChangeTitle 16 $t
938         End
939         Else
940         Begin
941             Set $UpdateItemsList = 1
942             Set $Value =(Add $Value 1)
943             Set $UpdateTheItem = 1
944         End
945     End
946  End
949 #-----------------------------------------------------------------------------
950 # Up, Open and Add Item
952 #open push button
953 Widget 13
954 Property
955     Flags NoReliefString
956     Position 260 255
957     Type PushButton
958     Title {Open}
959 Main
960  Case message of
961  SingleClic :
962  Begin
963     Set $Value = (GetValue 4)
964     Set $tmp = 0
965     If $Type == {Sub Menu} Then
966         Set $tmp = 1
967     If $Type == {Menu} Then
968         Set $tmp = 1
969     Set $tmp = (Mult $tmp $Value) 
970     If $tmp == 0 Then
971     Begin
972         Set $t={Msg: You need to select a (Sub)Menu!}
973         ChangeTitle 16 $t
974     End
975     Else
976     Begin
977         Set $OpenSubMenu = 1
978     End
979  End
982 #add item push button
983 Widget 14
984 Property
985     Flags NoReliefString
986     Position 120 255
987     Type PushButton
988     Title {Add Item}
989 Main
990  Case message of
991   SingleClic :
992   Begin
993     Set $EditorValue = (GetValue 4)
994     If $EditorValue == 0 Then
995         Set $EditorValue = $NbrOfItems
996     Set $EditOrAdd = {A}
997     ChangeMinValue 39 0
998     ChangeMaxValue 39 0
999     ChangeValue 39 0
1000     ChangeTitle 39 $Empty
1001     Set $EditorMenuIcon = {}
1002     ChangeIcon 41 None
1003     ChangeMinValue 44 0
1004     ChangeMaxValue 44 0
1005     ChangeValue 44 0
1006     ChangeTitle 44 $Empty
1007     ChangeMinValue 48 0
1008     ChangeMaxValue 48 0
1009     ChangeValue 48 0
1010     ChangeTitle 48 $Empty
1011     Set $HideMainWidgets = 1
1012     Set $UpdateEditorWidgets = 1
1013   End
1016 # Up menu push button
1017 Widget 15
1018 Property
1019     Flags NoReliefString
1020     Position 30 255
1021     Type PushButton
1022     Title {Up}
1023 Main
1024  Case message of
1025  SingleClic :
1026  Begin
1027     If $UP == {} Then
1028     Begin
1029         Set $t={Msg: No Up Menu}
1030         ChangeTitle 16 $t
1031     End
1032     Else
1033     Begin
1034         Set $LevelMenu = (Add $LevelMenu -1)
1035         Set $cmd={perl -e '@l=split(" ","}$UP{"); print "$l[-1]\n"'}
1036         Set $Menu=(GetOutput $cmd 1 -1)
1037         Set $cmd={perl -e '@l=split(" ","}$UP{"); pop(@l); print "@l\n"'}
1038         Set $UP=(GetOutput $cmd 1 -1)
1039         #Do {echo } $UP
1040         Set $cmd={echo "}$UP{"|sed -e 's/ /->/g'}
1041         Set $t = (GetOutput $cmd 1 -1)
1042         If $t <> {} Then
1043         Begin
1044                 Set $t = {Menu: }$t{->}$Menu
1045                 ChangeTitle 3 $t
1046         End
1047         Else
1048         Begin
1049                 If $UseRootMenusList <> {0} Then
1050                 Begin
1051                     HideWidget 3
1052                     ShowWidget 1
1053                     ShowWidget 2
1054                     ChangeValue 2 $RootValue
1055                     Set $isRootMenu = 1
1056                  End
1057                  Else
1058                  Begin
1059                     Set $t = {Menu: }$Menu
1060                     ChangeTitle 3 $t
1061                 End
1062         End
1063         If $UP == {} Then
1064                 ChangeFont 15  $ShadeFont
1066         Set $UpdateItemsList = 1
1067         Set $MenuListValueIsZero = 1 
1068     End
1069  End
1072 #----------------------------------------------------------------------------
1073 # Message
1075 Widget 16
1076 Property
1077     Flags NoReliefString
1078     Size 330 20
1079     Position 10 310
1080     Type ItemDraw
1081     Title {}
1082 Main
1083  Case message of
1084   SingleClic :
1085   Begin
1086   End
1089 #----------------------------------------------------------------------------
1090 # Selection area
1092 Widget 17
1093 Property
1094     Flags NoReliefString
1095     Position 450 190
1096     Type ItemDraw
1097     Title {Selection}
1098 Main
1099  Case message of
1100   SingleClic :
1101   Begin
1102   End
1105 Widget 18
1106 Property
1107     Flags NoReliefString
1108     Position 345 220
1109     Type PushButton
1110     Title {Copy}
1111 Main
1112  Case message of
1113   SingleClic :
1114   Begin
1115     Set $SelValue = (GetValue 22)
1116     Set $tmpValue  = (GetValue 4)
1117     If $tmpValue == 0 Then
1118         Set $tmpValue = $NbrOfItems
1119     If $SelValue == 0 Then
1120     Begin
1121         Set $t={Msg: No "selection" item selected!}
1122         ChangeTitle 16 $t
1123     End
1124     Else
1125     Begin
1126         Set $cmd=$SendMsgAndGet{"copy-sel-item }$Menu{:}$tmpValue{:}$SelValue{"}
1127         Set $Err=(GetOutput $cmd 1 -1)
1128         If $Err == {0} Then
1129         Begin
1130             Set $t = {Msg: No items in selection!}
1131             ChangeTitle 16 $t
1132         End
1133         Else
1134         Begin
1135             Set $Value = (Add $tmpValue 1)
1136             Set $UpdateTheItem = 1
1137             Set $UpdateItemsList = 1
1138         End     
1139     End
1140   End
1143 Widget 19
1144 Property
1145     Flags NoReliefString
1146     Position 400 220
1147     Type PushButton
1148     Title {Copy All}
1149 Main
1150  Case message of
1151   SingleClic :
1152   Begin
1153     Set $tmpValue  = (GetValue 4)
1154     If $tmpValue == 0 Then
1155         Set $tmpValue = $NbrOfItems
1156     Set $cmd=$SendMsgAndGet{"copy-all-sel }$Menu{:}$tmpValue{"}
1157     Set $Err=(GetOutput $cmd 1 -1)
1158     #Do {Echo }$Err
1159     If $Err == {0} Then
1160     Begin
1161         Set $t = {Msg: No items in selection!}
1162         ChangeTitle 16 $t
1163     End
1164     Else
1165     Begin
1166         Set $Value = (Add $tmpValue $SelNumber)
1167         Set $UpdateTheItem = 1
1168         Set $UpdateItemsList = 1
1169     End
1171   End
1174 Widget 20
1175 Property
1176     Flags NoReliefString
1177     Position 472 220
1178     Type PushButton
1179     Title {Remove}
1180 Main
1181  Case message of
1182  SingleClic :
1183  Begin
1184     Set $SelValue = (GetValue 22)
1185     If $SelValue == 0 Then
1186     Begin
1187         Set $t={Msg: No "selection" item selected!}
1188         ChangeTitle 16 $t
1189     End
1190     Else
1191     Begin
1192         Set $cmd=$SendMsgAndGet{"remove-sel-item }$SelValue{"}
1193         Set $Err=(GetOutput $cmd 1 -1)
1194         #Do {Echo }$Err
1195         If $Err == {0} Then
1196         Begin
1197                 Set $t = {Msg: No items in selection!}
1198                 ChangeTitle 16 $t
1199         End
1200         Else
1201         Begin
1202             Set $UpdateSelectionList = 1
1203             Set $SelNumber = (Add $SelNumber -1)
1204         End
1205     End
1206  End
1209 Widget 21
1210 Property
1211     Flags NoReliefString
1212     Position 544 220
1213     Type PushButton
1214     Title {Remove All}
1215 Main
1216  Case message of
1217   SingleClic :
1218   Begin
1219     Set $cmd=$SendMsgAndGet{"remove-all-sel-item"}
1220     Set $Err=(GetOutput $cmd 1 -1)
1221     If $Err == {0} Then
1222     Begin
1223         Set $t = {Msg: Error!}
1224         ChangeTitle 16 $t
1225     End
1226     ChangeTitle 22 $Empty
1227     Set $SelNumber = 0
1228     ChangeValue 22 0
1229     Set $tmp = 18
1230     While $tmp <> 22 Do
1231     Begin
1232         ChangeFont $tmp $ShadeFont
1233         Set $tmp = (Add $tmp 1)
1234     End
1236   End
1239 Widget 22
1240 Property
1241     Flags NoReliefString
1242     Position 340 260
1243     Size 290 80
1244     Type List
1245     Title {}
1246 Main
1247  Case message of
1248   SingleClic :
1249   Begin
1250  End
1253 #-----------------------------------------------------------------------------
1254 # Down buttons
1256 Widget 23
1257 Property
1258     Flags NoReliefString
1259     Position 50 370
1260     Type PushButton
1261     Title {Try}
1262 Main
1263  Case message of
1264   SingleClic :
1265   Begin
1266     Set $cmd=$SendMsgAndGet{"try"}
1267     Do {PipeRead '}$cmd{'}
1269     Set $t={}
1270     ChangeTitle 16 $t
1272   End
1275 Widget 24
1276 Property
1277     Flags NoReliefString
1278     Position 200 370
1279     Type PushButton
1280     Title {Apply And Save}
1281 Main
1282  Case message of
1283   SingleClic :
1284   Begin
1285     Set $cmd=$SendMsgAndGet{"try"}
1286     Do {PipeRead '}$cmd{'}
1287         
1288     #Set $cmd=$SendMsgAndGet{"save"}
1289     #Set $dummy = (GetOutput $cmd 1 -1)
1290     Set $cmd=$SendMsg{"save"}
1291     Do {Exec }$cmd
1293     Set $cmd = {fvwm-themes-config --no-cfg-cache --load menus-extra@personal}
1294     Do {Exec }$cmd
1296     # In the future we replace the above with something like:
1297     # FuncFvwmThemeLoad "menus-extra@personal"
1298     # the problem with the current method is that the GNOME and KDE menu are
1299     # lost and that the personal component are not updated at once but
1300     # at the next switching. We can fix that by using the current method
1301     # and in the place of the previous effective line:
1302     #Do {PipeRead '}$cmd{'}
1303     #Do {FuncFvwmThemesFresh}
1304     #But without the CCDS this not IMHO a good idea. So:
1305     Set $t={"Refresh the Current Theme" when leaving the Editor}
1306     ChangeTitle 16 $t
1308   End
1311 Widget 25
1312 Property
1313     Flags NoReliefString
1314     Position 420 370
1315     Type PushButton
1316     Title {Help}
1317 Main
1318  Case message of
1319   SingleClic :
1320   Begin
1321     Set $arg={FvwmScript-Help --text-colorset }$TextColorset{ --message "                    Documentation in progress" --title "Help for the Menu Editor}
1322     Set $MenuIconBrowser = (LaunchScript $arg )    
1323   End
1326 Widget 26
1327 Property
1328     Flags NoReliefString
1329  Position 580 370
1330  Type PushButton
1331  Title {Quit}
1332 Main
1333  Case message of
1334   SingleClic :
1335   Begin
1336     Set $cmd = $SendMsg{"exit"}
1337     Do {Exec }$cmd
1338     Quit
1339   End
1342 #-----------------------------------------------------------------------------
1343 #-----------------------------------------------------------------------------
1346 ################### Editor
1348 #-----------------------------------------------------------------------------
1349 #-----------------------------------------------------------------------------
1350 # At first I do a special script and swallow it but I've got some
1351 # problems in communication between the two scripts ... We can do such 
1352 # thing in the case of the communication do not need big message!
1355 Widget 36
1356 Property
1357     Flags NoReliefString
1358     Position 30 30
1359     Type ItemDraw
1360     Title {Type of the Command:}
1361 Main
1362  Case message of
1363   SingleClic :
1364   Begin
1365   End
1368 Widget 37
1369 Property
1370     Flags NoReliefString
1371  Position 200 25
1372  Type PopupMenu
1373  Title {Separator|X Application|Run in a Terminal|Tail File|Title|Fvwm Command|Sub Menu|Menu}
1374 Main
1375  Case message of
1376  SingleClic :
1377  Begin
1379     Set $selTypeValue = (GetValue 37)
1381     If $selTypeValue == 1 Then
1382         Set $EditorType = {Separator}
1383     If $selTypeValue == 2 Then
1384         Set $EditorType = {X Application}
1385     If $selTypeValue == 3 Then
1386         Set $EditorType = {Run in a Terminal}
1387     If $selTypeValue == 4 Then
1388         Set $EditorType = {Tail File}
1389     If $selTypeValue == 5 Then
1390         Set $EditorType = {Title}
1391     If $selTypeValue == 6 Then
1392         Set $EditorType = {Fvwm Command}
1393     If $selTypeValue == 7 Then
1394         Set $EditorType = {Sub Menu}
1395     If $selTypeValue == 8 Then
1396         Set $EditorType = {Menu}
1397     Set $HideEditorWidgets = 1 
1398     Set $UpdateEditorWidgets = 1
1399  End
1403 #----------------------------------------------------------------------
1404 # Name
1406 Widget 38
1407 Property
1408     Flags NoReliefString
1409     Position 30 80
1410     Type ItemDraw
1411     Title {Name:}
1412 Main
1413  Case message of
1414   SingleClic :
1415   Begin
1416   End
1419 Widget 39
1420 Property
1421     Flags NoReliefString
1422     Size 200 20
1423     Position 120 75
1424     Type TextField
1425     Title {}
1426 Main
1427  Case message of
1428   SingleClic :
1429   Begin
1430   End
1433 #---------------------------------------------------------------------------
1434 # Menu Icon
1436 Widget 40
1437 Property
1438     Flags NoReliefString
1439     Position 350 80
1440     Type ItemDraw
1441     Title {Menu Icon: }
1442 Main
1443  Case message of
1444   SingleClic :
1445   Begin
1446   End
1449 Widget 41
1450 Property
1451     Flags NoReliefString
1452     Size 50 30
1453     Position 440 72
1454     Type ItemDraw
1455     Icon None
1456 Main
1457  Case message of
1458   SingleClic :
1459   Begin
1460   End
1463 Widget 42
1464 Property
1465     Flags NoReliefString
1466     Size 85 20
1467     Position 520 75
1468     Type PushButton
1469     Title {Set/Change}
1470 Main
1471  Case message of
1472  SingleClic :
1473   Begin
1474     If $MenuIconBrowser == {} Then
1475     Begin               
1476         Set $arg={FvwmScript-IconBrowser --dir } $ImagesDir { --icon-colorset }$IconColorset{ --text-colorset }$TextColorset
1477         Set $MenuIconBrowser = (LaunchScript $arg )
1478     End
1479  End
1482 #----------------------------------------------------------------------------
1483 # Action
1485 Widget 43
1486 Property
1487     Flags NoReliefString
1488     Position 30 120
1489     Type ItemDraw
1490     Title {Command:}
1491     #Command, Exec, File, Menu
1492 Main
1493  Case message of
1494   SingleClic :
1495   Begin
1496   End
1499 Widget 44
1500 Property
1501     Flags NoReliefString
1502     Size 280 20
1503     Position 120 115
1504     Type TextField
1505     Title {}
1506 Main
1507  Case message of
1508   SingleClic :
1509   Begin
1510   End
1513 #----------------------------------------------------------------------------
1514 # Run
1516 Widget 45
1517 Property
1518     Flags NoReliefString
1519     Position 285 225
1520     Type PushButton
1521     Title {   RUN   }
1522 Main
1523  Case message of
1524  SingleClic :
1525  Begin
1526     Set $a = (GetTitle 44)
1527     Set $dt = (GetTitle 48)
1528     If $EditorType == {X Application} Then
1529     Begin
1530         Set $a = {exec } $a
1531         If $dt <> {} Then 
1532             Set $a = {cd }$dt { ; ./}$a
1533         Set $a = {Exec }$a
1534     End
1535     If $EditorType == {Run in a Terminal} Then
1536         Set $a = {FuncFvwmRunInXterm "}$dt{" "}$a{"}
1537     If $EditorType == {Tail File} Then
1538         Set $a = {FuncFvwmViewFileTail "}$dt{" "}$a{"}
1540     Do $a
1542   End
1545 #----------------------------------------------------------------------------
1546 # Find app in path 
1548 Widget 46
1549 Property
1550     Flags NoReliefString
1551     Size 85 20
1552     Position 520 115
1553     Type PushButton
1554     Title {Find it}
1555 Main
1556  Case message of
1557   SingleClic :
1558   Begin
1559     If $FindItBrowser == {} Then
1560     Begin
1561         Set $tmp = {}
1563         If $EditorType == {Tail File} Then
1564         Begin
1565             Set $mode = {browser}
1566             Set $tmp = (GetTitle 44)
1567             If $tmp == {} Then
1568                 Set $tmp = {~/}
1569             Set $t = {dummy}
1570         End
1571         Else
1572         Begin
1573             If $EditorType == {X Application} Then
1574                 Set $tmp = (GetTitle 48)
1575             Set $t= {"files in the working directory"}
1576             If $tmp == {} Then
1577             Begin
1578                 Set $tmp = {PATH}
1579                 Set $t = {"All files in the path"}
1580             End
1581             Set $mode = {list}
1582         End
1584         Set $arg={FvwmScript-Browser --dir }$tmp { --text-colorset }$TextColorset{ --mode }$mode{ --list-title }$t
1585         Set $FindItBrowser = (LaunchScript $arg )
1587     End
1588   End
1591 #----------------------------------------------------------------------------
1592 # Working dir/Title
1594 Widget 47
1595 Property
1596     Flags NoReliefString
1597     Position 30 160
1598     Type ItemDraw
1599     Title {Window Title:}
1600           #Working Dir:
1601 Main
1602  Case message of
1603   SingleClic :
1604   Begin
1605   End
1608 Widget 48
1609 Property
1610     Flags NoReliefString
1611     Size 280 20
1612     Position 120 155
1613     Type TextField
1614     Title {}
1615 Main
1616  Case message of
1617   SingleClic :
1618   Begin
1619   End
1622 #----------------------------------------------------------------------------
1623 # Browser for working dir ...
1625 Widget 49
1626 Property
1627     Flags NoReliefString
1628     Size 85 20
1629     Position 520 155
1630     Type PushButton
1631     Title {Browse}
1632 Main
1633  Case message of
1634  SingleClic :
1635  Begin
1636     If $FileDirBrowser == {} Then
1637     Begin
1638         Set $tmp = (GetTitle 48)
1639         If $tmp == {} Then
1640             Set $tmp = {~/}
1641         Set $arg={FvwmScript-Browser --dir }$tmp { --text-colorset }$TextColorset{ --type dir}
1642         Set $FileDirBrowser = (LaunchScript $arg )
1643     End
1644  End
1648 #----------------------------------------------------------------------------
1649 # Menu List
1651 Widget 50
1652 Property
1653     Flags NoReliefString
1654     Position 110 160
1655     Type ItemDraw
1656     Title {List of Menus:}
1657 Main
1658  Case message of
1659   SingleClic :
1660   Begin
1661   End
1664 Widget 51
1665 Property
1666     Flags NoReliefString
1667     Size 250 100
1668     Position 40 190
1669     Type List
1670     Title {}
1671 Main
1672  Case message of
1673   SingleClic :
1674   Begin
1675   End
1679 Widget 52
1680 Property
1681     Flags NoReliefString
1682     Position 420 160
1683     Type ItemDraw
1684     Title {Special Menus:}
1685 Main
1686  Case message of
1687   SingleClic :
1688   Begin
1689   End
1692 Widget 53
1693 Property
1694     Flags NoReliefString
1695     Size 250 100
1696     Position 350 190
1697     Type List
1698     Title {}
1699 Main
1700  Case message of
1701   SingleClic :
1702   Begin
1703   End
1706 #----------------------------------------------------------------------------
1707 # Ok and Cancel
1709 Widget 70
1710 Property
1711     Flags NoReliefString
1712     Position 190 340
1713     Type PushButton
1714     Title {  OK  }
1715 Main
1716  Case message of
1717   SingleClic :
1718   Begin
1719     Set $HideEditorWidgets = 1
1720     Set $ShowMainWidgets = 1
1721     # need to do some protection here!
1722     # problem with the { and }
1723     # get problem with space (fixable in menuapp) and ":" in $Menus
1724     # real problem is the action
1725     Set $EditMess = $SendMsgAndGet{'add-or-edit-item }$EditOrAdd{ --it="}$Menu{:}$EditorValue{" --ti="}$EditorType{" --na="}(GetTitle 39){" --mi="}$EditorMenuIcon{" --ac="}(GetTitle 44){" --wd="}(GetTitle 48){"'}
1726     #Do {Echo }$EditMess
1727     If $EditOrAdd == {A} Then
1728         Set $Value = (Add $EditorValue 1)
1729     Else
1730         Set $Value = $EditorValue
1731     Set $UpdateItemsList = 1
1732     Set $UpdateTheItem = 1
1733   End
1736 Widget 71
1737 Property
1738     Flags NoReliefString
1739     Position 400 340
1740     Type PushButton
1741     Title {Cancel}
1742 Main
1743  Case message of
1744   SingleClic :
1745   Begin
1746     Set $HideEditorWidgets = 1
1747     Set $ShowMainWidgets = 1
1748   End