modified button layout; monospace font textview; spinner (WIP)
This commit is contained in:
parent
6a6d0f723a
commit
d20848878a
@ -78,6 +78,12 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
|||||||
|
|
||||||
def run(self, args, ignore_stderr=False, output_msg=None,
|
def run(self, args, ignore_stderr=False, output_msg=None,
|
||||||
empty_msg=None, env={}):
|
empty_msg=None, env={}):
|
||||||
|
self.clear()
|
||||||
|
self.lock()
|
||||||
|
self.spinner.start()
|
||||||
|
self.prepend_mesg(
|
||||||
|
"INFO",
|
||||||
|
"Running command \"%s\" ..." % " ".join(args))
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False,
|
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False,
|
||||||
env=dict(os.environ, **env))
|
env=dict(os.environ, **env))
|
||||||
@ -113,6 +119,9 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
|||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.spinner.stop()
|
||||||
|
self.unlock()
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@ -134,28 +143,36 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
|||||||
self.upgrade_button.set_sensitive(True)
|
self.upgrade_button.set_sensitive(True)
|
||||||
self.list_button.set_sensitive(True)
|
self.list_button.set_sensitive(True)
|
||||||
|
|
||||||
def on_upgrade(self, *args):
|
def upgrade(self):
|
||||||
self.clear()
|
args = ['/usr/bin/apt-get', '-yqq', 'full-upgrade']
|
||||||
|
env = {'DEBIAN_FRONTEND': 'noninteractive'}
|
||||||
self.run(
|
self.run(
|
||||||
['/usr/bin/apt-get', '-y', 'full-upgrade'],
|
args,
|
||||||
env={'DEBIAN_FRONTEND': 'noninteractive'})
|
env=env,
|
||||||
self.append_mesg("INFO", "Upgrade done.")
|
empty_msg="No package upgrades were performed.")
|
||||||
|
|
||||||
|
def on_upgrade(self, *args):
|
||||||
|
self.upgrade()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
args = ['/usr/bin/apt-get', '-y', 'update']
|
||||||
|
env = {'DEBIAN_FRONTEND': 'noninteractive'}
|
||||||
|
self.run(args, env=env)
|
||||||
|
|
||||||
def on_update(self, *args):
|
def on_update(self, *args):
|
||||||
self.clear()
|
self.update()
|
||||||
self.run(
|
|
||||||
['/usr/bin/apt-get', '-y', 'update'],
|
|
||||||
env={'DEBIAN_FRONTEND': 'noninteractive'})
|
|
||||||
self.append_mesg("INFO", "The package cache was updated.")
|
|
||||||
|
|
||||||
def on_list(self, *args):
|
def list(self):
|
||||||
self.clear()
|
args = ['/usr/bin/apt', '-qq', 'list', '--upgradable']
|
||||||
self.run(
|
self.run(
|
||||||
['/usr/bin/apt', '-qq', 'list', '--upgradable'],
|
args,
|
||||||
ignore_stderr=True,
|
ignore_stderr=True,
|
||||||
output_msg="Found the following package upgrades:",
|
output_msg="Found the following package upgrades:",
|
||||||
empty_msg="Currently there are no available package upgrades.")
|
empty_msg="Currently there are no available package upgrades.")
|
||||||
|
|
||||||
|
def on_list(self, *args):
|
||||||
|
self.list()
|
||||||
|
|
||||||
def on_ctrl_w(self, *args):
|
def on_ctrl_w(self, *args):
|
||||||
self.app.quit()
|
self.app.quit()
|
||||||
|
|
||||||
@ -180,20 +197,38 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
|||||||
hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)
|
hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)
|
||||||
self.add(hbox)
|
self.add(hbox)
|
||||||
|
|
||||||
self.update_button = Gtk.Button.new_with_label(
|
grid = Gtk.Grid()
|
||||||
"Update the Package Cache")
|
grid.set_row_spacing(5)
|
||||||
self.update_button.connect("clicked", self.on_update)
|
grid.set_column_spacing(5)
|
||||||
hbox.pack_start(self.update_button, True, True, 0)
|
hbox.add(grid)
|
||||||
|
|
||||||
self.upgrade_button = Gtk.Button.new_with_label(
|
self.update_button = Gtk.Button.new_with_label(
|
||||||
"Apply all Package Upgrades")
|
"Update Cache")
|
||||||
self.upgrade_button.connect("clicked", self.on_upgrade)
|
self.update_button.connect("clicked", self.on_update)
|
||||||
hbox.pack_start(self.upgrade_button, True, True, 0)
|
grid.attach(self.update_button, 0, 0, 1, 1)
|
||||||
|
|
||||||
self.list_button = Gtk.Button.new_with_label(
|
self.list_button = Gtk.Button.new_with_label(
|
||||||
"List available Package Updates")
|
"List Upgrades")
|
||||||
self.list_button.connect("clicked", self.on_list)
|
self.list_button.connect("clicked", self.on_list)
|
||||||
hbox.pack_start(self.list_button, True, True, 0)
|
grid.attach(self.list_button, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
self.upgrade_button = Gtk.Button.new_from_icon_name(
|
||||||
|
"gtk-apply", Gtk.IconSize.BUTTON)
|
||||||
|
self.upgrade_button.set_tooltip_text(
|
||||||
|
"Download and install all available upgrades")
|
||||||
|
self.upgrade_button.connect("clicked", self.on_upgrade)
|
||||||
|
grid.attach(self.upgrade_button, 2, 0, 1, 1)
|
||||||
|
|
||||||
|
self.spinner = Gtk.Spinner()
|
||||||
|
self.spinner.set_hexpand(True)
|
||||||
|
grid.attach(self.spinner, 4, 0, 1, 1)
|
||||||
|
|
||||||
|
self.quit_button = Gtk.Button.new_from_icon_name(
|
||||||
|
"gtk-cancel", Gtk.IconSize.BUTTON)
|
||||||
|
self.quit_button.set_tooltip_text("Exit the program")
|
||||||
|
self.quit_button.set_halign(Gtk.Align.END)
|
||||||
|
self.quit_button.connect("clicked", self.on_ctrl_w)
|
||||||
|
grid.attach(self.quit_button, 4, 0, 1, 1)
|
||||||
|
|
||||||
self.scrolledwindow = Gtk.ScrolledWindow()
|
self.scrolledwindow = Gtk.ScrolledWindow()
|
||||||
self.scrolledwindow.set_hexpand(True)
|
self.scrolledwindow.set_hexpand(True)
|
||||||
@ -204,6 +239,7 @@ class UpdateWindow(Gtk.ApplicationWindow):
|
|||||||
|
|
||||||
text_view = Gtk.TextView(buffer=self.buffer)
|
text_view = Gtk.TextView(buffer=self.buffer)
|
||||||
text_view.set_editable(False)
|
text_view.set_editable(False)
|
||||||
|
text_view.set_monospace(True)
|
||||||
text_view.set_cursor_visible(False)
|
text_view.set_cursor_visible(False)
|
||||||
|
|
||||||
self.scrolledwindow.add(text_view)
|
self.scrolledwindow.add(text_view)
|
||||||
@ -214,8 +250,8 @@ def on_activate(app):
|
|||||||
win = UpdateWindow(app)
|
win = UpdateWindow(app)
|
||||||
win.present()
|
win.present()
|
||||||
win.show_all()
|
win.show_all()
|
||||||
win.on_update()
|
win.update()
|
||||||
win.on_list()
|
win.list()
|
||||||
|
|
||||||
|
|
||||||
app = Gtk.Application(application_id='org.linuxfoo.SimpleAptUpdate')
|
app = Gtk.Application(application_id='org.linuxfoo.SimpleAptUpdate')
|
||||||
|
Loading…
Reference in New Issue
Block a user