Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/src/packagemanager.py
          +++ new/src/packagemanager.py
↓ open down ↓ 37 lines elided ↑ open up ↑
  38   38  PACKAGE_PROGRESS_PERCENT_INCREMENT = 0.01 # Amount to update progress during loading phase
  39   39  PACKAGE_PROGRESS_PERCENT_TOTAL = 1.0      # Total progress for loading phase
  40   40  MAX_DESC_LEN = 60                         # Max length of the description
  41   41  MAX_INFO_CACHE_LIMIT = 100                # Max number of package descriptions to cache
  42   42  NOTEBOOK_PACKAGE_LIST_PAGE = 0            # Main Package List page index
  43   43  NOTEBOOK_START_PAGE = 1                   # Main View Start page index
  44   44  INFO_NOTEBOOK_LICENSE_PAGE = 3            # License Tab index
  45   45  SHOW_INFO_DELAY = 600       # Delay before showing selected pacakge information
  46   46  SHOW_LICENSE_DELAY = 600    # Delay before showing license information
  47   47  SEARCH_STR_FORMAT = "<%s>"
  48      -SEARCH_LIMIT = 100                        # Maximum number of results shown for
  49      -                                          # api search
  50   48  MIN_APP_WIDTH = 750                       # Minimum application width
  51   49  MIN_APP_HEIGHT = 500                     # Minimum application height
  52   50  INITIAL_APP_WIDTH_PREFERENCES = "/apps/packagemanager/preferences/initial_app_width"
  53   51  INITIAL_APP_HEIGHT_PREFERENCES = "/apps/packagemanager/preferences/initial_app_height"
  54   52  INITIAL_APP_HPOS_PREFERENCES = "/apps/packagemanager/preferences/initial_app_hposition"
  55   53  INITIAL_APP_VPOS_PREFERENCES = "/apps/packagemanager/preferences/initial_app_vposition"
  56   54  INITIAL_SHOW_FILTER_PREFERENCES = "/apps/packagemanager/preferences/initial_show_filter"
  57   55  INITIAL_SECTION_PREFERENCES = "/apps/packagemanager/preferences/initial_section"
  58   56  SHOW_STARTPAGE_PREFERENCES = "/apps/packagemanager/preferences/show_startpage"
  59   57  API_SEARCH_ERROR_PREFERENCES = "/apps/packagemanager/preferences/api_search_error"
↓ open down ↓ 203 lines elided ↑ open up ↑
 263  261                      gui_misc.get_icon(self.icon_theme, 'search_all', 20),
 264  262                      _("_All Repositories"),
 265  263                      _("Search All Repositories"))
 266  264                      ]
 267  265                  self.__register_iconsets(self.search_options)               
 268  266                  self.visible_repository = None
 269  267                  self.visible_repository_uptodate = False
 270  268                  self.last_active_publisher = None
 271  269                  self.search_start = 0
 272  270                  self.search_time_sec = 0
      271 +                self.current_search_publisher = None
 273  272                  self.section_list = None
 274  273                  self.filter_list = self.__get_new_filter_liststore()
 275  274                  self.application_list = None
 276  275                  self.a11y_application_treeview = None
 277  276                  self.a11y_categories_treeview = None
 278  277                  self.application_treeview_range = None
 279  278                  self.application_treeview_initialized = False
 280  279                  self.categories_treeview_range = None
 281  280                  self.categories_treeview_initialized = False
 282  281                  self.category_list = None
