@@ -428,6 +428,21 @@ def open_create_new_project(self) -> None:
428
428
self .create_new_project_buttons ()
429
429
self .new_project_frame .wait_window ()
430
430
431
+ def clear_recent_projects (self ) -> None :
432
+ """
433
+ Clear the recent projects.
434
+
435
+ :return: None.
436
+ """
437
+ logger .debug ("Clearing recent projects..." )
438
+ if mbox .askokcancel ("CircuitPython Project Manager: Confirm" ,
439
+ "Are you sure you want to clear all recent projects?" ):
440
+ logger .debug ("Clearing all recent projects!" )
441
+ self .save_key ("opened_recent" , [])
442
+ self .update_recent_projects ()
443
+ else :
444
+ logger .debug ("User canceled clearing all recent projects!" )
445
+
431
446
def update_recent_projects (self ) -> None :
432
447
"""
433
448
Update the opened recent projects menu.
@@ -445,6 +460,9 @@ def update_recent_projects(self) -> None:
445
460
command = lambda path = path : self .open_project (path ))
446
461
if len (self .recent_projects ) == 0 :
447
462
self .opened_recent_menu .add_command (label = "No recent projects!" , state = tk .DISABLED )
463
+ self .opened_recent_menu .add_separator ()
464
+ self .opened_recent_menu .add_command (label = "Clear recent projects" , command = self .clear_recent_projects ,
465
+ state = tk .DISABLED if len (self .recent_projects ) == 0 else tk .NORMAL )
448
466
449
467
def create_file_menu (self ) -> None :
450
468
"""
@@ -838,7 +856,7 @@ def discard_modified(self) -> None:
838
856
return
839
857
try :
840
858
logger .debug ("Discarding all changes!" )
841
- self .make_main_gui ()
859
+ self .update_main_gui ()
842
860
except FileNotFoundError :
843
861
logger .exception ("Uh oh, an exception has occurred!" )
844
862
self .close_project ()
@@ -915,6 +933,7 @@ def update_main_gui(self) -> None:
915
933
916
934
:return: None.
917
935
"""
936
+ self .disable_closing = True
918
937
self .update_menu_state ()
919
938
logger .debug ("Updating main GUI..." )
920
939
self .destroy_all_children (widget = self .main_frame )
@@ -926,12 +945,15 @@ def create_main_gui(self) -> None:
926
945
927
946
:return: None.
928
947
"""
948
+ logger .debug (f"self.cpypmconfig_path: { repr (self .cpypmconfig_path )} " )
929
949
if self .cpypmconfig_path is None :
950
+ logger .info ("No project is open!" )
930
951
ttk .Label (
931
952
master = self .main_frame ,
932
953
text = "No project is open! Use the file menu to create\n a new project or open an existing project!"
933
954
).grid (row = 0 , column = 0 , sticky = tk .NW )
934
955
else :
956
+ logger .info ("Project is open - (re)loading everything!" )
935
957
logger .debug (f"Parsing { repr (self .cpypmconfig_path )} " )
936
958
self .cpypmconfig = json .loads (self .cpypmconfig_path .read_text ())
937
959
self .make_title (self .cpypmconfig ["project_name" ])
@@ -941,6 +963,7 @@ def create_main_gui(self) -> None:
941
963
self .make_file_sync_buttons ()
942
964
ttk .Separator (master = self .right_frame , orient = tk .HORIZONTAL ).grid (row = 3 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW + tk .E )
943
965
self .make_save_and_sync_buttons ()
966
+ self .disable_closing = False
944
967
945
968
def make_main_gui (self , cpypmconfig_path : Path = None ) -> None :
946
969
"""
0 commit comments