File: menus.template

package info (click to toggle)
dotfile 1%3A2.4-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,472 kB
  • ctags: 523
  • sloc: tcl: 14,072; sh: 918; makefile: 177; lisp: 18; ansic: 7
file content (140 lines) | stat: -rw-r--r-- 4,937 bytes parent folder | download | duplicates (2)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
### Copyright (C) 1995, 1996, 1997 Jeppe Buk (buk@imada.sdu.dk)
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

proc menus {} {
  # Menus and Bindings / Popup Menus
  Desc "Definitions of popup menus"
  ShortDesc "Popup menus"

  Header h -text "Popup Menus" -frame:relief flat \
      -help "On this page you define your own popup menus"
  Line l

  Entry pixmapDD -text "Global default pixmap for menus" \
      -help "Here you may enter the name of a pixmap to use as the default" \
            "pixmap for menu entries (except titles and separators), if no" \
	    "other pixmap is specified on a per-menu or per-entry basis."
  Radio placeDD -entries { "Left" "Top" } \
      -help "Select 'Left' if you want the pixmap at the left of the text, " \
            "and 'Top' if you want it above it."
  Frame f_pixmapDD -entries { pixmapDD placeDD }

  Line lineDD

  Entry popupName -text "Name of the popup menu" \
      -help "Here you enter the name of the menu."

  Entry pixmapD -text "Default pixmap for this menu" \
      -help "Here you may enter the name of a pixmap to use as the default" \
            "in this menu (overloads the global setting above)."
  Radio placeD -entries { "Left" "Top" } \
      -help "Select 'Left' if you want the pixmap at the left of the text, " \
            "and 'Top' if you want it above it."

  Frame f_pixmapD -entries { pixmapD placeD }

  Radio place -entries { "L" "T" } \
      -help "Select 'L' if you want the pixmap at the left of the text, " \
            "and 'T' if you want it above it." \
      -packSubFrame:side top
  Entry pixmap -text "Pixmap" \
      -help "Here you may enter the name of a pixmap to use in the menu" \
      -packLabel:side top
  Entry name -text "Name" \
     -help "Enter the name on the menu here" \
     -packLabel:side top
  global Builtins
  ComboBox builtinCall -noedit 1 -text "Builtin" -default Beep \
      -entryhelp $Builtins \
      -help "Select a built-in command to call from this menu" \
      -packLabel:side top
  Entry arguments -text "Arguments" \
      -help "Any additional arguments are entered here (the syntax is your" \
      "responsibility) - see help for the individual commands." \
      -packLabel:side top

  ExtEntry popupEntry -entries {place pixmap name builtinCall arguments} \
      -count 5
  ExtEntry popup -lines 1 -entries { popupName f_pixmapD popupEntry } \
      -orient top -index popupName -count 1

  Label funcArgs -justify left -wraplength 600
  Change {
    if {$changeElm == "builtinCall"} {
      set bcindex -1
      set found "no"
      foreach bc $Builtins {
	incr bcindex
	if {$bc == $builtinCall} {
	  set found "yes"
	  break
	}
      }
      if {$found == "yes"} {
	set help [lindex $Builtins [expr $bcindex + 1]]
      } else {
	set help "\[Help not found\]"
      }
      set funcArgs "Help for function \"$builtinCall\":\n$help"
      eval "[pick [funcWithArgs $builtinCall] Enable Disable] arguments"
    }
  }
  ShowPage {
    set funcArgs ""
  }

  Change {
    if {$changeElm == "pixmap"} {
      if {$pixmap == ""} {Disable place} else {Enable place}
    }
    if {$changeElm == "pixmapD"} {
      if {$pixmapD == ""} {Disable placeD} else {Enable placeD}
    }
    if {$changeElm == "pixmapDD"} {
      if {$pixmapDD == ""} {Disable placeDD} else {Enable placeDD}
    }
  }

  Save {
    forevery popup {
      if {$popupName != {}} {
	print "AddToMenu \"$popupName\""
	forevery popupEntry {
	  if { $pixmap != "" && $place(name) == "L" } {
	    set Gname "%$pixmap%$name"
	  } elseif { $pixmap != "" && $place(name) == "T" } {
	    set Gname "*$pixmap*$name"
	  } elseif { $builtinCall != "Title" && $builtinCall != "Nop" } {
	    # Titles and Nops shouldn't use default pixmaps
	    if { $pixmapD != "" && $placeD(name) == "Left" } {
	      set Gname "%$pixmapD%$name"
	    } elseif { $pixmapD != "" && $placeD(name) == "Top" } {
	      set Gname "*$pixmapD*$name"
	    } elseif { $pixmapDD != "" && $placeDD(name) == "Left" } {
	      set Gname "%$pixmapDD%$name"
	    } elseif { $pixmapDD != "" && $placeDD(name) == "Top" } {
	      set Gname "*$pixmapDD*$name"
	    } else {
	      set Gname $name
	    }
	  } else {
	    set Gname $name
	  }
	  print "+\t\"$Gname\"\t$builtinCall $arguments"
	}
      }
    }
  }
}