def __init__(self, cache, db, distro, icons, datadir,
                 navhistory_back_action, navhistory_forward_action):
        # parent
        SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
        self.searchentry.set_sensitive(False)
        # navigation history actions
        self.navhistory_back_action = navhistory_back_action
        self.navhistory_forward_action = navhistory_forward_action
        # configure any initial state attrs
        self.state.filter = AppFilter(db, cache)
        # the spec says we mix installed/not installed
        #self.apps_filter.set_not_installed_only(True)
        self.current_app_by_category = {}
        self.current_app_by_subcategory = {}
        self.pane_name = _("Get Software")

        # views to be created in init_view
        self.cat_view = None
        self.subcategories_view = None

        # integrate with the Unity launcher
        self.unity_launcher = UnityLauncher()
        # keep track of applications that are queued to be added
        # to the Unity launcher
        self.unity_launcher_transaction_queue = {}
        # flag to indicate whether applications should be added to the
        # unity launcher when installed (this value is initialized by
        # the config load in app.py)
        self.add_to_launcher_enabled = True
Esempio n. 2
0
    def __init__(self, cache, db, distro, icons, datadir):

        # parent
        SoftwarePane.__init__(self,
                              cache,
                              db,
                              distro,
                              icons,
                              datadir,
                              show_ratings=False)
        CategoriesParser.__init__(self, db)

        self.current_appview_selection = None
        self.icons = icons
        self.loaded = False
        self.pane_name = _("Installed Software")

        self.installed_apps = 0
        # None is local
        self.current_hostid = None
        self.current_hostname = None
        self.oneconf_additional_pkg = set()
        self.oneconf_missing_pkg = set()

        # switches to terminate build in progress
        self._build_in_progress = False
        self._halt_build = False

        self.nonapps_visible = NonAppVisibility.NEVER_VISIBLE

        self.visible_docids = None
        self.visible_cats = {}

        self.installed_spinner_notebook = None
Esempio n. 3
0
    def __init__(self,
                 cache,
                 db,
                 distro,
                 icons,
                 datadir,
                 navhistory_back_action,
                 navhistory_forward_action):
        # parent
        SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
        self.searchentry.set_sensitive(False)
        # navigation history actions
        self.navhistory_back_action = navhistory_back_action
        self.navhistory_forward_action = navhistory_forward_action
        # configure any initial state attrs
        self.state.filter = AppFilter(db, cache)
        # the spec says we mix installed/not installed
        #self.apps_filter.set_not_installed_only(True)
        self.current_app_by_category = {}
        self.current_app_by_subcategory = {}
        self.pane_name = _("Get Software")

        # views to be created in init_view
        self.cat_view = None
        self.subcategories_view = None

        # integrate with the Unity launcher
        self.unity_launcher = UnityLauncher()
        # keep track of applications that are queued to be added
        # to the Unity launcher
        self.unity_launcher_transaction_queue = {}
        # flag to indicate whether applications should be added to the
        # unity launcher when installed (this value is initialized by
        # the config load in app.py)
        self.add_to_launcher_enabled = True
Esempio n. 4
0
 def __init__(self, 
              cache,
              db, 
              distro, 
              icons, 
              datadir, 
              navhistory_back_action, 
              navhistory_forward_action):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
     self.searchentry.set_sensitive(False)
     # navigation history actions
     self.navhistory_back_action = navhistory_back_action
     self.navhistory_forward_action = navhistory_forward_action
     # configure any initial state attrs
     self.state.filter = AppFilter(db, cache)
     # the spec says we mix installed/not installed
     #self.apps_filter.set_not_installed_only(True)
     self.current_app_by_category = {}
     self.current_app_by_subcategory = {}
     self.pane_name = _("Get Software")
     
     # views to be created in init_view
     self.cat_view = None
     self.subcategories_view = None
Esempio n. 5
0
    def __init__(self, cache, db, distro, icons, datadir):

        # parent
        SoftwarePane.__init__(self, cache, db, distro, icons, datadir, show_ratings=False)
        CategoriesParser.__init__(self, db)

        self.current_appview_selection = None
        self.icons = icons
        self.loaded = False
        self.pane_name = _("Installed Software")

        self.installed_apps = 0
        # None is local
        self.current_hostid = None
        self.current_hostname = None
        self.oneconf_additional_pkg = set()
        self.oneconf_missing_pkg = set()

        # switches to terminate build in progress
        self._build_in_progress = False
        self._halt_build = False

        self.nonapps_visible = NonAppVisibility.NEVER_VISIBLE

        self.visible_docids = None
        self.visible_cats = {}

        self.installed_spinner_notebook = None
