diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-09 23:52:56 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-09 23:52:56 +0200 |
| commit | 47735c3d73cc677e519cd33b58232c97729596fa (patch) | |
| tree | 32b96f0388721dd63668cb159d05e6c934536268 /UPreferences.pas | |
| parent | f9c7a5f62f96fab9ce5e3d2c205bc9da3046c4d4 (diff) | |
| download | tuxcmd-0.6.40.tar.xz | |
Date/time string formatting revisionv0.6.40
Added ability to set custom date/time format
Diffstat (limited to 'UPreferences.pas')
| -rw-r--r-- | UPreferences.pas | 132 |
1 files changed, 122 insertions, 10 deletions
diff --git a/UPreferences.pas b/UPreferences.pas index fa6775d..90d5a5e 100644 --- a/UPreferences.pas +++ b/UPreferences.pas @@ -23,7 +23,7 @@ interface uses glib2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, + GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, Libc, UCoreClasses, UGnome; type @@ -66,6 +66,15 @@ type miEditorTerminalDetect, miEditorAlwaysTerminal, miEditorNoTerminal, miTerminalDetect, miAlwaysTerminal, miNoTerminal: TGTKMenuItem; ShowTextUIDsCheckBox: TGTKCheckButton; + DateFormatLabel: TGTKLabel; + DateFormatOptionMenu: TGTKOptionMenu; + CustomDateFormatEntry: TGTKEntry; + TimeFormatLabel: TGTKLabel; + TimeFormatOptionMenu: TGTKOptionMenu; + CustomTimeFormatEntry: TGTKEntry; + DateTimeFormatLabel: TGTKLabel; + DateTimeFormatOptionMenu: TGTKOptionMenu; + procedure FormCreate(Sender: TObject); override; procedure FormDestroy(Sender: TObject); procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); @@ -75,8 +84,10 @@ type procedure ColorButtonDefaultsToggled(Sender: TObject); procedure DefaultRowHeightCheckBoxToggled(Sender: TObject); procedure UseInternalViewerCheckBoxToggled(Sender: TObject); + procedure DateTimeFormatOptionMenuChanged(Sender: TObject); private DefaultGTKFont, LocalListFont: string; + FormatTime: time_t; public RebuildListViews, RebuildIcons: boolean; procedure AssignDefaultValues; @@ -93,8 +104,9 @@ uses ULocale, UFileAssoc, UCoreUtils, UConfig; procedure TFPreferences.FormCreate(Sender: TObject); var i: integer; + Item: TGTKMenuItem; begin - SetDefaultSize(450, 500); + SetDefaultSize(450, 570); Caption := LANGPreferences_Caption; Buttons := [mbOK, mbCancel]; ShowSeparator := False; @@ -199,13 +211,13 @@ begin miSizeFormat1 := TGTKMenuItem.CreateTyped(Self, itLabel); miSizeFormat1.Caption := Format('%s (%s)', [LANGPreferencesmiSizeFormat1, FormatSize(123456, 0, 0)]); miSizeFormat2 := TGTKMenuItem.CreateTyped(Self, itLabel); - miSizeFormat2.Caption := '123456'; + miSizeFormat2.Caption := FormatSize(123456, 0, 1); miSizeFormat3 := TGTKMenuItem.CreateTyped(Self, itLabel); - miSizeFormat3.Caption := '123,456'; + miSizeFormat3.Caption := FormatSize(123456, 0, 2); miSizeFormat4 := TGTKMenuItem.CreateTyped(Self, itLabel); - miSizeFormat4.Caption := '123 456'; + miSizeFormat4.Caption := FormatSize(123456, 0, 3); miSizeFormat5 := TGTKMenuItem.CreateTyped(Self, itLabel); - miSizeFormat5.Caption := '123''456'; + miSizeFormat5.Caption := FormatSize(123456, 0, 4); miSizeFormat6 := TGTKMenuItem.CreateTyped(Self, itLabel); miSizeFormat6.Caption := LANGPreferencesmiSizeFormat6; SizeFormatOptionMenu.Items.Add(miSizeFormat1); @@ -214,8 +226,9 @@ begin SizeFormatOptionMenu.Items.Add(miSizeFormat4); SizeFormatOptionMenu.Items.Add(miSizeFormat5); SizeFormatOptionMenu.Items.Add(miSizeFormat6); - Table2.AddControlEx(1, 6, 1, 1, SizeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); - Table2.AddControlEx(2, 6, 2, 1, SizeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); + Table2.AddControl(0, 7, 1, 1, TGTKVBox.Create(Self), 0, 4); + Table2.AddControlEx(1, 8, 1, 1, SizeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); + Table2.AddControlEx(2, 8, 2, 1, SizeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); TerminalOptionMenu := TGTKOptionMenu.Create(Self); miTerminalDetect := TGTKMenuItem.CreateTyped(Self, itLabel); @@ -232,8 +245,76 @@ begin CmdLineBehaviourLabel.XAlign := 0; CmdLineBehaviourLabel.FocusControl := TerminalOptionMenu; CmdLineBehaviourLabel.UseUnderline := True; - Table2.AddControlEx(1, 7, 1, 1, CmdLineBehaviourLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); - Table2.AddControlEx(2, 7, 2, 1, TerminalOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); + Table2.AddControlEx(1, 6, 1, 1, CmdLineBehaviourLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); + Table2.AddControlEx(2, 6, 2, 1, TerminalOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); + + FormatTime := Libc.__time(nil); + DateFormatLabel := TGTKLabel.Create(Self); + DateFormatLabel.Caption := '_Date format:'; + DateFormatLabel.XAlign := 0; + DateFormatLabel.UseUnderline := True; + DateFormatOptionMenu := TGTKOptionMenu.Create(Self); + DateFormatLabel.FocusControl := DateFormatOptionMenu; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := Format('%s (%s)', ['System', FormatDate(FormatTime, False, True, -1, 0, -1)]); + DateFormatOptionMenu.Items.Add(Item); + for i := 1 to 14 do begin + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, False, True, -1, i, -1); + DateFormatOptionMenu.Items.Add(Item); + end; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := 'Custom...'; + DateFormatOptionMenu.Items.Add(Item); + DateFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged; + Table2.AddControlEx(1, 9, 1, 1, DateFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); + Table2.AddControlEx(2, 9, 2, 1, DateFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); + + CustomDateFormatEntry := TGTKEntry.Create(Self); + CustomDateFormatEntry.Enabled := False; + CustomDateFormatEntry.Tooltip := 'Enter custom date format string.'#10'Please see "man strftime" for syntax reference.'; + Table2.AddControlEx(2, 10, 2, 1, CustomDateFormatEntry, [taoShrink], [taoShrink], 10, 2); + + TimeFormatLabel := TGTKLabel.Create(Self); + TimeFormatLabel.Caption := '_Time format:'; + TimeFormatLabel.XAlign := 0; + TimeFormatLabel.UseUnderline := True; + TimeFormatOptionMenu := TGTKOptionMenu.Create(Self); + TimeFormatLabel.FocusControl := TimeFormatOptionMenu; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := Format('%s (%s)', ['System', FormatDate(FormatTime, True, False, 0, -1, -1)]); + TimeFormatOptionMenu.Items.Add(Item); + for i := 1 to 11 do begin + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, True, False, i, -1, -1); + TimeFormatOptionMenu.Items.Add(Item); + end; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := 'Custom...'; + TimeFormatOptionMenu.Items.Add(Item); + TimeFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged; + Table2.AddControlEx(1, 11, 1, 1, TimeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); + Table2.AddControlEx(2, 11, 2, 1, TimeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); + + CustomTimeFormatEntry := TGTKEntry.Create(Self); + CustomTimeFormatEntry.Enabled := False; + CustomTimeFormatEntry.Tooltip := 'Enter custom time format string.'#10'Please see "man strftime" for syntax reference.'; + Table2.AddControlEx(2, 12, 2, 1, CustomTimeFormatEntry, [taoShrink], [taoShrink], 10, 2); + + DateTimeFormatLabel := TGTKLabel.Create(Self); + DateTimeFormatLabel.Caption := 'Date/time _order:'; + DateTimeFormatLabel.XAlign := 0; + DateTimeFormatLabel.UseUnderline := True; + DateTimeFormatOptionMenu := TGTKOptionMenu.Create(Self); + DateTimeFormatLabel.FocusControl := DateTimeFormatOptionMenu; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, True, True, -1, -1, 0); + DateTimeFormatOptionMenu.Items.Add(Item); + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, True, True, -1, -1, 1); + DateTimeFormatOptionMenu.Items.Add(Item); + Table2.AddControlEx(1, 13, 1, 1, DateTimeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); + Table2.AddControlEx(2, 13, 2, 1, DateTimeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); // ********* PAGE Panels @@ -590,6 +671,24 @@ begin end; +procedure TFPreferences.DateTimeFormatOptionMenuChanged(Sender: TObject); +var Item: TGTKMenuItem; + OldIndex: integer; +begin + CustomTimeFormatEntry.Enabled := TimeFormatOptionMenu.ItemIndex = TimeFormatOptionMenu.Items.Count - 1; + CustomDateFormatEntry.Enabled := DateFormatOptionMenu.ItemIndex = DateFormatOptionMenu.Items.Count - 1; + + OldIndex := DateTimeFormatOptionMenu.ItemIndex; + DateTimeFormatOptionMenu.Items.Clear; + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, True, True, TimeFormatOptionMenu.ItemIndex, DateFormatOptionMenu.ItemIndex, 0); + DateTimeFormatOptionMenu.Items.Add(Item); + Item := TGTKMenuItem.CreateTyped(Self, itLabel); + Item.Caption := FormatDate(FormatTime, True, True, TimeFormatOptionMenu.ItemIndex, DateFormatOptionMenu.ItemIndex, 1); + DateTimeFormatOptionMenu.Items.Add(Item); + DateTimeFormatOptionMenu.ItemIndex := OldIndex; +end; + (********************************************************************************************************************************) procedure TFPreferences.ViewerBrowseButtonClick(Sender: TObject); @@ -754,9 +853,16 @@ begin WMCompatModeCheckBox.Checked := ConfWMCompatMode; CompatUseLibcSystemCheckBox.Checked := ConfUseLibcSystem; + CustomTimeFormatEntry.Text := ConfCustomTimeFormat; + CustomDateFormatEntry.Text := ConfCustomDateFormat; + DateFormatOptionMenu.ItemIndex := ConfDateFormat; + TimeFormatOptionMenu.ItemIndex := ConfTimeFormat; + DateTimeFormatOptionMenu.ItemIndex := ConfDateTimeFormat; + DefaultFontCheckBoxToggled(Self); ColorButtonDefaultsToggled(Self); UseInternalViewerCheckBoxToggled(Self); + DateTimeFormatOptionMenuChanged(Self); end; procedure TFPreferences.SaveSettings; @@ -815,6 +921,12 @@ begin ConfUseLibcSystem := CompatUseLibcSystemCheckBox.Checked; ConfDisableFileTips := DisableFileTipsCheckBox.Checked; ConfShowFuncButtons := ShowFuncButtonsCheckBox.Checked; + + ConfCustomTimeFormat := CustomTimeFormatEntry.Text; + ConfCustomDateFormat := CustomDateFormatEntry.Text; + ConfDateFormat := DateFormatOptionMenu.ItemIndex; + ConfTimeFormat := TimeFormatOptionMenu.ItemIndex; + ConfDateTimeFormat := DateTimeFormatOptionMenu.ItemIndex; end; (********************************************************************************************************************************) |