↓ open down ↓ 472 lines elided ↑ open up ↑
 755  754          def __handle_startpage_load_error(self, start_page_url):
 756  755                  self.document.open_stream('text/html')
 757  756                  self.document.write_stream(_(
 758  757                      "<html><head></head><body><H2>Welcome to"
 759  758                      "PackageManager!</H2><br>"
 760  759                      "<font color='#0000FF'>Warning: Unable to "
 761  760                      "load Start Page:<br>%s</font></body></html>"
 762  761                      % (start_page_url)))
 763  762                  self.document.close_stream()
 764  763  
 765      -        def __parse_api_search_error(self, error):
      764 +        def __process_api_search_error(self, error):
 766  765                  self.current_repos_with_search_errors = []
 767      -                if "failed_servers" in error.__dict__ and len(error.failed_servers) > 0:
 768      -                        #TBD we should not have to parse the error output
 769      -                        rem_str = " doesn't speak a known version of search operation"
 770      -                        timeout_str = "urlopen error timed out"
 771      -                        repos = []
 772      -                        for err in error.failed_servers:
 773      -                                err_str = str(err[1])
 774      -                                if rem_str in err_str:
 775      -                                        repo = err_str.replace(rem_str,"")
 776      -                                        self.current_repos_with_search_errors.append(repo)
 777      -                                elif timeout_str in err_str:
 778      -                                        repo = err[0].repositories[0].origins[0].uri
 779      -                                        self.current_repos_with_search_errors.append(repo)
 780  766  
      767 +                for pub, err in error.failed_servers:
      768 +                        self.current_repos_with_search_errors.append(
      769 +                            (pub, _("failed to respond"), err))
      770 +                for pub in error.invalid_servers:
      771 +                        self.current_repos_with_search_errors.append(
      772 +                            (pub, _("invalid response"),
      773 +                                _("A valid response was not returned.")))
      774 +                for pub, err in error.unsupported_servers:
      775 +                        self.current_repos_with_search_errors.append(
      776 +                            (pub, _("unsupported search"), err))
      777 +
 781  778          def __on_infosearch_button_clicked(self, widget):
 782  779                  self.__handle_api_search_error(True)
 783  780  
 784  781          def __handle_api_search_error(self, show_all=False):
 785  782                  if len(self.current_repos_with_search_errors) == 0:
 786  783                          self.w_infosearch_frame.hide()
 787  784                          return
 788      -                else:
 789      -                        self.w_infosearch_button.set_size_request(26, 22)
 790      -                        self.w_infosearch_frame.show()
 791  785  
 792      -                repo_pubs = self.__get_repo_publishers()
 793  786                  repo_count = 0
 794      -                for url in self.current_repos_with_search_errors:
 795      -                        if show_all or (url not in self.gconf_not_show_repos):
      787 +                for pub, err_type, err_str in self.current_repos_with_search_errors:
      788 +                        if show_all or (pub not in self.gconf_not_show_repos):
 796  789                                  repo_count += 1
 797  790                  if repo_count == 0:
      791 +                        self.w_infosearch_frame.hide()
 798  792                          return
 799  793  
      794 +                self.w_infosearch_button.set_size_request(26, 22)
      795 +                self.w_infosearch_frame.show()
 800  796                  infobuffer = self.api_search_error_textview.get_buffer()
 801  797                  infobuffer.set_text("")
 802  798                  textiter = infobuffer.get_end_iter()
 803      -                for url in self.current_repos_with_search_errors:
 804      -                        if show_all or (url not in self.gconf_not_show_repos):
      799 +                for pub, err_type, err_str in self.current_repos_with_search_errors:
      800 +
      801 +                        if show_all or (pub not in self.gconf_not_show_repos):
 805  802                                  infobuffer.insert_with_tags_by_name(textiter,
 806      -                                        "%s" % repo_pubs[url], "bold")
 807      -                                infobuffer.insert(textiter, " (%s)\n" % url)
      803 +                                    "%(pub)s (%(err_type)s)\n" % {"pub": pub,
      804 +                                    "err_type": err_type}, "bold")
      805 +                                infobuffer.insert(textiter, "%s\n" % (err_str))
      806 +
 808  807                  self.api_search_checkbox.set_active(False)
 809  808                  self.api_search_error_dialog.show()
 810  809                  self.api_search_button.grab_focus()
 811  810  
 812  811          def __get_repo_publishers(self):
 813  812                  repo_pub_dict = {}
 814  813                  pubs = self.api_o.get_publishers()
 815  814                  for pub in pubs:
 816  815                          repo = pub.selected_repository
 817  816                          origin = repo.origins[0]
↓ open down ↓ 215 lines elided ↑ open up ↑
1033 1032                  column.set_sort_column_id(enumerations.MARK_COLUMN)
1034 1033                  column.set_sort_indicator(True)
1035 1034                  column.set_cell_data_func(toggle_renderer, self.cell_data_function, None)
1036 1035                  column.connect_after('clicked',
1037 1036                      self.__application_treeview_column_sorted, None)
1038 1037                  self.w_application_treeview.append_column(column)
1039 1038                  name_renderer = gtk.CellRendererText()
1040 1039                  column = gtk.TreeViewColumn(_("Name"), name_renderer,
1041 1040                      text = enumerations.NAME_COLUMN)
1042 1041                  column.set_resizable(True)
     1042 +                column.set_min_width(150)
