27 Preferences

▼ |  | Framework: Racket GUI Application Framework

1 | Framework Libraries Overview
2 | Application
3 | Autosave
4 | Canvas
5 | Color Model
6 | Color Prefs
7 | Color
8 | Comment Box
9 | Decorated Editor Snip
10 | Editor Snip
11 | Editor
12 | Exit
13 | Finder
14 | Frame
15 | Group
16 | GUI Utilities
17 | Handler
18 | Icon
19 | Keymap
20 | Menu
21 | Mode
22 | Notify-boxes
23 | Number Snip
24 | Panel
25 | Pasteboard
26 | Path Utils
27 | Preferences
28 | Preferences, Textual
29 | Racket
30 | Srcloc Snips
31 | Text
32 | Splash
33 | Test
34 | Version
35 | Backwards Compatibility
36 | Signatures
37 | Unit
| Index

On this page:

preferences: put-preferences/ gui
preferences: get-preference/ gui
preferences: add-panel
preferences: add-editor-checkbox-panel
preferences: add-general-checkbox-panel
preferences: add-warnings-checkbox-panel
preferences: add-scheme-checkbox-panel
preferences: add-to-warnings-checkbox-panel
preferences: add-to-scheme-checkbox-panel
preferences: add-to-editor-checkbox-panel
preferences: add-to-general-checkbox-panel
preferences: add-font-panel
preferences: add-boolean-option-with-ask-me
preferences: show-dialog
preferences: hide-dialog
preferences: add-on-close-dialog-callback
preferences: add-can-close-dialog-callback
preferences: add-check

top contents ← prev up next →

### 27`` Preferences🔗ℹ

> > procedure
> > (preferences:put-preferences/gui |  | name-list |  |  |  |
> > |  | val-list) |  | → |  | any
> name-list : (listof symbol?)
> val-list : (listof any/c)

Like put-preferences, but has more sophisticated error handling. In particular, when it fails to grab a lock, it

- waits for three consecutive failures before informing the user

- gives the user the opportunity to “steal” the lockfile after the third failure, and

- when lock failures occur, it remembers what its arguments were and if any preference save eventually succeeds, all of the past failures are also written at that point.

In addition when an error is raised trying to save a preference to the preference file, preferences:put-preferences/gui logs the error using log-warning, instead of raising an exception.

> > procedure
> > (preferences:get-preference/gui |  | sym |  |  |  |
> > | [ | default]) |  | → |  | any/c
> sym : symbol?
> | default |  | : |  | (-> void?)
> |  |  | = |  | (λ () (error 'get-preference/gui "unknown pref ~s" sym))

Like get-preference, but has more sophisticated error handling. In particular, it passes a #:timeout-lock-there argument that informs the user that the preferences file is locked (and offers the alternative of not showing the message again).

> procedure (preferences:add-panel labels f) → void?
> labels : (or/c string? (cons/c string? (listof string?)))
> | f |  | : |  |
> (->i ([parent (is-a?/c area-container-window<%>)])
> ()
> [_ (parent)
> (let ([old-children (send parent get-children)])
> (and/c (is-a?/c area-container-window<%>)
> (λ (child)
> (andmap eq?
> (append old-children (list child))
> (send parent get-children)))))])

preferences:add-preference-panel adds the result of f with name labels to the preferences dialog box.

The labels determine where this preference panel is placed in the dialog. If the list is just one string, the preferences panel is placed at the top level of the dialog. If there are more strings, a hierarchy of nested panels is created and the new panel is added at the end. If multiple calls to preferences:add-preference-panel pass the same prefix of strings, those panels are placed in the same children.

When the preference dialog is opened for the first time, the function f is called with a panel, and f is expected to add a new child panel to it and add whatever preferences configuration controls it wants to that panel. Then, f’s should return the panel it added.

> procedure (preferences:add-editor-checkbox-panel) → void?

Adds a preferences panel for configuring options related to editing.

> procedure (preferences:add-general-checkbox-panel) → void?

Adds a catch-all preferences panel for options.

> procedure (preferences:add-warnings-checkbox-panel) → void?

Adds a preferences panel for configuring options relating to warnings.

> procedure (preferences:add-scheme-checkbox-panel) → void?

Adds a preferences panel for configuring options related to Racket.

> procedure (preferences:add-to-warnings-checkbox-panel proc) → void?
> proc : ((is-a?/c vertical-panel%) . -> . void?)

Saves proc until the preferences panel is created, when it is called with the Misc. panel to add new children to the panel.

> procedure (preferences:add-to-scheme-checkbox-panel proc) → void?
> proc : ((is-a?/c vertical-panel%) . -> . void?)

Saves proc until the preferences panel is created, when it is called with the Racket preferences panel to add new children to the panel.

> procedure (preferences:add-to-editor-checkbox-panel proc) → void?
> proc : ((is-a?/c vertical-panel%) . -> . void?)

Saves proc until the preferences panel is created, when it is called with the editor preferences panel to add new children to the panel.

> procedure (preferences:add-to-general-checkbox-panel proc) → void?
> proc : ((is-a?/c vertical-panel%) . -> . void?)

Saves proc until the preferences panel is created, when it is called with the general preferences panel to add new children to the panel.

> procedure (preferences:add-font-panel) → void?

Adds a font selection preferences panel to the preferences dialog.

> > procedure
> > (preferences:add-boolean-option-with-ask-me |  | parent |  |  |  |
> > |  | label |  |  |  |
> > |  | option1 |  |  |  |
> > |  | option2 |  |  |  |
> > |  | pref-key) |  | → |  | void?
> parent : (or/c (is-a?/c area-container<%>) #f)
> label : string?
> option1 : string?
> option2 : string?
> pref-key : symbol?

Adds a checkbox to parent with three options; the first two are given by option1 and option2, and the third is "Ask me". The preference named bypref-key is updated based on the selection in the checkbox.

> procedure (preferences:show-dialog) → void?

Shows the preferences dialog.

> procedure (preferences:hide-dialog) → void?

Hides the preferences dialog.

> procedure (preferences:add-on-close-dialog-callback cb) → void?
> cb : (-> void?)

Registers cb. Next time the user clicks the OK button the preferences dialog, all of the cb functions are called, assuming that each of the callbacks passed to preferences:add-can-close-dialog-callback succeed.

> procedure (preferences:add-can-close-dialog-callback cb) → void?
> cb : (-> boolean?)

Registers cb. Next time the user clicks the OK button the preferences dialog, all of the cb functions are called. If any of them return #f, the dialog is not closed.

See also preferences:add-on-close-dialog-callback.

> > procedure
> > (preferences:add-check |  | parent |  |  |  |
> > |  | pref-key |  |  |  |
> > |  | label |  |  |  |
> > | [ | from-boolean |  |  |  |
> > |  | to-boolean]) |  | → |  | void?
> parent : (is-a?/c area-container<%>)
> pref-key : symbol?
> label : string?
> from-boolean : (-> boolean? any/c) = values
> to-boolean : (-> any/c boolean?) = values

Adds a radio-box% object (with label as its label) to parent that, when checked adjusts the preference with the key pref-key.

The to-boolean and from-boolean functions are used to convert from the preferences value to a booleans when checking/unchecking the radio-box% object. The defaults amount to treating the preference as a boolean such that checking the radio-box% sets the preference to #t and unchecking it sets the preference to #f.

top contents ← prev up next →