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 # keep track of applications that are candidates to be added # to the Unity launcher self.unity_launcher_items = {} # 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) # an empty notebook, where the details view will eventually go self.details_notebook = Gtk.Notebook() self.details_notebook.set_show_border(False) # make a spinner view to display while the applist is loading self.spinner_view = SpinnerView() self.spinner_notebook = Gtk.Notebook() self.spinner_notebook.set_show_tabs(False) self.spinner_notebook.set_show_border(False) self.spinner_notebook.append_page(self.notebook, None) self.spinner_notebook.append_page(self.details_notebook, None) self.spinner_notebook.append_page(self.spinner_view, None) 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
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)) stop_oneconf_share_menuitem = Gtk.MenuItem(label=_("Stop Syncing “%s”") % platform.node()) stop_oneconf_share_menuitem.connect("activate", self._on_stop_showing_oneconf_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('/usr/share/app-install') 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) # create a local spinner notebook for the installed view self.installed_spinner_view = SpinnerView() self.installed_spinner_notebook = Gtk.Notebook() self.installed_spinner_notebook.set_show_tabs(False) self.installed_spinner_notebook.set_show_border(False) self.installed_spinner_notebook.append_page(self.installed_spinner_view, None) self.box_app_list.remove(self.app_view) self.installed_spinner_notebook.append_page(self.app_view, None) 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() # now we are initialized self.emit("installed-pane-created") self.view_initialized = True return False
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_view = SpinnerView(_('Loading history')) self.spinner_notebook = Gtk.Notebook() self.spinner_notebook.set_show_tabs(False) self.spinner_notebook.set_show_border(False) self.spinner_notebook.append_page(self.history_view, None) self.spinner_notebook.append_page(self.spinner_view, None) 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)