1043 1043                  column.set_sort_column_id(enumerations.NAME_COLUMN)
1044 1044                  column.set_sort_indicator(True)
1045 1045                  column.set_cell_data_func(name_renderer, self.cell_data_function, None)
1046 1046                  column.connect_after('clicked',
1047 1047                      self.__application_treeview_column_sorted, None)
1048 1048                  self.w_application_treeview.append_column(column)
1049 1049                  column = self.__create_icon_column(_("Status"), True,
1050 1050                      enumerations.STATUS_ICON_COLUMN, True)
1051 1051                  column.set_sort_column_id(enumerations.STATUS_ICON_COLUMN)
1052 1052                  column.set_sort_indicator(True)
↓ open down ↓ 256 lines elided ↑ open up ↑
1309 1309                          obj = self.a11y_application_treeview.ref_at(
1310 1310                              int(model.get_string_from_iter(itr)),
1311 1311                              STATUS_COLUMN_INDEX)
1312 1312                          obj.set_image_description(desc)
1313 1313  
1314 1314          def __set_visible_status(self, check_range = True):
1315 1315                  self.visible_status_id = 0
1316 1316                  if self.w_main_view_notebook.get_current_page() != \
1317 1317                      NOTEBOOK_PACKAGE_LIST_PAGE:
1318 1318                          return
     1319 +                if self.__doing_search():
     1320 +                        return
     1321 +
1319 1322                  a11y_enabled = False
1320 1323                  if self.a11y_application_treeview.get_n_accessible_children() != 0:
1321 1324                          a11y_enabled = True
1322 1325  
1323 1326                  visible_range = self.w_application_treeview.get_visible_range()
1324 1327                  if visible_range == None:
1325 1328                          return
1326 1329                  start = visible_range[0][0]
1327 1330                  end = visible_range[1][0]
1328 1331                  if debug_descriptions:
↓ open down ↓ 36 lines elided ↑ open up ↑
1365 1368                              sf_itr)
1366 1369                          app_itr = filt_model.convert_iter_to_child_iter(filtered_itr)
1367 1370  
1368 1371                          desc = sort_filt_model.get_value(sf_itr,
1369 1372                              enumerations.DESCRIPTION_COLUMN)
1370 1373                          # Only Fetch description for packages without a
1371 1374                          # description
1372 1375                          if desc == '...':
1373 1376                                  fmri = sort_filt_model.get_value(sf_itr,
1374 1377                                      enumerations.FMRI_COLUMN)
1375      -                                pkg_stem = fmri.get_pkg_stem(
1376      -                                    include_scheme = True)
1377      -                                pkg_stems_and_itr_to_fetch[pkg_stem] = \
1378      -                                    model.get_string_from_iter(app_itr)
     1378 +                                if fmri != None:
     1379 +                                        pkg_stem = fmri.get_pkg_stem(
     1380 +                                            include_scheme = True)
     1381 +                                        pkg_stems_and_itr_to_fetch[pkg_stem] = \
     1382 +                                            model.get_string_from_iter(app_itr)
1379 1383                          if a11y_enabled:
1380 1384                                  self.__set_accessible_status(sort_filt_model, sf_itr)
1381 1385                          start += 1
1382 1386                          sf_itr = sort_filt_model.iter_next(sf_itr)
1383 1387  
1384 1388                  if debug_descriptions:
1385 1389                          print "PKGS to FETCH: \n%s" % pkg_stems_and_itr_to_fetch
1386 1390                  if len(pkg_stems_and_itr_to_fetch) > 0:
1387 1391                          Thread(target = self.__get_pkg_descriptions,
1388 1392                              args = [pkg_stems_and_itr_to_fetch, model]).start() 
↓ open down ↓ 26 lines elided ↑ open up ↑
1415 1419                              include_scheme = True)
1416 1420                          pkg_descriptions_for_update.append((short_fmri,
1417 1421                              pkg_stems_and_itr_to_fetch[short_fmri],
1418 1422                              pkg_info.summary))
1419 1423                  if debug_descriptions:
1420 1424                          print "FETCHED PKGS: \n%s" % pkg_descriptions_for_update
1421 1425                  gobject.idle_add(self.__update_description_from_iter,
1422 1426                      pkg_descriptions_for_update, orig_model)
1423 1427  
1424 1428          def __update_description_from_iter(self, pkg_descriptions_for_update, orig_model):
     1429 +                #If doing a search abandon description updates
     1430 +                if self.__doing_search():
     1431 +                        return
     1432 +
