first release using dbus
This commit is contained in:
parent
faf63b6780
commit
5974e58935
@ -6,9 +6,12 @@
|
|||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="title" translatable="yes"> </property>
|
<property name="title" translatable="yes"> </property>
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
|
<property name="modal">True</property>
|
||||||
<property name="window_position">center-on-parent</property>
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="urgency_hint">True</property>
|
||||||
|
<property name="has_resize_grip">False</property>
|
||||||
<property name="message_type">error</property>
|
<property name="message_type">error</property>
|
||||||
<property name="buttons">ok</property>
|
<property name="buttons">ok</property>
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
@ -39,12 +42,13 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<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="window_position">center</property>
|
<property name="modal">True</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>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
|
<property name="has_resize_grip">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box7">
|
<object class="GtkBox" id="box7">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -54,6 +58,7 @@
|
|||||||
<property name="margin_top">5</property>
|
<property name="margin_top">5</property>
|
||||||
<property name="margin_bottom">5</property>
|
<property name="margin_bottom">5</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">3</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box1">
|
<object class="GtkBox" id="box1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -97,7 +102,7 @@
|
|||||||
<property name="pulse_step">0.050000000000000003</property>
|
<property name="pulse_step">0.050000000000000003</property>
|
||||||
<property name="text" translatable="yes"> </property>
|
<property name="text" translatable="yes"> </property>
|
||||||
<property name="show_text">True</property>
|
<property name="show_text">True</property>
|
||||||
<property name="ellipsize">middle</property>
|
<property name="ellipsize">end</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -105,6 +110,33 @@
|
|||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButtonBox" id="buttonbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="layout_style">end</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="ProgressCancelButton">
|
||||||
|
<property name="label">gtk-cancel</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<signal name="clicked" handler="on_ProgressCancelButton_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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
<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>
|
||||||
<property name="window_position">center</property>
|
<property name="modal">True</property>
|
||||||
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="default_width">350</property>
|
<property name="default_width">350</property>
|
||||||
<property name="default_height">250</property>
|
<property name="default_height">250</property>
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
||||||
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="urgency_hint">True</property>
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box7">
|
<object class="GtkBox" id="box7">
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
<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>
|
||||||
<property name="window_position">center</property>
|
<property name="modal">True</property>
|
||||||
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="default_width">350</property>
|
<property name="default_width">350</property>
|
||||||
<property name="default_height">250</property>
|
<property name="default_height">250</property>
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
||||||
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="urgency_hint">True</property>
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box7">
|
<object class="GtkBox" id="box7">
|
||||||
@ -162,6 +165,21 @@
|
|||||||
<property name="has_focus">True</property>
|
<property name="has_focus">True</property>
|
||||||
<property name="spacing">5</property>
|
<property name="spacing">5</property>
|
||||||
<property name="layout_style">end</property>
|
<property name="layout_style">end</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="RefreshButton">
|
||||||
|
<property name="label">gtk-refresh</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_RefreshButton_clicked" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="ApplyButton">
|
<object class="GtkButton" id="ApplyButton">
|
||||||
<property name="label">gtk-apply</property>
|
<property name="label">gtk-apply</property>
|
||||||
@ -239,8 +257,8 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
<property name="width_request">300</property>
|
<property name="width_request">400</property>
|
||||||
<property name="height_request">420</property>
|
<property name="height_request">450</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
|
0
pamac/__init__.py
Normal file → Executable file
0
pamac/__init__.py
Normal file → Executable file
0
pamac/common.py
Normal file → Executable file
0
pamac/common.py
Normal file → Executable file
0
pamac/config.py
Normal file → Executable file
0
pamac/config.py
Normal file → Executable file
18
pamac/manager.py
Normal file → Executable file
18
pamac/manager.py
Normal file → Executable file
@ -14,7 +14,7 @@ from pamac import config, common, transaction
|
|||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
|
||||||
MainWindow = interface.get_object("MainWindow")
|
MainWindow = interface.get_object("MainWindow")
|
||||||
|
|
||||||
@ -128,6 +128,7 @@ def refresh_packages_list():
|
|||||||
|
|
||||||
def set_packages_list():
|
def set_packages_list():
|
||||||
global list_dict
|
global list_dict
|
||||||
|
transaction.get_handle()
|
||||||
if list_dict == "search":
|
if list_dict == "search":
|
||||||
search_strings_list = search_entry.get_text().split()
|
search_strings_list = search_entry.get_text().split()
|
||||||
set_list_dict_search(*search_strings_list)
|
set_list_dict_search(*search_strings_list)
|
||||||
@ -246,6 +247,11 @@ def handle_error(error):
|
|||||||
def handle_reply(reply):
|
def handle_reply(reply):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
|
if str(reply):
|
||||||
|
transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply))
|
||||||
|
response = transaction.ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
transaction.ErrorDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
@ -257,24 +263,20 @@ def handle_reply(reply):
|
|||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
def on_MainWindow_delete_event(self, *arg):
|
def on_MainWindow_delete_event(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
else:
|
||||||
MainWindow.hide()
|
MainWindow.hide()
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
def on_QuitButton_clicked(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
else:
|
||||||
MainWindow.hide()
|
MainWindow.hide()
|
||||||
|
|
||||||
def on_ValidButton_clicked(self, *arg):
|
def on_ValidButton_clicked(self, *arg):
|
||||||
#if not geteuid() == 0:
|
|
||||||
#transaction.ErrorDialog.format_secondary_text("You need to be root to run packages transactions")
|
|
||||||
#response = transaction.ErrorDialog.run()
|
|
||||||
#if response:
|
|
||||||
#transaction.ErrorDialog.hide()
|
|
||||||
#el
|
|
||||||
if not transaction_dict:
|
if not transaction_dict:
|
||||||
transaction.ErrorDialog.format_secondary_text("No package is selected")
|
transaction.ErrorDialog.format_secondary_text("No package is selected")
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.ErrorDialog.run()
|
||||||
@ -337,6 +339,8 @@ class Handler:
|
|||||||
|
|
||||||
def on_TransValidButton_clicked(self, *arg):
|
def on_TransValidButton_clicked(self, *arg):
|
||||||
ConfDialog.hide()
|
ConfDialog.hide()
|
||||||
|
progress_label.set_text('Preparing...')
|
||||||
|
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
if transaction_type is "remove":
|
if transaction_type is "remove":
|
||||||
|
27
pamac/pamac-daemon.py
Normal file → Executable file
27
pamac/pamac-daemon.py
Normal file → Executable file
@ -18,12 +18,18 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
self.t = None
|
self.t = None
|
||||||
self.error = ''
|
self.error = ''
|
||||||
self.warning = ''
|
self.warning = ''
|
||||||
self.action = ''
|
self.action = 'Preparing...'
|
||||||
self.icon = ''
|
self.icon = '/usr/share/pamac/icons/24x24/status/setup.png'
|
||||||
self.target = ''
|
self.target = ''
|
||||||
self.percent = 0
|
self.percent = 0
|
||||||
self.total_size = 0
|
self.total_size = 0
|
||||||
self.already_transferred = 0
|
self.already_transferred = 0
|
||||||
|
config.handle.dlcb = self.cb_dl
|
||||||
|
config.handle.totaldlcb = self.totaldlcb
|
||||||
|
config.handle.eventcb = self.cb_event
|
||||||
|
config.handle.questioncb = self.cb_conv
|
||||||
|
config.handle.progresscb = self.cb_progress
|
||||||
|
config.handle.logcb = self.cb_log
|
||||||
|
|
||||||
@dbus.service.signal('org.manjaro.pamac')
|
@dbus.service.signal('org.manjaro.pamac')
|
||||||
def EmitAction(self, action):
|
def EmitAction(self, action):
|
||||||
@ -116,6 +122,9 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
self.already_transferred += size
|
self.already_transferred += size
|
||||||
self.action = 'Downloading '+common.format_size(self.total_size)
|
self.action = 'Downloading '+common.format_size(self.total_size)
|
||||||
self.target = _target
|
self.target = _target
|
||||||
|
if fraction > 1:
|
||||||
|
self.percent = 0
|
||||||
|
else:
|
||||||
self.percent = fraction
|
self.percent = fraction
|
||||||
self.icon = '/usr/share/pamac/icons/24x24/status/package-download.png'
|
self.icon = '/usr/share/pamac/icons/24x24/status/package-download.png'
|
||||||
else:
|
else:
|
||||||
@ -152,16 +161,10 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global t
|
global t
|
||||||
global error
|
global error
|
||||||
error = ''
|
error = ''
|
||||||
config.handle.dlcb = self.cb_dl
|
|
||||||
config.handle.totaldlcb = self.totaldlcb
|
|
||||||
config.handle.eventcb = self.cb_event
|
|
||||||
config.handle.questioncb = self.cb_conv
|
|
||||||
config.handle.progresscb = self.cb_progress
|
|
||||||
config.handle.logcb = self.cb_log
|
|
||||||
for db in config.handle.get_syncdbs():
|
for db in config.handle.get_syncdbs():
|
||||||
try:
|
try:
|
||||||
t = config.handle.init_transaction()
|
t = config.handle.init_transaction()
|
||||||
db.update(force=True)
|
db.update(force=False)
|
||||||
print('refresh')
|
print('refresh')
|
||||||
t.release()
|
t.release()
|
||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
@ -175,12 +178,6 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
global error
|
global error
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
||||||
error = ''
|
error = ''
|
||||||
config.handle.dlcb = self.cb_dl
|
|
||||||
config.handle.totaldlcb = self.totaldlcb
|
|
||||||
config.handle.eventcb = self.cb_event
|
|
||||||
config.handle.questioncb = self.cb_conv
|
|
||||||
config.handle.progresscb = self.cb_progress
|
|
||||||
config.handle.logcb = self.cb_log
|
|
||||||
try:
|
try:
|
||||||
t = config.handle.init_transaction(**options)
|
t = config.handle.init_transaction(**options)
|
||||||
print('Init:',t.flags)
|
print('Init:',t.flags)
|
||||||
|
90
pamac/transaction.py
Normal file → Executable file
90
pamac/transaction.py
Normal file → Executable file
@ -19,6 +19,7 @@ ProgressWindow = interface.get_object('ProgressWindow')
|
|||||||
progress_bar = interface.get_object('progressbar2')
|
progress_bar = interface.get_object('progressbar2')
|
||||||
progress_label = interface.get_object('progresslabel2')
|
progress_label = interface.get_object('progresslabel2')
|
||||||
action_icon = interface.get_object('action_icon')
|
action_icon = interface.get_object('action_icon')
|
||||||
|
ProgressCancelButton = interface.get_object('ProgressCancelButton')
|
||||||
|
|
||||||
t_lock = False
|
t_lock = False
|
||||||
do_syncfirst = False
|
do_syncfirst = False
|
||||||
@ -26,6 +27,11 @@ list_first = []
|
|||||||
to_remove = []
|
to_remove = []
|
||||||
to_add = []
|
to_add = []
|
||||||
to_update = []
|
to_update = []
|
||||||
|
handle = None
|
||||||
|
|
||||||
|
def get_handle():
|
||||||
|
global handle
|
||||||
|
handle = config.pacman_conf.initialize_alpm()
|
||||||
|
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
@ -40,9 +46,16 @@ To_Remove = proxy.get_dbus_method('To_Remove','org.manjaro.pamac')
|
|||||||
To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac')
|
To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac')
|
||||||
Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac')
|
Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac')
|
||||||
Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
||||||
|
StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
|
||||||
|
|
||||||
def action_signal_handler(action):
|
def action_signal_handler(action):
|
||||||
progress_label.set_text(action)
|
progress_label.set_text(action)
|
||||||
|
#~ if 'Downloading' in action:
|
||||||
|
#~ print('cancel enabled')
|
||||||
|
#~ ProgressCancelButton.set_visible(True)
|
||||||
|
#~ else:
|
||||||
|
ProgressCancelButton.set_visible(False)
|
||||||
|
#~ print('cancel disabled')
|
||||||
|
|
||||||
def icon_signal_handler(icon):
|
def icon_signal_handler(icon):
|
||||||
action_icon.set_from_file(icon)
|
action_icon.set_from_file(icon)
|
||||||
@ -51,6 +64,9 @@ def target_signal_handler(target):
|
|||||||
progress_bar.set_text(target)
|
progress_bar.set_text(target)
|
||||||
|
|
||||||
def percent_signal_handler(percent):
|
def percent_signal_handler(percent):
|
||||||
|
if percent == '0':
|
||||||
|
progress_bar.pulse()
|
||||||
|
else:
|
||||||
progress_bar.set_fraction(float(percent))
|
progress_bar.set_fraction(float(percent))
|
||||||
|
|
||||||
bus.add_signal_receiver(action_signal_handler, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAction")
|
bus.add_signal_receiver(action_signal_handler, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAction")
|
||||||
@ -61,7 +77,7 @@ bus.add_signal_receiver(percent_signal_handler, dbus_interface = "org.manjaro.pa
|
|||||||
def init_transaction(**options):
|
def init_transaction(**options):
|
||||||
"Transaction initialization"
|
"Transaction initialization"
|
||||||
global t_lock
|
global t_lock
|
||||||
error = Init(options)
|
error = Init(dbus.Dictionary(options, signature='sb'))
|
||||||
if not error:
|
if not error:
|
||||||
t_lock = True
|
t_lock = True
|
||||||
return True
|
return True
|
||||||
@ -78,7 +94,7 @@ def check_conflicts():
|
|||||||
to_check = []
|
to_check = []
|
||||||
warning = ''
|
warning = ''
|
||||||
for pkgname in to_add:
|
for pkgname in to_add:
|
||||||
for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
|
for repo in handle.get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg:
|
if pkg:
|
||||||
to_check.append(pkg)
|
to_check.append(pkg)
|
||||||
@ -86,7 +102,7 @@ def check_conflicts():
|
|||||||
for target in to_check:
|
for target in to_check:
|
||||||
if target.replaces:
|
if target.replaces:
|
||||||
for name in target.replaces:
|
for name in target.replaces:
|
||||||
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
pkg = handle.get_localdb().get_pkg(name)
|
||||||
if pkg:
|
if pkg:
|
||||||
if not pkg.name in to_remove:
|
if not pkg.name in to_remove:
|
||||||
to_remove.append(pkg.name)
|
to_remove.append(pkg.name)
|
||||||
@ -95,11 +111,11 @@ def check_conflicts():
|
|||||||
warning = warning+pkg.name+' will be replaced by '+target.name
|
warning = warning+pkg.name+' will be replaced by '+target.name
|
||||||
if target.conflicts:
|
if target.conflicts:
|
||||||
for name in target.conflicts:
|
for name in target.conflicts:
|
||||||
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
pkg = handle.get_localdb().get_pkg(name)
|
||||||
if pkg:
|
if pkg:
|
||||||
if not pkg.name in to_remove:
|
if not pkg.name in to_remove:
|
||||||
to_remove.append(pkg.name)
|
to_remove.append(pkg.name)
|
||||||
for installed_pkg in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
|
for installed_pkg in handle.get_localdb().pkgcache:
|
||||||
if installed_pkg.conflicts:
|
if installed_pkg.conflicts:
|
||||||
for name in installed_pkg.conflicts:
|
for name in installed_pkg.conflicts:
|
||||||
if name == target.name:
|
if name == target.name:
|
||||||
@ -119,83 +135,49 @@ def get_to_add():
|
|||||||
global to_add
|
global to_add
|
||||||
to_add = To_Add()
|
to_add = To_Add()
|
||||||
|
|
||||||
def finalize():
|
def do_refresh():
|
||||||
|
"""Sync databases like pacman -Sy"""
|
||||||
global t_lock
|
global t_lock
|
||||||
error = Prepare()
|
ProgressWindow.show_all()
|
||||||
|
print('show')
|
||||||
|
if t_lock is False:
|
||||||
|
t_lock = True
|
||||||
|
ProgressWindow.show_all()
|
||||||
|
error = Refresh(timeout = 2000*1000)
|
||||||
if error:
|
if error:
|
||||||
ErrorDialog.format_secondary_text(error)
|
ErrorDialog.format_secondary_text(error)
|
||||||
response = ErrorDialog.run()
|
response = ErrorDialog.run()
|
||||||
if response:
|
if response:
|
||||||
ErrorDialog.hide()
|
ErrorDialog.hide()
|
||||||
Release()
|
Release()
|
||||||
t_lock = False
|
|
||||||
else:
|
|
||||||
ProgressWindow.show_all()
|
|
||||||
while Gtk.events_pending():
|
|
||||||
Gtk.main_iteration()
|
|
||||||
Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
|
|
||||||
def handle_error(error):
|
|
||||||
global t_lock
|
|
||||||
global to_add
|
|
||||||
global to_remove
|
|
||||||
if not 'DBus.Error.NoReply' in str(error):
|
|
||||||
ErrorDialog.format_secondary_text('Commit Error:\n'+str(error))
|
|
||||||
response = ErrorDialog.run()
|
|
||||||
if response:
|
|
||||||
ErrorDialog.hide()
|
|
||||||
t_lock = False
|
|
||||||
Release()
|
|
||||||
ProgressWindow.hide()
|
ProgressWindow.hide()
|
||||||
to_add = []
|
print('hide')
|
||||||
to_remove = []
|
|
||||||
|
|
||||||
def handle_reply(reply):
|
|
||||||
global t_lock
|
|
||||||
global to_add
|
|
||||||
global to_remove
|
|
||||||
print('reply',reply)
|
|
||||||
t_lock = False
|
t_lock = False
|
||||||
Release()
|
|
||||||
ProgressWindow.hide()
|
|
||||||
to_add = []
|
|
||||||
to_remove = []
|
|
||||||
|
|
||||||
def do_refresh():
|
|
||||||
"""Sync databases like pacman -Sy"""
|
|
||||||
global t
|
|
||||||
global t_lock
|
|
||||||
if t_lock is False:
|
|
||||||
progress_label.set_text('Refreshing...')
|
|
||||||
progress_bar.pulse()
|
|
||||||
action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
|
|
||||||
ProgressWindow.show_all()
|
|
||||||
t_lock = True
|
|
||||||
Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
|
||||||
|
|
||||||
def get_updates():
|
def get_updates():
|
||||||
"""Return a list of package objects in local db which can be updated"""
|
"""Return a list of package objects in local db which can be updated"""
|
||||||
global do_syncfirst
|
global do_syncfirst
|
||||||
global list_first
|
global list_first
|
||||||
|
get_handle()
|
||||||
if config.syncfirst:
|
if config.syncfirst:
|
||||||
for name in config.syncfirst:
|
for name in config.syncfirst:
|
||||||
pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
|
pkg = handle.get_localdb().get_pkg(name)
|
||||||
candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
list_first.append(candidate)
|
list_first.append(candidate)
|
||||||
if list_first:
|
if list_first:
|
||||||
do_syncfirst = True
|
do_syncfirst = True
|
||||||
return list_first
|
return list_first
|
||||||
result = []
|
result = []
|
||||||
installed_pkglist = config.pacman_conf.initialize_alpm().get_localdb().pkgcache
|
installed_pkglist = handle.get_localdb().pkgcache
|
||||||
for pkg in installed_pkglist:
|
for pkg in installed_pkglist:
|
||||||
candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
result.append(candidate)
|
result.append(candidate)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_new_version_available(pkgname):
|
def get_new_version_available(pkgname):
|
||||||
for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
|
for repo in handle.get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
return pkg.version
|
return pkg.version
|
||||||
|
0
pamac/tray.py
Normal file → Executable file
0
pamac/tray.py
Normal file → Executable file
70
pamac/updater.py
Normal file → Executable file
70
pamac/updater.py
Normal file → Executable file
@ -10,7 +10,7 @@ from pamac import config, common, transaction
|
|||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
interface.add_from_file('/usr/share/pamac/gui/updater.glade')
|
interface.add_from_file('/usr/share/pamac/gui/updater.glade')
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
|
|
||||||
UpdateWindow = interface.get_object("UpdateWindow")
|
UpdateWindow = interface.get_object("UpdateWindow")
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ def set_transaction_add():
|
|||||||
bottom_label.set_markup('')
|
bottom_label.set_markup('')
|
||||||
if transaction.to_add:
|
if transaction.to_add:
|
||||||
installed_name = []
|
installed_name = []
|
||||||
for pkg_object in config.handle.get_localdb().pkgcache:
|
for pkg_object in transaction.handle.get_localdb().pkgcache:
|
||||||
installed_name.append(pkg_object.name)
|
installed_name.append(pkg_object.name)
|
||||||
transaction.to_update = sorted(set(installed_name).intersection(transaction.to_add))
|
transaction.to_update = sorted(set(installed_name).intersection(transaction.to_add))
|
||||||
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(transaction.to_add))
|
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(transaction.to_add))
|
||||||
@ -65,20 +65,59 @@ def set_transaction_add():
|
|||||||
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
#bottom_label.set_markup('<b>Total Download size: </b>'+format_size(totaldlcb))
|
||||||
top_label.set_markup('<big><b>Additionnal Transaction(s)</b></big>')
|
top_label.set_markup('<big><b>Additionnal Transaction(s)</b></big>')
|
||||||
|
|
||||||
|
def finalize():
|
||||||
|
error = transaction.Prepare()
|
||||||
|
if error:
|
||||||
|
ErrorDialog.format_secondary_text(error)
|
||||||
|
response = ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
ErrorDialog.hide()
|
||||||
|
transaction.Release()
|
||||||
|
transaction.t_lock = False
|
||||||
|
else:
|
||||||
|
transaction.progress_label.set_text('Preparing...')
|
||||||
|
transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
|
||||||
|
transaction.ProgressWindow.show_all()
|
||||||
|
while Gtk.events_pending():
|
||||||
|
Gtk.main_iteration()
|
||||||
|
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
|
def handle_error(error):
|
||||||
|
if not 'DBus.Error.NoReply' in str(error):
|
||||||
|
transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(error))
|
||||||
|
response = transaction.ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
transaction.ErrorDialog.hide()
|
||||||
|
transaction.t_lock = False
|
||||||
|
transaction.Release()
|
||||||
|
transaction.ProgressWindow.hide()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
|
def handle_reply(reply):
|
||||||
|
if str(reply):
|
||||||
|
transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply))
|
||||||
|
response = transaction.ErrorDialog.run()
|
||||||
|
if response:
|
||||||
|
transaction.ErrorDialog.hide()
|
||||||
|
transaction.t_lock = False
|
||||||
|
transaction.Release()
|
||||||
|
transaction.ProgressWindow.hide()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
def do_sysupgrade():
|
def do_sysupgrade():
|
||||||
"""Upgrade a system like pacman -Su"""
|
"""Upgrade a system like pacman -Su"""
|
||||||
if transaction.t_lock is False:
|
if transaction.t_lock is False:
|
||||||
if transaction.do_syncfirst is True:
|
if transaction.do_syncfirst is True:
|
||||||
if transaction.init_transaction(recurse = True):
|
if transaction.init_transaction(recurse = True):
|
||||||
for pkg in transaction.list_first:
|
for pkg in transaction.list_first:
|
||||||
transaction.t.add_pkg(pkg)
|
transaction.Add(pkg.name)
|
||||||
transaction.to_remove = transaction.t.to_remove
|
transaction.get_to_remove()
|
||||||
transaction.to_add = transaction.t.to_add
|
transaction.get_to_add()
|
||||||
set_transaction_add()
|
set_transaction_add()
|
||||||
if len(transaction_add) != 0:
|
if len(transaction.to_add) != 0:
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
else:
|
else:
|
||||||
transaction.t_finalize()
|
finalize()
|
||||||
transaction.do_syncfirst = False
|
transaction.do_syncfirst = False
|
||||||
transaction.list_first = []
|
transaction.list_first = []
|
||||||
else:
|
else:
|
||||||
@ -108,16 +147,18 @@ def do_sysupgrade():
|
|||||||
if len(transaction_add) != 0:
|
if len(transaction_add) != 0:
|
||||||
ConfDialog.show_all()
|
ConfDialog.show_all()
|
||||||
else:
|
else:
|
||||||
transaction.t_finalize()
|
finalize()
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
def on_UpdateWindow_delete_event(self, *arg):
|
def on_UpdateWindow_delete_event(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
else:
|
||||||
UpdateWindow.hide()
|
UpdateWindow.hide()
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
def on_QuitButton_clicked(self, *arg):
|
||||||
|
transaction.StopDaemon()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
else:
|
else:
|
||||||
@ -125,7 +166,6 @@ class Handler:
|
|||||||
|
|
||||||
def on_ApplyButton_clicked(self, *arg):
|
def on_ApplyButton_clicked(self, *arg):
|
||||||
do_sysupgrade()
|
do_sysupgrade()
|
||||||
have_updates()
|
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
def on_RefreshButton_clicked(self, *arg):
|
||||||
transaction.do_refresh()
|
transaction.do_refresh()
|
||||||
@ -134,18 +174,24 @@ class Handler:
|
|||||||
def on_TransCancelButton_clicked(self, *arg):
|
def on_TransCancelButton_clicked(self, *arg):
|
||||||
ConfDialog.hide()
|
ConfDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.t.release()
|
transaction.Release()
|
||||||
|
|
||||||
def on_TransValidButton_clicked(self, *arg):
|
def on_TransValidButton_clicked(self, *arg):
|
||||||
ConfDialog.hide()
|
ConfDialog.hide()
|
||||||
transaction.t_finalize(t)
|
finalize()
|
||||||
|
|
||||||
|
def on_ProgressCancelButton_clicked(self, *arg):
|
||||||
|
transaction.t_lock = False
|
||||||
|
transaction.Release()
|
||||||
|
transaction.ProgressWindow.hide()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
#transaction.do_refresh()
|
||||||
have_updates()
|
have_updates()
|
||||||
interface.connect_signals(Handler())
|
interface.connect_signals(Handler())
|
||||||
UpdateWindow.show_all()
|
UpdateWindow.show_all()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
transaction.do_refresh()
|
|
||||||
main()
|
main()
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user