-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
74 lines (60 loc) · 1.79 KB
/
Copy pathmain.go
File metadata and controls
74 lines (60 loc) · 1.79 KB
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
package main
import (
"embed"
"os"
"path/filepath"
"github.com/MrSametBurgazoglu/atilgan/header"
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
"github.com/diamondburned/gotk4/pkg/gdk/v4"
"github.com/diamondburned/gotk4/pkg/gio/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
)
//go:embed style.css
var styleCSS embed.FS
//go:embed atilgan_icon.svg
var atilganIcon []byte
func main() {
app := adw.NewApplication("io.github.mrsametburgazoglu.AtilganFileManager", gio.ApplicationFlagsNone)
app.ConnectActivate(func() {
activate(app)
})
if code := app.Run(os.Args); code > 0 {
os.Exit(code)
}
}
func activate(app *adw.Application) {
window := adw.NewApplicationWindow(&app.Application)
window.SetTitle("Atilgan")
window.SetDefaultSize(1200, 800)
display := gdk.DisplayGetDefault()
cssProvider := gtk.NewCSSProvider()
cssBytes, err := styleCSS.ReadFile("style.css")
if err == nil {
cssProvider.LoadFromData(string(cssBytes))
}
gtk.StyleContextAddProviderForDisplay(display, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
iconTheme := gtk.IconThemeGetForDisplay(display)
exePath, err := os.Executable()
if err == nil {
exeDir := filepath.Dir(exePath)
iconTheme.AddSearchPath(exeDir)
iconTheme.AddSearchPath(filepath.Join(filepath.Dir(exeDir), "share", "icons"))
}
curDir, err := os.Getwd()
if err == nil {
iconTheme.AddSearchPath(curDir)
}
window.SetIconName("io.github.mrsametburgazoglu.AtilganFileManager")
headerBar := header.NewHeaderBar(window, atilganIcon)
initialPath := ""
if len(os.Args) > 1 {
initialPath = os.Args[1]
}
mainBox := NewMainBox(window, headerBar, initialPath)
window.SetContent(mainBox)
window.SetVisible(true)
activePanel := mainBox.getActivePanel()
if activePanel != nil {
activePanel.FileViewer.FileViewerList.FocusDrawingArea()
}
}