disable new folder, new document works in open mode
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -96,7 +96,7 @@ class SettingsDialog(tk.Toplevel):
|
|||||||
delete_frame.pack(fill="x", pady=5)
|
delete_frame.pack(fill="x", pady=5)
|
||||||
|
|
||||||
self.use_trash_checkbutton = ttk.Checkbutton(delete_frame, text="Dateien in den Papierkorb verschieben (empfohlen)",
|
self.use_trash_checkbutton = ttk.Checkbutton(delete_frame, text="Dateien in den Papierkorb verschieben (empfohlen)",
|
||||||
variable=self.use_trash)
|
variable=self.use_trash)
|
||||||
self.use_trash_checkbutton.pack(anchor="w")
|
self.use_trash_checkbutton.pack(anchor="w")
|
||||||
|
|
||||||
if not SEND2TRASH_AVAILABLE:
|
if not SEND2TRASH_AVAILABLE:
|
||||||
@@ -105,11 +105,11 @@ class SettingsDialog(tk.Toplevel):
|
|||||||
font=("TkDefaultFont", 9, "italic")).pack(anchor="w", padx=(20, 0))
|
font=("TkDefaultFont", 9, "italic")).pack(anchor="w", padx=(20, 0))
|
||||||
|
|
||||||
self.confirm_delete_checkbutton = ttk.Checkbutton(delete_frame, text="Löschen/Verschieben ohne Bestätigung",
|
self.confirm_delete_checkbutton = ttk.Checkbutton(delete_frame, text="Löschen/Verschieben ohne Bestätigung",
|
||||||
variable=self.confirm_delete)
|
variable=self.confirm_delete)
|
||||||
self.confirm_delete_checkbutton.pack(anchor="w")
|
self.confirm_delete_checkbutton.pack(anchor="w")
|
||||||
|
|
||||||
# Disable deletion options in "open" mode
|
# Disable deletion options in "open" mode
|
||||||
if self.dialog_mode == "open":
|
if not self.dialog_mode == "save":
|
||||||
self.use_trash_checkbutton.config(state=tk.DISABLED)
|
self.use_trash_checkbutton.config(state=tk.DISABLED)
|
||||||
self.confirm_delete_checkbutton.config(state=tk.DISABLED)
|
self.confirm_delete_checkbutton.config(state=tk.DISABLED)
|
||||||
info_label = ttk.Label(delete_frame, text="(Löschoptionen sind nur im Speichern-Modus verfügbar)",
|
info_label = ttk.Label(delete_frame, text="(Löschoptionen sind nur im Speichern-Modus verfügbar)",
|
||||||
@@ -215,7 +215,8 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
self.after(10, initial_load)
|
self.after(10, initial_load)
|
||||||
|
|
||||||
# Bind the intelligent return handler
|
# Bind the intelligent return handler
|
||||||
self.widget_manager.path_entry.bind("<Return>", self.handle_path_entry_return)
|
self.widget_manager.path_entry.bind(
|
||||||
|
"<Return>", self.handle_path_entry_return)
|
||||||
|
|
||||||
# Bind the delete key only in "save" mode
|
# Bind the delete key only in "save" mode
|
||||||
if self.dialog_mode == "save":
|
if self.dialog_mode == "save":
|
||||||
@@ -365,12 +366,16 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
def show_more_menu(self):
|
def show_more_menu(self):
|
||||||
# Create and display the dropdown menu for hidden buttons
|
# Create and display the dropdown menu for hidden buttons
|
||||||
more_menu = tk.Menu(self, tearoff=0, background=self.style_manager.header, foreground=self.style_manager.color_foreground,
|
more_menu = tk.Menu(self, tearoff=0, background=self.style_manager.header, foreground=self.style_manager.color_foreground,
|
||||||
activebackground=self.style_manager.selection_color, activeforeground=self.style_manager.color_foreground, relief='flat', borderwidth=0)
|
activebackground=self.style_manager.selection_color, activeforeground=self.style_manager.color_foreground, relief='flat', borderwidth=0)
|
||||||
|
|
||||||
|
# Determine the state for folder/file creation options
|
||||||
|
is_writable = os.access(self.current_dir, os.W_OK)
|
||||||
|
creation_state = tk.NORMAL if is_writable and self.dialog_mode != "open" else tk.DISABLED
|
||||||
|
|
||||||
more_menu.add_command(label="Neuer Ordner", command=self.create_new_folder,
|
more_menu.add_command(label="Neuer Ordner", command=self.create_new_folder,
|
||||||
image=self.icon_manager.get_icon('new_folder_small'), compound='left')
|
image=self.icon_manager.get_icon('new_folder_small'), compound='left', state=creation_state)
|
||||||
more_menu.add_command(label="Neues Dokument", command=self.create_new_file,
|
more_menu.add_command(label="Neues Dokument", command=self.create_new_file,
|
||||||
image=self.icon_manager.get_icon('new_document_small'), compound='left')
|
image=self.icon_manager.get_icon('new_document_small'), compound='left', state=creation_state)
|
||||||
more_menu.add_separator()
|
more_menu.add_separator()
|
||||||
more_menu.add_command(label="Kachelansicht", command=self.set_icon_view,
|
more_menu.add_command(label="Kachelansicht", command=self.set_icon_view,
|
||||||
image=self.icon_manager.get_icon('icon_view'), compound='left')
|
image=self.icon_manager.get_icon('icon_view'), compound='left')
|
||||||
@@ -379,8 +384,10 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
more_menu.add_separator()
|
more_menu.add_separator()
|
||||||
|
|
||||||
# Toggle hidden files option
|
# Toggle hidden files option
|
||||||
hidden_files_label = "Versteckte Dateien ausblenden" if self.show_hidden_files.get() else "Versteckte Dateien anzeigen"
|
hidden_files_label = "Versteckte Dateien ausblenden" if self.show_hidden_files.get(
|
||||||
hidden_files_icon = self.icon_manager.get_icon('unhide') if self.show_hidden_files.get() else self.icon_manager.get_icon('hide')
|
) else "Versteckte Dateien anzeigen"
|
||||||
|
hidden_files_icon = self.icon_manager.get_icon(
|
||||||
|
'unhide') if self.show_hidden_files.get() else self.icon_manager.get_icon('hide')
|
||||||
more_menu.add_command(label=hidden_files_label, command=self.toggle_hidden_files,
|
more_menu.add_command(label=hidden_files_label, command=self.toggle_hidden_files,
|
||||||
image=hidden_files_icon, compound='left')
|
image=hidden_files_icon, compound='left')
|
||||||
|
|
||||||
@@ -438,7 +445,8 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
self.widget_manager.path_entry.insert(0, "Suchbegriff eingeben...")
|
self.widget_manager.path_entry.insert(0, "Suchbegriff eingeben...")
|
||||||
# Use after() to ensure the focus is set after the UI has updated
|
# Use after() to ensure the focus is set after the UI has updated
|
||||||
self.after(10, lambda: self.widget_manager.path_entry.focus_set())
|
self.after(10, lambda: self.widget_manager.path_entry.focus_set())
|
||||||
self.after(20, lambda: self.widget_manager.path_entry.select_range(0, tk.END))
|
self.after(
|
||||||
|
20, lambda: self.widget_manager.path_entry.select_range(0, tk.END))
|
||||||
|
|
||||||
self.widget_manager.path_entry.bind(
|
self.widget_manager.path_entry.bind(
|
||||||
"<FocusIn>", self.clear_search_placeholder)
|
"<FocusIn>", self.clear_search_placeholder)
|
||||||
@@ -1085,7 +1093,7 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
child.state(['selected'])
|
child.state(['selected'])
|
||||||
self.selected_item_frame = item_frame
|
self.selected_item_frame = item_frame
|
||||||
self.selected_file = path
|
self.selected_file = path
|
||||||
self.update_status_bar(path) # Pass selected path
|
self.update_status_bar(path) # Pass selected path
|
||||||
self.bind("<F2>", lambda e, p=path,
|
self.bind("<F2>", lambda e, p=path,
|
||||||
f=item_frame: self.on_rename_request(e, p, f))
|
f=item_frame: self.on_rename_request(e, p, f))
|
||||||
if self.dialog_mode == "save" and not os.path.isdir(path):
|
if self.dialog_mode == "save" and not os.path.isdir(path):
|
||||||
@@ -1100,7 +1108,7 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
item_text = self.tree.item(item_id, 'text').strip()
|
item_text = self.tree.item(item_id, 'text').strip()
|
||||||
path = os.path.join(self.current_dir, item_text)
|
path = os.path.join(self.current_dir, item_text)
|
||||||
self.selected_file = path
|
self.selected_file = path
|
||||||
self.update_status_bar(path) # Pass selected path
|
self.update_status_bar(path) # Pass selected path
|
||||||
if self.dialog_mode == "save" and not os.path.isdir(self.selected_file):
|
if self.dialog_mode == "save" and not os.path.isdir(self.selected_file):
|
||||||
self.widget_manager.filename_entry.delete(0, tk.END)
|
self.widget_manager.filename_entry.delete(0, tk.END)
|
||||||
self.widget_manager.filename_entry.insert(0, item_text)
|
self.widget_manager.filename_entry.insert(0, item_text)
|
||||||
@@ -1230,7 +1238,8 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
if selected_path and os.path.exists(selected_path):
|
if selected_path and os.path.exists(selected_path):
|
||||||
if os.path.isdir(selected_path):
|
if os.path.isdir(selected_path):
|
||||||
# Display item count for directories
|
# Display item count for directories
|
||||||
content_count = self._get_folder_content_count(selected_path)
|
content_count = self._get_folder_content_count(
|
||||||
|
selected_path)
|
||||||
if content_count is not None:
|
if content_count is not None:
|
||||||
status_text = f"'{os.path.basename(selected_path)}' ({content_count} Einträge)"
|
status_text = f"'{os.path.basename(selected_path)}' ({content_count} Einträge)"
|
||||||
else:
|
else:
|
||||||
@@ -1270,7 +1279,8 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
if not self.selected_file or not os.path.exists(self.selected_file):
|
if not self.selected_file or not os.path.exists(self.selected_file):
|
||||||
return
|
return
|
||||||
|
|
||||||
use_trash = self.settings.get("use_trash", False) and SEND2TRASH_AVAILABLE
|
use_trash = self.settings.get(
|
||||||
|
"use_trash", False) and SEND2TRASH_AVAILABLE
|
||||||
confirm = self.settings.get("confirm_delete", False)
|
confirm = self.settings.get("confirm_delete", False)
|
||||||
|
|
||||||
action_text = "in den Papierkorb verschieben" if use_trash else "endgültig löschen"
|
action_text = "in den Papierkorb verschieben" if use_trash else "endgültig löschen"
|
||||||
@@ -1475,7 +1485,7 @@ class CustomFileDialog(tk.Toplevel):
|
|||||||
|
|
||||||
def update_action_buttons_state(self):
|
def update_action_buttons_state(self):
|
||||||
is_writable = os.access(self.current_dir, os.W_OK)
|
is_writable = os.access(self.current_dir, os.W_OK)
|
||||||
state = tk.NORMAL if is_writable else tk.DISABLED
|
state = tk.NORMAL if is_writable and self.dialog_mode != "open" else tk.DISABLED
|
||||||
self.widget_manager.new_folder_button.config(state=state)
|
self.widget_manager.new_folder_button.config(state=state)
|
||||||
self.widget_manager.new_file_button.config(state=state)
|
self.widget_manager.new_file_button.config(state=state)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class GlotzMol(tk.Tk):
|
|||||||
dialog = CustomFileDialog(self,
|
dialog = CustomFileDialog(self,
|
||||||
initial_dir=os.path.expanduser("~"),
|
initial_dir=os.path.expanduser("~"),
|
||||||
filetypes=[("All Files", "*.*")
|
filetypes=[("All Files", "*.*")
|
||||||
])
|
], dialog_mode="save")
|
||||||
|
|
||||||
# This is the crucial part: wait for the dialog to be closed
|
# This is the crucial part: wait for the dialog to be closed
|
||||||
self.wait_window(dialog)
|
self.wait_window(dialog)
|
||||||
|
|||||||
Reference in New Issue
Block a user