This file is indexed.

/usr/share/amsn/plugins/chameleon/notebook.tcl is in amsn-data 0.98.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
namespace eval ::chameleon::notebook {
  proc notebook_customParseConfArgs {w parsed_options args } {
    array set options		$args
    array set ttk_options	$parsed_options

    if { [info exists options(-width)] } {
      if {$options(-width) == 0} {
	set ttk_options(-width) [list]
      } else {
	set ttk_options(-width) $options(-width)
      }
    }

    return [array get ttk_options]
  }

  proc init_notebookCustomOptions { } {
    variable notebook_widgetOptions
    variable notebook_widgetCommands 

    array set notebook_widgetOptions {
      -activebackground		-styleOption
      -activeforeground		-styleOption
      -arcradius		-ignore
      -background		-styleOption
      -bd			-styleOption
      -bg			-styleOption
      -borderwidth		-styleOption
      -disabledforeground	-styleOption
      -fg			-styleOption
      -font			-styleOption
      -foreground		-styleOption
      -height			-ignore
      -homogeneous		-ignore
      -ibd			-ignore
      -internalborderwidth	-ignore
      -repeatdelay		-ignore
      -repeatinterval		-ignore
      -side			-ignore
      -tabbevelsize		-ignore
      -tabpady			-ignore
      -width			-toImplement
    }

    # ignoring -width because we need to map 0 to "" and "" to 0 in cget/configure
    
    array set notebook_widgetCommands {
      add		{1 {notebook_add $w}}
      bindtabs		{1 {notebook_bindtabs $w}} 
      compute_size	{3 {notebook_compute_size $w}}
      delete		{1 {notebook_delete $w}}
      forget		{1 {notebook_forget $w}}
      getframe		{1 {notebook_getframe $w}}
      index		{3 {notebook_index $w}}
      insert		{3 {notebook_insert $w}}
      itemcget		{3 {notebook_itemCget $w}}
      itemconfigure	{3 {notebook_itemConfigure $w}}
      move		{1 {notebook_move $w}}
      page		{4 {notebook_page $w}}
      pages		{5 {notebook_pages $w}}
      raise		{1 {notebook_raise $w}}
      see		{3 {notebook_see $w}}
      select		{3 {notebook_select $w}}
      tab		{3 {notebook_tab $w}}
      tabs		{4 {notebook_tabs $w}}
    }

    ::chameleon::addBinding <<WidgetCreated>>	{::chameleon::notebook::notebook_widgetCreated}
    ::chameleon::addBinding <<WidgetDestroyed>>	{::chameleon::notebook::notebook_widgetDestroyed}
  }

  proc notebook_widgetCreated { } {
    set nb [::chameleon::getLastCreatedWidget ]

    if {[string first "::chameleon::notebook::notebook" $nb] == 0 } {
      #puts "Notebook $nb is created"
      ::ttk::notebook::enableTraversal [::chameleon::getWidgetPath $nb]

      bind $nb					<<NotebookTabChanged>> "::chameleon::notebook::notebook_tabChanged $nb"
      bind [::chameleon::getWidgetPath $nb]	<<NotebookTabChanged>> "::chameleon::notebook::notebook_tabChanged $nb"
    }
  }

  proc notebook_widgetDestroyed { } {
    variable pages

    set nb [::chameleon::getLastDestroyedWidget ]

    if {[string first "::chameleon::notebook::notebook" $nb] == 0 } {
      #puts "Notebook $nb is destroyed"
      array unset pages [::chameleon::getWidgetPath $nb]
    }
  }

  proc notebook_tabChanged { w } {
    variable pageOptions

    set page [notebook_getPageAt $w [$w index current]]

    if { [info exists pageOptions($w:$page)] } {
      array set opts [set pageOptions($w:$page)]

      if {[info exists opts(-raisecmd)] } {
	if 1 $opts(-raisecmd)
      }
    }
  }

  proc notebook_customCget { w option } {
    if {$option eq "-width"} {
      set width [$w cget -width]

      if {![string is digit -strict $width]} {
	return 0
      } else {
	return $width
      }
    }

    return ""
  }

  proc notebook_bindtabs { w event script } {
    #TODO
  }

  proc notebook_compute_size { w } {
    set max_h 0
    set max_w 0

    update idletasks 

    foreach child [winfo children [::chameleon::getWidgetPath $w]] {
      set reqw	[winfo reqwidth  $child]
      set reqh	[winfo reqheight $child]
      set max_w [expr {$reqw > $max_w ? $reqw : $max_w}]
      set max_h [expr {$reqh > $max_h ? $reqh : $max_h}] 
    }

    notebook_configure $w -width $max_w -height $max_h
  }

  proc notebook_delete { w page {destroyframe 1}} {
    set tab [notebook_getframe $w $page]

    $w forget $tab

    if {$destroyframe} {
      destroy $tab
    }

    array unset tabs $page      
  }
  
  proc notebook_getframe { w page } {
    return [lindex [notebook_getPageInfo $w $page] 1]
  }

  proc notebook_index {w page_or_index} {
    if { [catch {set tab [notebook_getframe $w $page_or_index]}] } {
      return [$w index $page_or_index]
    } else {
      return [$w index $tab]
    }
  }
  
