@@ -52,7 +52,6 @@ class DotfilesInstallerWindow(Adw.ApplicationWindow):
52
52
spinner = Gtk .Template .Child ()
53
53
btn_add_project = Gtk .Template .Child ()
54
54
toast_overlay = Gtk .Template .Child ()
55
- update_banner = Gtk .Template .Child ()
56
55
progress_bar = Gtk .Template .Child ()
57
56
install_mode = "install"
58
57
@@ -77,7 +76,7 @@ def __init__(self, **kwargs):
77
76
self .settings = Gio .Settings (schema_id = app_id )
78
77
79
78
self .create_actions ()
80
- self .check_for_update ()
79
+ self .check_for_update (True )
81
80
self .progress_bar .set_visible (False )
82
81
83
82
if get_dev_enabled ():
@@ -436,32 +435,40 @@ def on_start_migration(self, widget, param):
436
435
437
436
# Check for Updates menu action
438
437
def on_check_updates_action (self , widget , _ ):
439
- self .check_for_update ()
438
+ self .check_for_update (False )
440
439
441
440
# Start Update Thread
442
- def check_for_update (self ):
441
+ def check_for_update (self , init ):
443
442
printLog ("Checking for updates..." )
444
- thread = threading .Thread (target = self .check_latest_version )
443
+ thread = threading .Thread (target = self .check_latest_version , args = ( init ,) )
445
444
thread .daemon = True
446
445
thread .start ()
447
446
448
447
# Check Latest Tag
449
- def check_latest_version (self ):
448
+ def check_latest_version (self , args ):
450
449
try :
451
450
response = urlopen (app_github_api_tags )
452
451
tags = json .load (response )
453
452
if not tags [0 ]["name" ] == app_version :
454
453
printLog ("Update is available" )
455
- self .update_banner .set_revealed (True )
454
+ toast = Adw .Toast .new ("A new version of the Dotfiles Installer is available." )
455
+ toast .set_button_label ("Update Now" )
456
+ toast .connect ("button-clicked" ,self .on_update_app )
457
+ toast .set_timeout (5 )
458
+ self .toast_overlay .add_toast (toast )
456
459
else :
457
- printLog ("No update available" )
460
+ if not args :
461
+ printLog ("No Update available" )
462
+ toast = Adw .Toast .new ("You're using already the latest version of the Dotfiles Installer." )
463
+ toast .set_timeout (5 )
464
+ self .toast_overlay .add_toast (toast )
465
+
458
466
except :
459
467
printLog ("Check for updates failed" ,"e" )
460
468
461
469
# Open the homepage with update information
462
- def on_update_app (self , widget , _ ):
470
+ def on_update_app (self , widget ):
463
471
Gtk .UriLauncher (uri = "https://mylinuxforwork.github.io/dotfiles-installer/getting-started/update" ).launch ()
464
- self .update_banner .set_revealed (False )
465
472
466
473
# --------------------------------------------
467
474
# About Dialog
0 commit comments