forked from FaithLife-Community/LogosLinuxInstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_app.py
906 lines (820 loc) · 32.4 KB
/
gui_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
# References:
# - https://tkdocs.com/
# - https://github.com/thw26/LogosLinuxInstaller/blob/master/LogosLinuxInstaller.sh # noqa: E501
import logging
from pathlib import Path
from queue import Queue
from threading import Thread
from tkinter import PhotoImage
from tkinter import Tk
from tkinter import Toplevel
from tkinter import filedialog as fd
from tkinter.ttk import Style
import config
import control
import gui
import installer
import utils
import wine
class Root(Tk):
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
self.classname = kwargs.get('classname')
# Set the theme.
self.style = Style()
self.style.theme_use('alt')
# Update color scheme.
self.style.configure('TCheckbutton', bordercolor=config.LOGOS_GRAY)
self.style.configure('TCombobox', bordercolor=config.LOGOS_GRAY)
self.style.configure('TCheckbutton', indicatorcolor=config.LOGOS_GRAY)
self.style.configure('TRadiobutton', indicatorcolor=config.LOGOS_GRAY)
bg_widgets = [
'TCheckbutton', 'TCombobox', 'TFrame', 'TLabel', 'TRadiobutton'
]
fg_widgets = ['TButton', 'TSeparator']
for w in bg_widgets:
self.style.configure(w, background=config.LOGOS_WHITE)
for w in fg_widgets:
self.style.configure(w, background=config.LOGOS_GRAY)
self.style.configure(
'Horizontal.TProgressbar',
thickness=10, background=config.LOGOS_BLUE,
bordercolor=config.LOGOS_GRAY,
troughcolor=config.LOGOS_GRAY,
)
# Justify to the left [('Button.label', {'sticky': 'w'})]
self.style.layout(
"TButton", [(
'Button.border', {
'sticky': 'nswe', 'children': [(
'Button.focus', {
'sticky': 'nswe', 'children': [(
'Button.padding', {
'sticky': 'nswe', 'children': [(
'Button.label', {'sticky': 'w'}
)]
}
)]
}
)]
}
)]
)
# Make root widget's outer border expand with window.
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
# Set panel icon.
app_dir = Path(__file__).parent
self.icon = app_dir / 'img' / 'logos4-128-icon.png'
self.pi = PhotoImage(file=f'{self.icon}')
self.iconphoto(False, self.pi)
class InstallerWindow():
def __init__(self, new_win, root, **kwargs):
# Set root parameters.
self.win = new_win
self.root = root
self.win.title("Faithlife Bible Software Installer")
self.win.resizable(False, False)
self.gui = gui.InstallerGui(self.win)
# Initialize variables.
self.flproduct = None # config.FLPRODUCT
self.release_thread = None
self.wine_exe = None
self.wine_thread = None
self.winetricksbin = None
self.appimages = None
# self.appimage_verified = None
# self.logos_verified = None
# self.tricks_verified = None
# Set widget callbacks and event bindings.
self.gui.product_dropdown.bind(
'<<ComboboxSelected>>',
self.set_product
)
self.gui.version_dropdown.bind(
'<<ComboboxSelected>>',
self.set_version
)
self.gui.release_dropdown.bind(
'<<ComboboxSelected>>',
self.set_release
)
self.gui.release_check_button.config(
command=self.on_release_check_released
)
self.gui.wine_dropdown.bind(
'<<ComboboxSelected>>',
self.set_wine
)
self.gui.wine_check_button.config(
command=self.on_wine_check_released
)
self.gui.tricks_dropdown.bind(
'<<ComboboxSelected>>',
self.set_winetricks
)
self.gui.fonts_checkbox.config(command=self.set_skip_fonts)
self.gui.skipdeps_checkbox.config(command=self.set_skip_dependencies)
self.gui.cancel_button.config(command=self.on_cancel_released)
self.gui.okay_button.config(command=self.on_okay_released)
# Set root widget event bindings.
self.root.bind(
"<Return>",
self.on_okay_released
)
self.root.bind(
"<Escape>",
self.on_cancel_released
)
self.root.bind(
'<<StartIndeterminateProgress>>',
self.start_indeterminate_progress
)
self.root.bind(
"<<SetWineExe>>",
self.update_wine_check_progress
)
self.get_q = Queue()
self.get_evt = "<<GetFile>>"
self.root.bind(self.get_evt, self.update_download_progress)
self.check_evt = "<<CheckFile>>"
self.root.bind(self.check_evt, self.update_file_check_progress)
self.status_q = Queue()
self.root.bind(
"<<UpdateStatus>>",
self.update_status_text
)
self.progress_q = Queue()
self.root.bind(
"<<UpdateProgress>>",
self.update_progress
)
self.todo_q = Queue()
self.root.bind(
"<<ToDo>>",
self.todo
)
self.product_q = Queue()
self.version_q = Queue()
self.releases_q = Queue()
self.release_q = Queue()
self.wine_q = Queue()
self.tricksbin_q = Queue()
# Run commands.
self.get_winetricks_options()
self.start_ensure_config()
def start_ensure_config(self):
self.config_thread = Thread(
target=installer.ensure_installation_config,
kwargs={'app': self},
daemon=True
)
self.config_thread.start()
def get_winetricks_options(self):
self.gui.tricks_dropdown['values'] = utils.get_winetricks_options()
self.gui.tricksvar.set(self.gui.tricks_dropdown['values'][0])
def set_input_widgets_state(self, state, widgets='all'):
if state == 'enabled':
state = ['!disabled']
elif state == 'disabled':
state = ['disabled']
all_widgets = [
self.gui.product_dropdown,
self.gui.version_dropdown,
self.gui.release_dropdown,
self.gui.release_check_button,
self.gui.wine_dropdown,
self.gui.wine_check_button,
self.gui.tricks_dropdown,
self.gui.okay_button,
]
if widgets == 'all':
widgets = all_widgets
for w in widgets:
w.state(state)
def todo(self, evt=None, task=None):
widgets = []
if not task:
if not self.todo_q.empty():
task = self.todo_q.get()
else:
return
self.set_input_widgets_state('enabled')
if task == 'FLPRODUCT':
# Disable all input widgets after Version.
widgets = [
self.gui.version_dropdown,
self.gui.release_dropdown,
self.gui.release_check_button,
self.gui.wine_dropdown,
self.gui.wine_check_button,
# self.gui.tricks_dropdown,
self.gui.okay_button,
]
self.set_input_widgets_state('disabled', widgets=widgets)
if not self.gui.productvar.get():
self.gui.productvar.set(self.gui.product_dropdown['values'][0])
self.set_product()
elif task == 'TARGETVERSION':
# Disable all input widgets after Version.
widgets = [
self.gui.release_dropdown,
self.gui.release_check_button,
self.gui.wine_dropdown,
self.gui.wine_check_button,
self.gui.okay_button,
]
self.set_input_widgets_state('disabled', widgets=widgets)
if not self.gui.versionvar.get():
self.gui.versionvar.set(self.gui.version_dropdown['values'][1])
self.set_version()
elif task == 'LOGOS_RELEASE_VERSION':
# Disable all input widgets after Release.
widgets = [
self.gui.wine_dropdown,
self.gui.wine_check_button,
self.gui.okay_button,
]
self.set_input_widgets_state('disabled', widgets=widgets)
# if not self.gui.releasevar.get():
if not self.gui.release_dropdown['values']:
# No previous choice.
self.start_releases_check()
else:
# Check if previous choice was for other TARGETVERSION.
if config.TARGETVERSION == '9' and not self.gui.release_dropdown['values'][0].startswith('9'): # noqa: E501
self.start_releases_check()
if config.TARGETVERSION == '10' and self.gui.release_dropdown['values'][0].startswith('9'): # noqa: E501
self.start_releases_check()
elif task == 'WINE_EXE':
# Disable all input widgets after Wine Exe.
widgets = [
self.gui.okay_button,
]
self.set_input_widgets_state('disabled', widgets=widgets)
self.start_wine_versions_check()
elif task == 'WINETRICKSBIN':
# Disable all input widgets after Winetricks.
widgets = [
self.gui.okay_button,
]
self.set_input_widgets_state('disabled', widgets=widgets)
self.set_winetricks()
elif task == 'INSTALL':
self.gui.statusvar.set('Ready to install!')
self.gui.progressvar.set(0)
elif task == 'INSTALLING':
self.set_input_widgets_state('disabled')
elif task == 'DONE':
self.update_install_progress()
def set_product(self, evt=None):
if self.gui.productvar.get()[0] == 'C': # ignore default text
return
self.gui.flproduct = self.gui.productvar.get()
self.gui.product_dropdown.selection_clear()
if evt: # manual override; reset dependent variables
config.FLPRODUCT = None
config.INSTALLDIR = None
config.WINE_EXE = None
config.WINETRICKSBIN = None
self.start_ensure_config()
else:
self.product_q.put(self.gui.flproduct)
def set_version(self, evt=None):
self.gui.targetversion = self.gui.versionvar.get()
self.gui.version_dropdown.selection_clear()
if evt: # manual override; reset dependent variables
logging.debug(f"Change TARGETVERSION to {self.gui.targetversion}")
config.TARGETVERSION = None
self.gui.releasevar.set('')
config.LOGOS_RELEASE_VERSION = None
config.INSTALLDIR = None
config.WINE_EXE = None
config.WINETRICKSBIN = None
self.start_ensure_config()
else:
self.version_q.put(self.gui.targetversion)
def start_releases_check(self):
# Disable button; clear list.
self.gui.release_check_button.state(['disabled'])
# self.gui.releasevar.set('')
self.gui.release_dropdown['values'] = []
# Setup queue, signal, thread.
self.release_evt = "<<ReleaseCheckProgress>>"
self.root.bind(
self.release_evt,
self.update_release_check_progress
)
self.release_thread = Thread(
target=utils.get_logos_releases,
kwargs={'app': self},
daemon=True,
)
# Start progress.
self.gui.progress.config(mode='indeterminate')
self.gui.progress.start()
self.gui.statusvar.set("Downloading Release list…")
# Start thread.
self.release_thread.start()
def set_release(self, evt=None):
if self.gui.releasevar.get()[0] == 'C': # ignore default text
return
self.gui.logos_release_version = self.gui.releasevar.get()
self.gui.release_dropdown.selection_clear()
if evt: # manual override
config.LOGOS_RELEASE_VERSION = None
self.start_ensure_config()
else:
self.release_q.put(self.gui.logos_release_version)
def start_find_appimage_files(self):
# Setup queue, signal, thread.
self.appimage_q = Queue()
self.appimage_evt = "<<FindAppImageProgress>>"
self.root.bind(
self.appimage_evt,
self.update_find_appimage_progress
)
self.appimage_thread = Thread(
target=utils.find_appimage_files,
kwargs={'app': self},
daemon=True
)
# Start progress.
self.gui.progress.config(mode='indeterminate')
self.gui.progress.start()
self.gui.statusvar.set("Finding available wine AppImages…")
# Start thread.
self.appimage_thread.start()
def start_wine_versions_check(self):
if not self.appimages:
self.start_find_appimage_files()
return
# Setup queue, signal, thread.
self.wines_q = Queue()
self.wine_evt = "<<WineCheckProgress>>"
self.root.bind(
self.wine_evt,
self.update_wine_check_progress
)
self.wine_thread = Thread(
target=utils.get_wine_options,
args=[
self.appimages,
utils.find_wine_binary_files()
],
kwargs={'app': self},
daemon=True
)
# Start progress.
self.gui.progress.config(mode='indeterminate')
self.gui.progress.start()
self.gui.statusvar.set("Finding available wine binaries…")
# Start thread.
self.wine_thread.start()
def set_wine(self, evt=None):
self.gui.wine_exe = self.gui.winevar.get()
self.gui.wine_dropdown.selection_clear()
if evt: # manual override
config.WINE_EXE = None
self.start_ensure_config()
else:
self.wine_q.put(self.gui.wine_exe)
def set_winetricks(self, evt=None):
self.gui.winetricksbin = self.gui.tricksvar.get()
self.gui.tricks_dropdown.selection_clear()
if evt: # manual override
config.WINETRICKSBIN = None
self.start_ensure_config()
else:
self.tricksbin_q.put(self.gui.winetricksbin)
def on_release_check_released(self, evt=None):
self.start_releases_check()
def on_wine_check_released(self, evt=None):
self.gui.wine_check_button.state(['disabled'])
self.start_wine_versions_check()
def set_skip_fonts(self, evt=None):
self.gui.skip_fonts = 1 - self.gui.fontsvar.get() # invert True/False
config.SKIP_FONTS = self.gui.skip_fonts
logging.debug(f"> {config.SKIP_FONTS=}")
def set_skip_dependencies(self, evt=None):
self.gui.skip_dependencies = 1 - self.gui.skipdepsvar.get() # invert True/False # noqa: E501
config.SKIP_DEPENDENCIES = self.gui.skip_dependencies
logging.debug(f"> {config.SKIP_DEPENDENCIES=}")
def on_okay_released(self, evt=None):
# Update desktop panel icon.
self.root.icon = config.LOGOS_ICON_URL
self.start_install_thread()
def on_cancel_released(self, evt=None):
self.win.destroy()
return 1
def start_install_thread(self, evt=None):
self.gui.progress.config(mode='determinate')
th = Thread(
target=installer.ensure_launcher_shortcuts,
kwargs={'app': self},
daemon=True
)
th.start()
def start_indeterminate_progress(self, evt=None):
self.gui.progress.state(['!disabled'])
self.gui.progressvar.set(0)
self.gui.progress.config(mode='indeterminate')
self.gui.progress.start()
def stop_indeterminate_progress(self, evt=None):
self.gui.progress.stop()
self.gui.progress.state(['disabled'])
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
self.gui.statusvar.set('')
def update_release_check_progress(self, evt=None):
self.stop_indeterminate_progress()
self.gui.release_check_button.state(['!disabled'])
if not self.releases_q.empty():
self.gui.release_dropdown['values'] = self.releases_q.get()
self.gui.releasevar.set(self.gui.release_dropdown['values'][0])
self.set_release()
else:
self.gui.statusvar.set("Failed to get release list. Check connection and try again.") # noqa: E501
def update_find_appimage_progress(self, evt=None):
self.stop_indeterminate_progress()
if not self.appimage_q.empty():
self.appimages = self.appimage_q.get()
self.start_wine_versions_check()
def update_wine_check_progress(self, evt=None):
if evt and self.wines_q.empty():
return
self.gui.wine_dropdown['values'] = self.wines_q.get()
self.gui.winevar.set(self.gui.wine_dropdown['values'][0])
self.set_wine()
self.stop_indeterminate_progress()
self.gui.wine_check_button.state(['!disabled'])
def update_file_check_progress(self, evt=None):
self.gui.progress.stop()
self.gui.statusvar.set('')
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
def update_download_progress(self, evt=None):
d = self.get_q.get()
self.gui.progressvar.set(int(d))
def update_progress(self, evt=None):
progress = self.progress_q.get()
if not type(progress) is int:
return
if progress >= 100:
self.gui.progressvar.set(0)
# self.gui.progress.state(['disabled'])
else:
self.gui.progressvar.set(progress)
def update_status_text(self, evt=None, status=None):
text = ''
if evt:
text = self.status_q.get()
elif status:
text = status
self.gui.statusvar.set(text)
def update_install_progress(self, evt=None):
self.gui.progress.stop()
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
self.gui.statusvar.set('')
self.gui.okay_button.config(
text="Exit",
command=self.on_cancel_released,
)
self.gui.okay_button.state(['!disabled'])
self.root.event_generate('<<InstallFinished>>')
self.win.destroy()
return 0
class ControlWindow():
def __init__(self, root, *args, **kwargs):
# Set root parameters.
self.root = root
self.root.title("Faithlife Bible Software Control Panel")
self.root.resizable(False, False)
self.gui = gui.ControlGui(self.root)
text = self.gui.update_lli_label.cget('text')
ver = config.LLI_CURRENT_VERSION
new = config.LLI_LATEST_VERSION
text = f"{text}\ncurrent: v{ver}\nlatest: v{new}"
self.gui.update_lli_label.config(text=text)
self.configure_app_button()
self.gui.run_indexing_radio.config(
command=self.on_action_radio_clicked
)
self.gui.remove_library_catalog_radio.config(
command=self.on_action_radio_clicked
)
self.gui.remove_index_files_radio.config(
command=self.on_action_radio_clicked
)
self.gui.actions_button.config(command=self.gui.actioncmd)
self.gui.loggingstatevar.set('Enable')
self.gui.logging_button.config(
text=self.gui.loggingstatevar.get(),
command=self.switch_logging
)
self.gui.logging_button.state(['disabled'])
self.gui.config_button.config(command=control.edit_config)
self.gui.deps_button.config(command=self.install_deps)
self.gui.backup_button.config(command=self.run_backup)
self.gui.restore_button.config(command=self.run_restore)
self.gui.update_lli_button.config(
command=self.update_to_latest_lli_release
)
self.gui.latest_appimage_button.config(
command=self.update_to_latest_appimage
)
if config.WINEBIN_CODE != "AppImage" and config.WINEBIN_CODE != "Recommended": # noqa: E501
self.gui.latest_appimage_button.state(['disabled'])
gui.ToolTip(
self.gui.latest_appimage_button,
"This button is disabled. The configured install was not created using an AppImage." # noqa: E501
)
self.gui.set_appimage_button.state(['disabled'])
gui.ToolTip(
self.gui.set_appimage_button,
"This button is disabled. The configured install was not created using an AppImage." # noqa: E501
)
self.update_latest_lli_release_button()
self.update_latest_appimage_button()
self.gui.set_appimage_button.config(command=self.set_appimage)
self.gui.get_winetricks_button.config(command=self.get_winetricks)
self.gui.run_winetricks_button.config(command=self.launch_winetricks)
self.update_run_winetricks_button()
self.logging_q = Queue()
self.root.bind('<<InitLoggingButton>>', self.initialize_logging_button)
self.root.bind('<<UpdateLoggingButton>>', self.update_logging_button)
self.status_q = Queue()
self.root.bind('<<ClearStatus>>', self.clear_status_text)
self.root.bind('<<UpdateStatus>>', self.update_status_text)
self.progress_q = Queue()
self.root.bind(
'<<StartIndeterminateProgress>>',
self.start_indeterminate_progress
)
self.root.bind(
'<<StopIndeterminateProgress>>',
self.stop_indeterminate_progress
)
self.root.bind(
'<<UpdateProgress>>',
self.update_progress
)
self.root.bind(
"<<UpdateLatestAppImageButton>>",
self.update_latest_appimage_button
)
self.root.bind('<<InstallFinished>>', self.update_app_button)
self.get_q = Queue()
self.get_evt = "<<GetFile>>"
self.root.bind(self.get_evt, self.update_download_progress)
self.check_evt = "<<CheckFile>>"
self.root.bind(self.check_evt, self.update_file_check_progress)
# Start function to determine app logging state.
if utils.app_is_installed():
t = Thread(
target=wine.get_app_logging_state,
kwargs={'app': self, 'init': True}
)
t.start()
self.gui.statusvar.set('Getting current app logging status…')
self.start_indeterminate_progress()
def configure_app_button(self, evt=None):
if utils.find_installed_product():
self.gui.app_buttonvar.set(f"Run {config.FLPRODUCT}")
self.gui.app_button.config(command=self.run_logos)
self.gui.get_winetricks_button.state(['!disabled'])
else:
self.gui.app_button.config(command=self.run_installer)
def run_installer(self, evt=None):
classname = "LogosLinuxInstaller"
self.new_win = Toplevel()
InstallerWindow(self.new_win, self.root, class_=classname)
self.root.icon = config.LOGOS_ICON_URL
def run_logos(self, evt=None):
t = Thread(target=wine.run_logos)
t.start()
def on_action_radio_clicked(self, evt=None):
if utils.app_is_installed():
self.gui.actions_button.state(['!disabled'])
if self.gui.actionsvar.get() == 'run-indexing':
self.gui.actioncmd = self.run_indexing
elif self.gui.actionsvar.get() == 'remove-library-catalog':
self.gui.actioncmd = self.remove_library_catalog
elif self.gui.actionsvar.get() == 'remove-index-files':
self.gui.actioncmd = self.remove_indexes
def run_indexing(self, evt=None):
t = Thread(target=wine.run_indexing)
t.start()
def remove_library_catalog(self, evt=None):
control.remove_library_catalog()
def remove_indexes(self, evt=None):
self.gui.statusvar.set("Removing indexes…")
t = Thread(
target=control.remove_all_index_files,
kwargs={'app': self}
)
t.start()
def run_backup(self, evt=None):
# Get backup folder.
if config.BACKUPDIR is None:
config.BACKUPDIR = fd.askdirectory(
parent=self.root,
title=f"Choose folder for {config.FLPRODUCT} backups",
initialdir=Path().home(),
)
if not config.BACKUPDIR: # user cancelled
return
# Prepare progress bar.
self.gui.progress.state(['!disabled'])
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
# Start backup thread.
t = Thread(target=control.backup, args=[self], daemon=True)
t.start()
def run_restore(self, evt=None):
# FIXME: Allow user to choose restore source?
# Start restore thread.
t = Thread(target=control.restore, args=[self], daemon=True)
t.start()
def install_deps(self, evt=None):
t = Thread(target=utils.check_dependencies, daemon=True)
self.start_indeterminate_progress()
t.start()
def open_file_dialog(self, filetype_name, filetype_extension):
file_path = fd.askopenfilename(
title=f"Select {filetype_name}",
filetypes=[
(filetype_name, f"*.{filetype_extension}"),
("All Files", "*.*")
],
)
return file_path
def update_to_latest_lli_release(self, evt=None):
self.start_indeterminate_progress()
self.gui.statusvar.set("Updating to latest Logos Linux Installer version…") # noqa: E501
t = Thread(
target=utils.update_to_latest_lli_release,
kwargs={'app': self},
daemon=True,
)
t.start()
def update_to_latest_appimage(self, evt=None):
config.APPIMAGE_FILE_PATH = config.RECOMMENDED_WINE64_APPIMAGE_FULL_FILENAME # noqa: E501
self.start_indeterminate_progress()
self.gui.statusvar.set("Updating to latest AppImage…")
t = Thread(
target=utils.set_appimage_symlink,
kwargs={'app': self},
daemon=True,
)
t.start()
def set_appimage(self, evt=None):
appimage_filename = self.open_file_dialog("AppImage", "AppImage")
if not appimage_filename:
return
config.SELECTED_APPIMAGE_FILENAME = appimage_filename
t = Thread(
target=utils.set_appimage_symlink,
kwargs={'app': self},
daemon=True,
)
t.start()
def get_winetricks(self, evt=None):
self.gui.statusvar.set("Installing Winetricks…")
t1 = Thread(
target=utils.install_winetricks,
args=[config.APPDIR_BINDIR],
kwargs={'app': self},
daemon=True,
)
t1.start()
self.update_run_winetricks_button()
def launch_winetricks(self, evt=None):
self.gui.statusvar.set("Launching Winetricks…")
# Start winetricks in thread.
t1 = Thread(target=wine.run_winetricks)
t1.start()
# Start thread to clear status after delay.
args = [12000, self.root.event_generate, '<<ClearStatus>>']
t2 = Thread(target=self.root.after, args=args, daemon=True)
t2.start()
def switch_logging(self, evt=None):
prev_state = self.gui.loggingstatevar.get()
new_state = 'Enable' if prev_state == 'Disable' else 'Disable'
kwargs = {
'action': new_state.lower(),
'app': self,
}
self.gui.statusvar.set(f"Switching app logging to '{prev_state}d'…")
self.gui.progress.state(['!disabled'])
self.gui.progress.start()
self.gui.logging_button.state(['disabled'])
t = Thread(target=wine.switch_logging, kwargs=kwargs)
t.start()
def initialize_logging_button(self, evt=None):
self.gui.statusvar.set('')
self.gui.progress.stop()
self.gui.progress.state(['disabled'])
state = self.reverse_logging_state_value(self.logging_q.get())
self.gui.loggingstatevar.set(state[:-1].title())
self.gui.logging_button.state(['!disabled'])
def update_logging_button(self, evt=None):
self.gui.statusvar.set('')
self.gui.progress.stop()
self.gui.progress.state(['disabled'])
state = self.logging_q.get()
self.gui.loggingstatevar.set(state[:-1].title())
self.gui.logging_button.state(['!disabled'])
def update_app_button(self, evt=None):
self.gui.app_button.state(['!disabled'])
self.gui.app_buttonvar.set(f"Run {config.FLPRODUCT}")
self.configure_app_button()
self.update_run_winetricks_button()
def update_latest_lli_release_button(self, evt=None):
status, reason = utils.compare_logos_linux_installer_version()
msg = None
if utils.get_runmode() != 'binary':
state = 'disabled'
msg = "This button is disabled. Can't run self-update from script."
elif status == 0:
state = '!disabled'
elif status == 1:
state = 'disabled'
msg = "This button is disabled. Logos Linux Installer is up-to-date." # noqa: E501
elif status == 2:
state = 'disabled'
msg = "This button is disabled. Logos Linux Installer is newer than the latest release." # noqa: E501
if msg:
gui.ToolTip(self.gui.update_lli_button, msg)
self.clear_status_text()
self.stop_indeterminate_progress()
self.gui.update_lli_button.state([state])
def update_latest_appimage_button(self, evt=None):
status, reason = utils.compare_recommended_appimage_version()
msg = None
if status == 0:
state = '!disabled'
elif status == 1:
state = 'disabled'
msg = "This button is disabled. The AppImage is already set to the latest recommended." # noqa: E501
elif status == 2:
state = 'disabled'
msg = "This button is disabled. The AppImage version is newer than the latest recommended." # noqa: E501
if msg:
gui.ToolTip(self.gui.latest_appimage_button, msg)
self.clear_status_text()
self.stop_indeterminate_progress()
self.gui.latest_appimage_button.state([state])
def update_run_winetricks_button(self, evt=None):
if utils.file_exists(config.WINETRICKSBIN):
state = '!disabled'
else:
state = 'disabled'
self.gui.run_winetricks_button.state([state])
def reverse_logging_state_value(self, state):
if state == 'DISABLED':
return 'ENABLED'
else:
return 'DISABLED'
def clear_status_text(self, evt=None):
self.gui.statusvar.set('')
def update_file_check_progress(self, evt=None):
self.gui.progress.stop()
self.gui.statusvar.set('')
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
def update_download_progress(self, evt=None):
d = self.get_q.get()
self.gui.progressvar.set(int(d))
def update_progress(self, evt=None):
if self.config_thread.is_alive():
# Don't update config progress.
self.gui.progressvar.set(0)
return
progress = self.progress_q.get()
if not type(progress) is int:
return
if progress >= 100:
self.gui.progressvar.set(0)
# self.gui.progress.state(['disabled'])
else:
self.gui.progressvar.set(progress)
def update_status_text(self, evt=None):
self.gui.statusvar.set(self.status_q.get())
def start_indeterminate_progress(self, evt=None):
self.gui.progress.state(['!disabled'])
self.gui.progressvar.set(0)
self.gui.progress.config(mode='indeterminate')
self.gui.progress.start()
def stop_indeterminate_progress(self, evt=None):
self.gui.progress.stop()
self.gui.progress.state(['disabled'])
self.gui.progress.config(mode='determinate')
self.gui.progressvar.set(0)
def control_panel_app():
utils.set_debug()
classname = "LogosLinuxControlPanel"
root = Root(className=classname)
ControlWindow(root, class_=classname)
root.mainloop()