1425 1433                  sort_filt_model = \
1426 1434                      self.w_application_treeview.get_model() #gtk.TreeModelSort
1427 1435                  filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
1428 1436                  model = filt_model.get_model() #gtk.ListStore
1429 1437  
1430      -                #If model has changed abandon description updates
     1438 +                #If model has changed
1431 1439                  if orig_model != model:
1432 1440                          return
1433 1441  
1434 1442                  if debug_descriptions:
1435 1443                          print "UPDATE DESCRIPTIONS: \n%s" % pkg_descriptions_for_update
1436 1444                  for pkg_stem, path, summary in pkg_descriptions_for_update:
1437 1445                          itr = model.get_iter_from_string(path)
1438 1446                          stored_pkg_fmri = model.get_value(itr, enumerations.FMRI_COLUMN)
1439 1447                          stored_pkg_stem = stored_pkg_fmri.get_pkg_stem(
1440 1448                              include_scheme = True)
↓ open down ↓ 286 lines elided ↑ open up ↑
1727 1735                          servers = None
1728 1736                  else:
1729 1737                          pub_prefix = self.__get_active_publisher()
1730 1738                          if pub_prefix != None:
1731 1739                                  pub = self.api_o.get_publisher(prefix=pub_prefix)
1732 1740                          else:
1733 1741                                  pub = self.api_o.get_preferred_publisher()
1734 1742                          origin_uri = self.__get_origin_uri(pub.selected_repository)
1735 1743                          servers.append({"origin": origin_uri})
1736 1744                  if debug:
1737      -                        print "pargs:", pargs
1738      -                        print "servers:", servers
1739      -                        
     1745 +                        print "Search: pargs %s servers: %s" % (pargs, servers)
     1746 +
     1747 +                #TBD If we ever search just Installed pkgs should allow for a local search
1740 1748                  case_sensitive = False
     1749 +                return_actions = True
1741 1750                  searches.append(self.api_o.remote_search(
1742      -                    [api.Query(" ".join(pargs), case_sensitive, True, None, None)],
     1751 +                    [api.Query(" ".join(pargs), case_sensitive, return_actions)],
1743 1752                      servers=servers))
1744      -                result_tuple = {}
     1753 +                if debug:
     1754 +                        print "Search Args: %s : cs: %s : retact: %s" % \
     1755 +                                ("".join(pargs), case_sensitive, return_actions)
     1756 +
     1757 +                last_name = ""
     1758 +                self.current_search_publisher = None
1745 1759                  try:
1746 1760                          for query_num, publisher, (v, return_type, tmp) in \
1747 1761                              itertools.chain(*searches):
1748      -                                if v == 1 and \
1749      -                                    return_type == api.Query.RETURN_PACKAGES:
1750      -                                        repo = None
1751      -                                        if publisher is not None \
1752      -                                            and "prefix" in publisher:
1753      -                                                repo = publisher["prefix"]
1754      -                                        name = fmri.PkgFmri(str(tmp)).get_name()
1755      -                                        result_tuple[(name, repo)] = -1
1756      -                                        if len(result_tuple) == SEARCH_LIMIT:
1757      -                                                break
1758      -                                else:
1759      -                                        # We are not interested in this error
     1762 +                                if v < 1 or return_type != api.Query.RETURN_PACKAGES:
