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

Improve "Install" menu item function

* Update a related ref row on the list if a related ref is app
  (not runtime) after installing a related ref.
üst 0f607353
......@@ -74,7 +74,7 @@ class InstallWindow(object):
self.install_progress_callback)
self.handler_id_2 = self.FlatpakTransaction.connect(
"operation-done",
self.install_progress_callback_disconnect)
self.install_progress_callback_done)
self.handler_id_error = self.FlatpakTransaction.connect(
"operation-error",
self.install_progress_callback_error)
......@@ -114,6 +114,11 @@ class InstallWindow(object):
GLib.threads_init()
def install(self):
GLib.idle_add(self.Selection.unselect_all,
data=None,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
handler_id_cancel = self.InstallCancellation.connect(self.cancellation_callback, None)
try:
self.FlatpakTransaction.run(self.InstallCancellation)
......@@ -140,16 +145,37 @@ class InstallWindow(object):
self.disconnect_handlers(handler_id_cancel)
time.sleep(0.5)
installed_ref = Flatpak.InstalledRef()
for ref in self.FlatpakInstallation.list_installed_refs():
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
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()
status_text = _("Installing: ") + ref_to_install_real_name
self.StatusText = self.StatusText + "\n" + status_text
GLib.idle_add(self.InstallLabel.set_text,
status_text,
priority=GLib.PRIORITY_DEFAULT)
GLib.idle_add(self.InstallTextBuffer.set_text,
self.StatusText,
priority=GLib.PRIORITY_DEFAULT)
self.TransactionProgress = progress # FIXME: Fix PyCharm warning
self.TransactionProgress.set_update_frequency(200)
self.handler_id_progress = self.TransactionProgress.connect(
"changed",
self.progress_bar_update) # FIXME: Fix PyCharm warning
def install_progress_callback_done(self, transaction, operation, commit, result):
self.TransactionProgress.disconnect(self.handler_id_progress)
operation_ref = Flatpak.Ref.parse(operation.get_ref())
operation_ref_real_name = operation_ref.get_name()
operation_ref_arch = operation_ref.get_arch()
operation_ref_branch = operation_ref.get_branch()
for installed_ref in self.FlatpakInstallation.list_installed_refs():
if installed_ref.get_name() == operation_ref_real_name and \
installed_ref.get_arch() == operation_ref_arch and \
installed_ref.get_branch() == operation_ref_branch and \
installed_ref.get_kind() == Flatpak.RefKind.APP:
installed_ref_real_name = installed_ref.get_name()
installed_ref_arch = installed_ref.get_arch()
installed_ref_branch = installed_ref.get_branch()
......@@ -163,9 +189,15 @@ class InstallWindow(object):
download_size_mib_str = ""
name = installed_ref.get_appdata_name()
tree_iter = self.TreeModel.convert_iter_to_child_iter(self.TreeIter)
tree_model = self.TreeModel.get_model()
tree_iter = tree_model.get_iter_first()
while tree_iter:
real_name = tree_model.get_value(tree_iter, 0)
arch = tree_model.get_value(tree_iter, 1)
branch = tree_model.get_value(tree_iter, 2)
if real_name == installed_ref_real_name and \
arch == installed_ref_arch and \
branch == installed_ref_branch:
GLib.idle_add(tree_model.set_row,
tree_iter, [installed_ref_real_name,
installed_ref_arch,
......@@ -177,32 +209,9 @@ class InstallWindow(object):
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
GLib.idle_add(self.Selection.unselect_all,
data=None,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
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()
status_text = _("Installing: ") + ref_to_install_real_name
self.StatusText = self.StatusText + "\n" + status_text
GLib.idle_add(self.InstallLabel.set_text,
status_text,
priority=GLib.PRIORITY_DEFAULT)
GLib.idle_add(self.InstallTextBuffer.set_text,
self.StatusText,
priority=GLib.PRIORITY_DEFAULT)
self.TransactionProgress = progress # FIXME: Fix PyCharm warning
self.TransactionProgress.set_update_frequency(200)
self.handler_id_progress = self.TransactionProgress.connect(
"changed",
self.progress_bar_update) # FIXME: Fix PyCharm warning
def install_progress_callback_disconnect(self, transaction, operation, commit, result):
self.TransactionProgress.disconnect(self.handler_id_progress)
tree_model.refilter()
time.sleep(0.3)
tree_iter = tree_model.iter_next(tree_iter)
def install_progress_callback_error(self, transaction, operation, error, details):
ref_to_install = Flatpak.Ref.parse(operation.get_ref())
......
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