Esempio n. 6
0
    def display_details_page(self, view_state):
        if self.searchentry.get_text() != self.state.search_term:
            self.searchentry.set_text_with_no_signal(self.state.search_term)

        self.action_bar.clear()

        SoftwarePane.display_details_page(self, view_state)
        return True
 def refresh_apps(self, query=None):
     SoftwarePane.refresh_apps(self, query)
     # tell the lobby to update its content
     if self.cat_view:
         self.cat_view.refresh_apps()
     # and the subcat view as well...
     if self.subcategories_view:
         self.subcategories_view.refresh_apps()
Esempio n. 8
0
 def refresh_apps(self, query=None):
     SoftwarePane.refresh_apps(self, query)
     # tell the lobby to update its content
     if self.cat_view:
         self.cat_view.refresh_apps()
     # and the subcat view as well...
     if self.subcategories_view:
         self.subcategories_view.refresh_apps()
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir, show_ratings=False)
     # state
     self.apps_filter = AppViewFilter(db, cache)
     self.apps_filter.set_installed_only(True)
     self.current_appview_selection = None
     # UI
     self._build_ui()
    def display_details_page(self, page, view_state):
        if self.searchentry.get_text() != self.state.search_term:
            self.searchentry.set_text_with_no_signal(self.state.search_term)

        self.action_bar.clear()

        SoftwarePane.display_details_page(self, page, view_state)
        self.cat_view.stop_carousels()
        return True
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir, show_ratings=False)
     self.channel = None
     self.apps_filter = None
     self.search_terms = ""
     self.current_appview_selection = None
     self.distro = get_distro()
     # UI
     self._build_ui()
Esempio n. 12
0
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir,
                           show_ratings=False)
     self.channel = None
     self.apps_filter = None
     self.apps_search_term = ""
     self.current_appview_selection = None
     self.distro = get_distro()
     self.pane_name = _("Software Channels")
 def init_view(self):
     if not self.view_initialized:
         SoftwarePane.init_view(self)
         self.notebook.append_page(self.box_app_list, Gtk.Label(label="channel"))
         # details
         self.notebook.append_page(self.scroll_details, Gtk.Label(label="details"))
         # purchase view
         self.notebook.append_page(self.purchase_view, Gtk.Label(label="purchase"))
         # now we are initialized
         self.emit("channel-pane-created")
         self.show_all()
         self.view_initialized = True
    def __init__(self, cache, db, distro, icons, datadir,
                 navhistory_back_action, navhistory_forward_action):
        # parent
        SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
        self.searchentry.set_sensitive(False)
        # navigation history actions
        self.navhistory_back_action = navhistory_back_action
        self.navhistory_forward_action = navhistory_forward_action
        # configure any initial state attrs
        self.state.filter = AppFilter(db, cache)
        # the spec says we mix installed/not installed
        #self.apps_filter.set_not_installed_only(True)
        self.current_app_by_category = {}
        self.current_app_by_subcategory = {}
        self.pane_name = _("Get Software")

        # views to be created in init_view
        self.cat_view = None
        self.subcategories_view = None
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir)
     # state
     self.apps_category = None
     self.apps_subcategory = None
     self.apps_search_term = ""
     self.apps_sorted = True
     self.apps_limit = 0
     self.apps_filter = AppViewFilter(db, cache)
     self.apps_filter.set_only_packages_without_applications(True)
     # the spec says we mix installed/not installed
     #self.apps_filter.set_not_installed_only(True)
     self._status_text = ""
     self.connect("app-list-changed", self._on_app_list_changed)
     self.current_app_by_category = {}
     self.current_app_by_subcategory = {}
     # track navigation history
     self.nav_history = NavigationHistory(self)
     # UI
     self._build_ui()
