Verified Kaydet (Commit) 1c8c9bd1 authored tarafından Erdem Ersoy's avatar Erdem Ersoy

Rewrite Flatpak GUI mess (8/X):

* Rewrite installwindow.py (2/X)
üst 7deb7aa4
...@@ -36,7 +36,7 @@ gettext.install("flatpak-gui", "po/") ...@@ -36,7 +36,7 @@ gettext.install("flatpak-gui", "po/")
class InstallWindow(object): class InstallWindow(object):
def __init__(self, application, flatpak_installation, real_name, arch, def __init__(self, application, flatpak_installation, real_name, arch,
branch, remote, list_store, search_filter): branch, remote, tree_model, tree_iter, selection, search_filter):
self.Application = application self.Application = application
self.RealName = real_name self.RealName = real_name
...@@ -64,7 +64,9 @@ class InstallWindow(object): ...@@ -64,7 +64,9 @@ class InstallWindow(object):
self.RefFormat, self.RefFormat,
None) None)
self.ListStoreMain = list_store self.TreeModel = tree_model
self.TreeIter = tree_iter
self.Selection = selection
self.SearchFilter = search_filter self.SearchFilter = search_filter
try: try:
...@@ -134,61 +136,45 @@ class InstallWindow(object): ...@@ -134,61 +136,45 @@ class InstallWindow(object):
self.FlatpakTransaction.disconnect(self.handler_id_error) self.FlatpakTransaction.disconnect(self.handler_id_error)
time.sleep(0.5) time.sleep(0.5)
GLib.idle_add(self.ListStoreMain.clear, for ref in self.FlatpakInstallation.list_installed_refs():
data=None, if ref.get_name() == self.Ref.get_name() and \
ref.get_arch() == self.Arch and \
ref.get_branch() == self.Branch:
installed_ref = ref
break
else:
continue
installed_ref_real_name = installed_ref.get_name()
installed_ref_arch = installed_ref.get_arch()
installed_ref_branch = installed_ref.get_branch()
installed_ref_remote = "flathub"
installed_size = installed_ref.get_installed_size()
installed_size_mib = installed_size / 1048576
installed_size_mib_str = \
f"{installed_size_mib:.2f}" + " MiB"
download_size_mib_str = ""
name = installed_ref.get_appdata_name()
GLib.idle_add(self.TreeModel.set_row,
self.TreeIter, [installed_ref_real_name,
installed_ref_arch,
installed_ref_branch,
installed_ref_remote,
installed_size_mib_str,
download_size_mib_str,
name],
priority=GLib.PRIORITY_DEFAULT) priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
self.InstalledRefsList = self.FlatpakInstallation.list_installed_refs() GLib.idle_add(self.Selection.unselect_iter,
self.FlatHubRefsList = self.FlatpakInstallation.list_remote_refs_sync( self.TreeIter,
"flathub", Gio.Cancellable.new()) priority=GLib.PRIORITY_DEFAULT)
self.NonInstalledRefsList = [] time.sleep(0.2)
for item in self.FlatHubRefsList:
self.NonInstalledRefsList.append(item)
for item_2 in self.InstalledRefsList:
if item.get_name() == item_2.get_name() and \
item.get_arch() == item_2.get_arch() and \
item.get_branch() == item_2.get_branch():
if len(self.NonInstalledRefsList) != 0:
self.NonInstalledRefsList.pop(len(self.NonInstalledRefsList) - 1)
else:
self.NonInstalledRefsList = []
self.AllRefsList = self.InstalledRefsList + self.NonInstalledRefsList
for list_item in self.AllRefsList:
if list_item.get_kind() == Flatpak.RefKind.APP and \
list_item.get_arch() == Flatpak.get_default_arch():
if list_item not in self.NonInstalledRefsList:
remote_name = "flathub"
download_size_mib_str = ""
name = list_item.get_appdata_name()
elif list_item not in self.InstalledRefsList:
remote_name = self.Remote
download_size_mib = list_item.get_download_size()
download_size_mib_str = f"{download_size_mib:.2f}" + " MiB"
name = ""
else:
continue
installed_size = list_item.get_installed_size()
installed_size_mib = installed_size / 1048576
installed_size_mib_str = \
f"{installed_size_mib:.2f}" + " MiB"
self.ListStoreMain.append([list_item.get_name(),
list_item.get_arch(),
list_item.get_branch(),
remote_name,
installed_size_mib_str,
download_size_mib_str,
name])
self.SearchFilter.refilter()
time.sleep(0.01)
else: self.SearchFilter.refilter()
continue
def InstallProgressCallback(self, *args): def InstallProgressCallback(self, *args):
self.RefToInstall = Flatpak.Ref.parse(args[1].get_ref()) self.RefToInstall = Flatpak.Ref.parse(args[1].get_ref())
......
...@@ -566,7 +566,7 @@ class MainWindow(object): ...@@ -566,7 +566,7 @@ class MainWindow(object):
remote = tree_model.get_value(tree_iter, 3) remote = tree_model.get_value(tree_iter, 3)
InstallWindow(self.Application, self.FlatpakInstallation, real_name, arch, branch, InstallWindow(self.Application, self.FlatpakInstallation, real_name, arch, branch,
remote, self.ListStoreMain, self.SearchFilter) remote, tree_model, tree_iter, selection, self.SearchFilter)
def on_install_from_entry(self, menu_item): def on_install_from_entry(self, menu_item):
InstallFromEntryWindow(self.Application, self.FlatpakInstallation, InstallFromEntryWindow(self.Application, self.FlatpakInstallation,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment