Skip to content

Commit

Permalink
Implement dynamic app list, working main button, dynamic sttaus icons…
Browse files Browse the repository at this point in the history
…, hour and date
  • Loading branch information
Labfox committed Feb 8, 2025
1 parent d9ed402 commit c9a4231
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: sudo apt update

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

- name: Build
run: go build -v ./...
Expand Down
73 changes: 62 additions & 11 deletions bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ func createSidestuff() *gtk.Box {
volumeImage, _ := gtk.ImageNewFromIconName(volumeIcon, gtk.ICON_SIZE_BUTTON)
sc, _ = volumeImage.GetStyleContext()
sc.AddClass("sound")
glib.TimeoutAdd(uint(500), func() bool {

newVolumeIcon, err := volumeHandler.GetAudioIcon()
if err == nil {
volumeImage.SetFromIconName(newVolumeIcon, gtk.ICON_SIZE_BUTTON)
}

// Return true to keep the timeout active.
return true
})

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

glib.TimeoutAdd(uint(500), func() bool {

networkIcon, err := networkManagerHandler.GetNetworkIcon()
if err == nil {
networkImage.SetFromIconName(networkIcon, gtk.ICON_SIZE_BUTTON)
}

// Return true to keep the timeout active.
return true
})

statusBox.PackStart(networkImage, false, false, 0)
}

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

glib.TimeoutAdd(uint(500), func() bool {

if batteryHandler.IsBattery() {
newBatteryIcon := batteryHandler.GetBatteryIcon()
batteryImage.SetFromIconName(newBatteryIcon, gtk.ICON_SIZE_BUTTON)
}

// Return true to keep the timeout active.
return true
})

statusBox.PackStart(batteryImage, false, false, 0)
}

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

img, _ := gtk.ImageNewFromIconName(k.AppID, gtk.ICON_SIZE_BUTTON)
imgButton.Add(img)
pathn, err := foreignToplevel.GetIconFromToplevel(k, 16, 1)
if err == nil {
img, _ := gtk.ImageNewFromFile(pathn)
imgButton.Add(img)
}

imgButton.Connect("clicked", func() {
foreignToplevel.SelectToplevel(k)
})
box.PackStart(imgButton, false, false, 0)
}
// Placeholder for dynamic window list
imgButton1, _ := gtk.ButtonNew()
sc, _ = imgButton1.GetStyleContext()
sc.AddClass("app")
img1, _ := gtk.ImageNewFromIconName("preferences-desktop", gtk.ICON_SIZE_BUTTON)
imgButton1.Add(img1)
box.PackStart(imgButton1, false, false, 0)

return box
}
Expand All @@ -166,9 +198,15 @@ func createMainIcons() *gtk.Box {
customButton, _ := gtk.ButtonNew()
customButton.Add(customIcon)

mm := createMainMenu()

customButton.Connect("clicked", func() {
createMainMenu().ShowAll()
box.Hide()
if mm.IsVisible() {
mm.Hide()
} else {
mm.ShowAll()
}
//box.Hide()
})

box.PackStart(desktopImage, false, false, 0)
Expand Down Expand Up @@ -208,6 +246,19 @@ func createBar() *gtk.Window {
box.PackStart(createWorkspaces(), false, false, 0)
box.SetCenterWidget(createMainIcons())
box.PackEnd(createSidestuff(), false, false, 0)

glib.TimeoutAdd(uint(500), func() bool {
chil := box.GetChildren()
chil.NthData(uint(0)).(*gtk.Widget).Destroy()

wspaces := createWorkspaces()
box.PackStart(wspaces, false, false, 0)

box.ShowAll()
// Return true to keep the timeout active.
return true
})

win.Add(box)
return win
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/MiracleOS-Team/desktop
go 1.22.2

require (
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250203122932-0d6a9fc71582
github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774
github.com/gotk3/gotk3 v0.6.5-0.20240618185848-ff349ae13f56
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ github.com/MiracleOS-Team/desktoplib v0.0.0-20250203213240-ff0177e4ccaa h1:yAqSw
github.com/MiracleOS-Team/desktoplib v0.0.0-20250203213240-ff0177e4ccaa/go.mod h1:LvzdmHbq2om/X8sPOcR3faqsZQRHTVMCm58NFp2aLIU=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3 h1:+UZtfbdcpSCXIap83dOHxWcMOqc42jCpYepfidv6xGY=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250204155824-a42d5b7c24e3/go.mod h1:lsr1apHlN/KIBNQdH2ngannvIIBKnYRvyo8oCgBoaVE=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208144711-a5bbe5d446ea h1:vo1i1b8oLw8E//JbaCziKeVYstxWnyS+Vh7F+4rxal8=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208144711-a5bbe5d446ea/go.mod h1:0ngQ5R2b2J6/WRk1vhBiVrGYkc0XdUlD20rjFlM9vUs=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e h1:YculMH5KeiHvUKDHlKJmz/3GO1jWAAxxKv9X/N+Dekg=
github.com/MiracleOS-Team/desktoplib v0.0.0-20250208145244-91c183a6941e/go.mod h1:0ngQ5R2b2J6/WRk1vhBiVrGYkc0XdUlD20rjFlM9vUs=
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250126160842-bc18282c37ee h1:jsl3imeBR+qACjnTzGHJt1zrvrkW5MkHyFFpsmYnzxk=
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250126160842-bc18282c37ee/go.mod h1:mKskdRQzPihHpgc1aUN06dlR2ECTxQWgPzOY3u2To+I=
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250130123149-66a2b3e59a66 h1:zax0cvv63QOakMKGH4p1UN9UfVW9bRHEe1Q2GGRPt00=
Expand Down
12 changes: 11 additions & 1 deletion mainMenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ func createAppList() *gtk.ScrolledWindow {
scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
vbox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)

apps, _ := desktopFiles.ListAllApplications()
apps1, _ := desktopFiles.ListAllApplications()

apps := []desktopFiles.DesktopFile{}

for _, app := range apps1 {
if app.NoDisplay {
continue
} else {
apps = append(apps, app)
}
}

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

Expand Down

0 comments on commit c9a4231

Please sign in to comment.