diff --git a/auto_cpufreq/gui/objects.py b/auto_cpufreq/gui/objects.py index 87c04dfb..1b44b632 100644 --- a/auto_cpufreq/gui/objects.py +++ b/auto_cpufreq/gui/objects.py @@ -6,10 +6,11 @@ import sys import os +import platform as pl sys.path.append("../../") -from subprocess import getoutput -from auto_cpufreq.core import sysinfo, distro_info, set_override, get_override +from subprocess import getoutput, call +from auto_cpufreq.core import sysinfo, distro_info, set_override, get_override, get_formatted_version, dist_name from io import StringIO @@ -25,6 +26,25 @@ def get_stats(): stats = [line for line in (file.readlines() [-50:])] return "".join(stats) +def get_version(): + # snap package + if os.getenv("PKG_MARKER") == "SNAP": + return getoutput("echo \(Snap\) $SNAP_VERSION") + # aur package + elif dist_name in ["arch", "manjaro", "garuda"]: + aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True) + if aur_pkg_check == 1: + return get_formatted_version() + else: + return getoutput("pacman -Qi auto-cpufreq | grep Version") + else: + # source code (auto-cpufreq-installer) + try: + return get_formatted_version() + except Exception as e: + print(repr(e)) + pass + class RadioButtonView(Gtk.Box): def __init__(self): @@ -151,10 +171,24 @@ def about_dialog(self, MenuItem, parent): class AboutDialog(Gtk.Dialog): def __init__(self, parent): super().__init__(title="About", transient_for=parent) + app_version = get_version() self.box = self.get_content_area() + # self.box.set_homogeneous(True) + self.box.set_spacing(10) self.add_button("Close", Gtk.ResponseType.CLOSE) - self.set_default_size(150, 100) - - label = Gtk.Label("Hello World") - self.box.pack_start(label, False, False, 0) + self.set_default_size(400, 350) + + self.title = Gtk.Label(label="auto-cpufreq", name="bold") + self.version = Gtk.Label(label=app_version) + self.python = Gtk.Label(label=f"Python {pl.python_version()}") + self.github = Gtk.Label(label="https://github.com/AdnanHodzic/auto-cpufreq") + self.license = Gtk.Label(label="Licensed under LGPL3", name="small") + self.love = Gtk.Label(label="Made with <3", name="small") + + self.box.pack_start(self.title, False, False, 0) + self.box.pack_start(self.version, False, False, 0) + self.box.pack_start(self.python, False, False, 0) + self.box.pack_start(self.github, False, False, 0) + self.box.pack_start(self.license, False, False, 0) + self.box.pack_start(self.love, False, False, 0) self.show_all() \ No newline at end of file diff --git a/scripts/style.css b/scripts/style.css index 2ce2edb6..d432bbf7 100644 --- a/scripts/style.css +++ b/scripts/style.css @@ -3,7 +3,15 @@ label{ font-size: 15px; } +#bold{ + font-weight: bold; +} + +#small{ + font-size: 12px; +} + button.popup{ background-image: none; background-color: white; -} \ No newline at end of file +}