Exemple #1
0
def select_optdeps(widget, pkg, optdeps):
	transaction.choose_label.set_markup('<b>{}</b>'.format(_('{pkgname} has {number} uninstalled optional deps.\nPlease choose those you would like to install:').format(pkgname = pkg.name, number = str(len(optdeps)))))
	transaction.choose_list.clear()
	for long_string in optdeps:
		transaction.choose_list.append([False, long_string])
	transaction.ChooseDialog.run()
	# some optdep can be virtual package so check for providers
	for name in transaction.to_add:
		if not transaction.get_syncpkg(name):
			transaction.to_add.discard(name)
			# if a provider is already installed, do nothing
			if pyalpm.find_satisfier(transaction.localdb.pkgcache, name):
				continue
			providers = set()
			for db in transaction.syncdbs:
				pkgs = db.pkgcache
				provider = pyalpm.find_satisfier(pkgs, name)
				while provider:
					providers.add(provider.name)
					for pkg in pkgs:
						if pkg.name == provider.name:
							pkgs.remove(pkg)
							break
					provider = pyalpm.find_satisfier(pkgs, name)
			transaction.choose_provides((providers, name))
	if transaction.to_add:
		ManagerValidButton.set_sensitive(True)
		ManagerCancelButton.set_sensitive(True)
Exemple #2
0
def select_optdeps(widget, pkg, optdeps):
    transaction.choose_label.set_markup('<b>{}</b>'.format(
        _('{pkgname} has {number} uninstalled optional deps.\nPlease choose those you would like to install:'
          ).format(pkgname=pkg.name, number=str(len(optdeps)))))
    transaction.choose_list.clear()
    for long_string in optdeps:
        transaction.choose_list.append([False, long_string])
    transaction.ChooseDialog.run()
    # some optdep can be virtual package so check for providers
    for name in transaction.to_add:
        if not transaction.get_syncpkg(name):
            transaction.to_add.discard(name)
            # if a provider is already installed, do nothing
            if pyalpm.find_satisfier(transaction.localdb.pkgcache, name):
                continue
            providers = set()
            for db in transaction.syncdbs:
                pkgs = db.pkgcache
                provider = pyalpm.find_satisfier(pkgs, name)
                while provider:
                    providers.add(provider.name)
                    for pkg in pkgs:
                        if pkg.name == provider.name:
                            pkgs.remove(pkg)
                            break
                    provider = pyalpm.find_satisfier(pkgs, name)
            transaction.choose_provides((providers, name))
    if transaction.to_add:
        ManagerValidButton.set_sensitive(True)
        ManagerCancelButton.set_sensitive(True)
Exemple #3
0
def get_state_list(state):
    global states_dict
    if state == _('To install'):
        liststore = Gtk.ListStore(object)
        for name in transaction.to_add:
            pkg = transaction.get_localpkg(name)
            if pkg:
                liststore.append([pkg])
            else:
                pkg = transaction.get_syncpkg(name)
                if pkg:
                    liststore.append([pkg])
        return liststore
    elif state == _('To remove'):
        liststore = Gtk.ListStore(object)
        for name in transaction.to_remove:
            pkg = transaction.get_localpkg(name)
            if pkg:
                liststore.append([pkg])
        return liststore
    elif state in states_dict.keys():
        return states_dict[state]
    else:
        states_dict[state] = Gtk.ListStore(object)
        if state == _('Installed'):
            for pkg in transaction.localdb.pkgcache:
                states_dict[state].append([pkg])
        elif state == _('Uninstalled'):
            for pkg in get_uninstalled_pkgs():
                states_dict[state].append([pkg])
        elif state == _('Orphans'):
            for pkg in get_orphan_pkgs():
                states_dict[state].append([pkg])
        return states_dict[state]
