Skip to content

Commit c9a4231

Browse files
committed
Implement dynamic app list, working main button, dynamic sttaus icons, hour and date
1 parent d9ed402 commit c9a4231

File tree

5 files changed

+79
-14
lines changed

5 files changed

+79
-14
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: sudo apt update
2626

2727
- name: Install dependencies
28-
run: sudo apt install -y libgtk-3-dev libcairo2-dev libglib2.0-dev
28+
run: sudo apt install -y libgtk-3-dev libcairo2-dev libglib2.0-dev libgtk-layer-shell0
2929

3030
- name: Build
3131
run: go build -v ./...

bar.go

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ func createSidestuff() *gtk.Box {
5454
volumeImage, _ := gtk.ImageNewFromIconName(volumeIcon, gtk.ICON_SIZE_BUTTON)
5555
sc, _ = volumeImage.GetStyleContext()
5656
sc.AddClass("sound")
57+
glib.TimeoutAdd(uint(500), func() bool {
58+
59+
newVolumeIcon, err := volumeHandler.GetAudioIcon()
60+
if err == nil {
61+
volumeImage.SetFromIconName(newVolumeIcon, gtk.ICON_SIZE_BUTTON)
62+
}
63+
64+
// Return true to keep the timeout active.
65+
return true
66+
})
5767

5868
statusBox.PackStart(volumeImage, false, false, 0)
5969
}
@@ -66,6 +76,17 @@ func createSidestuff() *gtk.Box {
6676
sc, _ = networkImage.GetStyleContext()
6777
sc.AddClass("network")
6878

79+
glib.TimeoutAdd(uint(500), func() bool {
80+
81+
networkIcon, err := networkManagerHandler.GetNetworkIcon()
82+
if err == nil {
83+
networkImage.SetFromIconName(networkIcon, gtk.ICON_SIZE_BUTTON)
84+
}
85+
86+
// Return true to keep the timeout active.
87+
return true
88+
})
89+
6990
statusBox.PackStart(networkImage, false, false, 0)
7091
}
7192

@@ -75,6 +96,17 @@ func createSidestuff() *gtk.Box {
7596
sc, _ = batteryImage.GetStyleContext()
7697
sc.AddClass("power")
7798

99+
glib.TimeoutAdd(uint(500), func() bool {
100+
101+
if batteryHandler.IsBattery() {
102+
newBatteryIcon := batteryHandler.GetBatteryIcon()
103+
batteryImage.SetFromIconName(newBatteryIcon, gtk.ICON_SIZE_BUTTON)
104+
}
105+
106+
// Return true to keep the timeout active.
107+
return true
108+
})
109+
78110
statusBox.PackStart(batteryImage, false, false, 0)
79111
}
80112

@@ -141,17 +173,17 @@ func createWorkspaces() *gtk.Box {
141173
sc, _ := imgButton.GetStyleContext()
142174
sc.AddClass("app")
143175

144-
img, _ := gtk.ImageNewFromIconName(k.AppID, gtk.ICON_SIZE_BUTTON)
145-
imgButton.Add(img)
176+
pathn, err := foreignToplevel.GetIconFromToplevel(k, 16, 1)
177+
if err == nil {
178+
img, _ := gtk.ImageNewFromFile(pathn)
179+
imgButton.Add(img)
180+
}
181+
182+
imgButton.Connect("clicked", func() {
183+
foreignToplevel.SelectToplevel(k)
184+
})
146185
box.PackStart(imgButton, false, false, 0)
147186
}
148-
// Placeholder for dynamic window list
149-
imgButton1, _ := gtk.ButtonNew()
150-
sc, _ = imgButton1.GetStyleContext()
151-
sc.AddClass("app")
152-
img1, _ := gtk.ImageNewFromIconName("preferences-desktop", gtk.ICON_SIZE_BUTTON)
153-
imgButton1.Add(img1)
154-
box.PackStart(imgButton1, false, false, 0)
155187

