152
152
self.active_app = None
153
153
self._prev_active_app = 0
154
154
self.limit = limit
155
# keep track of the index for a transaction in progress
156
self.transaction_index = None
155
# keep track of indicies for transactions in progress
156
self.transaction_index_map = {}
157
157
# no search query means "all"
158
158
if not search_query:
159
159
self.search_query = SearchQuery(xapian.Query(""))
343
343
def _on_transaction_progress_changed(self, backend, pkgname, progress):
344
if self.transaction_index is not None:
345
row = self[self.transaction_index]
344
if pkgname in self.transaction_index_map:
345
row = self[self.transaction_index_map[pkgname]]
346
346
self.row_changed(row.path, row.iter)
348
348
# the following methods ensure that the contents data is refreshed
351
351
def _on_transaction_started(self, backend, pkgname):
352
352
self._existing_apps = None
353
353
self._installable_apps = None
354
from softwarecenter.utils import ExecutionTime
355
with ExecutionTime("TIME get_index_for_pkgname"):
356
self.transaction_index = self._get_index_for_pkgname(pkgname)
354
gobject.idle_add(self._register_transaction_index_for_pkgname, pkgname)
358
def _get_index_for_pkgname(self, pkgname_to_match):
356
def _register_transaction_index_for_pkgname(self, pkgname_to_match):
359
357
for index in range(len(self.matches)):
360
358
doc = self.matches[index].document
361
359
pkgname = self.db.get_pkgname(doc)
362
360
if pkgname == pkgname_to_match:
361
self.transaction_index_map[pkgname] = index
365
def _on_transaction_finished(self, *args, **kwargs):
364
def _on_transaction_finished(self, backend, result):
366
365
self._existing_apps = None
367
366
self._installable_apps = None
368
self.transaction_index = None
367
if result.pkgname in self.transaction_index_map:
368
del self.transaction_index_map[result.pkgname]
370
370
def _download_icon_and_show_when_ready(self, cache, pkgname, icon_file_name):
371
371
self._logger.debug("did not find the icon locally, must download %s" % icon_file_name)