1760 1763                                          gobject.idle_add(self.w_progress_dialog.hide)
1761 1764                                          self.__process_after_search_failure()
1762 1765                                          return
     1766 +
     1767 +                                pub = None
     1768 +                                if publisher is not None \
     1769 +                                    and "prefix" in publisher:
     1770 +                                        pub = publisher["prefix"]
     1771 +                                name = fmri.PkgFmri(str(tmp)).get_name()
     1772 +                                if last_name != name:
     1773 +                                        if debug:
     1774 +                                                print "Result Name: %s (%s)" % (name, pub)
     1775 +                                        a_res = name, pub
     1776 +                                        result.append(a_res)
     1777 +                                        #Ignore Status when fetching
     1778 +                                        application_list = \
     1779 +                                                self.__get_min_list_from_search(result)
     1780 +                                        self.current_search_publisher = pub
     1781 +                                        self.in_setup = True
     1782 +                                        gobject.idle_add(self.__init_tree_views, 
     1783 +                                            application_list, None, None)
     1784 +                                last_name = name
1763 1785                                  self.pylintstub = query_num
1764 1786                  except api_errors.ProblematicSearchServers, ex:
1765      -                        self.__parse_api_search_error(ex)
     1787 +                        self.__process_api_search_error(ex)
1766 1788                          gobject.idle_add(self.w_progress_dialog.hide)
1767 1789                          gobject.idle_add(self.__handle_api_search_error)
1768      -                        if len(result_tuple) == 0:
     1790 +                        if len(result) == 0:
1769 1791                                  self.__process_after_search_with_zero_results()
1770 1792                                  return
1771 1793                  except Exception, ex:
1772 1794                          # We are not interested in this error
1773 1795                          gobject.idle_add(self.w_progress_dialog.hide)
1774 1796                          self.__process_after_search_failure()
1775 1797                          return
1776 1798                  if debug:
1777      -                        print "Number of search results:", len(result_tuple)
1778      -                for name, repo in result_tuple:
1779      -                        a_res = name, repo
1780      -                        result.append(a_res)
     1799 +                        print "Number of search results:", len(result)
1781 1800                  if len(result) == 0:
1782 1801                          if debug:
1783 1802                                  print "No search results"
1784 1803                          self.__process_after_search_with_zero_results()
1785 1804                          return
1786 1805                  # We cannot get status of the packages if catalogs have not
1787 1806                  # been loaded so we pause for up to 5 seconds here to
1788 1807                  # allow catalogs to be loaded
1789 1808                  times = 5
1790 1809                  while self.catalog_loaded == False:
1791 1810                          if times == 0:
1792 1811                                  break
1793 1812                          time.sleep(1)
1794 1813                          times -= 1
     1814 +
     1815 +                #Now fetch full result set with Status
1795 1816                  self.in_setup = True
1796      -                application_list = self.__get_list_from_search(result)
     1817 +                application_list = self.__get_full_list_from_search(result)
     1818 +                gobject.idle_add(self.__init_tree_views, application_list, None, None)
     1819 +
1797 1820                  if self.search_start > 0:
1798 1821                          self.search_time_sec = int(time.time() - self.search_start)
     1822 +                        if debug:
     1823 +                                print "Search time: %d (sec)" % self.search_time_sec
1799 1824                  self.search_start = 0
1800      -                gobject.idle_add(self.__set_empty_details_panel)
1801      -                gobject.idle_add(self.__set_main_view_package_list)
1802      -                gobject.idle_add(self.__init_tree_views, application_list,
1803      -                    None, None)
1804 1825  
1805 1826          def __process_after_search_with_zero_results(self):
1806 1827                  if self.search_start > 0:
1807 1828                          self.search_time_sec = int(time.time() - self.search_start)
1808 1829                  self.search_start = 0
1809 1830                  self.in_setup = True
1810 1831                  application_list = self.__get_new_application_liststore()
1811 1832                  gobject.idle_add(self.__set_empty_details_panel)
1812 1833                  gobject.idle_add(self.__set_main_view_package_list)
1813 1834                  gobject.idle_add(self.__init_tree_views, application_list, None, None)
1814 1835  
1815      -        def __get_list_from_search(self, search_result):
     1836 +        def __get_min_list_from_search(self, search_result):
1816 1837                  application_list = self.__get_new_application_liststore()
     1838 +                for name, publisher in search_result:
     1839 +                        application_list.append(
     1840 +                            [False, None, name, '...', enumerations.NOT_INSTALLED, None, 
     1841 +                            "pkg://" + publisher + "/" + name, None, True, None, 
     1842 +                            publisher])
     1843 +                return application_list
     1844 +
     1845 +        def __get_full_list_from_search(self, search_result):
     1846 +                application_list = self.__get_new_application_liststore()
