Skip to content

Commit

Permalink
improve AboutDialog
Browse files Browse the repository at this point in the history
Please enter the commit message for your changes. Lines starting
  • Loading branch information
shadeyg56 committed Feb 6, 2023
1 parent cb8cfe7 commit f7e03c9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
46 changes: 40 additions & 6 deletions auto_cpufreq/gui/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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()
10 changes: 9 additions & 1 deletion scripts/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ label{
font-size: 15px;
}

#bold{
font-weight: bold;
}

#small{
font-size: 12px;
}

button.popup{
background-image: none;
background-color: white;
}
}

0 comments on commit f7e03c9

Please sign in to comment.