parent
41d81d5de1
commit
5ecbbbd9c3
@ -0,0 +1,51 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8-*-
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
import transaction, update
|
||||||
|
|
||||||
|
class Tray:
|
||||||
|
def __init__(self, icon, info):
|
||||||
|
self.icon = icon
|
||||||
|
self.info = info
|
||||||
|
self.statusIcon = Gtk.StatusIcon()
|
||||||
|
self.statusIcon.set_from_file(icon)
|
||||||
|
self.statusIcon.set_visible(True)
|
||||||
|
self.statusIcon.set_tooltip_markup(info)
|
||||||
|
|
||||||
|
self.menu = Gtk.Menu()
|
||||||
|
self.menuItem = Gtk.ImageMenuItem()
|
||||||
|
self.menuItem.seet_image('/usr/share/icons/hicolor/24x24/status/package-update.png')
|
||||||
|
self.menuItem.connect('activate', self.execute_cb, self.statusIcon)
|
||||||
|
self.menu.append(self.menuItem)
|
||||||
|
self.menuItem = Gtk.ImageMenuItem(Gtk.STOCK_QUIT)
|
||||||
|
self.menuItem.connect('activate', self.quit_cb, self.statusIcon)
|
||||||
|
self.menu.append(self.menuItem)
|
||||||
|
|
||||||
|
self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
|
||||||
|
self.statusIcon.set_visible(1)
|
||||||
|
|
||||||
|
Gtk.main()
|
||||||
|
|
||||||
|
def execute_cb(self, widget, event, data = None):
|
||||||
|
update.main()
|
||||||
|
|
||||||
|
def quit_cb(self, widget, data = None):
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def popup_menu_cb(self, widget, button, time, data = None):
|
||||||
|
if button == 3:
|
||||||
|
if data:
|
||||||
|
data.show_all()
|
||||||
|
data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
updates = transaction.get_updates()
|
||||||
|
if updates:
|
||||||
|
icon = '/usr/share/icons/hicolor/24x24/status/update-normal.png'
|
||||||
|
info = str(len(updates))+' update(s) available'
|
||||||
|
else:
|
||||||
|
icon = '/usr/share/icons/hicolor/24x24/status/update-enhancement.png'
|
||||||
|
info = ' No update available'
|
||||||
|
tray = Tray(icon, info)
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
# -*-coding:utf-8 -*-
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
import pyalpm
|
||||||
|
from os import geteuid
|
||||||
|
|
||||||
|
from backend import 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')
|
||||||
|
top_label = interface.get_object('top_label')
|
||||||
|
|
||||||
|
def have_updates():
|
||||||
|
available_updates = transaction.get_updates()
|
||||||
|
update_listore.clear()
|
||||||
|
top_label.set_justify(Gtk.Justification.CENTER)
|
||||||
|
if not available_updates:
|
||||||
|
update_listore.append(["", ""])
|
||||||
|
top_label.set_markup("<big><b>No update available</b></big>")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
for pkg in available_updates:
|
||||||
|
pkgname = pkg.name
|
||||||
|
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>")
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Handler:
|
||||||
|
def on_UpdateWindow_delete_event(self, *arg):
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def on_QuitButton_clicked(self, *arg):
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
def on_ApplyButton_clicked(self, *arg):
|
||||||
|
transaction.do_sysupgrade()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
|
def on_RefreshButton_clicked(self, *arg):
|
||||||
|
transaction.do_refresh()
|
||||||
|
have_updates()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
have_updates()
|
||||||
|
interface.connect_signals(Handler())
|
||||||
|
UpdateWindow = interface.get_object("UpdateWindow")
|
||||||
|
UpdateWindow.show_all()
|
||||||
|
Gtk.main()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if geteuid() == 0:
|
||||||
|
transaction.do_refresh()
|
||||||
|
main()
|
||||||
@ -1,60 +1,16 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python
|
||||||
# -*-coding:utf-8 -*-
|
# -*-coding:utf-8 -*-
|
||||||
|
|
||||||
from gi.repository import Gtk, GdkPixbuf, Gdk
|
|
||||||
|
|
||||||
import pyalpm
|
|
||||||
from time import strftime, localtime
|
|
||||||
from os import geteuid
|
from os import geteuid
|
||||||
from backend import 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')
|
|
||||||
top_label = interface.get_object('top_label')
|
|
||||||
|
|
||||||
def have_updates():
|
|
||||||
available_updates = transaction.get_updates()
|
|
||||||
update_listore.clear()
|
|
||||||
top_label.set_justify(Gtk.Justification.CENTER)
|
|
||||||
if not available_updates:
|
|
||||||
update_listore.append(["", ""])
|
|
||||||
top_label.set_markup("<big><b>No update available</b></big>")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
for pkg in available_updates:
|
|
||||||
pkgname = pkg.name
|
|
||||||
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>")
|
|
||||||
return True
|
|
||||||
|
|
||||||
class Handler:
|
|
||||||
def on_UpdateWindow_delete_event(self, *arg):
|
|
||||||
Gtk.main_quit()
|
|
||||||
|
|
||||||
def on_QuitButton_clicked(self, *arg):
|
|
||||||
Gtk.main_quit()
|
|
||||||
|
|
||||||
def on_ApplyButton_clicked(self, *arg):
|
|
||||||
transaction.do_sysupgrade()
|
|
||||||
have_updates()
|
|
||||||
|
|
||||||
def on_RefreshButton_clicked(self, *arg):
|
|
||||||
transaction.do_refresh()
|
|
||||||
have_updates()
|
|
||||||
|
|
||||||
def main():
|
from backend import update, transaction
|
||||||
have_updates()
|
|
||||||
interface.connect_signals(Handler())
|
|
||||||
UpdateWindow = interface.get_object("UpdateWindow")
|
|
||||||
UpdateWindow.show_all()
|
|
||||||
Gtk.main()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if geteuid() == 0:
|
if geteuid() == 0:
|
||||||
|
transaction.progress_label.set_text('Refreshing...')
|
||||||
|
transaction.progress_bar.pulse()
|
||||||
|
transaction.action_icon.set_from_file('/usr/share/icons/hicolor/24x24/status/refresh-cache.png')
|
||||||
|
transaction.ProgressWindow.show_all()
|
||||||
transaction.do_refresh()
|
transaction.do_refresh()
|
||||||
main()
|
transaction.ProgressWindow.hide()
|
||||||
|
update.main()
|
||||||
|
|||||||
Loading…
Reference in new issue