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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
|
#!/usr/bin/tclsh
# Part of MCU 8051 IDE ( http://http://www.moravia-microsystems.com/mcu8051ide )
############################################################################
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# Copyright (C) 2014 by Moravia Microsystems, s.r.o. #
# martin.osmera@moravia-microsystems.com #
# #
# 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., #
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
# >>> File inclusion guard
if { ! [ info exists _TOOLBAR_CONFIG_TCL ] } {
set _TOOLBAR_CONFIG_TCL _
# <<< File inclusion guard
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements main toolbar configuration dialog
# --------------------------------------------------------------------------
namespace eval toolbar {
variable win ;# ID of toplevel dialog window
variable dialog_opened 0 ;# Bool: True if this dialog is already opened
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
variable changed ;# Bool: Settings changed
variable apply_button ;# ID of button "Apply"
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
variable options_search_clear ;# ID of search EntryBox clear button for $options_ListBox
variable up_button ;# ID of button "Up"
variable left_button ;# ID of button "Left"
variable right_button ;# ID of button "Right"
variable down_button ;# ID of button "Down"
## Create the dialog
# @return void
proc mkDialog {} {
variable win ;# ID of toplevel dialog window
variable dialog_opened ;# Bool: True if this dialog is already opened
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
variable changed ;# Bool: Settings changed
variable apply_button ;# ID of button "Apply"
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
variable options_search_clear ;# ID of search EntryBox clear button for $options_ListBox
variable up_button ;# ID of button "Up"
variable left_button ;# ID of button "Left"
variable right_button ;# ID of button "Right"
variable down_button ;# ID of button "Down"
# Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .toolbar_config_dialog
}
set anything_modified 0
set dialog_opened 1
set changed 0
# Create toplevel window
set win [toplevel .toolbar_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::32::configure \
-text [mc "Toolbar configuration"] \
-font [font create -size [expr {int(-20 * $::font_size_factor)}]]
# Create main frame (ListBoxes and Arrows)
set main_frame [frame $win.main_frame]
## Create arrows frame and buttons
set arrows [frame $main_frame.arrows]
# Arrow "Up"
set up_button [ttk::button $arrows.up \
-image ::ICONS::16::up \
-state disabled \
-style Flat.TButton \
-command {::configDialogues::toolbar::up} \
]
# Arrow "Left"
set left_button [ttk::button $arrows.left \
-image ::ICONS::16::left \
-state disabled \
-style Flat.TButton \
-command {::configDialogues::toolbar::left} \
]
# Arrow "Right"
set right_button [ttk::button $arrows.right \
-image ::ICONS::16::right \
-state disabled \
-style Flat.TButton \
-command {::configDialogues::toolbar::right} \
]
# Arrow "Down"
set down_button [ttk::button $arrows.down \
-image ::ICONS::16::down \
-state disabled \
-style Flat.TButton \
-command {::configDialogues::toolbar::down} \
]
# Place arrows to the grid
grid $up_button -column 1 -row 0
grid $left_button -column 0 -row 1
grid $right_button -column 2 -row 1
grid $down_button -column 1 -row 2
# Create ListBox of available items and its scrollbar
set options_frame [frame $main_frame.options_frame]
set listbox_frame [frame $options_frame.listbox_frame]
set options_ListBox [ListBox $listbox_frame.options_ListBox \
-background {#FFFFFF} -deltay 21 \
-selectmode single \
-highlightcolor {#FFFFFF} \
-yscrollcommand "$listbox_frame.options_scrollbar set" \
-highlightthickness 0 \
]
if {[winfo exists $options_ListBox.c]} {
bind $options_ListBox.c <Button-5> {%W yview scroll +5 units; break}
bind $options_ListBox.c <Button-4> {%W yview scroll -5 units; break}
}
pack $options_ListBox -fill both -expand 1 -side left
pack [ttk::scrollbar $listbox_frame.options_scrollbar \
-takefocus 0 \
-orient vertical \
-command "$options_ListBox yview" \
] -side right -after $options_ListBox -fill y
# Create search bar for ListBox of available items
set search_frame [frame $options_frame.search_frame]
set options_search_entry [ttk::entry $search_frame.entry \
-validate all \
-validatecommand {::configDialogues::toolbar::search O %P} \
]
DynamicHelp::add $search_frame.entry -text [mc "Search for a string in ListBox"]
pack $options_search_entry -side left -fill x -expand 1
set options_search_clear [ttk::button $search_frame.button \
-image ::ICONS::16::clear_left \
-style Flat.TButton \
-command "$options_search_entry delete 0 end" \
-state disabled \
]
DynamicHelp::add $search_frame.button \
-text [mc "Clear"]
pack $options_search_clear -side right -after $options_search_entry
# Pack frames of the left part (available items)
pack $search_frame -fill x
pack [label $options_frame.label -text [mc "available items"]] -pady 5
pack $listbox_frame -fill both -expand 1
# Create ListBox of current items and its scrollbar
set current_frame [frame $main_frame.current_frame]
set listbox_frame [frame $current_frame.listbox_frame]
set current_ListBox [ListBox $listbox_frame.current_ListBox \
-background {#FFFFFF} -deltay 21 \
-selectmode single \
-highlightcolor {#FFFFFF} \
-yscrollcommand "$listbox_frame.current_scrollbar set" \
-highlightthickness 0 \
]
if {[winfo exists $current_ListBox.c]} {
bind $current_ListBox.c <Button-5> {%W yview scroll +5 units; break}
bind $current_ListBox.c <Button-4> {%W yview scroll -5 units; break}
}
pack $current_ListBox -fill both -expand 1 -side left
pack [ttk::scrollbar $listbox_frame.current_scrollbar \
-takefocus 0 \
-orient vertical \
-command "$current_ListBox yview" \
] -side right -after $current_ListBox -fill y
# Create search bar for ListBox of current items
set search_frame [frame $current_frame.search_frame]
set current_search_entry [ttk::entry $search_frame.entry \
-validate all \
-validatecommand {::configDialogues::toolbar::search C %P} \
]
DynamicHelp::add $search_frame.entry -text [mc "Search for a string in ListBox"]
pack $current_search_entry -side left -fill x -expand 1
set current_search_clear [ttk::button $search_frame.button \
-image ::ICONS::16::clear_left \
-style Flat.TButton \
-command "$current_search_entry delete 0 end" \
-state disabled \
]
DynamicHelp::add $search_frame.button \
-text [mc "Clear"]
pack $current_search_clear -side right -after $current_search_entry
# Pack frames of the left part (current items)
pack $search_frame -fill x
pack [label $current_frame.label -text [mc "Current toolbar items"]] -pady 5
pack $listbox_frame -fill both -expand 1
# Set event bindings for ListBoxes
bind $options_ListBox <<ListboxSelect>> \
"::configDialogues::toolbar::reevaluateArrows"
bind $current_ListBox <<ListboxSelect>> \
"::configDialogues::toolbar::reevaluateArrows"
# Pack left ListBox, arrows frame, right ListBox
pack $options_frame -side left -anchor n -fill both -expand 1 -padx 5
pack $arrows -side left -anchor center
pack $current_frame -side left -anchor n -fill both -expand 1 -padx 5
# Fill up ListBoxes
fillListBox ${::ICONBAR_CURRENT}
# Create button frame at the bottom
set but_frame [frame $win.button_frame]
# Button "Defaults"
pack [ttk::button $but_frame.but_default \
-text [mc "Defaults"] \
-command {::configDialogues::toolbar::DEFAULTS} \
] -side left
DynamicHelp::add $but_frame.but_default \
-text [mc "Reset settings to defaults"]
# Button "Ok"
pack [ttk::button $but_frame.but_ok \
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
-command {::configDialogues::toolbar::OK} \
] -side right -padx 2
# Button "Apply"
set apply_button [ttk::button $but_frame.but_apply \
-state disabled \
-text [mc "Apply"] \
-compound left \
-image ::ICONS::16::ok \
-command {::configDialogues::toolbar::APPLY} \
]
pack $apply_button -side right -padx 2
# Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {::configDialogues::toolbar::CANCEL} \
] -side right -padx 2
# Pack frames and notebook
pack $but_frame -side bottom -fill x -expand 0 -anchor s -padx 10 -pady 5
pack $win.header_label -side top -pady 6
pack $main_frame -side top -fill both -expand 1 -padx 10
# Finalize creation of the dialog
wm iconphoto $win ::ICONS::16::configure
wm transient $win .
wm title $win [mc "Configure Main Toolbar - %s" ${::APPNAME}]
wm minsize $win 600 400
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
if {${::configDialogues::toolbar::anything_modified}} {
set result [tk_messageBox \
-parent .toolbar_config_dialog \
-title [mc "Save changes?"] \
-icon question \
-type yesno \
-message [mc "The settings have been changed. Do you want to save the changes?"] \
]
if {$result == {yes}} {
::configDialogues::toolbar::OK
} else {
::configDialogues::toolbar::CANCEL
}
} else {
::configDialogues::toolbar::CANCEL
}
}
tkwait window $win
}
## Validator procedure for search EntryBoxes
# Search for the given string in the given ListBox and
#+ adjust EntryBox background color according to search result
# @parm Char where -
# "O" (O as Omega not 0 as zero) == Options ListBox (available items)
# "C" == ListBox containing current onfiguration
# @parm String what - String to search for
# @return Bool - Always true
proc search {where what} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
variable options_search_clear ;# ID of search EntryBox clear button for $options_ListBox
if {$where == {C}} {
set listbox $current_ListBox
set entry $current_search_entry
set clearbut $current_search_clear
} else {
set listbox $options_ListBox
set entry $options_search_entry
set clearbut $options_search_clear
}
# Empty string
if {$what == {}} {
$entry configure -style TEntry
$clearbut configure -state disabled
return 1
} else {
$clearbut configure -state normal
}
# Search for the given string
set what [string tolower $what]
foreach item [$listbox items] {
if {
[string first $what \
[string tolower \
[$listbox itemcget $item -text] \
] \
] != -1
} then {
$listbox selection clear
$listbox selection set $item
$listbox see $item
$entry configure -style StringFound.TEntry
return 1
}
}
# String not found
$entry configure -style StringNotFound.TEntry
return 1
}
## Fill ListBoxes acoring to the given toolbar definition
# Note: function depends on toplevel variable 'ICONBAR_ICONS'
# @parm List definition - Definition of current toolbar (eg. {new open | exit})
# @return void
proc fillListBox {definition} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
# Fill in left ListBox
$options_ListBox insert end sep -text [mc " -- SEPARATOR --"]
for {set i 0} {$i < [llength ${::ICONBAR_ICONS}]} {incr i} {
# Determinate item name
set item [lindex ${::ICONBAR_ICONS} $i]
incr i
# Skip invalid items
if {[lsearch $definition $item] != -1} {continue}
# Insert item
$options_ListBox insert end $item \
-text [mc [lindex ${::ICONBAR_ICONS} [list $i 0]]] \
-image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
# Fill in right ListBox
foreach key $definition {
# Insert separator
if {$key == {|}} {
$current_ListBox insert end #auto -text [mc " -- SEPARATOR --"]
}
# Deteminate item index
set i [lsearch ${::ICONBAR_ICONS} $key]
if {$i == -1} {continue}
incr i
# Insert regular item
$current_ListBox insert end $key \
-text [mc [lindex ${::ICONBAR_ICONS} [list $i 0]]] \
-image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
}
## Enable/Disable arrow buttons according to selection in ListBoxes
# @return void
proc reevaluateArrows {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
variable left_button ;# ID of button "Left"
variable right_button ;# ID of button "Right"
# Button "Left"
if {[$current_ListBox selection get] == {}} {
$left_button configure -state disabled
} else {
$left_button configure -state normal
}
# Button "Right"
if {[$options_ListBox selection get] == {}} {
$right_button configure -state disabled
} else {
$right_button configure -state normal
}
# Evaluate buttons "Up/Down"
reevaluateUpDown
}
## Enable/Disable Up/Down arrow according to selection in the right ListBox
# @return void
proc reevaluateUpDown {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable down_button ;# ID of button "Down"
variable up_button ;# ID of button "Up"
# Determinate ID of selected item
set sel [$current_ListBox selection get]
# Valid selection
if {$sel != {}} {
# Button "Up"
set curIndex [$current_ListBox index $sel]
if {$curIndex == 0} {
$up_button configure -state disabled
} else {
$up_button configure -state normal
}
# Button "Down"
set numberOfItems [llength [$current_ListBox items]]
if {$curIndex == ($numberOfItems - 1)} {
$down_button configure -state disabled
} else {
$down_button configure -state normal
}
# Empty selection
} else {
$up_button configure -state disabled
$down_button configure -state disabled
}
}
## Command for button "Up"
# Move selected item in the right listbox up
# @return void
proc up {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
# Deteminate ID of selected item
set sel [$current_ListBox selection get]
# Determinate target index
set trgIdx [$current_ListBox index $sel]
incr trgIdx -1
# Move item
$current_ListBox move $sel $trgIdx
$current_ListBox see $sel
# Enable/Disabled buttons "Up/Down"
reevaluateUpDown
# Adjust status changed
settings_changed
}
## Command for button "Down"
# Move selected item in the right listbox down
# @return void
proc down {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
# Deteminate ID of selected item
set sel [$current_ListBox selection get]
# Determinate target index
set trgIdx [$current_ListBox index $sel]
incr trgIdx
# Move item
$current_ListBox move $sel $trgIdx
$current_ListBox see $sel
# Enable/Disabled buttons "Up/Down"
reevaluateUpDown
# Adjust status changed
settings_changed
}
## Command for button "Left"
# Move selected item from the right ListBox to the left one
# @return void
proc left {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
# Local variables
set sel [$current_ListBox selection get] ;# ID of the selected item
set idx [$current_ListBox index $sel] ;# Index of the selected item
# Remove selected item
$current_ListBox delete $sel
# Regular item (no separator)
if {![regexp {^\d+$} $sel]} {
# Find index of the item (in available icons)
set i [lsearch ${::ICONBAR_ICONS} $sel]
if {$i == -1} {return}
incr i
# Insert removed item into left ListBox
$options_ListBox insert 1 $sel \
-text [lindex ${::ICONBAR_ICONS} [list $i 0]] \
-image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
# Restore selection
if {[llength [$current_ListBox items]] == $idx} {
if {$idx} {
incr idx -1
}
}
set idx [$current_ListBox item $idx]
$current_ListBox selection set $idx
$current_ListBox see $idx
$options_ListBox see $sel
# Enable/Disable arrow buttons
reevaluateArrows
# Adjust status changed
settings_changed
}
## Command for button "Right"
# Move selected item from the left ListBox to the right one
# @return void
proc right {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
# Determinate target index
set sel [$current_ListBox selection get]
if {$sel == {}} {
set trgIdx {end}
} else {
set trgIdx [$current_ListBox index $sel]
}
# Determinate source index and source item ID
set sel [$options_ListBox selection get]
set idx [$options_ListBox index $sel]
# Separator
if {$sel == {sep}} {
$current_ListBox insert $trgIdx #auto -text [mc " -- SEPARATOR --"]
# Regular item
} else {
set i [lsearch ${::ICONBAR_ICONS} $sel]
if {$i == -1} {return}
incr i
$current_ListBox insert $trgIdx $sel \
-text [lindex ${::ICONBAR_ICONS} [list $i 0]] \
-image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
$options_ListBox delete $sel
}
# Restore selection
if {[llength [$options_ListBox items]] == $idx} {
if {$idx} {
incr idx -1
}
}
set idx [$options_ListBox item $idx]
$options_ListBox selection set $idx
$options_ListBox see $idx
$current_ListBox see [$current_ListBox item $trgIdx]
# Enable/Disable arrow buttons
reevaluateArrows
# Adjust status changed
settings_changed
}
## Change content of configuration variables
# @return void
proc use_settings {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
set ::ICONBAR_CURRENT { }
append ::ICONBAR_CURRENT [$current_ListBox items]
append ::ICONBAR_CURRENT { }
regsub -all {\s\d+\s} ${::ICONBAR_CURRENT} { | } ::ICONBAR_CURRENT
regsub -all {\s\d+\s} ${::ICONBAR_CURRENT} { | } ::ICONBAR_CURRENT
set ::ICONBAR_CURRENT [string trim ${::ICONBAR_CURRENT}]
}
## Save configuration to config file
# @return void
proc save_config {} {
::settings setValue "Main toolbar" ${::ICONBAR_CURRENT}
# Commit
::settings saveConfig
}
## Load configuratin from config file
# @return void
proc load_config {} {
set ::ICONBAR_CURRENT [::settings getValue "Main toolbar" ${::ICONBAR_DEFAULT}]
}
## Set status changed to True
# @return true
proc settings_changed {} {
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
variable changed ;# Bool: Settings changed
variable apply_button ;# ID of button "Apply"
if {$changed} {return}
set changed 1
set anything_modified 1
$apply_button configure -state normal
}
## Take back changes and destroy dialog window
# @return void
proc CANCEL {} {
variable win ;# ID of dialog toplevel window
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
variable dialog_opened ;# Bool: True if this dialog is already opened
# Restore previous configuration
if {$anything_modified} {
load_config
iconbar_redraw
set anything_modified 0
::X::disaena_menu_toolbar_for_current_project
set anything_modified 0
}
# Get rid of dialog window
set dialog_opened 0
grab release $win
destroy $win
}
## Apply changes and destroy dialog window
# @return void
proc OK {} {
variable win ;# ID of dialog toplevel window
variable changed ;# Bool: Settings changed
variable dialog_opened ;# Bool: True if this dialog is already opened
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
# Apply new settings
if {$anything_modified} {
use_settings ;# Adjust NS variables
iconbar_redraw ;# Adjust GUI
save_config ;# Save new config
# Restore previous state of menu items (enabled / disabled)
::X::disaena_menu_toolbar_for_current_project
set anything_modified 0
}
# Get rid of dialog window
set dialog_opened 0
grab release $win
destroy $win
}
## Apply changes in GUI
# @return Bool - result
proc APPLY {} {
variable apply_button ;# ID of button "Apply"
variable changed ;# Bool: Settings changed
# Reset status changed
set changed 0
$apply_button configure -state disabled
# Adjust NS variables
use_settings
iconbar_redraw
# Restore previous state of menu items (enabled / disabled)
::X::disaena_menu_toolbar_for_current_project
# done ...
return 1
}
## Restrore defaults
# @return void
proc DEFAULTS {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
variable options_ListBox ;# ID of ListBox containing available icons
variable win ;# ID of dialog toplevel window
# Ask user
if {[tk_messageBox \
-parent $win -type yesno \
-icon question -title [mc "Restore defaults"] \
-message [mc "Are you sure that you want restore default settings ?"]
] != {yes}} {
return
}
# Clear ListBoxes
$current_ListBox delete [$current_ListBox items]
$options_ListBox delete [$options_ListBox items]
# Refill ListBoxes
fillListBox ${::ICONBAR_DEFAULT}
# Adjust status changed
settings_changed
}
}
# >>> File inclusion guard
}
# <<< File inclusion guard
|