Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
Librem 5 Package Information Tool
Commits
b8e47763
Commit
b8e47763
authored
Nov 12, 2019
by
David Boddie
💬
Browse files
Use an idle callback, batch background work
parent
20bc5166
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.py
View file @
b8e47763
...
...
@@ -20,9 +20,9 @@ from .package_info import Worker
class
Application
(
Gtk
.
Application
):
def
__init__
(
self
):
super
().
__init__
(
application_id
=
'
sm.puri.Get_P
ackage_
I
nfo'
)
GLib
.
set_application_name
(
'
Get
Package Info'
)
GLib
.
set_prgname
(
'
sm.puri.Get_P
ackage_
I
nfo'
)
super
().
__init__
(
application_id
=
'
librem5_p
ackage_
i
nfo
_tool
'
)
GLib
.
set_application_name
(
'
Librem 5
Package Info
rmation
'
)
GLib
.
set_prgname
(
'
librem5_p
ackage_
i
nfo
_tool
'
)
self
.
timeout_id
=
None
self
.
lines
=
[]
...
...
@@ -31,15 +31,15 @@ class Application(Gtk.Application):
def
do_activate
(
self
):
window
=
Gtk
.
ApplicationWindow
(
application
=
self
)
window
.
set_icon_name
(
'
sm.puri.Get_P
ackage_
I
nfo'
)
window
.
set_icon_name
(
'
librem5_p
ackage_
i
nfo
_tool
'
)
header
=
Gtk
.
HeaderBar
(
title
=
_
(
'
Get
Package Info'
),
header
=
Gtk
.
HeaderBar
(
title
=
_
(
'
Librem 5
Package Info
rmation
'
),
show_close_button
=
True
)
window
.
set_titlebar
(
header
)
self
.
layout
=
Gtk
.
Box
(
orientation
=
'vertical'
,
margin
=
8
,
spacing
=
12
)
if
os
.
path
.
exists
(
self
.
output_dir
):
if
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
output_dir
,
'index.html'
)
):
question_label
=
Gtk
.
Label
()
question_label
.
set_markup
(
_
(
'<b>Existing information is available.</b>'
))
...
...
@@ -106,7 +106,7 @@ class Application(Gtk.Application):
self
.
state
=
'sources'
self
.
iter
=
self
.
worker
.
read_sources
()
self
.
timeout_id
=
GLib
.
timeout
_add
(
1
,
self
.
timeout
,
None
)
self
.
timeout_id
=
GLib
.
idle
_add
(
self
.
timeout
,
None
)
def
timeout
(
self
,
user_data
):
...
...
@@ -118,17 +118,18 @@ class Application(Gtk.Application):
def
read_source
(
self
):
try
:
info
=
self
.
iter
.
__next__
()
for
i
in
range
(
250
):
info
=
self
.
iter
.
__next__
()
suite_name
,
i
,
total
=
info
if
self
.
lines
[
-
1
]
!=
suite_name
:
self
.
lines
.
append
(
suite_name
)
suite_name
,
i
,
total
=
info
self
.
progress
.
set_text
(
'%i/%i'
%
(
i
,
total
))
self
.
progress
.
set_fraction
(
i
/
total
)
if
self
.
lines
[
-
1
]
!=
suite_name
:
self
.
lines
.
append
(
suite_name
)
self
.
update_label
()
except
StopIteration
:
# Start a new timer and stop the current one.
self
.
progress
.
set_fraction
(
1.0
)
self
.
state
=
'listing'
self
.
lines
.
append
(
_
(
'Listing packages'
))
self
.
lines
.
append
(
''
)
...
...
@@ -140,8 +141,10 @@ class Application(Gtk.Application):
def
list_package
(
self
):
try
:
name
=
self
.
iter
.
__next__
()
self
.
lines
[
-
1
]
=
name
for
i
in
range
(
100
):
name
=
self
.
iter
.
__next__
()
self
.
lines
[
-
1
]
=
name
self
.
update_label
()
except
StopIteration
:
...
...
Write
Preview
Supports
Markdown
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