156188
return box
157189
}
@@ -166,9 +198,15 @@ func createMainIcons() *gtk.Box {
166198
customButton, _ := gtk.ButtonNew()
167199
customButton.Add(customIcon)
168200

201+
mm := createMainMenu()
202+
169203
customButton.Connect("clicked", func() {
170-
createMainMenu().ShowAll()
171-
box.Hide()
204+
if mm.IsVisible() {
205+
mm.Hide()
206+
} else {
207+
mm.ShowAll()
208+
}
209+
//box.Hide()
172210
})
173211

174212
box.PackStart(desktopImage, false, false, 0)
@@ -208,6 +246,19 @@ func createBar() *gtk.Window {
208246
box.PackStart(createWorkspaces(), false, false, 0)
209247
box.SetCenterWidget(createMainIcons())
210248
box.PackEnd(createSidestuff(), false, false, 0)
249+
250+
glib.TimeoutAdd(uint(500), func() bool {
251+
chil := box.GetChildren()
252+
chil.NthData(uint(0)).(*gtk.Widget).Destroy()
253+
254+
wspaces := createWorkspaces()
255+
box.PackStart(wspaces, false, false, 0)
256+
257+
box.ShowAll()
258+
// Return true to keep the timeout active.
259+
return true
260+
})
261+
211262
win.Add(box)
212263
return win
213264
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/MiracleOS-Team/desktop
33
go 1.22.2
44

55
require (
6-
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3
6+
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e
77
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250203122932-0d6a9fc71582
88
github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774
99
github.com/gotk3/gotk3 v0.6.5-0.20240618185848-ff349ae13f56

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ github.com/MiracleOS-Team/desktoplib v0.0.0-20250203213240-ff0177e4ccaa h1:yAqSw
66
github.com/MiracleOS-Team/desktoplib v0.0.0-20250203213240-ff0177e4ccaa/go.mod h1:LvzdmHbq2om/X8sPOcR3faqsZQRHTVMCm58NFp2aLIU=
77
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3 h1:+UZtfbdcpSCXIap83dOHxWcMOqc42jCpYepfidv6xGY=
88
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3/go.mod h1:lsr1apHlN/KIBNQdH2ngannvIIBKnYRvyo8oCgBoaVE=
9+
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208144711-a5bbe5d446ea h1:vo1i1b8oLw8E//JbaCziKeVYstxWnyS+Vh7F+4rxal8=
10+
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208144711-a5bbe5d446ea/go.mod h1:0ngQ5R2b2J6/WRk1vhBiVrGYkc0XdUlD20rjFlM9vUs=
11+
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e h1:YculMH5KeiHvUKDHlKJmz/3GO1jWAAxxKv9X/N+Dekg=
12+
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e/go.mod h1:0ngQ5R2b2J6/WRk1vhBiVrGYkc0XdUlD20rjFlM9vUs=
913
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250126160842-bc18282c37ee h1:jsl3imeBR+qACjnTzGHJt1zrvrkW5MkHyFFpsmYnzxk=
1014
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250126160842-bc18282c37ee/go.mod h1:mKskdRQzPihHpgc1aUN06dlR2ECTxQWgPzOY3u2To+I=
1115
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250130123149-66a2b3e59a66 h1:zax0cvv63QOakMKGH4p1UN9UfVW9bRHEe1Q2GGRPt00=

mainMenu.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ func createAppList() *gtk.ScrolledWindow {
5050
scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
5151
vbox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
5252

53-
apps, _ := desktopFiles.ListAllApplications()
53+
apps1, _ := desktopFiles.ListAllApplications()
54+
55+
apps := []desktopFiles.DesktopFile{}
56+
57+
for _, app := range apps1 {
58+
if app.NoDisplay {
59+
continue
60+
} else {
61+
apps = append(apps, app)
62+
}
63+
}
5464

5565
categories := map[string][]desktopFiles.DesktopFile{}
5666

0 commit comments

Comments
 (0)