1817 1847                  self.__add_pkgs_to_list_from_search(search_result,
1818 1848                      application_list)
1819 1849                  return application_list
1820 1850  
1821 1851          def __add_pkgs_to_list_from_search(self, search_result,
1822 1852              application_list):
1823 1853                  pargs = []
1824 1854                  default_pub = self.api_o.get_preferred_publisher().prefix
1825 1855                  for name, publisher in search_result:
1826 1856                          pargs.append("pkg://" + publisher + "/" + name)
↓ open down ↓ 246 lines elided ↑ open up ↑
2073 2103                  try:
2074 2104                          self.client.set_bool(SHOW_STARTPAGE_PREFERENCES,
2075 2105                              self.show_startpage)
2076 2106                  except GError:
2077 2107                          pass
2078 2108  
2079 2109          def __on_api_search_checkbox_toggled(self, widget):
2080 2110                  active = self.api_search_checkbox.get_active()
2081 2111                  if len(self.current_repos_with_search_errors) > 0:
2082 2112                          if active:
2083      -                                for url in self.current_repos_with_search_errors:
2084      -                                        if url not in self.gconf_not_show_repos:
2085      -                                                self.gconf_not_show_repos += url + ","
     2113 +                                for pub, err_type, err_str in \
     2114 +                                        self.current_repos_with_search_errors:
     2115 +                                        if pub not in self.gconf_not_show_repos:
     2116 +                                                self.gconf_not_show_repos += pub + ","
2086 2117                          else:
2087      -                                for url in self.current_repos_with_search_errors:
     2118 +                                for pub, err_type, err_str in \
     2119 +                                        self.current_repos_with_search_errors:
2088 2120                                          self.gconf_not_show_repos = \
2089 2121                                              self.gconf_not_show_repos.replace(
2090      -                                            url + ",", "")
     2122 +                                            pub + ",", "")
2091 2123                          try:
2092 2124                                  self.client.set_string(API_SEARCH_ERROR_PREFERENCES,
2093 2125                                      self.gconf_not_show_repos)
2094 2126                          except GError:
2095 2127                                  pass
2096 2128  
2097 2129          def __on_searchentry_focus_in(self, widget, event):
2098 2130                  if self.w_main_clipboard.wait_is_text_available():
2099 2131                          self.w_paste_menuitem.set_sensitive(True)
2100 2132                  char_count = widget.get_text_length()
↓ open down ↓ 320 lines elided ↑ open up ↑
2421 2453                  pub_iter = self.w_repository_combobox.get_active_iter()
2422 2454                  if pub_iter == None:
2423 2455                          return None
2424 2456                  return self.repositories_list.get_value(pub_iter, \
2425 2457                              enumerations.REPOSITORY_NAME)
2426 2458  
2427 2459          def __setup_publisher(self, publishers=[]):
2428 2460                  self.saved_filter_combobox_active = self.initial_show_filter
2429 2461                  application_list, category_list , section_list = \
2430 2462                      self.__get_application_categories_lists(publishers)
     2463 +                self.__unset_saved()
2431 2464                  gobject.idle_add(self.__init_tree_views, application_list,
2432 2465                      category_list, section_list)
2433 2466  
     2467 +        def __unset_saved(self):
     2468 +                self.saved_application_list = None
     2469 +                self.saved_application_list_filter = None
     2470 +                self.saved_application_list_sort = None
     2471 +                self.saved_category_list = None
     2472 +                self.saved_section_list = None
     2473 +
2434 2474          def __get_application_categories_lists(self, publishers=[]):
2435 2475                  if not self.visible_repository:
2436 2476                          self.visible_repository = self.__get_active_publisher()
2437 2477                  application_list = self.__get_new_application_liststore()
2438 2478                  category_list = self.__get_new_category_liststore()
2439 2479                  section_list = self.__get_new_section_liststore()
2440 2480                  first_loop = True
2441 2481                  for publisher in publishers:
2442 2482                          uptodate = False
2443 2483                          try:
↓ open down ↓ 13 lines elided ↑ open up ↑
2457 2497                                          first_loop = False
2458 2498                                          gobject.idle_add(self.setup_progressdialog_show)
2459 2499                                  self.api_o.refresh(pubs=[publisher])
2460 2500                                  self.__add_pkgs_to_lists_from_api(publisher,
2461 2501                                      application_list, category_list, section_list)
2462 2502                                  category_list.prepend([0, _('All'), None, None, False,
2463 2503                                      True, None])
2464 2504                          if self.application_list and self.category_list and \
2465 2505                              not self.visible_repository_uptodate:
2466 2506                                  if self.visible_repository:
     2507 +                                        dump_list = self.application_list
     2508 +                                        if self.saved_application_list != None:
     2509 +                                                dump_list = \
     2510 +                                                    self.saved_application_list
