Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-system-updater
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-system-updater
Commits
3efa852e
Commit
3efa852e
authored
Oct 31, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented background mode
parent
5e827820
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
11 deletions
+77
-11
main.go
main.go
+77
-11
No files found.
main.go
View file @
3efa852e
...
...
@@ -2,8 +2,8 @@ package main
import
(
"SystemUpdater/lib/apm"
sudbus
"SystemUpdater/lib/apm/sudbus"
bldr
"SystemUpdater/lib/gtks/builder"
"fmt"
"os"
"unsafe"
...
...
@@ -11,6 +11,7 @@ import (
_
"embed"
"github.com/diamondburned/gotk4-adwaita/pkg/adw"
"github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gio/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
)
...
...
@@ -26,7 +27,7 @@ var mainApp *SystemUpdater
func
GetSystemUpdater
()
*
SystemUpdater
{
if
mainApp
==
nil
{
xdgName
:=
"ru.ximperlinux.SystemUpdater"
appAdw
:=
adw
.
NewApplication
(
xdgName
,
gio
.
ApplicationFlags
None
)
appAdw
:=
adw
.
NewApplication
(
xdgName
,
gio
.
ApplicationFlags
(
8
)
)
appGtk
:=
(
*
gtk
.
Application
)(
unsafe
.
Pointer
(
appAdw
))
mainApp
=
&
SystemUpdater
{
...
...
@@ -38,22 +39,36 @@ func GetSystemUpdater() *SystemUpdater {
return
mainApp
}
func
(
su
*
SystemUpdater
)
onActivate
()
{
conn
:=
sudbus
.
GetConnection
()
var
updates
[]
apm
.
PackageChanges
defer
conn
.
Conn
.
Close
()
func
(
su
*
SystemUpdater
)
backgroundStart
()
{
updatesSources
:=
apm
.
NewUpdatesSources
()
upds
:=
apm
.
NewUpdatesSources
()
for
_
,
u
:=
range
updatesSources
{
updates
=
append
(
updates
,
u
.
GetPackageChanges
())
}
}
func
(
su
*
SystemUpdater
)
onActivate
()
{
su
.
App
.
Release
()
window
:=
GetSystemUpdaterWindow
()
window
.
SetApplication
(
su
.
AppGTK
)
window
.
stack
.
SetVisibleChildName
(
"loading"
)
window
.
Present
()
// Это выглядит прям очень плохо... Потом надо бы переделать по уму
glib
.
TimeoutAdd
(
100
,
func
()
bool
{
if
len
(
updates
)
>
0
{
window
.
FillWithChanges
(
su
,
updates
)
for
_
,
us
:=
range
upds
{
window
.
FillWithChanges
(
su
,
us
)
window
.
stack
.
SetVisibleChildName
(
"main"
)
return
false
}
window
.
Present
()
return
true
})
}
//go:embed window.ui
...
...
@@ -63,6 +78,7 @@ type SystemUpdaterWindow struct {
*
adw
.
ApplicationWindow
navView
*
adw
.
NavigationView
listbox
*
gtk
.
ListBox
stack
*
gtk
.
Stack
}
var
mainWin
*
SystemUpdaterWindow
...
...
@@ -75,18 +91,22 @@ func GetSystemUpdaterWindow() *SystemUpdaterWindow {
navView
:=
bldr
.
GetObject
[
*
adw
.
NavigationView
](
builder
,
"navigationv"
)
listbox
:=
bldr
.
GetObject
[
*
gtk
.
ListBox
](
builder
,
"updates_listbox"
)
stack
:=
bldr
.
GetObject
[
*
gtk
.
Stack
](
builder
,
"main_stack"
)
mainWin
=
&
SystemUpdaterWindow
{
win
,
navView
,
listbox
,
stack
,
}
}
return
mainWin
}
func
(
sw
*
SystemUpdaterWindow
)
FillWithChanges
(
su
*
SystemUpdater
,
us
apm
.
UpdaterSource
)
{
sw
.
listbox
.
Append
(
NewUpdateRow
(
"System packages"
,
us
.
GetPackageChanges
()))
func
(
sw
*
SystemUpdaterWindow
)
FillWithChanges
(
su
*
SystemUpdater
,
u
[]
apm
.
PackageChanges
)
{
for
_
,
updatesList
:=
range
u
{
sw
.
listbox
.
Append
(
NewUpdateRow
(
"System packages"
,
updatesList
))
}
}
func
SystemUpdaterApplication
(
su
*
SystemUpdater
)
{
...
...
@@ -94,6 +114,52 @@ func SystemUpdaterApplication(su *SystemUpdater) {
su
.
onActivate
()
})
su
.
App
.
ConnectCommandLine
(
func
(
cmd
*
gio
.
ApplicationCommandLine
)
int
{
args
:=
cmd
.
Arguments
()
fmt
.
Println
(
"Got args:"
,
args
)
if
cmd
.
IsRemote
()
{
fmt
.
Println
(
"Remote command received!"
)
su
.
App
.
Activate
()
cmd
.
Done
()
return
0
}
backgroundMode
:=
false
if
len
(
args
)
>
1
{
for
_
,
arg
:=
range
args
[
1
:
]
{
switch
arg
{
case
"--background"
,
"-b"
:
backgroundMode
=
true
default
:
fmt
.
Fprintf
(
os
.
Stderr
,
"Error: unknown argument %q
\n
"
,
arg
)
cmd
.
Done
()
os
.
Exit
(
1
)
}
}
}
if
backgroundMode
{
fmt
.
Println
(
"Running in background mode..."
)
su
.
App
.
Hold
()
go
su
.
backgroundStart
()
cmd
.
Done
()
return
0
}
go
su
.
backgroundStart
()
su
.
App
.
Activate
()
cmd
.
Done
()
return
0
})
os
.
Exit
(
su
.
App
.
Run
(
os
.
Args
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment