Add warn_if_modified setting

This commit is contained in:
CorpNewt
2024-10-27 13:18:00 -05:00
committed by GitHub
parent c6c0f925f6
commit b101a77a95
+21 -13
View File
@@ -175,25 +175,28 @@ class ProperTree:
self.snapshot_menu.grid(row=11,column=1,columnspan=2,sticky="we",padx=10)
self.schema_check = tk_or_ttk.Checkbutton(self.settings_window,text="Force Update Snapshot Schema",variable=self.force_schema,command=self.schema_command)
self.schema_check.grid(row=12,column=0,columnspan=3,sticky="w",padx=10)
self.mod_check = tk.IntVar()
self.enable_mod_check = tk_or_ttk.Checkbutton(self.settings_window,text="Warn If Files Are Externally Modified",variable=self.mod_check,command=self.mod_check_command)
self.enable_mod_check.grid(row=13,column=0,columnspan=3,stick="w",padx=10)
self.enable_drag_and_drop = tk.BooleanVar()
self.toggle_drag_drop = tk_or_ttk.Checkbutton(self.settings_window,text="Enable Row Drag & Drop", variable=self.enable_drag_and_drop,command=self.drag_drop_command)
self.toggle_drag_drop.grid(row=13,column=0,columnspan=3,sticky="w",padx=10)
self.toggle_drag_drop.grid(row=14,column=0,columnspan=3,sticky="w",padx=10)
self.drag_label = tk.Label(self.settings_window,text="Drag Dead Zone (1-100 pixels):")
self.drag_label.grid(row=14,column=0,sticky="w",padx=10)
self.drag_label.grid(row=15,column=0,sticky="w",padx=10)
self.drag_pixels = tk.Label(self.settings_window,text="20")
self.drag_pixels.grid(row=14,column=1,sticky="w",padx=(10,0))
self.drag_pixels.grid(row=15,column=1,sticky="w",padx=(10,0))
self.drag_scale = tk_or_ttk.Scale(self.settings_window,from_=1,to=100,orient=tk.HORIZONTAL,command=self.scale_command)
# Try to hide the value if using tk - will throw an exception in ttk
try: self.drag_scale.configure(showvalue=False)
except tk.TclError: pass
self.drag_scale.grid(row=14,column=2,sticky="we",padx=(0,10))
self.drag_scale.grid(row=15,column=2,sticky="we",padx=(0,10))
self.drag_disabled = tk.Label(self.settings_window,text="[ Drag & Drop Disabled ]")
self.drag_disabled.configure(state="disabled")
self.drag_disabled.grid(row=14,column=1,columnspan=2,sticky="we",padx=10)
self.drag_disabled.grid(row=15,column=1,columnspan=2,sticky="we",padx=10)
undo_max_label = tk.Label(self.settings_window,text="Max Undo (0=unlim, {}=default):".format(self.max_undo))
undo_max_label.grid(row=15,column=0,sticky="w",padx=10)
undo_max_label.grid(row=16,column=0,sticky="w",padx=10)
self.undo_max_text = plistwindow.EntryPlus(self.settings_window,self.tk,self)
self.undo_max_text.grid(row=15,column=1,columnspan=2,sticky="we",padx=10)
self.undo_max_text.grid(row=16,column=1,columnspan=2,sticky="we",padx=10)
# Left/right separator:
sep = ttk.Separator(self.settings_window,orient="vertical")
@@ -286,21 +289,21 @@ class ProperTree:
default_dark.grid(row=14,column=5,columnspan=2,sticky="we",padx=10)
sep_theme = ttk.Separator(self.settings_window,orient="horizontal")
sep_theme.grid(row=16,column=0,columnspan=7,sticky="we",padx=10,pady=(10,0))
sep_theme.grid(row=17,column=0,columnspan=7,sticky="we",padx=10,pady=(10,0))
# Add the check for updates checkbox and button
self.update_int = tk.IntVar()
self.update_check = tk_or_ttk.Checkbutton(self.settings_window,text="Check For Updates At Start",variable=self.update_int,command=self.update_command)
self.update_check.grid(row=17,column=0,sticky="w",padx=10,pady=(5,0))
self.update_check.grid(row=18,column=0,sticky="w",padx=10,pady=(5,0))
self.notify_once_int = tk.IntVar()
self.notify_once_check = tk_or_ttk.Checkbutton(self.settings_window,text="Only Notify Once Per Version",variable=self.notify_once_int,command=self.notify_once)
self.notify_once_check.grid(row=18,column=0,sticky="w",padx=10,pady=(0,10))
self.notify_once_check.grid(row=19,column=0,sticky="w",padx=10,pady=(0,10))
self.update_button = tk_or_ttk.Button(self.settings_window,text="Check Now",command=lambda:self.check_for_updates(user_initiated=True))
self.update_button.grid(row=18,column=1,columnspan=2,sticky="w",padx=10,pady=(0,10))
self.update_button.grid(row=19,column=1,columnspan=2,sticky="w",padx=10,pady=(0,10))
self.tex_button = tk_or_ttk.Button(self.settings_window,text="Get Configuration.tex",command=self.get_latest_tex)
self.tex_button.grid(row=18,column=4,sticky="we",padx=10,pady=(0,10))
self.tex_button.grid(row=19,column=4,sticky="we",padx=10,pady=(0,10))
reset_settings = tk_or_ttk.Button(self.settings_window,text="Restore All Defaults",command=self.reset_settings)
reset_settings.grid(row=18,column=5,columnspan=2,sticky="we",padx=10,pady=(0,10))
reset_settings.grid(row=19,column=5,columnspan=2,sticky="we",padx=10,pady=(0,10))
# Setup the color picker click methods
self.r1_canvas.bind("<ButtonRelease-1>",lambda x:self.pick_color("alternating_color_1",self.r1_canvas))
@@ -479,6 +482,7 @@ class ProperTree:
# invert_row1_text_color: bool
# invert_row2_text_color: bool
# invert_hl_text_color: bool
# warn_if_modified: bool
# enable_drag_and_drop: bool
# drag_dead_zone: pixel distance before drag starts (default is 20)
# open_recent: list, paths recently opened
@@ -1071,6 +1075,9 @@ class ProperTree:
def schema_command(self, event = None):
self.settings["force_snapshot_schema"] = True if self.force_schema.get() else False
def mod_check_command(self, event = None):
self.settings["warn_if_modified"] = True if self.mod_check.get() else False
def update_command(self, event = None):
self.settings["check_for_updates_at_startup"] = True if self.update_int.get() else False
self.update_notify()
@@ -1222,6 +1229,7 @@ class ProperTree:
snapshot_name = next((x for x in snapshot_choices if x.split(" ")[0] == snapshot_vers),None)
self.snapshot_string.set(snapshot_name if snapshot_name in snapshot_choices else "Auto-detect")
self.force_schema.set(self.settings.get("force_snapshot_schema",False))
self.mod_check.set(self.settings.get("warn_if_modified",True))
self.comment_ignore_case.set(self.settings.get("comment_strip_ignore_case",False))
self.comment_check_string.set(self.settings.get("comment_strip_check_string",True))
self.update_int.set(self.settings.get("check_for_updates_at_startup",True))