Exemple #4
0
def get_state_list(state):
	global states_dict
	if state == _('To install'):
		liststore = Gtk.ListStore(object)
		for name in transaction.to_add:
			pkg = transaction.get_localpkg(name)
			if pkg:
				liststore.append([pkg])
			else:
				pkg = transaction.get_syncpkg(name)
				if pkg:
					liststore.append([pkg])
		return liststore
	elif state == _('To remove'):
		liststore = Gtk.ListStore(object)
		for name in transaction.to_remove:
			pkg = transaction.get_localpkg(name)
			if pkg:
				liststore.append([pkg])
		return liststore
	elif state in states_dict.keys():
		return states_dict[state]
	else:
		states_dict[state] = Gtk.ListStore(object)
		if state == _('Installed'):
			for pkg in transaction.localdb.pkgcache:
				states_dict[state].append([pkg])
		elif state == _('Uninstalled'):
			for pkg in get_uninstalled_pkgs():
				states_dict[state].append([pkg])
		elif state == _('Orphans'):
			for pkg in get_orphan_pkgs():
				states_dict[state].append([pkg])
		return states_dict[state]
Exemple #5
0
def get_repo_list(repo):
    global repos_dict
    if repo in repos_dict.keys():
        return repos_dict[repo]
    else:
        repos_dict[repo] = Gtk.ListStore(object)
        if repo == _('local'):
            for pkg in transaction.localdb.pkgcache:
                if not transaction.get_syncpkg(pkg.name):
                    repos_dict[repo].append([pkg])
        else:
            for db in transaction.syncdbs:
                if db.name == repo:
                    for pkg in db.pkgcache:
                        local_pkg = transaction.get_localpkg(pkg.name)
                        if local_pkg:
                            repos_dict[repo].append([local_pkg])
                        else:
                            repos_dict[repo].append([pkg])
        return repos_dict[repo]
Exemple #6
0
def get_repo_list(repo):
	global repos_dict
	if repo in repos_dict.keys():
		return repos_dict[repo]
	else:
		repos_dict[repo] = Gtk.ListStore(object)
		if repo == _('local'):
			for pkg in transaction.localdb.pkgcache:
				if not transaction.get_syncpkg(pkg.name):
					repos_dict[repo].append([pkg])
		else:
			for db in transaction.syncdbs:
				if db.name ==repo:
					for pkg in db.pkgcache:
						local_pkg = transaction.get_localpkg(pkg.name)
						if local_pkg:
							repos_dict[repo].append([local_pkg])
						else:
							repos_dict[repo].append([pkg])
		return repos_dict[repo]
Exemple #7
0
def get_pkgs(pkgs):
	error = ''
	for name in pkgs:
		if '.pkg.tar.' in name:
			full_path = abspath(name)
			transaction.to_load.add(full_path)
		elif transaction.get_syncpkg(name):
			transaction.to_add.add(name)
		else:
			aur_pkg = None
			if config.enable_aur:
				aur_pkg = aur.info(name)
				if aur_pkg:
					transaction.to_build.append(aur_pkg)
			if not aur_pkg:
				if error:
					error += '\n'
				error += _('{pkgname} is not a valid path or package name').format(pkgname = name)
	if error:
		handle_error(error)
		return False
	else:
		return True
Exemple #8
0
def get_pkgs(pkgs):
    error = ''
    for name in pkgs:
        if '.pkg.tar.' in name:
            full_path = abspath(name)
            transaction.to_load.add(full_path)
        elif transaction.get_syncpkg(name):
            transaction.to_add.add(name)
        else:
            aur_pkg = None
            if config.enable_aur:
                aur_pkg = aur.info(name)
                if aur_pkg:
                    transaction.to_build.append(aur_pkg)
            if not aur_pkg:
                if error:
                    error += '\n'
                error += _('{pkgname} is not a valid path or package name'
                           ).format(pkgname=name)
    if error:
        handle_error(error)
        return False
    else:
        return True