Esempio n. 16
0
    def init_view(self):
        if self.view_initialized:
            return

        self.show_appview_spinner()
        window = self.get_window()
        if window is not None:
            window.set_cursor(self.busy_cursor)

        while Gtk.events_pending():
            Gtk.main_iteration()

        # open the cache since we are initializing the UI for the first time
        GObject.idle_add(self.cache.open)

        SoftwarePane.init_view(self)
        # set the AppTreeView model, available pane uses list models
        liststore = AppListStore(self.db, self.cache, self.icons)
        # ~ def on_appcount_changed(widget, appcount):
        # ~ self.subcategories_view._append_appcount(appcount)
        # ~ self.app_view._append_appcount(appcount)
        # ~ liststore.connect('appcount-changed', on_appcount_changed)
        self.app_view.set_model(liststore)
        # setup purchase stuff
        self.app_details_view.connect("purchase-requested", self.on_purchase_requested)
        # purchase view
        self.purchase_view = PurchaseView()
        self.purchase_view.connect("purchase-succeeded", self.on_purchase_succeeded)
        self.purchase_view.connect("purchase-failed", self.on_purchase_failed)
        self.purchase_view.connect("purchase-cancelled-by-user", self.on_purchase_cancelled_by_user)
        # categories, appview and details into the notebook in the bottom
        self.scroll_categories = Gtk.ScrolledWindow()
        self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH, self.cache, self.db, self.icons, self.apps_filter)
        self.scroll_categories.add(self.cat_view)
        self.notebook.append_page(self.scroll_categories, Gtk.Label(label="categories"))

        # sub-categories view
        self.subcategories_view = SubCategoryViewGtk(
            self.datadir,
            APP_INSTALL_PATH,
            self.cache,
            self.db,
            self.icons,
            self.apps_filter,
            root_category=self.cat_view.categories[0],
        )
        self.subcategories_view.connect("category-selected", self.on_subcategory_activated)
        self.subcategories_view.connect("application-activated", self.on_application_activated)
        self.subcategories_view.connect("show-category-applist", self.on_show_category_applist)
        # FIXME: why do we have two application-{selected,activated] ?!?
        self.subcategories_view.connect("application-selected", self.on_application_selected)
        self.subcategories_view.connect("application-activated", self.on_application_activated)
        self.scroll_subcategories = Gtk.ScrolledWindow()
        self.scroll_subcategories.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scroll_subcategories.add(self.subcategories_view)
        self.notebook.append_page(self.scroll_subcategories, Gtk.Label(label=NavButtons.SUBCAT))

        # app list
        self.notebook.append_page(self.box_app_list, Gtk.Label(label=NavButtons.LIST))

        self.cat_view.connect("category-selected", self.on_category_activated)
        self.cat_view.connect("application-selected", self.on_application_selected)
        self.cat_view.connect("application-activated", self.on_application_activated)

        # details
        self.notebook.append_page(self.scroll_details, Gtk.Label(label=NavButtons.DETAILS))

        # purchase view
        self.notebook.append_page(self.purchase_view, Gtk.Label(label=NavButtons.PURCHASE))

        # install backend
        self.backend.connect("transactions-changed", self._on_transactions_changed)
        # now we are initialized
        self.searchentry.set_sensitive(True)
        self.emit("available-pane-created")
        self.show_all()
        self.hide_appview_spinner()

        # consider the view initialized here already as display_page()
        # may run into a endless recurison otherwise (it will call init_view())
        # again (LP: #851671)
        self.view_initialized = True

        vm = get_viewmanager()
        vm.display_page(self, AvailablePane.Pages.LOBBY, self.state, self.display_lobby_page)

        if window is not None:
            window.set_cursor(None)
Esempio n. 17
0
    def init_view(self):
        if self.view_initialized:
            return

        SoftwarePane.init_view(self)

        # show a busy cursor and display the main spinner while we build the
        # view
        window = self.get_window()
        if window:
            window.set_cursor(self.busy_cursor)
        self.show_appview_spinner()

        self.oneconf_viewpickler = OneConfViews(self.icons)
        self.oneconf_viewpickler.register_computer(
            None,
            _("This computer (%s)") % platform.node())
        self.oneconf_viewpickler.select_first()
        self.oneconf_viewpickler.connect('computer-changed',
                                         self._selected_computer_changed)
        self.oneconf_viewpickler.connect('current-inventory-refreshed',
                                         self._current_inventory_need_refresh)

        # Start OneConf
        self.oneconf_handler = get_oneconf_handler(self.oneconf_viewpickler)
        if self.oneconf_handler:
            self.oneconf_handler.connect('show-oneconf-changed',
                                         self._show_oneconf_changed)
            self.oneconf_handler.connect('last-time-sync-changed',
                                         self._last_time_sync_oneconf_changed)

        # OneConf pane
        self.computerpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
        self.oneconfcontrol = Gtk.Box()
        self.oneconfcontrol.set_orientation(Gtk.Orientation.VERTICAL)
        self.computerpane.pack1(self.oneconfcontrol, False, False)
        # size negotiation takes everything for the first one
        self.oneconfcontrol.set_property('width-request', 200)
        self.box_app_list.pack_start(self.computerpane, True, True, 0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.oneconf_viewpickler)
        self.oneconfcontrol.pack_start(scroll, True, True, 0)

        oneconftoolbar = Gtk.Box()
        oneconftoolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
        oneconfpropertymenu = Gtk.Menu()
        self.oneconfproperty = MenuButton(
            oneconfpropertymenu,
            Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES,
                                     Gtk.IconSize.BUTTON))
        self.stopsync_label = _(u"Stop Syncing “%s”")
        stop_oneconf_share_menuitem = Gtk.MenuItem(label=self.stopsync_label %
                                                   platform.node())
        stop_oneconf_share_menuitem.connect(
            "activate", self._on_stop_oneconf_hostshare_clicked)
        stop_oneconf_share_menuitem.show()
        oneconfpropertymenu.append(stop_oneconf_share_menuitem)
        self.oneconfcontrol.pack_start(oneconftoolbar, False, False, 1)
        self.oneconf_last_sync = Gtk.Label()
        self.oneconf_last_sync.set_line_wrap(True)
        oneconftoolbar.pack_start(self.oneconfproperty, False, False, 0)
        oneconftoolbar.pack_start(self.oneconf_last_sync, True, True, 1)

        self.notebook.append_page(self.box_app_list, Gtk.Label(label="list"))

        # details
        self.notebook.append_page(self.scroll_details,
                                  Gtk.Label(label="details"))
        # initial refresh
        self.state.search_term = ""

        # build models and filters
        self.base_model = AppTreeStore(self.db, self.cache, self.icons)

        self.treefilter = self.base_model.filter_new(None)
        self.treefilter.set_visible_func(self._row_visibility_func,
                                         AppTreeStore.COL_ROW_DATA)
        self.app_view.set_model(self.treefilter)
        self.app_view.tree_view.connect("row-collapsed",
                                        self._on_row_collapsed)

        self._all_cats = self.parse_applications_menu(APP_INSTALL_PATH)
        self._all_cats = categories_sorted_by_name(self._all_cats)

        # we do not support the search aid feature in the installedview
        self.box_app_list.remove(self.search_aid)

        # remove here
        self.box_app_list.remove(self.app_view)

        # create a local spinner notebook for the installed view
        self.installed_spinner_notebook = SpinnerNotebook(self.app_view)

        self.computerpane.pack2(self.installed_spinner_notebook, True, True)
        self.show_installed_view_spinner()

        self.show_all()

        # initialize view to hide the oneconf computer selector
        self.oneconf_viewpickler.select_first()
        self.oneconfcontrol.hide()

        # hacky, hide the header
        self.app_view.header_hbox.hide()

        self.hide_appview_spinner()

        # keep track of the current view by tracking its origin
        self.current_displayed_origin = None

        # now we are initialized
        self.emit("installed-pane-created")

        self.view_initialized = True
        return False
Esempio n. 18
0
    def init_view(self):
        if self.view_initialized:
            return

        SoftwarePane.init_view(self)

        # show a busy cursor and display the main spinner while we build the
        # view
        window = self.get_window()
        if window:
            window.set_cursor(self.busy_cursor)
        self.show_appview_spinner()

        self.oneconf_viewpickler = OneConfViews(self.icons)
        self.oneconf_viewpickler.register_computer(None, _("This computer (%s)") % platform.node())
        self.oneconf_viewpickler.select_first()
        self.oneconf_viewpickler.connect("computer-changed", self._selected_computer_changed)
        self.oneconf_viewpickler.connect("current-inventory-refreshed", self._current_inventory_need_refresh)

        # Start OneConf
        self.oneconf_handler = get_oneconf_handler(self.oneconf_viewpickler)
        if self.oneconf_handler:
            self.oneconf_handler.connect("show-oneconf-changed", self._show_oneconf_changed)
            self.oneconf_handler.connect("last-time-sync-changed", self._last_time_sync_oneconf_changed)

        # OneConf pane
        self.computerpane = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
        self.oneconfcontrol = Gtk.Box()
        self.oneconfcontrol.set_orientation(Gtk.Orientation.VERTICAL)
        self.computerpane.pack1(self.oneconfcontrol, False, False)
        # size negotiation takes everything for the first one
        self.oneconfcontrol.set_property("width-request", 200)
        self.box_app_list.pack_start(self.computerpane, True, True, 0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.oneconf_viewpickler)
        self.oneconfcontrol.pack_start(scroll, True, True, 0)

        oneconftoolbar = Gtk.Box()
        oneconftoolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
        oneconfpropertymenu = Gtk.Menu()
        self.oneconfproperty = MenuButton(
            oneconfpropertymenu, Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON)
        )
        self.stopsync_label = _(u"Stop Syncing “%s”")
        stop_oneconf_share_menuitem = Gtk.MenuItem(label=self.stopsync_label % platform.node())
        stop_oneconf_share_menuitem.connect("activate", self._on_stop_oneconf_hostshare_clicked)
        stop_oneconf_share_menuitem.show()
        oneconfpropertymenu.append(stop_oneconf_share_menuitem)
        self.oneconfcontrol.pack_start(oneconftoolbar, False, False, 1)
        self.oneconf_last_sync = Gtk.Label()
        self.oneconf_last_sync.set_line_wrap(True)
        oneconftoolbar.pack_start(self.oneconfproperty, False, False, 0)
        oneconftoolbar.pack_start(self.oneconf_last_sync, True, True, 1)

        self.notebook.append_page(self.box_app_list, Gtk.Label(label="list"))

        # details
        self.notebook.append_page(self.scroll_details, Gtk.Label(label="details"))
        # initial refresh
        self.state.search_term = ""

        # build models and filters
        self.base_model = AppTreeStore(self.db, self.cache, self.icons)

        self.treefilter = self.base_model.filter_new(None)
        self.treefilter.set_visible_func(self._row_visibility_func, AppTreeStore.COL_ROW_DATA)
        self.app_view.set_model(self.treefilter)
        self.app_view.tree_view.connect("row-collapsed", self._on_row_collapsed)

        self._all_cats = self.parse_applications_menu(APP_INSTALL_PATH)
        self._all_cats = categories_sorted_by_name(self._all_cats)

        # we do not support the search aid feature in the installedview
        self.box_app_list.remove(self.search_aid)

        # remove here
        self.box_app_list.remove(self.app_view)

        # create a local spinner notebook for the installed view
        self.installed_spinner_notebook = SpinnerNotebook(self.app_view)

        self.computerpane.pack2(self.installed_spinner_notebook, True, True)
        self.show_installed_view_spinner()

        self.show_all()

        # initialize view to hide the oneconf computer selector
        self.oneconf_viewpickler.select_first()
        self.oneconfcontrol.hide()

        # hacky, hide the header
        self.app_view.header_hbox.hide()

        self.hide_appview_spinner()

        # keep track of the current view by tracking its origin
        self.current_displayed_origin = None

        # now we are initialized
        self.emit("installed-pane-created")

        self.view_initialized = True
        return False
    def init_view(self):
        if self.view_initialized:
            return

        self.show_appview_spinner()

        window = self.get_window()
        if window is not None:
            window.set_cursor(self.busy_cursor)

        while Gtk.events_pending():
            Gtk.main_iteration()

        SoftwarePane.init_view(self)
        # set the AppTreeView model, available pane uses list models
        liststore = AppListStore(self.db, self.cache, self.icons)
        #~ def on_appcount_changed(widget, appcount):
        #~ self.subcategories_view._append_appcount(appcount)
        #~ self.app_view._append_appcount(appcount)
        #~ liststore.connect('appcount-changed', on_appcount_changed)
        self.app_view.set_model(liststore)
        liststore.connect("needs-refresh",
                          lambda helper, pkgname: self.app_view.queue_draw())

        # purchase view
        self.purchase_view = PurchaseView()
        app_manager = get_appmanager()
        app_manager.connect("purchase-requested", self.on_purchase_requested)
        self.purchase_view.connect("purchase-succeeded",
                                   self.on_purchase_succeeded)
        self.purchase_view.connect("purchase-failed", self.on_purchase_failed)
        self.purchase_view.connect("purchase-cancelled-by-user",
                                   self.on_purchase_cancelled_by_user)
        self.purchase_view.connect("terms-of-service-declined",
                                   self.on_terms_of_service_declined)
        self.purchase_view.connect("purchase-needs-spinner",
                                   self.on_purchase_needs_spinner)

        # categories, appview and details into the notebook in the bottom
        self.scroll_categories = Gtk.ScrolledWindow()
        self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
                                          Gtk.PolicyType.AUTOMATIC)
        self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH,
                                     self.cache, self.db, self.icons,
                                     self.apps_filter)
        self.scroll_categories.add(self.cat_view)
        self.notebook.append_page(self.scroll_categories,
                                  Gtk.Label(label="categories"))

        # sub-categories view
        self.subcategories_view = SubCategoryViewGtk(
            self.datadir,
            APP_INSTALL_PATH,
            self.cache,
            self.db,
            self.icons,
            self.apps_filter,
            root_category=self.cat_view.categories[0])
        self.subcategories_view.connect("category-selected",
                                        self.on_subcategory_activated)
        self.subcategories_view.connect("application-activated",
                                        self.on_application_activated)
        self.subcategories_view.connect("show-category-applist",
                                        self.on_show_category_applist)
        # FIXME: why do we have two application-{selected,activated] ?!?
        self.subcategories_view.connect("application-selected",
                                        self.on_application_selected)
        self.subcategories_view.connect("application-activated",
                                        self.on_application_activated)
        self.scroll_subcategories = Gtk.ScrolledWindow()
        self.scroll_subcategories.set_policy(Gtk.PolicyType.AUTOMATIC,
                                             Gtk.PolicyType.AUTOMATIC)
        self.scroll_subcategories.add(self.subcategories_view)
        self.notebook.append_page(self.scroll_subcategories,
                                  Gtk.Label(label=NavButtons.SUBCAT))

        # app list
        self.notebook.append_page(self.box_app_list,
                                  Gtk.Label(label=NavButtons.LIST))

        self.cat_view.connect("category-selected", self.on_category_activated)
        self.cat_view.connect("application-selected",
                              self.on_application_selected)
        self.cat_view.connect("application-activated",
                              self.on_application_activated)

        # details
        self.notebook.append_page(self.scroll_details,
                                  Gtk.Label(label=NavButtons.DETAILS))

        # purchase view
        self.notebook.append_page(self.purchase_view,
                                  Gtk.Label(label=NavButtons.PURCHASE))

        # install backend
        self.backend.connect("transaction-started",
                             self.on_transaction_started)
        self.backend.connect("transactions-changed",
                             self.on_transactions_changed)
        self.backend.connect("transaction-finished",
                             self.on_transaction_complete)
        self.backend.connect("transaction-cancelled",
                             self.on_transaction_cancelled)
        # a transaction error is treated the same as a cancellation
        self.backend.connect("transaction-stopped",
                             self.on_transaction_cancelled)

        # now we are initialized
        self.searchentry.set_sensitive(True)
        self.emit("available-pane-created")
        self.show_all()
        self.hide_appview_spinner()

        # consider the view initialized here already as display_page()
        # may run into a endless recurison otherwise (it will call init_view())
        # again (LP: #851671)
        self.view_initialized = True

        # important to "seed" the initial history stack (LP: #1005104)
        vm = get_viewmanager()
        vm.display_page(self, AvailablePane.Pages.LOBBY, self.state,
                        self.display_lobby_page)

        if window is not None:
            window.set_cursor(None)
Esempio n. 20
0
    def init_view(self):
        if self.view_initialized:
            return

        self.show_appview_spinner()

        window = self.get_window()
        if window is not None:
            window.set_cursor(self.busy_cursor)

        with ExecutionTime("AvailablePane.init_view pending events"):
            while Gtk.events_pending():
                Gtk.main_iteration()

        with ExecutionTime("SoftwarePane.init_view()"):
            SoftwarePane.init_view(self)
        # set the AppTreeView model, available pane uses list models
        with ExecutionTime("create AppListStore"):
            liststore = AppListStore(self.db, self.cache, self.icons)
        #~ def on_appcount_changed(widget, appcount):
            #~ self.subcategories_view._append_appcount(appcount)
            #~ self.app_view._append_appcount(appcount)
        #~ liststore.connect('appcount-changed', on_appcount_changed)
        self.app_view.set_model(liststore)
        liststore.connect("needs-refresh",
            lambda helper, pkgname: self.app_view.queue_draw())

        # purchase view
        self.purchase_view = PurchaseView()
        app_manager = get_appmanager()
        app_manager.connect("purchase-requested",
            self.on_purchase_requested)
        self.purchase_view.connect("purchase-succeeded",
            self.on_purchase_succeeded)
        self.purchase_view.connect("purchase-failed",
            self.on_purchase_failed)
        self.purchase_view.connect("purchase-cancelled-by-user",
            self.on_purchase_cancelled_by_user)
        self.purchase_view.connect("terms-of-service-declined",
            self.on_terms_of_service_declined)
        self.purchase_view.connect("purchase-needs-spinner",
            self.on_purchase_needs_spinner)

        # categories, appview and details into the notebook in the bottom
        self.scroll_categories = Gtk.ScrolledWindow()
        self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
                                        Gtk.PolicyType.AUTOMATIC)
        with ExecutionTime("create LobbyView"):
            self.cat_view = LobbyView(
                self.cache, self.db, self.icons, self.apps_filter)
        self.scroll_categories.add(self.cat_view)
        self.notebook.append_page(self.scroll_categories,
            Gtk.Label(label="categories"))

        # sub-categories view
        with ExecutionTime("create SubCategoryView"):
            self.subcategories_view = SubCategoryView(
                self.cache, self.db, self.icons, self.apps_filter,
                root_category=self.cat_view.categories[0])
        self.subcategories_view.connect(
            "category-selected", self.on_subcategory_activated)
        self.subcategories_view.connect(
            "show-category-applist", self.on_show_category_applist)
        self.subcategories_view.connect(
            "application-activated", self.on_application_activated)
        self.scroll_subcategories = Gtk.ScrolledWindow()
        self.scroll_subcategories.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scroll_subcategories.add(self.subcategories_view)
        self.notebook.append_page(self.scroll_subcategories,
                                    Gtk.Label(label=NavButtons.SUBCAT))

        # app list
        self.notebook.append_page(self.box_app_list,
                                    Gtk.Label(label=NavButtons.LIST))

        self.cat_view.connect(
            "category-selected", self.on_category_activated)
        self.cat_view.connect(
            "application-activated", self.on_application_activated)

        # details
        self.notebook.append_page(self.scroll_details,
            Gtk.Label(label=NavButtons.DETAILS))

        # purchase view
        self.notebook.append_page(self.purchase_view,
            Gtk.Label(label=NavButtons.PURCHASE))

        # install backend
        # FIXME: move this out of the available pane really
        self.backend.connect("transaction-started",
            self.on_transaction_started)
        self.backend.connect("transactions-changed",
            self.on_transactions_changed)
        self.backend.connect("transaction-finished",
            self.on_transaction_complete)
        # a transaction error is treated the same as a cancellation
        self.backend.connect("transaction-stopped",
            self.on_transaction_cancelled)
        self.backend.connect("transaction-cancelled",
            self.on_transaction_cancelled)

        # now we are initialized
        self.searchentry.set_sensitive(True)
        self.emit("available-pane-created")
        self.show_all()
        self.hide_appview_spinner()

        # consider the view initialized here already as display_page()
        # may run into a endless recursion otherwise (it will call init_view())
        # again (LP: #851671)
        self.view_initialized = True

        # important to "seed" the initial history stack (LP: #1005104)
        vm = get_viewmanager()
        vm.display_page(self, self.Pages.LOBBY, self.state)

        if window is not None:
            window.set_cursor(None)