Exemple #1
0
	def show_explaination(self, impl):
		reason = self.driver.solver.justify_decision(self.driver.requirements, self.interface, impl)

		parent = self.tree_view.get_toplevel()

		if '\n' not in reason:
			gtkutils.show_message_box(parent, reason, gtk.MESSAGE_INFO)
			return

		box = gtk.Dialog(_("{prog} version {version}").format(
					prog = self.interface.get_name(),
					version = impl.get_version()),
				parent,
				gtk.DIALOG_DESTROY_WITH_PARENT,
				(gtk.STOCK_OK, gtk.RESPONSE_OK))

		swin = gtk.ScrolledWindow()
		swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		text = gtk.Label(reason)
		swin.add_with_viewport(text)
		swin.show_all()
		box.vbox.pack_start(swin)

		box.set_position(gtk.WIN_POS_CENTER)
		def resp(b, r):
			b.destroy()
		box.connect('response', resp)

		box.set_default_size(gtk.gdk.screen_width() * 3 / 4, gtk.gdk.screen_height() / 3)

		box.show()
Exemple #2
0
    def show_explaination(self, impl):
        reason = self.driver.solver.justify_decision(self.driver.requirements,
                                                     self.interface, impl)

        parent = self.tree_view.get_toplevel()

        if '\n' not in reason:
            gtkutils.show_message_box(parent, reason, gtk.MESSAGE_INFO)
            return

        box = gtk.Dialog(
            _("{prog} version {version}").format(
                prog=self.interface.get_name(), version=impl.get_version()),
            parent, gtk.DIALOG_DESTROY_WITH_PARENT,
            (gtk.STOCK_OK, gtk.RESPONSE_OK))

        swin = gtk.ScrolledWindow()
        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        text = gtk.Label(reason)
        swin.add_with_viewport(text)
        swin.show_all()
        box.vbox.pack_start(swin)

        box.set_position(gtk.WIN_POS_CENTER)

        def resp(b, r):
            b.destroy()

        box.connect('response', resp)

        box.set_default_size(gtk.gdk.screen_width() * 3 / 4,
                             gtk.gdk.screen_height() / 3)

        box.show()
    def trust_keys(self, agreed_sigs, domain):
        assert domain
        try:
            for sig in agreed_sigs:
                trust.trust_db.trust_key(sig.fingerprint, domain)

            trust.trust_db.notify()
        except Exception as ex:
            gtkutils.show_message_box(self, str(ex), gtk.MESSAGE_ERROR)
            if not isinstance(ex, SafeException):
                raise
	def trust_keys(self, agreed_sigs, domain):
		assert domain
		try:
			for sig in agreed_sigs:
				trust.trust_db.trust_key(sig.fingerprint, domain)

			trust.trust_db.notify()
		except Exception, ex:
			gtkutils.show_message_box(self, str(ex), gtk.MESSAGE_ERROR)
			if not isinstance(ex, SafeException):
				raise
Exemple #5
0
	def _delete(self):
		errors = []

		model = self.model
		paths = get_selected_paths(self.tree_view)
		paths.reverse()
		for path in paths:
			item = model[path][ITEM_OBJECT.idx]
			assert item.delete
			try:
				item.delete()
			except OSError as ex:
				errors.append(str(ex))
			else:
				model.remove(model.get_iter(path))
		self._update_sizes()

		if errors:
			gtkutils.show_message_box(self.window, _("Failed to delete:\n%s") % '\n'.join(errors))
Exemple #6
0
	def _delete(self):
		errors = []

		model = self.model
		paths = get_selected_paths(self.tree_view)
		paths.reverse()
		for path in paths:
			item = model[path][ITEM_OBJECT.idx]
			assert item.delete
			try:
				item.delete()
			except OSError as ex:
				errors.append(str(ex))
			else:
				model.remove(model.get_iter(path))
		self._update_sizes()

		if errors:
			gtkutils.show_message_box(self.window, _("Failed to delete:\n%s") % '\n'.join(errors))
Exemple #7
0
	def show_explaination(self, impl):
		try:
			blocker = slave.justify_decision(self.interface.uri, impl['from-feed'], impl['id'])
			yield blocker
			tasks.check(blocker)
			reason = blocker.result

			parent = self.tree_view.get_toplevel()

			if '\n' not in reason:
				gtkutils.show_message_box(parent, reason, gtk.MESSAGE_INFO)
				return

			box = gtk.Dialog(_("{prog} version {version}").format(
						prog = self.interface.uri,
						version = impl['version']),
					parent,
					gtk.DIALOG_DESTROY_WITH_PARENT,
					(gtk.STOCK_OK, gtk.RESPONSE_OK))

			swin = gtk.ScrolledWindow()
			swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
			text = gtk.Label(reason)
			swin.add_with_viewport(text)
			swin.show_all()
			box.vbox.pack_start(swin)

			box.set_position(gtk.WIN_POS_CENTER)
			def resp(b, r):
				b.destroy()
			box.connect('response', resp)

			box.set_default_size(gtk.gdk.screen_width() * 3 / 4, gtk.gdk.screen_height() / 3)

			box.show()
		except Exception:
			logger.warning("show_explaination", exc_info = True)
			raise
