Skip to content

Commit f7e03c9

Browse files
committed
improve AboutDialog
Please enter the commit message for your changes. Lines starting
1 parent cb8cfe7 commit f7e03c9

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

auto_cpufreq/gui/objects.py

+40-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
import sys
88
import os
9+
import platform as pl
910

1011
sys.path.append("../../")
11-
from subprocess import getoutput
12-
from auto_cpufreq.core import sysinfo, distro_info, set_override, get_override
12+
from subprocess import getoutput, call
13+
from auto_cpufreq.core import sysinfo, distro_info, set_override, get_override, get_formatted_version, dist_name
1314

1415
from io import StringIO
1516

@@ -25,6 +26,25 @@ def get_stats():
2526
stats = [line for line in (file.readlines() [-50:])]
2627
return "".join(stats)
2728

29+
def get_version():
30+
# snap package
31+
if os.getenv("PKG_MARKER") == "SNAP":
32+
return getoutput("echo \(Snap\) $SNAP_VERSION")
33+
# aur package
34+
elif dist_name in ["arch", "manjaro", "garuda"]:
35+
aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True)
36+
if aur_pkg_check == 1:
37+
return get_formatted_version()
38+
else:
39+
return getoutput("pacman -Qi auto-cpufreq | grep Version")
40+
else:
41+
# source code (auto-cpufreq-installer)
42+
try:
43+
return get_formatted_version()
44+
except Exception as e:
45+
print(repr(e))
46+
pass
47+
2848

2949
class RadioButtonView(Gtk.Box):
3050
def __init__(self):
@@ -151,10 +171,24 @@ def about_dialog(self, MenuItem, parent):
151171
class AboutDialog(Gtk.Dialog):
152172
def __init__(self, parent):
153173
super().__init__(title="About", transient_for=parent)
174+
app_version = get_version()
154175
self.box = self.get_content_area()
176+
# self.box.set_homogeneous(True)
177+
self.box.set_spacing(10)
155178
self.add_button("Close", Gtk.ResponseType.CLOSE)
156-
self.set_default_size(150, 100)
157-
158-
label = Gtk.Label("Hello World")
159-
self.box.pack_start(label, False, False, 0)
179+
self.set_default_size(400, 350)
180+
181+
self.title = Gtk.Label(label="auto-cpufreq", name="bold")
182+
self.version = Gtk.Label(label=app_version)
183+
self.python = Gtk.Label(label=f"Python {pl.python_version()}")
184+
self.github = Gtk.Label(label="https://github.com/AdnanHodzic/auto-cpufreq")
185+
self.license = Gtk.Label(label="Licensed under LGPL3", name="small")
186+
self.love = Gtk.Label(label="Made with <3", name="small")
187+
188+
self.box.pack_start(self.title, False, False, 0)
189+
self.box.pack_start(self.version, False, False, 0)
190+
self.box.pack_start(self.python, False, False, 0)
191+
self.box.pack_start(self.github, False, False, 0)
192+
self.box.pack_start(self.license, False, False, 0)
193+
self.box.pack_start(self.love, False, False, 0)
160194
self.show_all()

scripts/style.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ label{
33
font-size: 15px;
44
}
55

6+
#bold{
7+
font-weight: bold;
8+
}
9+
10+
#small{
11+
font-size: 12px;
12+
}
13+
614
button.popup{
715
background-image: none;
816
background-color: white;
9-
}
17+
}

0 commit comments

Comments
 (0)