forked from cromer/pamac-classic
another try
This commit is contained in:
parent
5ecbbbd9c3
commit
9095ef993c
@ -18,9 +18,6 @@ action_icon = interface.get_object('action_icon')
|
||||
ErrorDialog = interface.get_object('ErrorDialog')
|
||||
WarningDialog = interface.get_object('WarningDialog')
|
||||
QuestionDialog = interface.get_object('QuestionDialog')
|
||||
ConfDialog = interface.get_object('ConfDialog')
|
||||
transaction_desc = interface.get_object('transaction_desc')
|
||||
down_label = interface.get_object('down_label')
|
||||
|
||||
t = None
|
||||
t_lock = False
|
||||
@ -105,74 +102,7 @@ def do_refresh():
|
||||
progress_label.set_text('')
|
||||
progress_bar.set_text('')
|
||||
|
||||
def do_sysupgrade():
|
||||
"""Upgrade a system like pacman -Su"""
|
||||
global t
|
||||
global t_lock
|
||||
global to_remove
|
||||
global to_add
|
||||
global to_update
|
||||
if t_lock is False:
|
||||
if do_syncfirst is True:
|
||||
t = init_transaction(config.handle, recurse = True)
|
||||
for pkg in list_first:
|
||||
t.add_pkg(pkg)
|
||||
to_remove = t.to_remove
|
||||
to_add = t.to_add
|
||||
set_transaction_desc('update')
|
||||
response = ConfDialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
t_finalize(t)
|
||||
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||
ProgressWindow.hide()
|
||||
ConfDialog.hide()
|
||||
t.release()
|
||||
t_lock = False
|
||||
else:
|
||||
try:
|
||||
t = init_transaction(config.handle)
|
||||
t.sysupgrade(downgrade=False)
|
||||
except pyalpm.error:
|
||||
ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||
response = ErrorDialog.run()
|
||||
if response:
|
||||
ErrorDialog.hide()
|
||||
t.release()
|
||||
t_lock = False
|
||||
check_conflicts()
|
||||
to_add = t.to_add
|
||||
to_remove = []
|
||||
for pkg in conflict_to_remove.values():
|
||||
to_remove.append(pkg)
|
||||
if len(to_add) + len(to_remove) == 0:
|
||||
t.release()
|
||||
print("Nothing to update")
|
||||
else:
|
||||
t.release()
|
||||
t = init_transaction(config.handle, noconflicts = True, nodeps = True)
|
||||
for pkg in to_add:
|
||||
t.add_pkg(pkg)
|
||||
for pkg in conflict_to_remove.values():
|
||||
t.remove_pkg(pkg)
|
||||
to_remove = t.to_remove
|
||||
to_add = t.to_add
|
||||
set_transaction_desc('update')
|
||||
if len(transaction_desc) != 0:
|
||||
response = ConfDialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
t_finalize(t)
|
||||
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||
ProgressWindow.hide()
|
||||
ConfDialog.hide()
|
||||
t.release()
|
||||
t_lock = False
|
||||
else:
|
||||
t_finalize(t)
|
||||
t.release()
|
||||
t_lock = False
|
||||
|
||||
def t_finalize(t):
|
||||
ConfDialog.hide()
|
||||
ProgressWindow.show_all()
|
||||
try:
|
||||
t.prepare()
|
||||
@ -181,8 +111,6 @@ def t_finalize(t):
|
||||
response = ErrorDialog.run()
|
||||
if response:
|
||||
ErrorDialog.hide()
|
||||
t.release()
|
||||
t_lock = False
|
||||
try:
|
||||
t.commit()
|
||||
except pyalpm.error:
|
||||
@ -190,7 +118,9 @@ def t_finalize(t):
|
||||
response = ErrorDialog.run()
|
||||
if response:
|
||||
ErrorDialog.hide()
|
||||
t_lock = False
|
||||
ProgressWindow.hide()
|
||||
t.release()
|
||||
|
||||
def get_updates():
|
||||
"""Return a list of package objects in local db which can be updated"""
|
||||
@ -229,46 +159,6 @@ def format_size(size):
|
||||
size_string = '%.2f MiB' % (KiB_size / 1024)
|
||||
return size_string
|
||||
|
||||
def set_transaction_desc(mode):
|
||||
global transaction_desc
|
||||
global down_label
|
||||
global to_add
|
||||
global to_remove
|
||||
global to_update
|
||||
transaction_desc.clear()
|
||||
if to_remove:
|
||||
transaction_desc.append(['To remove:', to_remove[0].name])
|
||||
i = 1
|
||||
while i < len(to_remove):
|
||||
transaction_desc.append([' ', to_remove[i].name])
|
||||
i += 1
|
||||
down_label.set_markup('')
|
||||
if to_add:
|
||||
installed_name = []
|
||||
for pkg_object in config.handle.get_localdb().pkgcache:
|
||||
installed_name.append(pkg_object.name)
|
||||
to_add_name = []
|
||||
for pkg_object in to_add:
|
||||
to_add_name.append(pkg_object.name)
|
||||
to_update = sorted(set(installed_name).intersection(to_add_name))
|
||||
to_remove_from_add_name = sorted(set(to_update).intersection(to_add_name))
|
||||
for name in to_remove_from_add_name:
|
||||
to_add_name.remove(name)
|
||||
if to_add_name:
|
||||
transaction_desc.append(['To install:', to_add_name[0]])
|
||||
i = 1
|
||||
while i < len(to_add_name):
|
||||
transaction_desc.append([' ', to_add_name[i]])
|
||||
i += 1
|
||||
if mode == 'normal':
|
||||
if to_update:
|
||||
transaction_desc.append(['To update:', to_update[0]])
|
||||
i = 1
|
||||
while i < len(to_update):
|
||||
transaction_desc.append([' ', to_update[i]])
|
||||
i += 1
|
||||
down_label.set_markup('')
|
||||
# down_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
||||
|
||||
# Callbacks
|
||||
event_text = ' '
|
||||
|
@ -6,22 +6,26 @@ from gi.repository import Gtk
|
||||
import pyalpm
|
||||
from os import geteuid
|
||||
|
||||
from backend import transaction
|
||||
from backend import config, transaction
|
||||
|
||||
interface = Gtk.Builder()
|
||||
interface.add_from_file('/usr/share/pamac/pamac_update.glade')
|
||||
interface.add_from_file('/usr/share/pamac/dialogs.glade')
|
||||
|
||||
update_listore = interface.get_object('update_list')
|
||||
ConfDialog = interface.get_object('ConfDialog')
|
||||
transaction_add = interface.get_object('transaction_add')
|
||||
top_label = interface.get_object('top_label')
|
||||
bottom_label = interface.get_object('bottom_label')
|
||||
update_listore = interface.get_object('update_list')
|
||||
update_label = interface.get_object('update_label')
|
||||
|
||||
def have_updates():
|
||||
available_updates = transaction.get_updates()
|
||||
update_listore.clear()
|
||||
top_label.set_justify(Gtk.Justification.CENTER)
|
||||
update_label.set_justify(Gtk.Justification.CENTER)
|
||||
if not available_updates:
|
||||
update_listore.append(["", ""])
|
||||
top_label.set_markup("<big><b>No update available</b></big>")
|
||||
update_label.set_markup("<big><b>No update available</b></big>")
|
||||
return False
|
||||
else:
|
||||
for pkg in available_updates:
|
||||
@ -29,9 +33,91 @@ def have_updates():
|
||||
newversion = transaction.get_new_version_available(pkgname)
|
||||
pkgname = pkg.name+" "+newversion
|
||||
update_listore.append([pkgname, transaction.format_size(pkg.size)])
|
||||
top_label.set_markup("<big><b>Available updates</b></big>")
|
||||
update_label.set_markup("<big><b>Available updates</b></big>")
|
||||
return True
|
||||
|
||||
def set_transaction_add():
|
||||
transaction_add.clear()
|
||||
if transaction.to_remove:
|
||||
transaction_add.append(['To remove:', transaction.to_remove[0].name])
|
||||
i = 1
|
||||
while i < len(transaction.to_remove):
|
||||
transaction_add.append([' ', transaction.to_remove[i].name])
|
||||
i += 1
|
||||
bottom_label.set_markup('')
|
||||
if transaction.to_add:
|
||||
installed_name = []
|
||||
for pkg_object in config.handle.get_localdb().pkgcache:
|
||||
installed_name.append(pkg_object.name)
|
||||
to_add_name = []
|
||||
for pkg_object in transaction.to_add:
|
||||
to_add_name.append(pkg_object.name)
|
||||
transaction.to_update = sorted(set(installed_name).intersection(to_add_name))
|
||||
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(to_add_name))
|
||||
for name in to_remove_from_add_name:
|
||||
to_add_name.remove(name)
|
||||
if to_add_name:
|
||||
transaction_add.append(['To install:', to_add_name[0]])
|
||||
i = 1
|
||||
while i < len(to_add_name):
|
||||
transaction_add.append([' ', to_add_name[i]])
|
||||
i += 1
|
||||
if transaction.to_update:
|
||||
transaction_add.append(['To update:', transaction.to_update[0]])
|
||||
i = 1
|
||||
while i < len(transaction.to_update):
|
||||
transaction_add.append([' ', transaction.to_update[i]])
|
||||
i += 1
|
||||
bottom_label.set_markup('')
|
||||
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
||||
top_label.set_markup('<big><b>Additionnal Transaction(s)</b></big>')
|
||||
|
||||
def do_sysupgrade():
|
||||
"""Upgrade a system like pacman -Su"""
|
||||
if transaction.t_lock is False:
|
||||
if transaction.do_syncfirst is True:
|
||||
transaction.t = transaction.init_transaction(config.handle, recurse = True)
|
||||
for pkg in list_first:
|
||||
transaction.t.add_pkg(pkg)
|
||||
transaction.to_remove = transaction.t.to_remove
|
||||
transaction.to_add = transaction.t.to_add
|
||||
set_transaction_add()
|
||||
ConfDialog.show_all()
|
||||
else:
|
||||
try:
|
||||
transaction.t = transaction.init_transaction(config.handle)
|
||||
transaction.t.sysupgrade(downgrade=False)
|
||||
except pyalpm.error:
|
||||
ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||
response = ErrorDialog.run()
|
||||
if response:
|
||||
ErrorDialog.hide()
|
||||
transaction.t.release()
|
||||
transaction.t_lock = False
|
||||
transaction.check_conflicts()
|
||||
transaction.to_add = transaction.t.to_add
|
||||
transaction.to_remove = []
|
||||
for pkg in transaction.conflict_to_remove.values():
|
||||
transaction.to_remove.append(pkg)
|
||||
if len(transaction.to_add) + len(transaction.to_remove) == 0:
|
||||
transaction.t.release()
|
||||
transaction.t_lock = False
|
||||
print("Nothing to update")
|
||||
else:
|
||||
transaction.t.release()
|
||||
transaction.t = transaction.init_transaction(config.handle, noconflicts = True, nodeps = True)
|
||||
for pkg in transaction.to_add:
|
||||
transaction.t.add_pkg(pkg)
|
||||
for pkg in transaction.conflict_to_remove.values():
|
||||
transaction.t.remove_pkg(pkg)
|
||||
transaction.to_remove = transaction.t.to_remove
|
||||
transaction.to_add = transaction.t.to_add
|
||||
set_transaction_add()
|
||||
if len(transaction.to_update) + len(transaction.to_remove) != 0:
|
||||
ConfDialog.show_all()
|
||||
else:
|
||||
transaction.t_finalize(t)
|
||||
|
||||
class Handler:
|
||||
def on_UpdateWindow_delete_event(self, *arg):
|
||||
Gtk.main_quit()
|
||||
@ -40,13 +126,22 @@ class Handler:
|
||||
Gtk.main_quit()
|
||||
|
||||
def on_ApplyButton_clicked(self, *arg):
|
||||
transaction.do_sysupgrade()
|
||||
do_sysupgrade()
|
||||
have_updates()
|
||||
|
||||
def on_RefreshButton_clicked(self, *arg):
|
||||
transaction.do_refresh()
|
||||
have_updates()
|
||||
|
||||
def on_TransCancelButton_clicked(self, *arg):
|
||||
ConfDialog.hide()
|
||||
transaction.t_lock = False
|
||||
transaction.t.release()
|
||||
|
||||
def on_TransValidButton_clicked(self, *arg):
|
||||
ConfDialog.hide()
|
||||
transaction.t_finalize(t)
|
||||
|
||||
def main():
|
||||
have_updates()
|
||||
interface.connect_signals(Handler())
|
||||
|
@ -1,113 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkMessageDialog" id="ConfDialog">
|
||||
<property name="width_request">250</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="default_width">200</property>
|
||||
<property name="default_height">100</property>
|
||||
<property name="icon">/usr/share/icons/hicolor/22x22/status/package-info.png</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="deletable">False</property>
|
||||
<property name="message_type">other</property>
|
||||
<property name="buttons">ok-cancel</property>
|
||||
<property name="text" translatable="yes"><b>Transaction summary</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="messagedialog-vbox3">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="messagedialog-action_area3">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow4">
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">transaction_desc</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="search_column">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_action">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext5">
|
||||
<property name="yalign">0</property>
|
||||
<property name="weight">600</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_packages">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
||||
<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">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="down_label">
|
||||
<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">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkMessageDialog" id="ErrorDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
@ -279,12 +172,4 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="transaction_desc">
|
||||
<columns>
|
||||
<!-- column-name action -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name packages -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
|
160
gui/pamac.glade
160
gui/pamac.glade
@ -1,11 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkListStore" id="groups_list">
|
||||
<columns>
|
||||
<!-- column-name name -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<object class="GtkWindow" id="ConfDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes"> </property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">350</property>
|
||||
<property name="default_height">250</property>
|
||||
<property name="icon">/usr/share/icons/hicolor/22x22/status/package-info.png</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="deletable">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="top_label">
|
||||
<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="scrolledwindow4">
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">transaction_sum</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="search_column">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_action">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext5">
|
||||
<property name="yalign">0</property>
|
||||
<property name="weight">600</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_packages">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
||||
<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="GtkLabel" id="bottom_label">
|
||||
<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">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="buttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="TransCancelButton">
|
||||
<property name="label">gtk-cancel</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_TransCancelButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="TransValidButton">
|
||||
<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_TransValidButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="MainWindow">
|
||||
<property name="width_request">800</property>
|
||||
@ -366,6 +502,12 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="groups_list">
|
||||
<columns>
|
||||
<!-- column-name name -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkListStore" id="package_desc">
|
||||
<columns>
|
||||
<!-- column-name info_type -->
|
||||
@ -397,4 +539,12 @@
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="transaction_sum">
|
||||
<columns>
|
||||
<!-- column-name action -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name packages -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -1,6 +1,148 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkWindow" id="ConfDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes"> </property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">350</property>
|
||||
<property name="default_height">250</property>
|
||||
<property name="icon">/usr/share/icons/hicolor/22x22/status/package-info.png</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="deletable">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="top_label1">
|
||||
<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="scrolledwindow4">
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">120</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">transaction_add</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="search_column">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection6"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_action">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext5">
|
||||
<property name="yalign">0</property>
|
||||
<property name="weight">600</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="_packages">
|
||||
<property name="title" translatable="yes">column</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext6"/>
|
||||
<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="GtkLabel" id="bottom_label">
|
||||
<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">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="buttonbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="TransCancelButton">
|
||||
<property name="label">gtk-cancel</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_TransCancelButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="TransValidButton">
|
||||
<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_TransValidButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="UpdateWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Update Manager</property>
|
||||
@ -77,7 +219,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="top_label">
|
||||
<object class="GtkLabel" id="update_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">label</property>
|
||||
@ -150,6 +292,14 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="transaction_add">
|
||||
<columns>
|
||||
<!-- column-name action -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name packages -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkListStore" id="update_list">
|
||||
<columns>
|
||||
<!-- column-name name -->
|
||||
|
125
pamac
125
pamac
@ -25,6 +25,11 @@ tree2 = interface.get_object('treeview2_selection')
|
||||
tree1 = interface.get_object('treeview1_selection')
|
||||
installed_column = interface.get_object('installed_column')
|
||||
name_column = interface.get_object('name_column')
|
||||
ConfDialog = interface.get_object('ConfDialog')
|
||||
transaction_sum = interface.get_object('transaction_sum')
|
||||
top_label = interface.get_object('top_label')
|
||||
bottom_label = interface.get_object('bottom_label')
|
||||
|
||||
installed_column.set_sort_column_id(1)
|
||||
name_column.set_sort_column_id(0)
|
||||
|
||||
@ -186,6 +191,42 @@ def set_desc(pkg, style):
|
||||
else:
|
||||
package_desc.append(['Backup files:', '\n'.join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])])
|
||||
|
||||
def set_transaction_sum():
|
||||
transaction_sum.clear()
|
||||
if transaction.to_remove:
|
||||
transaction_sum.append(['To remove:', transaction.to_remove[0].name])
|
||||
i = 1
|
||||
while i < len(transaction.to_remove):
|
||||
transaction_sum.append([' ', transaction.to_remove[i].name])
|
||||
i += 1
|
||||
bottom_label.set_markup('')
|
||||
if transaction.to_add:
|
||||
installed_name = []
|
||||
for pkg_object in config.handle.get_localdb().pkgcache:
|
||||
installed_name.append(pkg_object.name)
|
||||
to_add_name = []
|
||||
for pkg_object in transaction.to_add:
|
||||
to_add_name.append(pkg_object.name)
|
||||
transaction.to_update = sorted(set(installed_name).intersection(to_add_name))
|
||||
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(to_add_name))
|
||||
for name in to_remove_from_add_name:
|
||||
to_add_name.remove(name)
|
||||
if to_add_name:
|
||||
transaction_sum.append(['To install:', to_add_name[0]])
|
||||
i = 1
|
||||
while i < len(to_add_name):
|
||||
transaction_sum.append([' ', to_add_name[i]])
|
||||
i += 1
|
||||
if transaction.to_update:
|
||||
transaction_sum.append(['To update:', transaction.to_update[0]])
|
||||
i = 1
|
||||
while i < len(transaction.to_update):
|
||||
transaction_sum.append([' ', transaction.to_update[i]])
|
||||
i += 1
|
||||
bottom_label.set_markup('')
|
||||
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
||||
top_label.set_markup('<big><b>Transaction Summary</b></big>')
|
||||
|
||||
class Handler:
|
||||
def on_MainWindow_delete_event(self, *arg):
|
||||
Gtk.main_quit()
|
||||
@ -209,7 +250,7 @@ class Handler:
|
||||
transaction.ErrorDialog.hide()
|
||||
else:
|
||||
if transaction.t_lock is True:
|
||||
pass
|
||||
print('Transaction locked')
|
||||
else:
|
||||
if transaction_type is "remove":
|
||||
transaction.t = transaction.init_transaction(config.handle, cascade = True)
|
||||
@ -226,27 +267,8 @@ class Handler:
|
||||
transaction.t_lock = False
|
||||
transaction.to_remove = transaction.t.to_remove
|
||||
transaction.to_add = transaction.t.to_add
|
||||
transaction.set_transaction_desc('normal')
|
||||
response = transaction.ConfDialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
transaction.ConfDialog.hide()
|
||||
transaction.ProgressWindow.show_all()
|
||||
try:
|
||||
transaction.t.commit()
|
||||
except pyalpm.error:
|
||||
transaction.ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||
response = transaction.ErrorDialog.run()
|
||||
if response:
|
||||
transaction.ErrorDialog.hide()
|
||||
transaction_dict.clear()
|
||||
transaction_type = None
|
||||
set_packages_list()
|
||||
transaction.ProgressWindow.hide()
|
||||
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||
transaction.ProgressWindow.hide()
|
||||
transaction.ConfDialog.hide()
|
||||
transaction.t.release()
|
||||
transaction.t_lock = False
|
||||
set_transaction_sum()
|
||||
ConfDialog.show_all()
|
||||
if transaction_type is "install":
|
||||
transaction.t = transaction.init_transaction(config.handle, noconflicts = True)
|
||||
for pkg in transaction_dict.values():
|
||||
@ -267,27 +289,8 @@ class Handler:
|
||||
for pkg in transaction.conflict_to_remove.values():
|
||||
transaction.to_remove.append(pkg)
|
||||
transaction.t.release()
|
||||
transaction.set_transaction_desc('normal')
|
||||
response = transaction.ConfDialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
transaction.ConfDialog.hide()
|
||||
transaction.t = transaction.init_transaction(config.handle, noconflicts = True, nodeps = True)
|
||||
print(transaction.to_add, transaction.to_remove)
|
||||
for pkg in transaction.to_add:
|
||||
print(pkg)
|
||||
transaction.t.add_pkg(pkg)
|
||||
for pkg in transaction.to_remove:
|
||||
print(pkg)
|
||||
transaction.t.remove_pkg(pkg)
|
||||
transaction.t_finalize(transaction.t)
|
||||
transaction_dict.clear()
|
||||
transaction_type = None
|
||||
set_packages_list()
|
||||
if response == Gtk.ResponseType.CANCEL or Gtk.ResponseType.CLOSE or Gtk.ResponseType.DELETE_EVENT:
|
||||
transaction.ProgressWindow.hide()
|
||||
transaction.ConfDialog.hide()
|
||||
transaction.t.release()
|
||||
transaction.t_lock = False
|
||||
set_transaction_sum()
|
||||
ConfDialog.show_all()
|
||||
|
||||
def on_EraseButton_clicked(self, *arg):
|
||||
global transaction_type
|
||||
@ -300,6 +303,42 @@ class Handler:
|
||||
transaction.do_refresh()
|
||||
refresh_packages_list()
|
||||
|
||||
def on_TransCancelButton_clicked(self, *arg):
|
||||
ConfDialog.hide()
|
||||
transaction.t_lock = False
|
||||
try:
|
||||
transaction.t.release()
|
||||
except:
|
||||
pass
|
||||
|
||||
def on_TransValidButton_clicked(self, *arg):
|
||||
global transaction_type
|
||||
ConfDialog.hide()
|
||||
if transaction_type is "remove":
|
||||
transaction.ProgressWindow.show_all()
|
||||
try:
|
||||
transaction.t.commit()
|
||||
except pyalpm.error:
|
||||
transaction.ErrorDialog.format_secondary_text(traceback.format_exc())
|
||||
response = transaction.ErrorDialog.run()
|
||||
if response:
|
||||
transaction.ErrorDialog.hide()
|
||||
transaction_dict.clear()
|
||||
transaction_type = None
|
||||
set_packages_list()
|
||||
transaction.ProgressWindow.hide()
|
||||
if transaction_type is "install":
|
||||
transaction.t = transaction.init_transaction(config.handle, noconflicts = True, nodeps = True)
|
||||
for pkg in transaction.to_add:
|
||||
transaction.t.add_pkg(pkg)
|
||||
for pkg in transaction.to_remove:
|
||||
transaction.t.remove_pkg(pkg)
|
||||
transaction.t_finalize(transaction.t)
|
||||
transaction_dict.clear()
|
||||
transaction_type = None
|
||||
set_packages_list()
|
||||
transaction.t_lock = False
|
||||
|
||||
def on_search_button_clicked(self, widget):
|
||||
global list_dict
|
||||
list_dict = "search"
|
||||
|
Loading…
Reference in New Issue
Block a user