~kolletzki/attachment-dl

312e7896df000491c0bbb62eb86af673b31dddca — Lukas Kolletzki 2 years ago d98b353
Add menu and about window

Signed-off-by: Lukas Kolletzki <mail@lukaskolletzki.com>
4 files changed, 43 insertions(+), 8 deletions(-)

M Makefile
A VERSION
M go.sum
M gui/app.go
M Makefile => Makefile +2 -2
@@ 1,5 1,5 @@
NAME=attachment-dl
VERSION=0.1.0
VERSION=$(file < VERSION)
OUTDIR=bin
BINARY_NAME=$(OUTDIR)/$(NAME)_$(VERSION)



@@ 12,7 12,7 @@ clean:
	rm -rf $(OUTDIR)

build:
	go build -o $(BINARY_NAME)_$(GOOS)_$(GOARCH)$(BINARY_EXT)
	go build -ldflags "-X git.sr.ht/~kolletzki/attachment-dl/gui.version=$(VERSION)" -o $(BINARY_NAME)_$(GOOS)_$(GOARCH)$(BINARY_EXT)

linux: export GOOS=linux
linux: build

A VERSION => VERSION +1 -0
@@ 0,0 1,1 @@
0.2.0
\ No newline at end of file

M go.sum => go.sum +2 -0
@@ 29,6 29,7 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fyne-io/mobile v0.0.1 h1:Skc/XcZy1ZNdBanhZB9D8114fU4K+kSi5QZXuG6JPeQ=
github.com/fyne-io/mobile v0.0.1/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/fyne-io/mobile v0.0.2 h1:eGmCR5lkFxk0PnPafGppLFRD5QODJfSVdrjhLjanOVg=
github.com/fyne-io/mobile v0.0.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=


@@ 80,6 81,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709 h1:Ko2LQMrRU+Oy/+EDBwX7eZ2jp3C47eDBB8EIhKTun+I=
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

M gui/app.go => gui/app.go +38 -6
@@ 2,10 2,12 @@ package gui

import (
	"fmt"
	"net/url"
	"os"

	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/dialog"
	"fyne.io/fyne/layout"
	"fyne.io/fyne/widget"
	"github.com/emersion/go-imap"


@@ 13,6 15,23 @@ import (
	attdl "git.sr.ht/~kolletzki/attachment-dl/attachment-dl"
)

const license = `Copyright (C) 2020  Lukas Kolletzki

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.`

var version string

type App struct {
	app fyne.App
	win fyne.Window


@@ 36,7 55,12 @@ func NewApp() *App {
}

func (a *App) ShowAndRun() {
	w := a.app.NewWindow("Attachment Dl")
	a.win = a.app.NewWindow("Attachment Dl")

	a.win.SetMainMenu(fyne.NewMainMenu(
		fyne.NewMenu("File", fyne.NewMenuItem("Settings", a.openSettings)),
		fyne.NewMenu("Help", fyne.NewMenuItem("About", a.showAbout))))
	a.win.SetMaster()

	// Status and progress bar
	a.statusLine = widget.NewLabel("")


@@ 44,16 68,13 @@ func (a *App) ShowAndRun() {
	a.progressBar.Hide()

	box := widget.NewVBox(
		widget.NewHBox(layout.NewSpacer(), widget.NewButton("Settings", a.openSettings)),
		layout.NewSpacer(),
		widget.NewButton("Start Download", a.startDownload),
		a.statusLine,
		a.progressBar,
	)

	w.SetContent(box)

	w.ShowAndRun()
	a.win.SetContent(box)
	a.win.ShowAndRun()
}

func (a *App) openSettings() {


@@ 64,6 85,17 @@ func (a *App) openSettings() {
	})
}

func (a *App) showAbout() {
	gitUrl, _ := url.Parse("https://git.sr.ht/~kolletzki/attachment-dl")

	dialog.ShowCustom("About", "Close", widget.NewVBox(
		widget.NewLabel("Attachment DL version "+version),
		layout.NewSpacer(),
		widget.NewHyperlink("Sources", gitUrl),
		widget.NewTextGridFromString(license),
	), a.win)
}

func (a *App) startDownload() {
	if a.cfg == nil {
		a.setStatus("No settings found")