This commit is contained in:
guinux 2013-01-27 18:15:34 +01:00
parent fd63f7a36d
commit 90b04d0319
5 changed files with 194 additions and 31 deletions

View File

@ -43,6 +43,7 @@
<property name="title" translatable="yes">Progress</property> <property name="title" translatable="yes">Progress</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<property name="modal">True</property> <property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">250</property> <property name="default_width">250</property>
<property name="default_height">60</property> <property name="default_height">60</property>
<property name="icon">/usr/share/pamac/icons/22x22/status/setup.png</property> <property name="icon">/usr/share/pamac/icons/22x22/status/setup.png</property>

View File

@ -1,6 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 3.0 --> <!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="ChooseDialog">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="urgency_hint">True</property>
<child>
<object class="GtkBox" id="box8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="chooselabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="treeview5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">choose_list</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="enable_search">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection5">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertoggle2">
<signal name="toggled" handler="on_cellrenderertoggle2_toggled" swapped="no"/>
</object>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="cellrenderertext7"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="buttonbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ChooseButton">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_ChooseButton_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="ConfDialog"> <object class="GtkWindow" id="ConfDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes"> </property> <property name="title" translatable="yes"> </property>
@ -504,6 +605,14 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkListStore" id="choose_list">
<columns>
<!-- column-name gboolean1 -->
<column type="gboolean"/>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="groups_list"> <object class="GtkListStore" id="groups_list">
<columns> <columns>
<!-- column-name name --> <!-- column-name name -->

View File

@ -27,12 +27,16 @@ ConfDialog = interface.get_object('ConfDialog')
transaction_sum = interface.get_object('transaction_sum') transaction_sum = interface.get_object('transaction_sum')
top_label = interface.get_object('top_label') top_label = interface.get_object('top_label')
bottom_label = interface.get_object('bottom_label') bottom_label = interface.get_object('bottom_label')
ChooseDialog = interface.get_object('ChooseDialog')
choose_list = interface.get_object('choose_list')
installed_column.set_sort_column_id(1) installed_column.set_sort_column_id(1)
name_column.set_sort_column_id(0) name_column.set_sort_column_id(0)
transaction.get_handle()
tmp_list = [] tmp_list = []
for repo in config.pacman_conf.initialize_alpm().get_syncdbs(): for repo in transaction.handle.get_syncdbs():
for name, pkgs in repo.grpcache: for name, pkgs in repo.grpcache:
if not name in tmp_list: if not name in tmp_list:
tmp_list.append(name) tmp_list.append(name)
@ -55,13 +59,13 @@ def set_list_dict_search(*patterns):
pkg_name_list = [] pkg_name_list = []
pkg_object_dict = {} pkg_object_dict = {}
pkg_installed_dict = {} pkg_installed_dict = {}
for db in config.pacman_conf.initialize_alpm().get_syncdbs(): for db in transaction.handle.get_syncdbs():
for pkg_object in db.search(*patterns): for pkg_object in db.search(*patterns):
if not pkg_object.name in pkg_name_list: if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name) pkg_name_list.append(pkg_object.name)
pkg_object_dict[pkg_object.name] = pkg_object pkg_object_dict[pkg_object.name] = pkg_object
pkg_installed_dict[pkg_object.name] = False pkg_installed_dict[pkg_object.name] = False
for pkg_object in config.pacman_conf.initialize_alpm().get_localdb().search(*patterns): for pkg_object in transaction.handle.get_localdb().search(*patterns):
if not pkg_object.name in pkg_name_list: if not pkg_object.name in pkg_name_list:
pkg_name_list.append(pkg_object.name) pkg_name_list.append(pkg_object.name)
pkg_installed_dict[pkg_object.name] = True pkg_installed_dict[pkg_object.name] = True
@ -75,7 +79,7 @@ def set_list_dict_group(group):
pkg_name_list = [] pkg_name_list = []
pkg_object_dict = {} pkg_object_dict = {}
pkg_installed_dict = {} pkg_installed_dict = {}
for db in config.pacman_conf.initialize_alpm().get_syncdbs(): for db in transaction.handle.get_syncdbs():
grp = db.read_grp(group) grp = db.read_grp(group)
if grp is not None: if grp is not None:
name, pkg_list = grp name, pkg_list = grp
@ -295,6 +299,42 @@ def handle_reply(reply):
transaction_type = None transaction_type = None
set_packages_list() set_packages_list()
def choose_provides():
to_check = []
depends = []
provides = {}
for pkgname in transaction.to_add:
for repo in transaction.handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg:
to_check.append(pkg)
break
for target in to_check:
for name in target.depends:
depends.append(name)
for installed_pkg in transaction.handle.get_localdb().pkgcache:
if installed_pkg.name in depends:
depends.remove(installed_pkg.name)
for repo in transaction.handle.get_syncdbs():
for pkg in repo.pkgcache:
if pkg.name in depends:
depends.remove(pkg.name)
if depends:
for repo in transaction.handle.get_syncdbs():
for pkg in repo.pkgcache:
for depend in depends:
for name in pkg.provides:
if name == depend:
if not provides.__contains__(depend):
provides[depend] = []
provides.get(depend).append(pkg.name)
if provides:
for virtualdep, liste in provides.items():
choose_list.clear()
for name in liste:
choose_list.append([False, name])
ChooseDialog.show_all()
class Handler: class Handler:
def on_MainWindow_delete_event(self, *arg): def on_MainWindow_delete_event(self, *arg):
transaction.StopDaemon() transaction.StopDaemon()
@ -350,6 +390,7 @@ class Handler:
transaction.t_lock = False transaction.t_lock = False
transaction.get_to_remove() transaction.get_to_remove()
transaction.get_to_add() transaction.get_to_add()
#choose_provides()
transaction.check_conflicts() transaction.check_conflicts()
transaction.Release() transaction.Release()
if len(transaction.to_add) + len(transaction.to_update) + len(transaction.to_remove) != 0: if len(transaction.to_add) + len(transaction.to_update) + len(transaction.to_remove) != 0:
@ -494,6 +535,19 @@ class Handler:
packages_list[line][1] = not packages_list[line][1] packages_list[line][1] = not packages_list[line][1]
packages_list[line][2] = True packages_list[line][2] = True
def on_cellrenderertoggle2_toggled(self, widget, line):
choose_list[line][0] = not choose_list[line][0]
def on_ChooseButton_clicked(self, *arg):
ChooseDialog.hide()
line = 0
while line < len(choose_list):
if choose_list[line][0] is True:
transaction.to_add.append(snap_list[line][1])
elif choose_list[line][0] in transaction.to_add:
transaction.to_add.remove(snap_list[line][1])
line += 1
def main(): def main():
interface.connect_signals(Handler()) interface.connect_signals(Handler())
transaction.do_refresh() transaction.do_refresh()

