diff --git a/userspace/py/bin/about-applet.py b/userspace/py/bin/about-applet.py index 323646ee..7a89c339 100755 --- a/userspace/py/bin/about-applet.py +++ b/userspace/py/bin/about-applet.py @@ -11,6 +11,8 @@ import yutani import text_region import toaru_fonts + + def version(): """Get a release from uname without a git short sha.""" release = os.uname().release @@ -18,6 +20,8 @@ def version(): return release[:release.index('-')] return release +_default_text = f"ToaruOS {version()}\n© 2011-2017 Kevin Lange, et al.\n\nToaruOS is free software released under the NCSA/University of Illinois license.\n\nhttp://toaruos.org\nhttps://github.com/klange/toaruos" + class AboutAppletWindow(yutani.Window): base_width = 350 @@ -25,15 +29,15 @@ class AboutAppletWindow(yutani.Window): text_offset = 110 - def __init__(self, decorator): - super(AboutAppletWindow, self).__init__(self.base_width + decorator.width(), self.base_height + decorator.height(), title="About ToaruOS", icon="star", doublebuffer=True) + def __init__(self, decorator, title="About ToaruOS", icon="star", logo="/usr/share/logo_login.png", text=_default_text): + super(AboutAppletWindow, self).__init__(self.base_width + decorator.width(), self.base_height + decorator.height(), title=title, icon=icon, doublebuffer=True) self.move(int((yutani.yutani_ctx._ptr.contents.display_width-self.width)/2),int((yutani.yutani_ctx._ptr.contents.display_height-self.height)/2)) self.decorator = decorator - self.logo = cairo.ImageSurface.create_from_png('/usr/share/logo_login.png') + self.logo = cairo.ImageSurface.create_from_png(logo) self.font = toaru_fonts.Font(toaru_fonts.FONT_SANS_SERIF, 13, 0xFF000000) self.tr = text_region.TextRegion(0,0,self.base_width-30,self.base_height-self.text_offset,font=self.font) self.tr.set_alignment(2) - self.tr.set_richtext(f"ToaruOS {version()}\n© 2011-2017 Kevin Lange, et al.\n\nToaruOS is free software released under the NCSA/University of Illinois license.\n\nhttp://toaruos.org\nhttps://github.com/klange/toaruos") + self.tr.set_richtext(text) def draw(self): surface = self.get_cairo_surface() @@ -46,7 +50,7 @@ class AboutAppletWindow(yutani.Window): ctx.set_source_rgb(204/255,204/255,204/255) ctx.fill() - ctx.set_source_surface(self.logo,(WIDTH-self.logo.get_width())/2,10) + ctx.set_source_surface(self.logo,int((WIDTH-self.logo.get_width())/2),10+int((84-self.logo.get_height())/2)) ctx.paint() self.tr.resize(WIDTH-30,HEIGHT-self.text_offset) @@ -81,7 +85,10 @@ if __name__ == '__main__': yutani.Yutani() d = yutani.Decor() - window = AboutAppletWindow(d) + if len(sys.argv) > 4: + window = AboutAppletWindow(d,sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4]) + else: + window = AboutAppletWindow(d) window.draw() window.flip()