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

Improve "Install" menu item function

üst 0c7e8722
...@@ -38,7 +38,8 @@ gettext.install("flatpak-gui", "po/") ...@@ -38,7 +38,8 @@ gettext.install("flatpak-gui", "po/")
class InstallWindow(object): class InstallWindow(object):
def __init__(self, application, apptoinstrealname, apptoinstarch, def __init__(self, application, apptoinstrealname, apptoinstarch,
apptoinstbranch, apptoinstremote, flatpakinstallation, apptoinstbranch, apptoinstremote, flatpakinstallation,
liststore, treemodel): liststore, treeviewmain, runmenuitem, installmenuitem,
uninstallmenuitem):
self.Application = application self.Application = application
self.AppToInstallRealName = apptoinstrealname self.AppToInstallRealName = apptoinstrealname
...@@ -68,7 +69,16 @@ class InstallWindow(object): ...@@ -68,7 +69,16 @@ class InstallWindow(object):
None) None)
self.ListStoreMain = liststore self.ListStoreMain = liststore
self.TreeModel = treemodel self.TreeViewMain = treeviewmain
self.Selection = self.TreeViewMain.get_selection()
self.TreeModel, self.TreeIter = self.Selection.get_selected()
self.TreePath = self.TreeModel.get_path(self.TreeIter)
self.SelectedRowIndex = self.TreePath.get_indices()[0]
self.RunMenuItem = runmenuitem
self.InstallMenuItem = installmenuitem
self.UninstallMenuItem = uninstallmenuitem
try: try:
InstallGUIFile = "ui/actionwindow.glade" InstallGUIFile = "ui/actionwindow.glade"
...@@ -138,16 +148,6 @@ class InstallWindow(object): ...@@ -138,16 +148,6 @@ 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,
data=None,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.25)
GLib.idle_add(self.TreeModel.refilter,
data=None,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.25)
flatpakrefslist = \ flatpakrefslist = \
self.FlatpakInstallation.list_installed_refs() self.FlatpakInstallation.list_installed_refs()
flathubrefslist = \ flathubrefslist = \
...@@ -162,7 +162,9 @@ class InstallWindow(object): ...@@ -162,7 +162,9 @@ class InstallWindow(object):
for listitem in flatpakrefslist: for listitem in flatpakrefslist:
if listitem.get_kind() == Flatpak.RefKind.APP and \ if listitem.get_kind() == Flatpak.RefKind.APP and \
listitem.get_arch() == Flatpak.get_default_arch(): listitem.get_arch() == Flatpak.get_default_arch() and \
listitem.get_branch() == self.AppToInstallBranch and \
listitem.get_name() == self.AppToInstallRealName:
if listitem in flathubrefslist: if listitem in flathubrefslist:
RemoteName = "flathub" RemoteName = "flathub"
DownloadSize = listitem.get_download_size() DownloadSize = listitem.get_download_size()
...@@ -179,18 +181,23 @@ class InstallWindow(object): ...@@ -179,18 +181,23 @@ class InstallWindow(object):
InstalledSizeMiBAsString = \ InstalledSizeMiBAsString = \
f"{InstalledSizeMiB:.2f}" + " MiB" f"{InstalledSizeMiB:.2f}" + " MiB"
self.ListStoreMain.append([listitem.get_name(), self.TreeModel.set_row(self.TreeIter, [listitem.get_name(),
listitem.get_arch(), listitem.get_arch(),
listitem.get_branch(), listitem.get_branch(),
RemoteName, RemoteName,
InstalledSizeMiBAsString, InstalledSizeMiBAsString,
DownloadSizeMiBAsString, DownloadSizeMiBAsString,
Name]) Name])
self.RunMenuItem.set_sensitive(True)
self.UninstallMenuItem.set_sensitive(True)
self.InstallMenuItem.set_sensitive(False)
GLib.idle_add(self.TreeModel.refilter, GLib.idle_add(self.TreeModel.refilter,
data=None, data=None,
priority=GLib.PRIORITY_DEFAULT) priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.02) time.sleep(0.25)
break
else: else:
continue continue
......
...@@ -511,7 +511,8 @@ class MainWindow(object): ...@@ -511,7 +511,8 @@ class MainWindow(object):
InstallWindow(self.Application, AppToInstallRealName, InstallWindow(self.Application, AppToInstallRealName,
AppToInstallArch, AppToInstallBranch, AppToInstallArch, AppToInstallBranch,
AppToInstallRemote, self.FlatpakInstallation, AppToInstallRemote, self.FlatpakInstallation,
self.ListStoreMain, TreeModel) self.ListStoreMain, self.TreeViewMain,
self.RunMenuItem, self.InstallMenuItem, self.UninstallMenuItem)
def onInstallFromEntry(self, menuitem): def onInstallFromEntry(self, menuitem):
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