diff --git a/Makefile b/Makefile index 40bc3fb..a791eda 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ BUILD_DIR := bin CMD_PATH := ./cmd GOCMD := go -GOBUILD := $(GOCMD) build +GOBUILD := $(GOCMD) build -v GOTEST := $(GOCMD) test GOCLEAN := $(GOCMD) clean GOTIDY := $(GOCMD) mod tidy @@ -42,6 +42,7 @@ tidy: clean: @$(RM) $(BINARY_NAME) + @go clean -modcache @echo "Clean complete" help: diff --git a/cmd/main.go b/cmd/main.go index 75773bb..9452dd5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -37,8 +37,7 @@ func main() { screencapturer.NewWholeScreenCapturer, vision.NewVision, ), - fx.Invoke(func(log *logger.Logger, capturer screencapturer.ScreenCapturer) { - log.Debug("starting application...") + fx.Invoke(func() { }), ) diff --git a/go.mod b/go.mod index f130c11..abfe5ff 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/gen2brain/shm v0.1.0 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/gotk3/gotk3 v0.6.4 + github.com/gotk3/gotk3 v0.6.5-0.20251124190141-e7a9e823ca35 github.com/jezek/xgb v1.1.1 // indirect github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect diff --git a/go.sum b/go.sum index 5179238..a03fcb7 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gotk3/gotk3 v0.6.4 h1:5ur/PRr86PwCG8eSj98D1eXvhrNNK6GILS2zq779dCg= github.com/gotk3/gotk3 v0.6.4/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= +github.com/gotk3/gotk3 v0.6.5-0.20251124190141-e7a9e823ca35 h1:BelWQzAzJfSMA1qbuzoV9Tp57+NCvYouEA5cWVpYcSk= +github.com/gotk3/gotk3 v0.6.5-0.20251124190141-e7a9e823ca35/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q= github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= github.com/kbinani/screenshot v0.0.0-20250624051815-089614a94018 h1:NQYgMY188uWrS+E/7xMVpydsI48PMHcc7SfR4OxkDF4= diff --git a/internal/constants/app.go b/internal/constants/app.go index 4e6eb7e..b281f50 100644 --- a/internal/constants/app.go +++ b/internal/constants/app.go @@ -21,4 +21,5 @@ package constants const ( AppName = "auto-attendance" + AppClassGtk = "su.weirdcat.autoattendance" ) diff --git a/internal/ui/builder.go b/internal/ui/builder.go new file mode 100644 index 0000000..6ae52af --- /dev/null +++ b/internal/ui/builder.go @@ -0,0 +1,36 @@ +// Copyright (c) 2025 Nikolai Papin +// +// This file is part of the Auto Attendance app that looks for +// self-attend QR-codes during lectures and opens their URLs in your +// browser. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +package ui + +import ( + "github.com/gotk3/gotk3/gtk" +) + +func NewBuilder() (*gtk.Builder, error) { + + gtk.Init(nil) + + builder, err := gtk.BuilderNew() + if err != nil { + return nil, err + } + + return builder, nil +} diff --git a/internal/ui/handlers.go b/internal/ui/handlers.go deleted file mode 100644 index 91836b7..0000000 --- a/internal/ui/handlers.go +++ /dev/null @@ -1,7 +0,0 @@ -package ui - -import "github.com/gotk3/gotk3/gtk" - -type Handlers struct { - gtk.AboutDialog -} diff --git a/internal/ui/mainwindow.go b/internal/ui/mainwindow.go new file mode 100644 index 0000000..a8684b0 --- /dev/null +++ b/internal/ui/mainwindow.go @@ -0,0 +1,74 @@ +// Copyright (c) 2025 Nikolai Papin +// +// This file is part of the Auto Attendance app that looks for +// self-attend QR-codes during lectures and opens their URLs in your +// browser. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +package ui + +import ( + "git.weirdcat.su/weirdcat/auto-attendance/internal/ui/resources" + "github.com/gotk3/gotk3/gtk" +) + +type MainWindow struct { + builder *gtk.Builder + window *gtk.Window +} + +func (m *MainWindow) Start() { + m.window.ShowAll() + go func() { gtk.Main() }() +} + +func NewMainWindow(builder *gtk.Builder) (*MainWindow, error) { + err := builder.AddFromString(string(resources.GladeMainWindow)) + if err != nil { + return nil, err + } + + windowObj, err := builder.GetObject("window_main") + if err != nil { + return nil, err + } + window := windowObj.(*gtk.Window) + window.Connect("destroy", func () { + gtk.MainQuit() + }) + + notebookObj, err := builder.GetObject("notebook_main") + if err != nil { + return nil, err + } + notebook := notebookObj.(*gtk.Notebook) + + mainPageObj, err := builder.GetObject("page_main") + if err != nil { + return nil, err + } + mainPage := mainPageObj.(*gtk.Grid) + + settingsPageObj, err := builder.GetObject("page_settings") + if err != nil { + return nil, err + } + settingsPage := settingsPageObj.(*gtk.Box) + + notebook.SetTabLabelText(mainPage, "Overview") + notebook.SetTabLabelText(settingsPage, "Settings") + + return &MainWindow{builder: builder, window: window}, nil +} diff --git a/internal/ui/resources/qrcode.png b/internal/ui/resources/qrcode.png new file mode 100644 index 0000000..baeb4f1 Binary files /dev/null and b/internal/ui/resources/qrcode.png differ diff --git a/internal/ui/resources/resources.go b/internal/ui/resources/resources.go new file mode 100644 index 0000000..33d9fcb --- /dev/null +++ b/internal/ui/resources/resources.go @@ -0,0 +1,30 @@ +// Copyright (c) 2025 Nikolai Papin +// +// This file is part of the Auto Attendance app that looks for +// self-attend QR-codes during lectures and opens their URLs in your +// browser. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +package resources + +import _ "embed" + +var ( + //go:embed window.glade + GladeMainWindow []byte + + //go:embed qrcode.png + QrCodePng []byte +) diff --git a/internal/ui/resources/window.glade b/internal/ui/resources/window.glade new file mode 100644 index 0000000..e50eaf3 --- /dev/null +++ b/internal/ui/resources/window.glade @@ -0,0 +1,367 @@ + + + + + + 100 + 5000 + 500 + 100 + 500 + + + [ERROR] 2025-11-26 14:24:15 - Failed to fetch data from API: Timeout occurred after 30 seconds. +[ERROR] 2025-11-26 14:24:30 - Exception: NullReferenceException in ModuleX: Object reference not set to an instance of an object. + + + + window_main + False + 400 + 600 + zoom-best-fit + + + True + True + + + + App + True + False + True + True + + + True + True + bottom-left + in + + + True + True + 10 + 10 + 10 + 10 + False + word-char + console_output + terminal + True + + + + + 0 + 3 + + + + + + True + False + True + True + + + True + False + vertical + top + + + + + + True + False + vertical + + + + + + False + True + 1 + + + + + + + + 0 + 0 + + + + + 0 + 0 + 3 + + + + + True + False + + + + + Settings + True + False + 20 + 20 + 20 + 20 + vertical + 12 + + + True + False + 0 + none + + + True + False + 12 + 12 + 12 + 12 + vertical + 6 + + + Auto-scan for QR codes + True + True + False + True + True + + + False + True + 0 + + + + + Beep on successful scan + True + True + False + True + True + + + False + True + 1 + + + + + + + True + False + Scanning Options + + + + + + + + False + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + 12 + 12 + 12 + vertical + 6 + + + True + False + 6 + + + True + False + Scan interval (ms): + 0 + + + False + True + 0 + + + + + True + True + adjustment1 + 1 + True + True + 500 + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 6 + + + True + False + Output format: + 0 + + + False + True + 0 + + + + + True + False + 0 + + Text + JSON + XML + URL + + + + False + True + 1 + + + + + False + True + 1 + + + + + + + True + False + Advanced Settings + + + + + + + + False + True + 1 + + + + + Save Settings + True + True + True + end + 12 + + + False + True + 2 + + + + + 1 + True + + + + + + + True + False + Qrminator + Offline + 1 + True + + + True + True + Toggle QR-searching + + + Toggle QR-handling + When enabled, program will search QR-codes on the screen and react to them according to user settings + + + + + + + True + False + True + + + 1 + + + + + + diff --git a/internal/ui/window.go b/internal/ui/window.go deleted file mode 100644 index 5b1faa2..0000000 --- a/internal/ui/window.go +++ /dev/null @@ -1 +0,0 @@ -package ui