Exemple #9
0
def on_list_treeview_button_press_event(treeview, event):
    global right_click_menu
    liststore = packages_list_treeview.get_model()
    # Check if right mouse button was clicked
    if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
        while Gtk.events_pending():
            Gtk.main_iteration()
        treepath, viewcolumn, x, y = treeview.get_path_at_pos(
            int(event.x), int(event.y))
        treeiter = liststore.get_iter(treepath)
        if treeiter:
            if liststore[treeiter][0] != _(
                    'No package found'
            ) and not liststore[treeiter][0].name in config.holdpkg:
                right_click_menu = Gtk.Menu()
                if liststore[treeiter][
                        0].name in transaction.to_add | transaction.to_remove or liststore[
                            treeiter][0] in transaction.to_build:
                    item = Gtk.ImageMenuItem(_('Deselect'))
                    item.set_image(
                        Gtk.Image.new_from_stock('gtk-undo',
                                                 Gtk.IconSize.MENU))
                    item.connect('activate', mark_to_deselect,
                                 liststore[treeiter][0])
                    right_click_menu.append(item)
                elif liststore[treeiter][0].db.name == 'local':
                    item = Gtk.ImageMenuItem(_('Remove'))
                    item.set_image(Gtk.Image.new_from_pixbuf(to_remove_icon))
                    item.connect('activate', mark_to_remove,
                                 liststore[treeiter][0])
                    right_click_menu.append(item)
                    if transaction.get_syncpkg(liststore[treeiter][0].name):
                        if not pyalpm.sync_newversion(liststore[treeiter][0],
                                                      transaction.syncdbs):
                            item = Gtk.ImageMenuItem(_('Reinstall'))
                            item.set_image(
                                Gtk.Image.new_from_pixbuf(to_reinstall_icon))
                            item.connect('activate', mark_to_reinstall,
                                         liststore[treeiter][0])
                            right_click_menu.append(item)
                    optdeps_strings = liststore[treeiter][0].optdepends
                    if optdeps_strings:
                        available_optdeps = []
                        for optdep_string in optdeps_strings:
                            if not pyalpm.find_satisfier(
                                    transaction.localdb.pkgcache,
                                    optdep_string.split(':')[0]):
                                available_optdeps.append(optdep_string)
                        if available_optdeps:
                            item = Gtk.ImageMenuItem(
                                _('Install optional deps'))
                            item.set_image(
                                Gtk.Image.new_from_pixbuf(to_install_icon))
                            item.connect('activate', select_optdeps,
                                         liststore[treeiter][0],
                                         available_optdeps)
                            right_click_menu.append(item)
                    if liststore[treeiter][
                            0].reason == pyalpm.PKG_REASON_DEPEND:
                        item = Gtk.MenuItem(_('Mark as explicitly installed'))
                        item.connect('activate', mark_explicitly_installed,
                                     liststore[treeiter][0])
                        right_click_menu.append(item)
                else:
                    item = Gtk.ImageMenuItem(_('Install'))
                    item.set_image(Gtk.Image.new_from_pixbuf(to_install_icon))
                    item.connect('activate', mark_to_install,
                                 liststore[treeiter][0])
                    right_click_menu.append(item)
                    optdeps_strings = liststore[treeiter][0].optdepends
                    if optdeps_strings:
                        available_optdeps = []
                        for optdep_string in optdeps_strings:
                            if not pyalpm.find_satisfier(
                                    transaction.localdb.pkgcache,
                                    optdep_string.split(':')[0]):
                                available_optdeps.append(optdep_string)
                        if available_optdeps:
                            item = Gtk.ImageMenuItem(
                                _('Install with optional deps'))
                            item.set_image(
                                Gtk.Image.new_from_pixbuf(to_install_icon))
                            item.connect('activate', install_with_optdeps,
                                         liststore[treeiter][0],
                                         available_optdeps)
                            right_click_menu.append(item)
                treeview.grab_focus()
                treeview.set_cursor(treepath, viewcolumn, 0)
                right_click_menu.show_all()
                right_click_menu.popup(None, None, None, None, event.button,
                                       event.time)
                return True