View File

@ -94,8 +94,6 @@ def check_conflicts():
to_check = [] to_check = []
installed_pkg_name = [] installed_pkg_name = []
syncdbs_pkg_name = [] syncdbs_pkg_name = []
depends = []
provides = {}
warning = '' warning = ''
for pkgname in to_add: for pkgname in to_add:
for repo in handle.get_syncdbs(): for repo in handle.get_syncdbs():
@ -106,8 +104,6 @@ def check_conflicts():
for installed_pkg in handle.get_localdb().pkgcache: for installed_pkg in handle.get_localdb().pkgcache:
installed_pkg_name.append(installed_pkg.name) installed_pkg_name.append(installed_pkg.name)
for target in to_check: for target in to_check:
for name in target.depends:
depends.append(name)
for name in target.replaces: for name in target.replaces:
if name in installed_pkg_name: if name in installed_pkg_name:
if not name in to_remove: if not name in to_remove:
@ -129,7 +125,6 @@ def check_conflicts():
warning = warning+'\n' warning = warning+'\n'
warning = warning+name+' conflicts with '+target.name warning = warning+name+' conflicts with '+target.name
for installed_pkg in handle.get_localdb().pkgcache: for installed_pkg in handle.get_localdb().pkgcache:
if installed_pkg.conflicts:
for name in installed_pkg.conflicts: for name in installed_pkg.conflicts:
if name == target.name: if name == target.name:
if not name in to_remove: if not name in to_remove:
@ -137,8 +132,6 @@ def check_conflicts():
if warning: if warning:
warning = warning+'\n' warning = warning+'\n'
warning = warning+installed_pkg.name+' conflicts with '+target.name warning = warning+installed_pkg.name+' conflicts with '+target.name
if installed_pkg.name in depends:
depends.remove(installed_pkg.name)
for repo in handle.get_syncdbs(): for repo in handle.get_syncdbs():
for pkg in repo.pkgcache: for pkg in repo.pkgcache:
for name in pkg.replaces: for name in pkg.replaces:
@ -150,19 +143,6 @@ def check_conflicts():
warning = warning+name+' will be replaced by '+pkg.name warning = warning+name+' will be replaced by '+pkg.name
if not pkg.name in to_add: if not pkg.name in to_add:
to_add.append(pkg.name) to_add.append(pkg.name)
if pkg.name in depends:
depends.remove(pkg.name)
if depends:
for repo in handle.get_syncdbs():
for pkg in repo.pkgcache:
for depend in depends:
for name in pkg.provides:
if name == depend:
if not provides.__contains__(depend):
provides[depend] = []
provides.get(depend).append(pkg.name)
if provides:
print(provides)
if warning: if warning:
WarningDialog.format_secondary_text(warning) WarningDialog.format_secondary_text(warning)
response = WarningDialog.run() response = WarningDialog.run()

19
test.py Executable file
View File

@ -0,0 +1,19 @@
#! /usr/bin/python
# -*-coding:utf-8 -*-
from pamac import config
syncpkgs = {}
virtualdeps = {}
for repo in config.handle.get_syncdbs():
for pkg in repo.pkgcache:
if not pkg.name in syncpkgs.keys():
syncpkgs[pkg.name] = pkg
for pkg in syncpkgs.values():
for name in pkg.depends:
if (not name in syncpkgs.keys()) and (not '>' in name) and (not '<' in name) and (not '=' in name):
if not virtualdeps.__contains__(name):
virtualdeps[name] = []
virtualdeps.get(name).append(pkg.name)
print(virtualdeps)