Skip to content

Commit 457746e

Browse files
committed
new auto mark functionality
preview threading fix
1 parent 80e0922 commit 457746e

File tree

2 files changed

+67
-13
lines changed

2 files changed

+67
-13
lines changed

src/dude.py

+50-13
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
CFG_KEY_SHOW_TOOLTIPS_INFO='show_tooltips_info'
9292
CFG_KEY_SHOW_TOOLTIPS_HELP='show_tooltips_help'
9393
CFG_KEY_PREVIEW_AUTO_UPDATE='preview_auto_update'
94+
CFG_KEY_AUTO_MARK='auto_mark'
9495
CFG_KEY_FULL_PATHS='show_full_paths'
9596
CFG_KEY_SHOW_MODE='show_mode'
9697
CFG_KEY_REL_SYMLINKS='relative_symlinks'
@@ -138,6 +139,7 @@
138139
CFG_KEY_SHOW_TOOLTIPS_INFO:True,
139140
CFG_KEY_SHOW_TOOLTIPS_HELP:True,
140141
CFG_KEY_PREVIEW_AUTO_UPDATE:True,
142+
CFG_KEY_AUTO_MARK:True,
141143
CFG_KEY_FULL_PATHS:False,
142144
CFG_KEY_SHOW_MODE:'0',
143145
CFG_KEY_REL_SYMLINKS:True,
@@ -627,6 +629,8 @@ def __init__(self,cwd,paths_to_add=None,exclude=None,exclude_regexp=None,norun=N
627629

628630
for name in themes_names:
629631
for darkness,darknesscode in (('',0),('Dark',1)):
632+
if name=='Vista' and darknesscode==1:
633+
continue
630634
full_name = name + ((' ' + darkness) if darknesscode else '')
631635
self.themes_combos[full_name]=name.lower(),darknesscode
632636

@@ -1813,6 +1817,7 @@ def get_settings_dialog(self):
18131817
self.show_tooltips_info = BooleanVar()
18141818
self.show_tooltips_help = BooleanVar()
18151819
self.preview_auto_update = BooleanVar()
1820+
self.auto_mark = BooleanVar()
18161821

18171822
self.show_full_paths = BooleanVar()
18181823
self.show_mode = StringVar()
@@ -1839,6 +1844,7 @@ def get_settings_dialog(self):
18391844
(self.show_tooltips_info,CFG_KEY_SHOW_TOOLTIPS_INFO),
18401845
(self.show_tooltips_help,CFG_KEY_SHOW_TOOLTIPS_HELP),
18411846
(self.preview_auto_update,CFG_KEY_PREVIEW_AUTO_UPDATE),
1847+
(self.auto_mark,CFG_KEY_AUTO_MARK),
18421848
(self.show_full_paths,CFG_KEY_FULL_PATHS),
18431849
(self.create_relative_symlinks,CFG_KEY_REL_SYMLINKS),
18441850
(self.erase_empty_directories,CFG_ERASE_EMPTY_DIRS),
@@ -1911,6 +1917,10 @@ def get_settings_dialog(self):
19111917
(preview_auto_update_cb:=Checkbutton(label_frame, text = ' ' + STR('Preview auto update'), variable=self.preview_auto_update)).grid(row=4,column=0,sticky='wens',padx=3,pady=2)
19121918
self_widget_tooltip(preview_auto_update_cb,STR('TOOLTIP_PAU'))
19131919

1920+
(auto_mark_cb:=Checkbutton(label_frame, text = ' ' + STR('Auto-mark behavior'), variable=self.auto_mark)).grid(row=5,column=0,sticky='wens',padx=3,pady=2)
1921+
self_widget_tooltip(auto_mark_cb,STR('TOOLTIP_AMB'))
1922+
1923+
19141924
label_frame=LabelFrame(self.settings_dialog.area_main, text=STR("Confirmation dialogs"),borderwidth=2,bg=self.bg_color)
19151925
label_frame.grid(row=row,column=0,sticky='wens',padx=3,pady=3) ; row+=1
19161926

@@ -3233,7 +3243,8 @@ def preview_focusin(self):
32333243

32343244
def show_preview(self,user_action=True):
32353245
self_preview = self.preview
3236-
self.preview_photo_image_cache = Image_Cache()
3246+
if not self.preview_photo_image_cache:
3247+
self.preview_photo_image_cache = Image_Cache()
32373248

32383249
if self.preview_shown:
32393250
self_preview.lift()
@@ -3308,19 +3319,24 @@ def update_preview(self):
33083319
elif ext_lower in TEXT_EXTENSIONS:
33093320
self.preview_label_img.pack_forget()
33103321
self.preview_text.delete(1.0, 'end')
3311-
try:
3312-
with open(path,'rt', encoding='utf-8', errors='ignore') as file:
3322+
if file_size<1024*1024*10:
3323+
try:
3324+
with open(path,'rt', encoding='utf-8', errors='ignore') as file:
33133325

3314-
cont_lines=file.readlines()
3315-
self.preview_label_txt_configure(text=STR('lines:') + f'{fnumber(len(cont_lines))}')
3316-
self.preview_text.insert('end', ''.join(cont_lines))
3317-
except Exception as e:
3318-
self.preview_label_txt_configure(text=str(e))
3319-
self.preview.title(path)
3320-
self.preview_frame_txt.pack_forget()
3326+
cont_lines=file.readlines()
3327+
self.preview_label_txt_configure(text=STR('lines:') + f'{fnumber(len(cont_lines))}')
3328+
self.preview_text.insert('end', ''.join(cont_lines))
3329+
except Exception as e:
3330+
self.preview_label_txt_configure(text=str(e))
3331+
self.preview.title(path)
3332+
self.preview_frame_txt.pack_forget()
3333+
else:
3334+
self.preview_frame_txt.pack(fill='both',expand=1)
3335+
self.preview.title(path)
33213336
else:
3322-
self.preview_frame_txt.pack(fill='both',expand=1)
3337+
self.preview_label_txt_configure(text='file size > 10MB')
33233338
self.preview.title(path)
3339+
self.preview_frame_txt.pack_forget()
33243340

33253341
elif file_size<1024*1024*10:
33263342
self.preview_label_img.pack_forget()
@@ -3366,7 +3382,8 @@ def hide_preview(self,user_action=True):
33663382
self.cfg.set_bool(CFG_KEY_SHOW_PREVIEW,False)
33673383

33683384
self.preview_photo_image_cache.end()
3369-
del self.preview_photo_image_cache
3385+
3386+
#del self.preview_photo_image_cache
33703387
self.preview_photo_image_cache = None
33713388

33723389
self.preview_label_txt_configure(text='')
@@ -4660,6 +4677,9 @@ def settings_ok(self):
46604677
self.cfg.set_bool(CFG_KEY_PREVIEW_AUTO_UPDATE,self.preview_auto_update.get())
46614678
self.preview_auto_update_bool = self.cfg_get_bool(CFG_KEY_PREVIEW_AUTO_UPDATE)
46624679

4680+
if self.cfg_get_bool(CFG_KEY_AUTO_MARK)!=self.auto_mark.get():
4681+
self.cfg.set_bool(CFG_KEY_AUTO_MARK,self.auto_mark.get())
4682+
46634683
if self.cfg_get_bool(CFG_KEY_FULL_PATHS)!=self.show_full_paths.get():
46644684
self.cfg.set_bool(CFG_KEY_FULL_PATHS,self.show_full_paths.get())
46654685
update1=True
@@ -5702,6 +5722,20 @@ def file_check_state(self,item):
57025722

57035723
return None
57045724

5725+
def check_and_auto_mark(self,action,tree):
5726+
#auto mark if nothing is selected
5727+
if not self.tagged and action!=HARDLINK and self.cfg_get_bool(CFG_KEY_AUTO_MARK):
5728+
item = self.sel_item
5729+
5730+
try:
5731+
kind,size,crc, (pathnr,path,file,ctime,dev,inode) = self.groups_tree_item_to_data[item]
5732+
print(kind)
5733+
if inode:
5734+
self.tag_toggle_selected(tree,item)
5735+
except:
5736+
#akcja na dolnym panelu na pliku "pojedynczym"
5737+
pass
5738+
57055739
@block_and_log
57065740
def process_files_in_groups_wrapper(self,action,all_groups):
57075741
processed_items=defaultdict(dict)
@@ -5714,6 +5748,8 @@ def process_files_in_groups_wrapper(self,action,all_groups):
57145748
self_sel_crc = self.sel_crc
57155749
self_tagged = self.tagged
57165750

5751+
self.check_and_auto_mark(action,self.groups_tree)
5752+
57175753
self_tree_children_sub = self.tree_children_sub
57185754

57195755
for crc in self.tree_children[self.groups_tree]:
@@ -5749,6 +5785,8 @@ def process_files_in_folder_wrapper(self,action,on_dir_action=False):
57495785
else:
57505786
scope_title=STR('Selected Directory.')
57515787

5788+
self.check_and_auto_mark(action,self.folder_tree)
5789+
57525790
self_current_folder_items_tagged = self.current_folder_items_tagged
57535791
self_groups_tree_item_to_data = self.groups_tree_item_to_data
57545792
index = defaultdict(int)
@@ -6527,7 +6565,6 @@ def process_files(self,action,processed_items,scope_title):
65276565
#kind,size_item,crc_item, (pathnr,path,file,ctime,dev,inode) = self_groups_tree_item_to_data[item] for index,item in items_dict.items()
65286566
self.process_files_total_size = sum([self_groups_tree_item_to_data[item][1] for group,items_dict in processed_items.items() for item in items_dict.values()])
65296567
else:
6530-
65316568
self.process_files_total_size = sum([self.crc_to_size[crc] for crc,items_dict in processed_items.items() for item in items_dict.values()])
65326569

65336570
self.process_files_total_size_str = bytes_to_str(self.process_files_total_size)

src/text.py

+17
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,23 @@ class LANGUAGES:
123123
'it': 'Interrotto ... ',
124124
'fr': 'Annulation en cours ... ',
125125
},
126+
'Auto-mark behavior': {
127+
'pl': 'Auto zaznaczanie',
128+
'es': 'Comportamiento de auto-marcado',
129+
'ru': 'Автоматическая отметка',
130+
'de': 'Automatisches Markierungsverhalten',
131+
'it': 'Comportamento di auto-segnalazione',
132+
'fr': 'Comportement de marquage automatique',
133+
},
134+
'TOOLTIP_AMB': {
135+
'en': 'If no files are marked,\nthe action automatically marks the currently selected file.',
136+
'pl': 'Jeżeli nie ma zaznaczonych plików,\nakcja automatycznie zaznacza aktualnie wybrany plik.',
137+
'es': 'Si no hay archivos marcados,\nla acción marca automáticamente el archivo actualmente seleccionado.',
138+
'ru': 'Если файлы не отмечены,\nдействие автоматически отмечает текущий выбранный файл.',
139+
'de': 'Wenn keine Dateien markiert sind,\nmarkiert die Aktion automatisch die derzeit ausgewählte Datei.',
140+
'it': 'Se nessun file è contrassegnato,\nl’azione contrassegna automaticamente il file attualmente selezionato.',
141+
'fr': 'Si aucun fichier n’est marqué,\nl’action marque automatiquement le fichier actuellement sélectionné.',
142+
},
126143
'Abort searching.': {
127144
'pl': 'Przerwij szukanie.',
128145
'es': 'Abortar búsqueda.',

0 commit comments

Comments
 (0)