Exemple #10
0
def on_list_treeview_button_press_event(treeview, event):
	global right_click_menu
	liststore = packages_list_treeview.get_model()
	# Check if right mouse button was clicked
	if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
		while Gtk.events_pending():
			Gtk.main_iteration()
		treepath, viewcolumn, x, y = treeview.get_path_at_pos(int(event.x), int(event.y))
		treeiter = liststore.get_iter(treepath)
		if treeiter:
			if liststore[treeiter][0] != _('No package found') and not liststore[treeiter][0].name in config.holdpkg:
				right_click_menu = Gtk.Menu()
				if liststore[treeiter][0].name in transaction.to_add | transaction.to_remove or liststore[treeiter][0] in transaction.to_build:
					item = Gtk.ImageMenuItem(_('Deselect'))
					item.set_image(Gtk.Image.new_from_stock('gtk-undo', Gtk.IconSize.MENU))
					item.connect('activate', mark_to_deselect, liststore[treeiter][0])
					right_click_menu.append(item)
				elif liststore[treeiter][0].db.name == 'local':
					item = Gtk.ImageMenuItem(_('Remove'))
					item.set_image(Gtk.Image.new_from_pixbuf(to_remove_icon))
					item.connect('activate', mark_to_remove, liststore[treeiter][0])
					right_click_menu.append(item)
					if transaction.get_syncpkg(liststore[treeiter][0].name):
						if not pyalpm.sync_newversion(liststore[treeiter][0], transaction.syncdbs):
							item = Gtk.ImageMenuItem(_('Reinstall'))
							item.set_image(Gtk.Image.new_from_pixbuf(to_reinstall_icon))
							item.connect('activate', mark_to_reinstall, liststore[treeiter][0])
							right_click_menu.append(item)
					optdeps_strings = liststore[treeiter][0].optdepends
					if optdeps_strings:
						available_optdeps = []
						for optdep_string in optdeps_strings:
							if not pyalpm.find_satisfier(transaction.localdb.pkgcache, optdep_string.split(':')[0]):
								available_optdeps.append(optdep_string)
						if available_optdeps:
							item = Gtk.ImageMenuItem(_('Install optional deps'))
							item.set_image(Gtk.Image.new_from_pixbuf(to_install_icon))
							item.connect('activate', select_optdeps, liststore[treeiter][0], available_optdeps)
							right_click_menu.append(item)
					if liststore[treeiter][0].reason == pyalpm.PKG_REASON_DEPEND:
						item = Gtk.MenuItem(_('Mark as explicitly installed'))
						item.connect('activate', mark_explicitly_installed, liststore[treeiter][0])
						right_click_menu.append(item)
				else:
					item = Gtk.ImageMenuItem(_('Install'))
					item.set_image(Gtk.Image.new_from_pixbuf(to_install_icon))
					item.connect('activate', mark_to_install, liststore[treeiter][0])
					right_click_menu.append(item)
					optdeps_strings = liststore[treeiter][0].optdepends
					if optdeps_strings:
						available_optdeps = []
						for optdep_string in optdeps_strings:
							if not pyalpm.find_satisfier(transaction.localdb.pkgcache, optdep_string.split(':')[0]):
								available_optdeps.append(optdep_string)
						if available_optdeps:
							item = Gtk.ImageMenuItem(_('Install with optional deps'))
							item.set_image(Gtk.Image.new_from_pixbuf(to_install_icon))
							item.connect('activate', install_with_optdeps, liststore[treeiter][0], available_optdeps)
							right_click_menu.append(item)
				treeview.grab_focus()
				treeview.set_cursor(treepath, viewcolumn, 0)
				right_click_menu.show_all()
				right_click_menu.popup(None, None, None, None, event.button, event.time)
				return True