6
6
7
7
import sys
8
8
import os
9
+ import platform as pl
9
10
10
11
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
13
14
14
15
from io import StringIO
15
16
@@ -25,6 +26,25 @@ def get_stats():
25
26
stats = [line for line in (file .readlines () [- 50 :])]
26
27
return "" .join (stats )
27
28
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
+
28
48
29
49
class RadioButtonView (Gtk .Box ):
30
50
def __init__ (self ):
@@ -151,10 +171,24 @@ def about_dialog(self, MenuItem, parent):
151
171
class AboutDialog (Gtk .Dialog ):
152
172
def __init__ (self , parent ):
153
173
super ().__init__ (title = "About" , transient_for = parent )
174
+ app_version = get_version ()
154
175
self .box = self .get_content_area ()
176
+ # self.box.set_homogeneous(True)
177
+ self .box .set_spacing (10 )
155
178
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 )
160
194
self .show_all ()
0 commit comments