-
Notifications
You must be signed in to change notification settings - Fork 0
/
gohOptions.go
128 lines (103 loc) · 3.39 KB
/
gohOptions.go
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
// gohOptions.go
/*
Source file auto-generated on Fri, 02 Apr 2021 15:44:30 using Gotk3 Objects Handler v1.7.5 ©2018-21 hfmrow
This software use gotk3 that is licensed under the ISC License:
https://github.com/gotk3/gotk3/blob/master/LICENSE
Copyright ©2019-21 hfmrow - file-stamper v1.1 github.com/hfmrow/file-stamper
This program comes with absolutely no warranty. See the The MIT License (MIT) for details:
https://opensource.org/licenses/mit-license.php
*/
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"os/exec"
gidg "github.com/hfmrow/gtk3Import/dialog"
gimc "github.com/hfmrow/gtk3Import/misc"
)
// App infos
var Name = "file-stamper"
var Vers = "v1.1"
var Descr = "This software allow you to clone timestamp between files"
var Creat = "hfmrow"
var YearCreat = "2019-21"
var LicenseShort = "This program comes with absolutely no warranty.\nSee the The MIT License (MIT) for details:\nhttps://opensource.org/licenses/mit-license.php"
var LicenseAbrv = "License (MIT)"
var Repository = "github.com/hfmrow/file-stamper"
// Vars declarations
var absoluteRealPath, optFilename = getAbsRealPath()
var mainOptions *MainOpt
var err error
var tempDir string
var doTempDir bool
var currentOutFilesList []string
var currentInFilesList []string
// Translations
var devMode bool
var nl = "\n"
var execCmd *exec.Cmd
var statusbar = new(gimc.StatusBar)
type MainOpt struct {
/* Public, will be saved and restored */
About *gidg.AboutInfos
MainWinWidth int
MainWinHeight int
LanguageFilename string
AtimeMod bool
MtimeMod bool
CtimeMod bool
SubDir bool
Directory bool
PrevInFilesTs timeList
PrevOutFilesTs timeList
/* Private, will NOT be saved */
}
// Main options initialisation
func (opt *MainOpt) Init() {
/* Aboutbox initialisation */
opt.About = new(gidg.AboutInfos)
opt.LanguageFilename = "assets/lang/eng.lang"
opt.MainWinWidth = 320
opt.MainWinHeight = 240
}
// Variables -> Objects.
func (opt *MainOpt) UpdateObjects() {
mainObjects.MainWindow.Resize(opt.MainWinWidth, opt.MainWinHeight)
mainObjects.CheckbuttonCtime.SetSensitive(false)
mainObjects.CheckbuttonAtime.SetActive(opt.AtimeMod)
mainObjects.CheckbuttonMtime.SetActive(opt.MtimeMod)
mainObjects.CheckbuttonCtime.SetActive(opt.CtimeMod)
mainObjects.CheckbuttonSubdir.SetActive(opt.SubDir)
mainObjects.CheckbuttonIncludeDir.SetActive(opt.Directory)
}
// Objects -> Variables.
func (opt *MainOpt) UpdateOptions() {
opt.MainWinWidth, opt.MainWinHeight = mainObjects.MainWindow.GetSize()
opt.AtimeMod = mainObjects.CheckbuttonAtime.GetActive()
opt.MtimeMod = mainObjects.CheckbuttonMtime.GetActive()
opt.CtimeMod = mainObjects.CheckbuttonCtime.GetActive()
opt.SubDir = mainObjects.CheckbuttonSubdir.GetActive()
opt.Directory = mainObjects.CheckbuttonIncludeDir.GetActive()
}
// Read Options from file
func (opt *MainOpt) Read() (err error) {
var textFileBytes []byte
if textFileBytes, err = ioutil.ReadFile(optFilename); err == nil {
err = json.Unmarshal(textFileBytes, &opt)
}
return err
}
// Write Options to file
func (opt *MainOpt) Write() (err error) {
var jsonData []byte
var out bytes.Buffer
opt.UpdateOptions()
opt.About.DlgBoxStruct = nil // remove dialog object before saving
if jsonData, err = json.Marshal(&opt); err == nil {
if err = json.Indent(&out, jsonData, "", "\t"); err == nil {
err = ioutil.WriteFile(optFilename, out.Bytes(), 0644)
}
}
return err
}