2467 2511                                          self.__dump_datamodels(self.visible_repository,
2468      -                                            self.application_list, self.category_list,
     2512 +                                            dump_list, self.category_list,
2469 2513                                              self.section_list)
2470 2514                          self.visible_repository = self.__get_active_publisher()
2471 2515                          self.visible_repository_uptodate = uptodate
2472 2516                  return application_list, category_list, section_list
2473 2517  
2474 2518          def __check_if_cache_uptodate(self, publisher):
2475 2519                  if self.cache_o:
2476 2520                          return self.cache_o.check_if_cache_uptodate(publisher)
2477 2521                  return False
2478 2522  
2479 2523          def __dump_datamodels(self, publisher, application_list, category_list,
2480 2524              section_list):
     2525 +                #Consistency check - only dump models if publisher passed in matches 
     2526 +                #publisher in application list
     2527 +                if application_list == None:
     2528 +                        return
     2529 +                app_pub = application_list[0][enumerations.AUTHORITY_COLUMN]
     2530 +                if publisher != app_pub:
     2531 +                        if debug:
     2532 +                                print "ERROR: __dump_data_models(): INCONSISTENT " \
     2533 +                                        "pub %s != app_list_pub %s" % \
     2534 +                                        (publisher,  app_pub)
     2535 +                        return
     2536 +
2481 2537                  if self.cache_o:
2482 2538                          if self.img_timestamp == \
2483 2539                              self.cache_o.get_index_timestamp():
2484 2540                                  Thread(target = self.cache_o.dump_datamodels,
2485 2541                                      args = (publisher, application_list, category_list,
2486 2542                                      section_list)).start()
2487 2543                          else:
2488 2544                                  self.__remove_cache()
2489 2545  
2490 2546          def __remove_cache(self):
↓ open down ↓ 1312 lines elided ↑ open up ↑
3803 3859          def get_icon_pixbuf_from_glade_dir(self, icon_name):
3804 3860                  return gui_misc.get_pixbuf_from_path(self.application_dir +
3805 3861                      "/usr/share/package-manager/", icon_name)
3806 3862  
3807 3863          def update_statusbar(self):
3808 3864                  '''Function which updates statusbar'''
3809 3865                  if self.statusbar_message_id > 0:
3810 3866                          self.w_main_statusbar.remove(0, self.statusbar_message_id)
3811 3867                          self.statusbar_message_id = 0
3812 3868                  search_text = self.w_searchentry.get_text()
3813      -                if self.in_search_mode:
3814      -                        if self.is_search_all:
3815      -                                opt_str = _('Searched All for "%s"') % (search_text)
3816      -                        else:
3817      -                                opt_str = \
3818      -                                        _('Searched %(last_active)s '
3819      -                                            'for "%(search_text)s"') \
3820      -                                        % {"last_active" : self.last_active_publisher,
3821      -                                            "search_text" : search_text}
3822      -                        if len(self.application_list) == SEARCH_LIMIT:
3823      -                                fmt_str = _("%(option_str)s:  first %(number)d "
3824      -                                    "found %(time)s")
3825      -                        else:
3826      -                                fmt_str = _("%(option_str)s:  %(number)d found %(time)s")
3827      -                        time_str = ""
3828      -                        if self.search_time_sec > 0:
3829      -                                time_str = _("in %d seconds") % self.search_time_sec
3830      -                        status_str = fmt_str % {"option_str" : opt_str,
3831      -                            "number" : len(self.application_list), "time" : time_str}
     3869 +
     3870 +                if not self.in_search_mode:
     3871 +                        installed = 0
     3872 +                        self.selected = 0
     3873 +                        sel = 0
     3874 +                        if self.application_list == None:
     3875 +                                return
     3876 +                        visible_repository = self.__get_visible_repository_name()
     3877 +                        pkgs = self.selected_pkgs.get(visible_repository)
     3878 +                        if pkgs:
     3879 +                                self.selected = len(pkgs)
     3880 +                        for pkg_row in self.application_list:
     3881 +                                if pkg_row[enumerations.STATUS_COLUMN] == \
     3882 +                                        enumerations.INSTALLED \
     3883 +                                        or pkg_row[enumerations.STATUS_COLUMN] == \
     3884 +                                    enumerations.UPDATABLE:
     3885 +                                        installed = installed + 1
     3886 +                                if pkg_row[enumerations.MARK_COLUMN]:
     3887 +                                        sel = sel + 1
     3888 +                        listed_str = _('%d listed') % len(self.application_list)
     3889 +                        sel_str = _('%d selected') % sel
     3890 +                        inst_str = _('%d installed') % installed
     3891 +                        status_str = _("%s: %s , %s, %s.") % (visible_repository,
     3892 +                            listed_str, inst_str, sel_str)
