Skip to content

Commit 9cca512

Browse files
author
zhou
committed
optimize ui&code
1 parent 5e364f4 commit 9cca512

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

app.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/base64"
66
"encoding/hex"
77
"fmt"
8-
"io/ioutil"
98
"net"
109
"os"
1110
"strconv"
@@ -41,7 +40,7 @@ const (
4140
IT_SEND string = "Send"
4241
IT_APPEND_RN string = "Append \\r\\n"
4342
IT_AUTO_CLEAR string = "Auto clear"
44-
IT_SEND_HEX string = "Send hex"
43+
IT_SEND_HEX string = "Send HEX"
4544
IT_SEND_CIRC string = "Send circularly"
4645
IT_LOAD_DATA string = "Load data"
4746
IT_DATA_RECVED string = "Data received"
@@ -191,7 +190,7 @@ func (app *NetAssistantApp) update(recvStr string) {
191190
}
192191

193192
if app.cbDisplayDate.GetActive() {
194-
recvStr = fmt.Sprintf("[%s]:%s\n", time.Now().Format("2006-01-02 15:04:05"), recvStr)
193+
recvStr = fmt.Sprintf("[%s]%s\n", time.Now().Format(time.DateTime+".000000"), recvStr)
195194
}
196195

197196
if app.cbReceive2File.GetActive() {
@@ -218,11 +217,11 @@ func (app *NetAssistantApp) handler(conn net.Conn) {
218217
var buf [2048]byte
219218
n, err := reader.Read(buf[:])
220219
if err != nil {
221-
log.Info("close connection:", err)
220+
log.Info("connection closed:", err)
222221
_, ok := conn.(*net.UDPConn)
223222
if !ok {
224223
ss := conn.RemoteAddr().String()
225-
tips := fmt.Sprintf(`<span foreground="pink">connection closed: %s </span>`, ss)
224+
tips := fmt.Sprintf(`<span foreground="red">connection closed: %s </span>`, ss)
226225
glib.IdleAdd(func() {
227226
app.labelStatus.SetMarkup(tips)
228227
})
@@ -242,13 +241,13 @@ func (app *NetAssistantApp) handler(conn net.Conn) {
242241
if app.cbHexDisplay.GetActive() {
243242
for i := 0; i < len(recvStr); i++ {
244243
log.Debug(i, recvStr[i])
245-
list = append(list, fmt.Sprintf("%X", recvStr[i]))
244+
list = append(list, fmt.Sprintf("%02X", recvStr[i]))
246245
}
247246
recvStr = strings.Join(list, " ")
248247
}
249248

250249
if app.cbDisplayDate.GetActive() {
251-
recvStr = fmt.Sprintf("[%s]:%s\n", time.Now().Format("2006-01-02 15:04:05"), recvStr)
250+
recvStr = fmt.Sprintf("[%s]%s\n", time.Now().Format(time.DateTime+".000000"), recvStr)
252251
}
253252

254253
if app.cbReceive2File.GetActive() {
@@ -271,6 +270,7 @@ func (app *NetAssistantApp) onBtnCleanCount() {
271270
app.sendCount = 0
272271
app.labelReceveCount.SetText(getI18nText(IT_RECEVER_COUNT))
273272
app.labelSendCount.SetText(getI18nText(IT_SEND_COUNT))
273+
app.labelStatus.SetText("")
274274
}
275275

276276
func (app *NetAssistantApp) onCbReceive2File() {
@@ -290,7 +290,7 @@ func (app *NetAssistantApp) onBtnLoadData() {
290290
res := dialog.Run()
291291
if res == int(gtk.RESPONSE_ACCEPT) {
292292
fileName := dialog.FileChooser.GetFilename()
293-
data, err := ioutil.ReadFile(fileName)
293+
data, err := os.ReadFile(fileName)
294294
if err != nil {
295295
log.Error(err)
296296
} else {
@@ -608,7 +608,7 @@ func (app *NetAssistantApp) doActivate(application *gtk.Application) {
608608
labelPort, _ := gtk.LabelNew(getI18nText(IT_PORT))
609609
labelPort.SetXAlign(0)
610610
app.entryPort, _ = gtk.EntryNew()
611-
app.entryPort.SetText("8003")
611+
app.entryPort.SetText("50023")
612612
verticalBox.PackStart(labelPort, false, false, 0)
613613
verticalBox.PackStart(app.entryPort, false, false, 0)
614614
app.btnConnect, _ = gtk.ButtonNewWithLabel(getI18nText(IT_CONNECT))
@@ -768,7 +768,7 @@ func init() {
768768
}
769769

770770
func main() {
771-
const appID = "com.github.baloneo.netassistant"
771+
const appID = "com.github.bytevoyager.netassistant"
772772
application, err := gtk.ApplicationNew(appID, glib.APPLICATION_NON_UNIQUE)
773773

774774
if err != nil {

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module netassistant
22

3-
go 1.23
3+
go 1.20
44

55
require (
66
github.com/gotk3/gotk3 v0.6.2

netassistant

6.33 MB
Binary file not shown.

0 commit comments

Comments
 (0)