; $VER: Save As Preset 1.1 (12.7.2004) Alex Carmona

Failat 10

Set Theme `RequestString "Save as Preset" "Enter a name for this theme" noempty`

If "$Theme" EQ ""
 Quit
Endif

If NOT Exists "$Theme"
 MakeDir "$Theme.preset"
Else
 Set Replace `RequestChoice TITLE "Confirm Replace" BODY "A theme by that name exists" GADGETS "_New Name" "_Overwrite" "_Cancel"`

 If $Replace eq 0
  Quit
 Endif

 If $Replace eq 1
  Execute "Save As Preset"
  Quit
 EndIf
Endif

Echo ";Theme Preset v1.1" TO "$Theme"

If Exists ENV:Sys/Font.prefs
 Copy ENV:Sys/Font.prefs TO "$Theme.preset" QUIET
 Echo "Font FROM *"$Theme.preset/Font.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/GUI.prefs
 Copy ENV:Sys/GUI.prefs TO "$Theme.preset" QUIET
 Echo "GUI FROM *"$Theme.preset/GUI.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/Palette.prefs
 Copy ENV:Sys/Palette.prefs TO "$Theme.preset" QUIET
 Echo "Palette FROM *"$Theme.preset/Palette.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/PopupMenu.prefs
 Copy ENV:Sys/PopupMenu.prefs TO "$Theme.preset" QUIET
 Echo "PopupMenu FROM *"$Theme.preset/PopupMenu.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/Pointer.prefs
 Copy ENV:Sys/Pointer.prefs TO "$Theme.preset" QUIET
 Echo "Pointer FROM *"$Theme.preset/Pointer.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/WBPattern.prefs
 Copy ENV:Sys/WBPattern.prefs TO "$Theme.preset" QUIET
 Echo "WBPattern FROM *"$Theme.preset/WBPattern.prefs*" USE" >>"$Theme"
Endif

If Exists ENV:Sys/Workbench.prefs
 Copy ENV:Sys/Workbench.prefs TO "$Theme.preset" QUIET
 Echo "Workbench *"$Theme.preset/Workbench.prefs*" USE" >>"$Theme"
Endif

Copy ENVARC:Sys/def_preset.info "$Theme.info"

RX 'address workbench "menu invoke window.update"
RX 'address workbench "menu invoke window.cleanupby.name"
RX 'address workbench "menu invoke window.resizetofit"
RX 'address workbench "menu invoke window.snapshot.all"

Unset Replace
Unset Theme