  proc notebook_insert {w index page args} {
    variable pages
    variable pageOptions

    set w_name [notebook_commandToWidget $w]

    if {![info exists pages($w_name)] } {
      set pages($w_name) [list]
    }

    array set tabs [set pages($w_name)]

    if {[info exists tabs($page)] } {
      error "Page $page already exists in notebook $w_name"
    }
    
    array set arguments $args

    set pageOptions($w:$page) $args

    array unset arguments -createcmd
    array unset arguments -leavecmd
    array unset arguments -raisecmd
    
    set child		[frame $w_name.f$page]
    set tabs($page)	[list [$w index end] $child]
    set pages($w_name)	[array get tabs]
    set ret		[eval [list $w] add $child [array get arguments]]

    notebook_move $w $page $index

    if {[info exists arguments(-createcmd)] } {
      after 100 "$arguments(-createcmd)"
    }

    return $ret
  }
  
  proc notebook_itemCget {w page option } {
    variable pageOptions

    if {$option == "-createcmd" || $option == "-leavecmd" || $option == "-raisecmd" } {
      array set opts [set pageOptions($w:$page)]

      if {[info exists opts($option)] } {
	return [set opts($option)]
      } else {
	return ""
      }
    } else {
      return [$w tab $option]
    }
  }

  proc notebook_itemConfigure { w page args } {
    variable pageOptions

    if {[llength $args] == 0 } {
      array set arguments {
	-createcmd	""
	-leavecmd	""
	-raisecmd	""
      }

      array set arguments [set pageOptions($w:$page)]
      array set arguments [$w tab [notebook_getFrameIndex $w $page]]

      return [array get arguments]
    } elseif {[llength $args] == 1} {
      return [notebook_itemCget $w $page $args]
    } else {
      array set arguments $args

      set pageOptions($w:$page) $args

      array unset arguments -createcmd
      array unset arguments -leavecmd
      array unset arguments -raisecmd
      
      return [eval [list $w] tab [array get arguments]]
    }
  }

  proc notebook_move { w page index } {
    #TODO
  }

  proc notebook_page { w first {last ""} } {
    return [notebook_pages $w $first $last]
  }

  proc notebook_pages { w {first ""} {last ""} } {
    set tabs [$w tabs]

    if { $first eq "" } {
      return $tabs
    } elseif {$last eq "" } {
      return [lrange $tabs $first end]
    } else {
      return [lrange $tabs $first $last]
    }
  }

  proc notebook_raise { w {page ""} } {
    if {$page eq "" } {
      set pageIdx [$w index current]
    } else {
      set pageIdx [notebook_getFrameIndex $w $page]

      catch { $w select $pageIdx }
    }

    return [notebook_getPageAt $w $pageIdx]
  }

  proc notebook_see { w page } {
  }

  proc notebook_add { w child args} {
    variable pages

    set w_name [notebook_commandToWidget $w]

    if {![info exists pages($w_name)] } {
      set pages($w_name) [list]
    }

    array set tabs [set pages($w_name)]

    set page	$child
    set i	1

    while {![info exists tabs($page)] } {
      set page "${child}#${i}"

      incr i
    }
    
    set tabs($page)	[list [$w index end] $child]
    set pages($w_name)	[array get tabs]

    return [eval [list $w] add $child $args]
    
  }

  proc notebook_forget { w index } {
    variable pages

    set w_name [notebook_commandToWidget $w]

    if {![info exists pages($w_name)] } {
      set pages($w_name) [list]
    }

    array set tabs [set pages($w_name)]

    foreach name [array names tabs] {
      foreach {idx frame} $tabs($name) break

      if {$idx == $index} {
	array unset tabs $name

	set pages($w_name) [array get tabs]

	return [$w forget $index]
      }
    }
    
    error "Unable to find tab with index $index"
  }

  proc notebook_select { w args } {
    return [eval [list $w] select $args]
  }

  proc notebook_tab { w index args } {
    return [eval [list $w] tab $index $args]
  } 

  proc notebook_tabs { w } {
    return [$w tabs]
  }

  proc notebook_getPageAt { w index } {
    variable pages
    
    set w_name [notebook_commandToWidget $w]

    if {![info exists pages($w_name)] } {
      set pages($w_name) [list]
    }

    array set tabs [set pages($w_name)]
    
    foreach name [array names tabs] {
      foreach {idx frame} $tabs($name) break

      if {$idx == $index} {
	return $name
      }
    }
    
    return ""
  }

  proc notebook_getPageInfo { w page } {
    variable pages
    
    set w_name [notebook_commandToWidget $w]

    if {![info exists pages($w_name)] } {
      set pages($w_name) [list]
    }

    array set tabs [set pages($w_name)]

    if {![info exists tabs($page)] } {
      error "Unknown page $page for notebook $w"
    }
    
    return [set tabs($page)]
  }

  proc notebook_getFrameIndex { w page } {
    return [lindex [notebook_getPageInfo $w $page] 0]
  }

  proc notebook_commandToWidget {w} {
    return [::chameleon::getWidgetPath $w]
  }
}