Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
P
pardus-flatpak-gui
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Pardus
ondokuz
pardus-flatpak-gui
Commits
1a88e087
Verified
Kaydet (Commit)
1a88e087
authored
Nis 22, 2020
tarafından
Erdem Ersoy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rewrite Flatpak GUI mess (14/X):
* Re-implement installing from file with command-line argument
üst
04ddb942
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
114 deletions
+54
-114
flatpakguiapp.py
pardusflatpakgui/flatpakguiapp.py
+2
-2
installfromfilewindow.py
pardusflatpakgui/installfromfilewindow.py
+52
-112
No files found.
pardusflatpakgui/flatpakguiapp.py
Dosyayı görüntüle @
1a88e087
...
...
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
pardusflatpakgui.mainwindow
import
MainWindow
from
pardusflatpakgui.install
window
import
Install
Window
from
pardusflatpakgui.install
fromfilewindow
import
InstallFromFile
Window
import
gettext
import
locale
...
...
@@ -74,7 +74,7 @@ class FlatpakGUIApp(Gtk.Application):
file_contents_bytes
=
bytes
(
file_contents
,
"utf-8"
)
file_contents_glib_bytes
=
GLib
.
Bytes
.
new
(
file_contents_bytes
)
Install
Window
(
self
,
application
,
file_contents_glib_bytes
)
Install
FromFileWindow
(
application
,
file_contents_glib_bytes
)
else
:
self
.
MessageDialogError
.
set_markup
(
_
(
"<big><b>Argument Error</b></big>"
))
...
...
pardusflatpakgui/installfromfilewindow.py
Dosyayı görüntüle @
1a88e087
...
...
@@ -36,18 +36,11 @@ gettext.install("pardus-flatpak-gui", "po/")
class
InstallFromFileWindow
(
object
):
def
__init__
(
self
,
application
,
file_contents
):
def
__init__
(
self
,
application
,
file_contents
_glib_bytes
):
self
.
Application
=
application
self
.
FlatpakInstallation
=
flatpakinstallation
self
.
FileFlatpakRefName
=
fileflatpakrefname
self
.
FileFlatpakRef
=
open
(
self
.
FileFlatpakRefName
,
"r"
)
self
.
FileFlatpakRefContents
=
self
.
FileFlatpakRef
.
read
(
-
1
)
self
.
FileFlatpakRefContentsAsBytes
=
bytes
(
self
.
FileFlatpakRefContents
,
"utf-8"
)
self
.
FileFlatpakRefContentsAsGLibBytes
=
GLib
.
Bytes
.
new
(
self
.
FileFlatpakRefContentsAsBytes
)
self
.
FileFlatpakRefContentsGLibBytes
=
file_contents_glib_bytes
self
.
FlatpakInstallation
=
Flatpak
.
Installation
.
new_system
(
Gio
.
Cancellable
.
new
())
self
.
FlatpakTransaction
=
\
Flatpak
.
Transaction
.
new_for_installation
(
self
.
FlatpakInstallation
,
...
...
@@ -59,33 +52,41 @@ class InstallFromFileWindow(object):
self
.
FlatpakTransaction
.
set_no_deploy
(
False
)
self
.
FlatpakTransaction
.
set_no_pull
(
False
)
self
.
FlatpakTransaction
.
add_install_flatpakref
(
self
.
FileFlatpakRefContentsAsGLibB
ytes
)
file_contents_glib_b
ytes
)
self
.
ListStoreMain
=
liststore
self
.
handler_id
=
self
.
FlatpakTransaction
.
connect
(
"new-operation"
,
self
.
install_progress_callback
)
self
.
handler_id_2
=
self
.
FlatpakTransaction
.
connect
(
"operation-done"
,
self
.
install_progress_callback_disconnect
)
self
.
handler_id_error
=
self
.
FlatpakTransaction
.
connect
(
"operation-error"
,
self
.
install_progress_callback_error
)
try
:
InstallFromFileGUIF
ile
=
"ui/actionwindow.glade"
InstallFromFileB
uilder
=
Gtk
.
Builder
.
new_from_file
(
InstallFromFileGUIF
ile
)
InstallFromFileB
uilder
.
connect_signals
(
self
)
install_from_file_gui_f
ile
=
"ui/actionwindow.glade"
install_from_file_b
uilder
=
Gtk
.
Builder
.
new_from_file
(
install_from_file_gui_f
ile
)
install_from_file_b
uilder
.
connect_signals
(
self
)
except
GLib
.
GError
:
print
(
_
(
"Error reading GUI file: "
)
+
InstallFromFileGUIF
ile
)
print
(
_
(
"Error reading GUI file: "
)
+
install_from_file_gui_f
ile
)
raise
self
.
InstallFromFileWindow
=
InstallFromFileB
uilder
.
get_object
(
self
.
InstallFromFileWindow
=
install_from_file_b
uilder
.
get_object
(
"ActionWindow"
)
self
.
InstallFromFileWindow
.
set_application
(
application
)
self
.
InstallFromFileWindow
.
set_title
(
_
(
"Installing from file..."
))
self
.
InstallFromFileWindow
.
show
()
self
.
InstallFromFileProgressBar
=
InstallFromFileB
uilder
.
get_object
(
self
.
InstallFromFileProgressBar
=
install_from_file_b
uilder
.
get_object
(
"ActionProgressBar"
)
self
.
ProgressBarValue
=
int
(
self
.
InstallFromFileProgressBar
.
get_fraction
()
*
100
)
self
.
InstallFromFileLabel
=
InstallFromFileB
uilder
.
get_object
(
self
.
InstallFromFileLabel
=
install_from_file_b
uilder
.
get_object
(
"ActionLabel"
)
self
.
InstallFromFileTextBuffer
=
InstallFromFileB
uilder
.
get_object
(
self
.
InstallFromFileTextBuffer
=
install_from_file_b
uilder
.
get_object
(
"ActionTextBuffer"
)
self
.
InstallFromFileTextBuffer
.
set_text
(
"
\0
"
,
-
1
)
...
...
@@ -94,37 +95,28 @@ class InstallFromFileWindow(object):
self
.
InstallFromFileTextBuffer
.
set_text
(
self
.
StatusText
)
self
.
InstallFromFileThread
=
threading
.
Thread
(
target
=
self
.
InstallFromF
ile
,
target
=
self
.
install_from_f
ile
,
args
=
())
self
.
InstallFromFileThread
.
start
()
GLib
.
threads_init
()
def
InstallFromFile
(
self
):
self
.
handler_id
=
self
.
FlatpakTransaction
.
connect
(
"new-operation"
,
self
.
InstallProgressCallback
)
self
.
handler_id_2
=
self
.
FlatpakTransaction
.
connect
(
"operation-done"
,
self
.
InstallProgressCallbackDisconnect
)
self
.
handler_id_error
=
self
.
FlatpakTransaction
.
connect
(
"operation-error"
,
self
.
InstallProgressCallbackError
)
def
install_from_file
(
self
):
try
:
self
.
FlatpakTransaction
.
run
(
Gio
.
Cancellable
.
new
())
except
GLib
.
Error
:
statustext
=
_
(
"Error at installation!"
)
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
statustext
status
_
text
=
_
(
"Error at installation!"
)
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
status
_
text
GLib
.
idle_add
(
self
.
InstallFromFileLabel
.
set_text
,
statustext
,
status
_
text
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
GLib
.
idle_add
(
self
.
InstallFromFileTextBuffer
.
set_text
,
self
.
StatusText
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
else
:
statustext
=
_
(
"Installing completed!"
)
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
statustext
status
_
text
=
_
(
"Installing completed!"
)
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
status
_
text
GLib
.
idle_add
(
self
.
InstallFromFileLabel
.
set_text
,
statustext
,
status
_
text
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
GLib
.
idle_add
(
self
.
InstallFromFileTextBuffer
.
set_text
,
self
.
StatusText
,
...
...
@@ -134,99 +126,47 @@ class InstallFromFileWindow(object):
self
.
FlatpakTransaction
.
disconnect
(
self
.
handler_id_error
)
time
.
sleep
(
0.5
)
GLib
.
idle_add
(
self
.
ListStoreMain
.
clear
,
data
=
None
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
def
install_progress_callback
(
self
,
transaction
,
operation
,
progress
):
ref_to_install
=
Flatpak
.
Ref
.
parse
(
operation
.
get_ref
())
ref_to_install_real_name
=
ref_to_install
.
get_name
(
)
flatpakrefslist
=
\
self
.
FlatpakInstallation
.
list_installed_refs
()
flathubrefslist
=
\
self
.
FlatpakInstallation
.
list_remote_refs_sync
(
"flathub"
,
Gio
.
Cancellable
.
new
())
for
item
in
flatpakrefslist
:
for
item2
in
flathubrefslist
:
if
item
.
get_name
()
==
item2
.
get_name
():
flathubrefslist
.
remove
(
item2
)
flatpakrefslist
=
flatpakrefslist
+
flathubrefslist
for
listitem
in
flatpakrefslist
:
if
listitem
.
get_kind
()
==
Flatpak
.
RefKind
.
APP
and
\
listitem
.
get_arch
()
==
Flatpak
.
get_default_arch
():
if
listitem
in
flathubrefslist
:
RemoteName
=
"flathub"
DownloadSize
=
listitem
.
get_download_size
()
DownloadSizeMiB
=
DownloadSize
/
1048576
DownloadSizeMiBAsString
=
f
"{DownloadSizeMiB:.2f}"
+
" MiB"
Name
=
""
else
:
RemoteName
=
""
DownloadSizeMiBAsString
=
""
Name
=
listitem
.
get_appdata_name
()
InstalledSize
=
listitem
.
get_installed_size
()
InstalledSizeMiB
=
InstalledSize
/
1048576
InstalledSizeMiBAsString
=
\
f
"{InstalledSizeMiB:.2f}"
+
" MiB"
self
.
ListStoreMain
.
append
([
listitem
.
get_name
(),
listitem
.
get_arch
(),
listitem
.
get_branch
(),
RemoteName
,
InstalledSizeMiBAsString
,
DownloadSizeMiBAsString
,
Name
])
else
:
continue
def
InstallProgressCallback
(
self
,
*
args
):
self
.
RefToInstall
=
Flatpak
.
Ref
.
parse
(
args
[
1
]
.
get_ref
())
self
.
RefToInstallRealName
=
self
.
RefToInstall
.
get_name
()
self
.
RefToInstallArch
=
self
.
RefToInstall
.
get_arch
()
self
.
RefToInstallBranch
=
self
.
RefToInstall
.
get_branch
()
self
.
FlatpakTransaction
.
set_default_arch
(
self
.
RefToInstallArch
)
statustext
=
_
(
"Installing: "
)
+
self
.
RefToInstallRealName
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
statustext
status_text
=
_
(
"Installing: "
)
+
ref_to_install_real_name
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
status_text
GLib
.
idle_add
(
self
.
InstallFromFileLabel
.
set_text
,
statustext
,
status
_
text
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
GLib
.
idle_add
(
self
.
InstallFromFileTextBuffer
.
set_text
,
self
.
StatusText
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
self
.
TransactionProgress
=
args
[
2
]
self
.
TransactionProgress
=
progress
# FIXME: Fix PyCharm warning
self
.
TransactionProgress
.
set_update_frequency
(
200
)
self
.
handler_id_progress
=
self
.
TransactionProgress
.
connect
(
"changed"
,
self
.
ProgressBarUpdate
)
"changed"
,
self
.
progress_bar_update
)
# FIXME: Fix PyCharm warning
def
InstallProgressCallbackDisconnect
(
self
,
*
args
):
def
install_progress_callback_disconnect
(
self
,
transaction
,
operation
,
commit
,
result
):
self
.
TransactionProgress
.
disconnect
(
self
.
handler_id_progress
)
def
InstallProgressCallbackError
(
self
,
*
arg
s
):
self
.
RefToInstall
=
Flatpak
.
Ref
.
parse
(
args
[
1
]
.
get_ref
())
self
.
RefToInstallRealName
=
self
.
RefToI
nstall
.
get_name
()
def
install_progress_callback_error
(
self
,
transaction
,
operation
,
error
,
detail
s
):
ref_to_install
=
Flatpak
.
Ref
.
parse
(
operation
.
get_ref
())
ref_to_install_real_name
=
ref_to_i
nstall
.
get_name
()
status
text
=
_
(
"Not installed: "
)
+
self
.
RefToInstallRealN
ame
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
statustext
GLib
.
idle_add
(
self
.
InstallLabel
.
set_text
,
statustext
,
status
_text
=
_
(
"Not installed: "
)
+
ref_to_install_real_n
ame
self
.
StatusText
=
self
.
StatusText
+
"
\n
"
+
status
_
text
GLib
.
idle_add
(
self
.
Install
FromFile
Label
.
set_text
,
status
_
text
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
GLib
.
idle_add
(
self
.
InstallTextBuffer
.
set_text
,
GLib
.
idle_add
(
self
.
Install
FromFile
TextBuffer
.
set_text
,
self
.
StatusText
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
if
self
.
RefToInstallRealName
!=
self
.
AppToInstallRealName
:
return
True
else
:
return
False
return
False
def
ProgressBarU
pdate
(
self
,
transaction_progress
):
def
progress_bar_u
pdate
(
self
,
transaction_progress
):
GLib
.
idle_add
(
self
.
InstallFromFileProgressBar
.
set_fraction
,
float
(
transaction_progress
.
get_progress
())
/
100.0
,
priority
=
GLib
.
PRIORITY_DEFAULT
)
def
on
Destroy
(
self
,
*
args
):
self
.
InstallFromFileWindow
.
destroy
()
def
on
_delete_action_window
(
self
,
widget
,
event
):
widget
.
hide_on_delete
()
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