3832 3893                          self.w_main_statusbar.push(0, status_str)
3833 3894                          return
3834      -                installed = 0
3835      -                self.selected = 0
3836      -                sel = 0
3837      -                if self.application_list == None:
3838      -                        return
3839      -                visible_repository = self.__get_visible_repository_name()
3840      -                pkgs = self.selected_pkgs.get(visible_repository)
3841      -                if pkgs:
3842      -                        self.selected = len(pkgs)
3843      -                for pkg_row in self.application_list:
3844      -                        if pkg_row[enumerations.STATUS_COLUMN] == enumerations.INSTALLED \
3845      -                            or pkg_row[enumerations.STATUS_COLUMN] == \
3846      -                            enumerations.UPDATABLE:
3847      -                                installed = installed + 1
3848      -                        if pkg_row[enumerations.MARK_COLUMN]:
3849      -                                sel = sel + 1
3850      -                listed_str = _('%d listed') % len(self.application_list)
3851      -                sel_str = _('%d selected') % sel
3852      -                inst_str = _('%d installed') % installed
3853      -                status_str = _("%s: %s , %s, %s.") % (visible_repository, listed_str,
3854      -                        inst_str, sel_str)
     3895 +
     3896 +                # In Search Mode
     3897 +                active = ""
     3898 +                if self.is_search_all:
     3899 +                        if self.__doing_search():
     3900 +                                if self.current_search_publisher != None:
     3901 +                                        active = "(" + self.current_search_publisher + \
     3902 +                                                ") "
     3903 +                                opt_str = _('Searching... '
     3904 +                                    '%(active)sfor "%(search_text)s"') % \
     3905 +                                        {"active": active, "search_text": search_text}
     3906 +                        else:
     3907 +                                opt_str = _('Searched All for "%s"') % (search_text)
     3908 +                else:
     3909 +                        search_str = _("Searched")
     3910 +                        if self.__doing_search():
     3911 +                                search_str = _("Searching...")
     3912 +                        if self.last_active_publisher != None:
     3913 +                                active = "(" + self.last_active_publisher + ") "
     3914 +                        opt_str = \
     3915 +                                _('%(search)s %(last_active)sfor "%(search_text)s"') \
     3916 +                                % {"search": search_str, "last_active" : active,
     3917 +                                    "search_text" : search_text}
     3918 +                fmt_str = _("%(option_str)s:  %(number)d found %(time)s")
     3919 +                time_str = ""
     3920 +                if self.search_time_sec > 0:
     3921 +                        time_str = _("in %d seconds") % self.search_time_sec
     3922 +                status_str = fmt_str % {"option_str" : opt_str, "number" :
     3923 +                    len(self.application_list), "time" : time_str}
3855 3924                  self.w_main_statusbar.push(0, status_str)
3856 3925  
3857 3926          def update_package_list(self, update_list):
3858 3927                  if update_list == None and self.img_timestamp:
3859 3928                          return
3860 3929                  visible_repository = self.__get_visible_repository_name()
3861 3930                  default_publisher = self.default_publisher
3862 3931                  self.api_o.refresh()
3863 3932                  if not self.img_timestamp:
3864 3933                          self.img_timestamp = self.cache_o.get_index_timestamp()
↓ open down ↓ 178 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX