def test_get_viewmanager(self):
     view_manager = get_viewmanager()
     self.assertNotEqual(view_manager, None)
     # is a singleton singleton
     view_manager2 = get_viewmanager()
     self.assertIs(view_manager, view_manager2)
     # test creating it twice raises a error
     self.assertRaises(ValueError, ViewManager, Gtk.Notebook())
Пример #2
0
 def on_purchase_requested(self, appmanager, app, iconname, url):
     self.purchase_view.initiate_purchase(app, iconname, url)
     vm = get_viewmanager()
     vm.display_page(
         self, AvailablePane.Pages.PURCHASE, self.state,
         self.display_purchase)
     return
Пример #3
0
    def on_search_terms_changed(self, widget, new_text):
        """callback when the search entry widget changes"""
        LOG.debug("on_search_terms_changed: %s" % new_text)

        self.state.search_term = new_text

        # do not hide technical items for a custom list search
        if self._is_custom_list_search(self.state.search_term):
            self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE

        vm = get_viewmanager()

        # yeah for special cases - as discussed on irc, mpt
        # wants this to return to the category screen *if*
        # we are searching but we are not in any category
        if not self.state.category and not new_text:
            # category activate will clear search etc
            self.state.reset()
            vm.display_page(self, AvailablePane.Pages.LOBBY, self.state, self.display_lobby_page)
            return False

        elif self.state.subcategory and not new_text:
            vm.display_page(self, AvailablePane.Pages.LIST, self.state, self.display_app_view_page)
            return False

        elif self.state.category and self.state.category.subcategories and not new_text:
            vm.display_page(self, AvailablePane.Pages.SUBCATEGORY, self.state, self.display_subcategory_page)
            return False
        vm.display_page(self, AvailablePane.Pages.LIST, self.state, self.display_search_page)
    def setUp(self):
        # create it once, it becomes global instance
        self.vm = get_viewmanager()
        if self.vm is None:
            self.vm = ViewManager(Gtk.Notebook())

        self.addCleanup(self.vm.destroy)
Пример #5
0
def get_test_gtk3_viewmanager():
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
Пример #6
0
    def on_purchase_requested(self, widget, app, url):

        self.appdetails = app.get_details(self.db)
        iconname = self.appdetails.icon
        self.purchase_view.initiate_purchase(app, iconname, url)
        vm = get_viewmanager()
        vm.display_page(self, AvailablePane.Pages.PURCHASE, self.state, self.display_purchase)
Пример #7
0
    def on_search_terms_changed(self, widget, new_text):
        """callback when the search entry widget changes"""
        LOG.debug("on_search_terms_changed: %s" % new_text)

        self.state.search_term = new_text

        # do not hide technical items for a custom list search
        if self._is_custom_list_search(self.state.search_term):
            self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE

        vm = get_viewmanager()

        # yeah for special cases - as discussed on irc, mpt
        # wants this to return to the category screen *if*
        # we are searching but we are not in any category or channel
        if not self.state.category and not self.state.channel and not new_text:
            # category activate will clear search etc
            self.state.reset()
            vm.display_page(self, AvailablePane.Pages.LOBBY, self.state,
                            self.display_lobby_page)
            return False

        elif (self.state.subcategory and not new_text):
            vm.display_page(self, AvailablePane.Pages.LIST, self.state,
                            self.display_app_view_page)
            return False

        elif (self.state.category and self.state.category.subcategories
              and not new_text):
            vm.display_page(self, AvailablePane.Pages.SUBCATEGORY, self.state,
                            self.display_subcategory_page)
            return False
        vm.display_page(self, AvailablePane.Pages.LIST, self.state,
                        self.display_search_page)
Пример #8
0
 def on_previous_purchases_activated(self, query):
     """ called to activate the previous purchases view """
     # print cat_view, name, query
     LOG.debug("on_previous_purchases_activated with query: %s" % query)
     self.previous_purchases_query = query
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.LIST, self.state, self.display_previous_purchases)
 def on_application_activated(self, appview, app):
     """callback when an app is clicked"""
     LOG.debug("on_application_activated: '%s'" % app)
     self.state.application = app
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.DETAILS, self.state,
                     self.display_details_page)
Пример #10
0
    def on_search_terms_changed(self, widget, new_text):
        """callback when the search entry widget changes"""
        LOG.debug("on_search_terms_changed: %s" % new_text)

        # reset the flag in the app_view because each new search should
        # reset the sort criteria
        self.app_view.reset_default_sort_mode()

        self.state.search_term = new_text

        # do not hide technical items for a custom list search
        if self._is_custom_list_search(self.state.search_term):
            self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE

        vm = get_viewmanager()
        adj = self.app_view.tree_view_scroll.get_vadjustment()
        if adj:
            adj.set_value(0.0)

        # yeah for special cases - as discussed on irc, mpt
        # wants this to return to the category screen *if*
        # we are searching but we are not in any category or channel
        if not self.state.category and not self.state.channel and not new_text:
            # category activate will clear search etc
            self.state.reset()
            vm.display_page(self, self.Pages.LOBBY, self.state)
        elif self.state.subcategory and not new_text:
            vm.display_page(self, self.Pages.LIST, self.state)
        elif (self.state.category and
              self.state.category.subcategories and not new_text):
            vm.display_page(self, self.Pages.SUBCATEGORY, self.state)
        else:
            vm.display_page(self, self.Pages.LIST, self.state)

        return False
Пример #11
0
def get_test_gtk3_viewmanager():
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
Пример #12
0
 def on_application_activated(self, appview, app):
     """callback when an app is clicked"""
     LOG.debug("on_application_activated: '%s'" % app)
     self.state.application = app
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.DETAILS, self.state,
                     self.display_details_page)
 def on_previous_purchases_activated(self, query):
     """ called to activate the previous purchases view """
     #print cat_view, name, query
     LOG.debug("on_previous_purchases_activated with query: %s" % query)
     self.previous_purchases_query = query
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.LIST, self.state,
                     self.display_previous_purchases)
Пример #14
0
    def on_subcategory_activated(self, subcat_view, category):
        LOG.debug("on_subcategory_activated: %s %s" % (category.name, category))
        self.state.subcategory = category
        self.state.application = None
        page = AvailablePane.Pages.LIST

        vm = get_viewmanager()
        vm.display_page(self, page, self.state, self.display_app_view_page)
 def _return_to_appdetails_view(self):
     vm = get_viewmanager()
     vm.nav_back()
     # don't keep the purchase view in navigation history
     # as its contents are no longer valid
     vm.clear_forward_history()
     window = self.get_window()
     if window is not None:
         window.set_cursor(None)
Пример #16
0
 def _return_to_appdetails_view(self):
     vm = get_viewmanager()
     vm.nav_back()
     # don't keep the purchase view in navigation history
     # as its contents are no longer valid
     vm.clear_forward_history()
     window = self.get_window()
     if window is not None:
         window.set_cursor(None)
Пример #17
0
 def on_previous_purchases_activated(self, query):
     """ called to activate the previous purchases view """
     #print cat_view, name, query
     LOG.debug("on_previous_purchases_activated with query: %s" % query)
     self.state.channel = SoftwareChannel("Previous Purchases",
                                          "software-center-agent",
                                          None, channel_query=query)
     vm = get_viewmanager()
     vm.display_page(self, self.Pages.PREVIOUS_PURCHASES, self.state)
    def on_subcategory_activated(self, subcat_view, category):
        LOG.debug("on_subcategory_activated: %s %s" %
                  (category.name, category))
        self.state.subcategory = category
        self.state.application = None
        page = AvailablePane.Pages.LIST

        vm = get_viewmanager()
        vm.display_page(self, page, self.state, self.display_app_view_page)
Пример #19
0
    def on_application_activated(self, appview, app):
        """Callback when an app is clicked."""
        LOG.debug("%r.on_application_activated: %r",
                  self.__class__.__name__, app)

        self.state.application = app

        vm = get_viewmanager()
        # self.Pages will access the Page definition of each child correctly
        vm.display_page(self, self.Pages.DETAILS, self.state)
def get_test_gtk3_viewmanager():
    from gi.repository import Gtk
    from softwarecenter.ui.gtk3.session.viewmanager import (
        ViewManager, get_viewmanager)
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None: None}
    return vm
Пример #21
0
    def on_application_activated(self, appview, app):
        """Callback when an app is clicked."""
        LOG.debug("%r.on_application_activated: %r", self.__class__.__name__,
                  app)

        self.state.application = app

        vm = get_viewmanager()
        # self.Pages will access the Page definition of each child correctly
        vm.display_page(self, self.Pages.DETAILS, self.state)
Пример #22
0
def get_test_gtk3_viewmanager():
    from gi.repository import Gtk
    from softwarecenter.ui.gtk3.session.viewmanager import (
        ViewManager, get_viewmanager)
    vm = get_viewmanager()
    if not vm:
        notebook = Gtk.Notebook()
        vm = ViewManager(notebook)
        vm.view_to_pane = {None : None}
    return vm
 def on_previous_purchases_activated(self, query):
     """ called to activate the previous purchases view """
     #print cat_view, name, query
     LOG.debug("on_previous_purchases_activated with query: %s" % query)
     self.state.channel = SoftwareChannel("Previous Purchases",
                                          "software-center-agent",
                                          None,
                                          channel_query=query)
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.LIST, self.state,
                     self.display_previous_purchases)
Пример #24
0
    def __init__(self, cache, db, distro, icons, datadir, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.datadir = datadir
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None
Пример #25
0
    def __init__(self, cache, db, distro, icons, datadir, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
                            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.datadir = datadir
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not "SOFTWARE_CENTER_DEBUG_TABS" in os.environ:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None
Пример #26
0
    def __init__(self, view_manager, datadir, db, cache, icons):
        Gtk.Toolbar.__init__(self)
        context = self.get_style_context()
        context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        # add nav history back/forward buttons...
        # note:  this is hacky, would be much nicer to make the custom
        # self/right buttons in BackForwardButton to be
        # Gtk.Activatable/Gtk.Widgets, then wire in the actions using e.g.
        # self.navhistory_back_action.connect_proxy(self.back_forward.left),
        # but couldn't seem to get this to work..so just wire things up
        # directly
        vm = get_viewmanager()
        self.back_forward = vm.get_global_backforward()
        self.back_forward.set_vexpand(False)
        self.back_forward.set_valign(Gtk.Align.CENTER)

        if self.get_direction() != Gtk.TextDirection.RTL:
            _widget_set_margins(self.back_forward,
                                left=StockEms.MEDIUM,
                                right=StockEms.MEDIUM + 2)
        else:
            _widget_set_margins(self.back_forward,
                                right=StockEms.MEDIUM,
                                left=StockEms.MEDIUM + 2)
        self._insert_as_tool_item(self.back_forward, 0)

        # this is what actually draws the All Software, Installed etc buttons
        self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache,
            icons)
        self._insert_as_tool_item(self.view_switcher, 1)

        item = Gtk.ToolItem()
        item.set_expand(True)
        self.insert(item, -1)

        #~ self.init_atk_name(self.searchentry, "searchentry")
        self.searchentry = vm.get_global_searchentry()
        self._insert_as_tool_item(self.searchentry, -1)

        # spinner
        self.spinner = vm.get_global_spinner()
        self.spinner.set_size_request(StockEms.XLARGE, StockEms.XLARGE)
        self._insert_as_tool_item(self.spinner, -1)

        if self.get_direction() != Gtk.TextDirection.RTL:
            _widget_set_margins(self.searchentry, right=StockEms.MEDIUM)
        else:
            _widget_set_margins(self.searchentry, left=StockEms.MEDIUM)
    def __init__(self, view_manager, datadir, db, cache, icons):
        Gtk.Toolbar.__init__(self)
        context = self.get_style_context()
        context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        # add nav history back/forward buttons...
        # note:  this is hacky, would be much nicer to make the custom
        # self/right buttons in BackForwardButton to be
        # Gtk.Activatable/Gtk.Widgets, then wire in the actions using e.g.
        # self.navhistory_back_action.connect_proxy(self.back_forward.left),
        # but couldn't seem to get this to work..so just wire things up
        # directly
        vm = get_viewmanager()
        self.back_forward = vm.get_global_backforward()
        self.back_forward.set_vexpand(False)
        self.back_forward.set_valign(Gtk.Align.CENTER)

        if self.get_direction() != Gtk.TextDirection.RTL:
            _widget_set_margins(self.back_forward,
                                left=StockEms.MEDIUM,
                                right=StockEms.MEDIUM + 2)
        else:
            _widget_set_margins(self.back_forward,
                                right=StockEms.MEDIUM,
                                left=StockEms.MEDIUM + 2)
        self._insert_as_tool_item(self.back_forward, 0)

        # this is what actually draws the All Software, Installed etc buttons
        self.view_switcher = ViewSwitcher(view_manager, datadir, db, cache,
                                          icons)
        self._insert_as_tool_item(self.view_switcher, 1)

        item = Gtk.ToolItem()
        item.set_expand(True)
        self.insert(item, -1)

        #~ self.init_atk_name(self.searchentry, "searchentry")
        self.searchentry = vm.get_global_searchentry()
        self._insert_as_tool_item(self.searchentry, -1)

        # spinner
        self.spinner = vm.get_global_spinner()
        self.spinner.set_size_request(StockEms.XLARGE, StockEms.XLARGE)
        self._insert_as_tool_item(self.spinner, -1)

        if self.get_direction() != Gtk.TextDirection.RTL:
            _widget_set_margins(self.searchentry, right=StockEms.MEDIUM)
        else:
            _widget_set_margins(self.searchentry, left=StockEms.MEDIUM)
Пример #28
0
    def on_category_activated(self, lobby_view, category):
        """ callback when a category is selected """
        LOG.debug("on_category_activated: %s %s" % (
                category.name, category))

        if category.subcategories:
            page = self.Pages.SUBCATEGORY
        else:
            page = self.Pages.LIST

        self.state.category = category
        self.state.subcategory = None
        self.state.application = None

        vm = get_viewmanager()
        vm.display_page(self, page, self.state)
    def on_category_activated(self, lobby_view, category):
        """ callback when a category is selected """
        LOG.debug("on_category_activated: %s %s" % (category.name, category))

        if category.subcategories:
            page = AvailablePane.Pages.SUBCATEGORY
            callback = self.display_subcategory_page
        else:
            page = AvailablePane.Pages.LIST
            callback = self.display_app_view_page

        self.state.category = category
        self.state.subcategory = None
        self.state.application = None

        vm = get_viewmanager()
        vm.display_page(self, page, self.state, callback)
Пример #30
0
 def on_transaction_changed(self, backend, total_transactions):
     LOG.debug("on_transactions_changed '%s'" % total_transactions)
     pending = len(total_transactions)
     self.notify_icon_of_pending_count(pending)
     if pending > 0:
         self.start_icon_animation()
         pending_btn = self.view_buttons[ViewPages.PENDING]
         if not pending_btn.get_visible():
             pending_btn.set_visible(True)
     else:
         self.stop_icon_animation()
         pending_btn = self.view_buttons[ViewPages.PENDING]
         from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager
         vm = get_viewmanager()
         if vm.get_active_view() == 'view-page-pending':
             vm.nav_back()
             vm.clear_forward_history()
         pending_btn.set_visible(False)
     return
Пример #31
0
 def on_transaction_changed(self, backend, total_transactions):
     LOG.debug("on_transactions_changed '%s'" % total_transactions)
     pending = len(total_transactions)
     self.notify_icon_of_pending_count(pending)
     if pending > 0:
         self.start_icon_animation()
         pending_btn = self.view_buttons[ViewPages.PENDING]
         if not pending_btn.get_visible():
             pending_btn.set_visible(True)
     else:
         self.stop_icon_animation()
         pending_btn = self.view_buttons[ViewPages.PENDING]
         from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager
         vm = get_viewmanager()
         if vm.get_active_view() == 'view-page-pending':
             vm.nav_back()
             vm.clear_forward_history()
         pending_btn.set_visible(False)
     return
Пример #32
0
    def __init__(self, cache, db, distro, icons):
        Gtk.VBox.__init__(self)
        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons

        self.apps_filter = None
        self.state = DisplayState()

        self.pane_name = _("History")

        # Icon cache, invalidated upon icon theme changes
        self._app_icon_cache = {}
        self._reset_icon_cache()
        self.icons.connect('changed', self._reset_icon_cache)

        self._emblems = {}
        self._get_emblems(self.icons)

        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()

        self.toolbar = Gtk.Toolbar()
        self.toolbar.show()
        self.toolbar.set_style(Gtk.ToolbarStyle.TEXT)
        self.pack_start(self.toolbar, False, True, 0)

        all_action = Gtk.RadioAction('filter_all', _('All Changes'), None,
                                     None, self.ALL)
        all_action.connect('changed', self.change_filter)
        all_button = all_action.create_tool_item()
        self.toolbar.insert(all_button, 0)

        installs_action = Gtk.RadioAction('filter_installs',
                                          _('Installations'), None, None,
                                          self.INSTALLED)
        installs_action.join_group(all_action)
        installs_button = installs_action.create_tool_item()
        self.toolbar.insert(installs_button, 1)

        upgrades_action = Gtk.RadioAction('filter_upgrads', _('Updates'), None,
                                          None, self.UPGRADED)
        upgrades_action.join_group(all_action)
        upgrades_button = upgrades_action.create_tool_item()
        self.toolbar.insert(upgrades_button, 2)

        removals_action = Gtk.RadioAction('filter_removals', _('Removals'),
                                          None, None, self.REMOVED)
        removals_action.join_group(all_action)
        removals_button = removals_action.create_tool_item()
        self.toolbar.insert(removals_button, 3)
        self.toolbar.connect('draw', self.on_toolbar_draw)

        self._actions_list = all_action.get_group()
        self._set_actions_sensitive(False)

        self.view = Gtk.TreeView()
        self.view.set_headers_visible(False)
        self.view.show()
        self.history_view = Gtk.ScrolledWindow()
        self.history_view.set_policy(Gtk.PolicyType.AUTOMATIC,
                                     Gtk.PolicyType.AUTOMATIC)
        self.history_view.show()
        self.history_view.add(self.view)

        # make a spinner to display while history is loading
        self.spinner_notebook = SpinnerNotebook(self.history_view,
                                                _('Loading history'))

        self.pack_start(self.spinner_notebook, True, True, 0)

        self.store = Gtk.TreeStore(*self.COL_TYPES)
        self.visible_changes = 0
        self.store_filter = self.store.filter_new(None)
        self.store_filter.set_visible_func(self.filter_row, None)
        self.view.set_model(self.store_filter)
        all_action.set_active(True)
        self.last = None

        # to save (a lot of) time at startup we load history later, only when
        # it is selected to be viewed
        self.history = None

        self.column = Gtk.TreeViewColumn(_('Date'))
        self.view.append_column(self.column)
        self.cell_icon = Gtk.CellRendererPixbuf()
        self.cell_icon.set_padding(self.PADDING, self.PADDING / 2)
        self.column.pack_start(self.cell_icon, False)
        self.column.set_cell_data_func(self.cell_icon, self.render_cell_icon)
        self.cell_text = Gtk.CellRendererText()
        self.column.pack_start(self.cell_text, True)
        self.column.set_cell_data_func(self.cell_text, self.render_cell_text)
        self.cell_time = Gtk.CellRendererText()
        self.cell_time.set_padding(6, 0)
        self.cell_time.set_alignment(1.0, 0.5)
        self.column.pack_end(self.cell_time, False)
        self.column.set_cell_data_func(self.cell_time, self.render_cell_time)

        # busy cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
Пример #33
0
 def on_purchase_needs_spinner(self, appmanager, active):
     vm = get_viewmanager()
     vm.set_spinner_active(active)
Пример #34
0
 def on_nav_forward_clicked(self, widget):
     vm = get_viewmanager()
     vm.nav_forward()
Пример #35
0
 def on_nav_back_clicked(self, widget):
     vm = get_viewmanager()
     vm.nav_back()
Пример #36
0
 def on_nav_forward_clicked(self, widget):
     vm = get_viewmanager()
     vm.nav_forward()
Пример #37
0
    def __init__(self, cache, db, distro, icons, datadir):
        Gtk.VBox.__init__(self)
        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.datadir = datadir

        self.apps_filter = None
        self.state = DisplayState()

        self.pane_name = _("History")

        # Icon cache, invalidated upon icon theme changes
        self._app_icon_cache = {}
        self._reset_icon_cache()
        self.icons.connect('changed', self._reset_icon_cache)

        self._emblems = {}
        self._get_emblems(self.icons)

        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()

        self.toolbar = Gtk.Toolbar()
        self.toolbar.show()
        self.toolbar.set_style(Gtk.ToolbarStyle.TEXT)
        self.pack_start(self.toolbar, False, True, 0)

        all_action = Gtk.RadioAction('filter_all', _('All Changes'), None,
            None, self.ALL)
        all_action.connect('changed', self.change_filter)
        all_button = all_action.create_tool_item()
        self.toolbar.insert(all_button, 0)

        installs_action = Gtk.RadioAction('filter_installs',
            _('Installations'), None, None, self.INSTALLED)
        installs_action.join_group(all_action)
        installs_button = installs_action.create_tool_item()
        self.toolbar.insert(installs_button, 1)

        upgrades_action = Gtk.RadioAction(
            'filter_upgrads', _('Updates'), None, None, self.UPGRADED)
        upgrades_action.join_group(all_action)
        upgrades_button = upgrades_action.create_tool_item()
        self.toolbar.insert(upgrades_button, 2)

        removals_action = Gtk.RadioAction(
            'filter_removals', _('Removals'), None, None, self.REMOVED)
        removals_action.join_group(all_action)
        removals_button = removals_action.create_tool_item()
        self.toolbar.insert(removals_button, 3)
        self.toolbar.connect('draw', self.on_toolbar_draw)

        self._actions_list = all_action.get_group()
        self._set_actions_sensitive(False)

        self.view = Gtk.TreeView()
        self.view.set_headers_visible(False)
        self.view.show()
        self.history_view = Gtk.ScrolledWindow()
        self.history_view.set_policy(Gtk.PolicyType.AUTOMATIC,
                                      Gtk.PolicyType.AUTOMATIC)
        self.history_view.show()
        self.history_view.add(self.view)

        # make a spinner to display while history is loading
        self.spinner_notebook = SpinnerNotebook(
            self.history_view, _('Loading history'))

        self.pack_start(self.spinner_notebook, True, True, 0)

        self.store = Gtk.TreeStore(*self.COL_TYPES)
        self.visible_changes = 0
        self.store_filter = self.store.filter_new(None)
        self.store_filter.set_visible_func(self.filter_row, None)
        self.view.set_model(self.store_filter)
        all_action.set_active(True)
        self.last = None

        # to save (a lot of) time at startup we load history later, only when
        # it is selected to be viewed
        self.history = None

        self.column = Gtk.TreeViewColumn(_('Date'))
        self.view.append_column(self.column)
        self.cell_icon = Gtk.CellRendererPixbuf()
        self.column.pack_start(self.cell_icon, False)
        self.column.set_cell_data_func(self.cell_icon, self.render_cell_icon)
        self.cell_text = Gtk.CellRendererText()
        self.column.pack_start(self.cell_text, True)
        self.column.set_cell_data_func(self.cell_text, self.render_cell_text)

        # busy cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
Пример #38
0
 def on_nav_back_clicked(self, widget):
     vm = get_viewmanager()
     vm.nav_back()
Пример #39
0
 def on_purchase_requested(self, appmanager, app, iconname, url):
     if self.purchase_view.initiate_purchase(app, iconname, url):
         vm = get_viewmanager()
         vm.display_page(self, self.Pages.PURCHASE, self.state)
    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)
 def on_purchase_requested(self, appmanager, app, iconname, url):
     if self.purchase_view.initiate_purchase(app, iconname, url):
         vm = get_viewmanager()
         vm.display_page(self, AvailablePane.Pages.PURCHASE, self.state,
                         self.display_purchase)
 def on_purchase_needs_spinner(self, appmanager, active):
     vm = get_viewmanager()
     vm.set_spinner_active(active)
Пример #43
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)
Пример #44
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)