Exemple #8
0
def alert(parent, message, type=gtk.MESSAGE_ERROR):
    if type == gtk.MESSAGE_ERROR:
        global last_error
        last_error = message

    gtkutils.show_message_box(parent, message, type)
Exemple #9
0
class CacheExplorer:
    """A graphical interface for viewing the cache and deleting old items."""
    def __init__(self, iface_cache):
        widgets = gtkutils.Template(
            os.path.join(os.path.dirname(__file__), 'cache.ui'), 'cache')
        self.window = window = widgets.get_widget('cache')
        window.set_default_size(gtk.gdk.screen_width() / 2,
                                gtk.gdk.screen_height() / 2)
        self.iface_cache = iface_cache

        # Model
        self.model = gtk.TreeStore(str, int, str, str, object)
        self.tree_view = widgets.get_widget('treeview')
        self.tree_view.set_model(self.model)

        column = gtk.TreeViewColumn(_('Item'),
                                    gtk.CellRendererText(),
                                    text=ITEM)
        column.set_resizable(True)
        self.tree_view.append_column(column)

        cell = gtk.CellRendererText()
        cell.set_property('xalign', 1.0)
        column = gtk.TreeViewColumn(_('Size'), cell, text=PRETTY_SIZE)
        self.tree_view.append_column(column)

        def button_press(tree_view, bev):
            if bev.button != 3:
                return False
            pos = tree_view.get_path_at_pos(int(bev.x), int(bev.y))
            if not pos:
                return False
            path, col, x, y = pos
            obj = self.model[path][ITEM_OBJECT]
            if obj and hasattr(obj, 'menu_items'):
                popup_menu(bev, obj)

        self.tree_view.connect('button-press-event', button_press)

        # Tree tooltips
        def motion(tree_view, ev):
            if ev.window is not tree_view.get_bin_window():
                return False
            pos = tree_view.get_path_at_pos(int(ev.x), int(ev.y))
            if pos:
                path = pos[0]
                row = self.model[path]
                tip = row[TOOLTIP]
                if tip:
                    if tip != tips.item:
                        tips.prime(tree_view, tip)
                else:
                    tips.hide()
            else:
                tips.hide()

        self.tree_view.connect('motion-notify-event', motion)
        self.tree_view.connect('leave-notify-event',
                               lambda tv, ev: tips.hide())

        # Responses
        window.set_default_response(gtk.RESPONSE_CLOSE)

        selection = self.tree_view.get_selection()

        def selection_changed(selection):
            any_selected = False
            for x in get_selected_paths(self.tree_view):
                obj = self.model[x][ITEM_OBJECT]
                if obj is None or not obj.may_delete:
                    window.set_response_sensitive(DELETE, False)
                    return
                any_selected = True
            window.set_response_sensitive(DELETE, any_selected)

        selection.set_mode(gtk.SELECTION_MULTIPLE)
        selection.connect('changed', selection_changed)
        selection_changed(selection)

        def response(dialog, resp):
            if resp == gtk.RESPONSE_CLOSE:
                window.destroy()
            elif resp == gtk.RESPONSE_HELP:
                cache_help.display()
            elif resp == DELETE:
                self._delete()

        window.connect('response', response)

    def _delete(self):
        errors = []

        model = self.model
        paths = get_selected_paths(self.tree_view)
        paths.reverse()
        for path in paths:
            item = model[path][ITEM_OBJECT]
            assert item.delete
            try:
                item.delete()
            except OSError, ex:
                errors.append(str(ex))
            else:
                model.remove(model.get_iter(path))
        self._update_sizes()

        if errors:
            gtkutils.show_message_box(
                self,
                _("Failed to delete:\n%s") % '\n'.join(errors))
Exemple #10
0
def alert(parent, message, type = gtk.MESSAGE_ERROR):
	if type == gtk.MESSAGE_ERROR:
		global last_error
		last_error = message

	gtkutils.show_message_box(parent, message, type)
Exemple #11
0
	def show_explaination(self, impl):
		reason = self.policy.solver.justify_decision(self.policy.requirements, self.interface, impl)
		gtkutils.show_message_box(self.tree_view.get_toplevel(), reason, gtk.MESSAGE_INFO)
Exemple #12
0
 def show_explaination(self, impl):
     reason = self.driver.solver.justify_decision(self.driver.requirements,
                                                  self.interface, impl)
     gtkutils.show_message_box(self.tree_view.get_toplevel(), reason,
                               gtk.MESSAGE_INFO)