Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/src/packagemanager.py
          +++ new/src/packagemanager.py
↓ open down ↓ 51 lines elided ↑ open up ↑
  52   52          import gtk
  53   53          import gtk.glade
  54   54          import pygtk
  55   55          pygtk.require("2.0")
  56   56  except ImportError:
  57   57          sys.exit(1)
  58   58  import pkg.client.image as image
  59   59  import pkg.client.progress as progress
  60   60  import pkg.misc as misc
  61   61  import pkg.portable as portable
       62 +import pkg.gui.beadmin as beadm
  62   63  import pkg.gui.imageinfo as imageinfo
  63   64  import pkg.gui.installupdate as installupdate
  64   65  import pkg.gui.remove as remove
  65   66  import pkg.gui.enumerations as enumerations
  66   67  
  67   68  
  68   69  class PackageManager:
  69   70          def __init__(self):
  70   71                  self.image_o = None
  71   72                  socket.setdefaulttimeout(
↓ open down ↓ 147 lines elided ↑ open up ↑
 219  220                                      self.__on_searchentry_focus_out,
 220  221                                  "on_searchentry_event":self.__on_searchentry_event,
 221  222                                  "on_sectionscombobox_changed": \
 222  223                                      self.__on_sectionscombobox_changed,
 223  224                                  "on_filtercombobox_changed": \
 224  225                                      self.__on_filtercombobox_changed,
 225  226                                  "on_repositorycombobox_changed": \
 226  227                                      self.__on_repositorycombobox_changed,
 227  228                                  #menu signals
 228  229                                  "on_file_quit_activate":self.__on_file_quit_activate,
      230 +                                "on_file_be_activate":self.__on_file_be_activate,
 229  231                                  "on_package_install_update_activate": \
 230  232                                      self.__on_install_update,
 231  233                                  "on_package_remove_activate":self.__on_remove,
 232  234                                  "on_help_about_activate":self.__on_help_about,
 233  235                                  "on_edit_paste_activate":self.__on_edit_paste,
 234  236                                  "on_edit_clear_activate":self.__on_clear_paste,
 235  237                                  "on_edit_copy_activate":self.__on_copy,
 236  238                                  "on_edit_cut_activate":self.__on_cut,
 237  239                                  "on_edit_select_all_activate":self.__on_select_all,
 238  240                                  "on_edit_select_updates_activate": \
↓ open down ↓ 183 lines elided ↑ open up ↑
 422  424                          # XXX if some changes were applied:
 423  425                          self.__main_application_quit()
 424  426                          return True
 425  427                  else:
 426  428                          self.__main_application_quit()
 427  429  
 428  430          def __on_file_quit_activate(self, widget):
 429  431                  ''' handler for quit menu event '''
 430  432                  self.__on_mainwindow_delete_event(None, None)
 431  433  
      434 +        def __on_file_be_activate(self, widget):
      435 +                ''' handler for be menu event '''
      436 +                beadm.Beadmin(self)
      437 +
 432  438          def __on_searchentry_changed(self, widget):
 433  439                  '''On text search field changed we should refilter the main view'''
 434  440                  Thread(target = self.__on_searchentry_threaded, args = ()).start()
 435  441  
 436  442          def __on_searchentry_threaded(self):
 437  443                  gobject.idle_add(self.application_list_filter.refilter)
 438  444                  gobject.idle_add(self.__enable_disable_selection_menus)
 439  445  
 440  446          def __on_edit_paste(self, widget):
 441  447                  self.w_searchentry_dialog.insert_text(self.main_clipboard_text, \
↓ open down ↓ 768 lines elided ↑ open up ↑
1210 1216          def __get_image_from_directory(self, image_obj, progressdialog_progress):
1211 1217                  """ This method set up image from the given directory and
1212 1218                  returns the image object or None"""
1213 1219                  # XXX Convert timestamp to some nice date :)
1214 1220                  self.application_list.clear()
1215 1221                  self.category_list.clear()
1216 1222                  self.application_list_filter.refilter()
1217 1223                  pkgs_known = [ pf[0] for pf in
1218 1224                      sorted(image_obj.inventory(all_known = True)) ]
1219 1225                  #Only one instance of those icons should be in memory
1220      -                update_available_icon = self.__get_icon_pixbuf("new_update")
     1226 +                update_available_icon = self.get_icon_pixbuf("new_update")
1221 1227                  #Imageinfo for categories
1222 1228                  imginfo = imageinfo.ImageInfo()
1223 1229                  sectioninfo = imageinfo.ImageInfo()
1224 1230                  catalogs = image_obj.catalogs
1225 1231                  categories = {}
1226 1232                  sections = {}
1227 1233                  self.__setup_repositories_combobox(image_obj)
1228 1234                  for cat in catalogs:
1229 1235                          category = imginfo.read(self.application_dir + \
1230 1236                              "/usr/share/package-manager/data/" + cat)
↓ open down ↓ 209 lines elided ↑ open up ↑
1440 1446                                                          if not section_name in \
1441 1447                                                              category[ \
1442 1448                                                              enumerations. \
1443 1449                                                              SECTION_LIST_OBJECT]:
1444 1450                                                                  category[enumerations. \
1445 1451                                                                      SECTION_LIST_OBJECT \
1446 1452                                                                      ].append(section[ \
1447 1453                                                                      enumerations. \
1448 1454                                                                      SECTION_ID])
1449 1455  
1450      -        def __get_icon_pixbuf(self, icon_name):
1451      -                #2821: The __get_icon_pixbuf should use PACKAGE_MANAGER_ROOT
1452      -                return self.__get_pixbuf_from_path(self.application_dir + \
1453      -                    "/usr/share/icons/package-manager/", icon_name)
1454      -
1455 1456          def __get_pixbuf_from_path(self, path, icon_name):
1456 1457                  icon = icon_name.replace(' ', '_')
1457 1458  
1458 1459                  # Performance: Faster to check if files exist rather than catching
1459 1460                  # exceptions when they do not. Picked up open failures using dtrace
1460 1461                  png_exists = os.path.exists(self.application_dir + path + icon + ".png")
1461 1462                  svg_exists = os.path.exists(self.application_dir + path + icon + ".svg")
1462 1463                         
1463 1464                  if not png_exists and not svg_exists:
1464 1465                          return None
↓ open down ↓ 178 lines elided ↑ open up ↑
1643 1644                          
1644 1645          def init_package_view(self):
1645 1646                  self.__init_show_filter()                
1646 1647                  self.__setup_data_finished()
1647 1648                  self.__init_tree_views()                 
1648 1649  
1649 1650                  self.w_filter_combobox.set_active(0)
1650 1651                  self.w_sections_combobox.set_active(0)
1651 1652                  self.application_list_filter.set_visible_func(self.__application_filter)
1652 1653                  self.__setup_repositories_combobox(self.image_o)
     1654 +
     1655 +        def get_icon_pixbuf(self, icon_name):
     1656 +                #2821: The get_icon_pixbuf should use PACKAGE_MANAGER_ROOT
     1657 +                return self.__get_pixbuf_from_path(self.application_dir + \
     1658 +                    "/usr/share/icons/package-manager/", icon_name)
1653 1659                  
1654 1660          def get_manifests_for_packages(self):
1655 1661                  ''' Function, which get's manifest for packages. If the manifest is not
1656 1662                  locally tries to retrieve it. For installed packages gets manifest
1657 1663                  for the particular version (local operation only), if the package is 
1658 1664                  not installed than the newest one'''
1659 1665                  self.description_thread_running = True
1660 1666                  for pkg in self.application_list:
1661 1667                          if self.cancelled:
1662 1668                                  self.description_thread_running = False
↓ open down ↓ 101 lines elided ↑ open up ↑
1764 1770                  msgbox.run()
1765 1771                  msgbox.destroy()
1766 1772                  self.__main_application_quit()
1767 1773  
1768 1774  ###############################################################################
1769 1775  #-----------------------------------------------------------------------------#
1770 1776  # Test functions
1771 1777  #-----------------------------------------------------------------------------#
1772 1778          def fill_with_fake_data(self):
1773 1779                  '''test data for gui'''
1774      -                app1 = [False, self.__get_icon_pixbuf("locked"), \
1775      -                    self.__get_icon_pixbuf("None"), "acc", None, None, None, 4, "desc6", \
     1780 +                app1 = [False, self.get_icon_pixbuf("locked"), \
     1781 +                    self.get_icon_pixbuf("None"), "acc", None, None, None, 4, "desc6", \
1776 1782                      "Object Name1", None, True, None]
1777      -                app2 = [False, self.__get_icon_pixbuf("update_available"), \
1778      -                    self.__get_icon_pixbuf(self._('All')), "acc_gam", \
     1783 +                app2 = [False, self.get_icon_pixbuf("update_available"), \
     1784 +                    self.get_icon_pixbuf(self._('All')), "acc_gam", \
1779 1785                      "2.3", None, "2.8", \
1780 1786                      4, "desc7", "Object Name2", None, True, None]
1781      -                app3 = [False, self.__get_icon_pixbuf("None"), \
1782      -                    self.__get_icon_pixbuf("Other"), "gam_grap", "2.3", None, None, 4, \
     1787 +                app3 = [False, self.get_icon_pixbuf("None"), \
     1788 +                    self.get_icon_pixbuf("Other"), "gam_grap", "2.3", None, None, 4, \
1783 1789                      "desc8", "Object Name3", None, True, None]
1784      -                app4 = [False, self.__get_icon_pixbuf("update_locked"), \
1785      -                    self.__get_icon_pixbuf("Office"), "grap_gam", "2.3", None, "2.8", 4, \
     1790 +                app4 = [False, self.get_icon_pixbuf("update_locked"), \
     1791 +                    self.get_icon_pixbuf("Office"), "grap_gam", "2.3", None, "2.8", 4, \
1786 1792                      "desc9", "Object Name2", None, True, None]
1787      -                app5 = [False, self.__get_icon_pixbuf("update_available"), \
1788      -                    self.__get_icon_pixbuf("None"), "grap", "2.3", None, "2.8", 4, \
     1793 +                app5 = [False, self.get_icon_pixbuf("update_available"), \
     1794 +                    self.get_icon_pixbuf("None"), "grap", "2.3", None, "2.8", 4, \
1789 1795                      "desc0", "Object Name3", None, True, None]
1790 1796                  itr1 = self.application_list.append(app1)
1791 1797                  itr2 = self.application_list.append(app2)
1792 1798                  itr3 = self.application_list.append(app3)
1793 1799                  itr4 = self.application_list.append(app4)
1794 1800                  itr5 = self.application_list.append(app5)
1795 1801                  #      self.__add_package_to_category(_("All"),None,None,None);
1796 1802                  self.__add_package_to_category(self._("Accessories"), None, None, itr1)
1797 1803                  self.__add_package_to_category(self._("Accessories"), None, None, itr2)
1798 1804                  self.__add_package_to_category(self._("Games"), None, None, itr3)
↓ open down ↓ 113 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX