Skip to content

Commit 03ae60c

Browse files
committed
feat: Support Stop app operation on GUI
The TUI already has this behavior Tested (40.2 clean install pre-login): - Started OD with app installed, but not running -> Run Logos shown - When "Run Logos" is hit, button switches to "Stop Logos" - When Logos was launched using OD, but is closed independently of OD, button switches to "Run Logos" after the app closes - "Run App" -> Switches to "Stop App", when "Stop App" is clicked, it stops Logos and switches to "Run Logos", when "Run Logos" is hit again, it launches - GUI when Logos isn't installed no errors seen on console - When Logos is installed via the GUI, button switches from "Install" to "Run Logos". Hitting that switches to "Stop Logos", hitting that switches to "Run Logos" which launches Logos
1 parent 9c5a8d2 commit 03ae60c

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

ou_dedetai/gui_app.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# - https://tkdocs.com/
44
# - https://github.com/thw26/LogosLinuxInstaller/blob/master/LogosLinuxInstaller.sh
55

6+
import copy
67
import logging
78
from pathlib import Path
89
from queue import Queue
@@ -25,6 +26,7 @@
2526
PROMPT_OPTION_NEW_FILE,
2627
)
2728
from ou_dedetai.config import EphemeralConfiguration
29+
import ou_dedetai.logos
2830

2931
from . import backup
3032
from . import constants
@@ -34,6 +36,7 @@
3436
from . import system
3537
from . import utils
3638
from . import wine
39+
import ou_dedetai
3740

3841
class GuiApp(App):
3942
"""Implements the App interface for all windows"""
@@ -441,6 +444,21 @@ def _update_lli_version():
441444
self.update_latest_lli_release_button()
442445
self.gui.update_lli_button.state(['disabled'])
443446
self.start_thread(_update_lli_version)
447+
# Spawn a thread to ensure our logos state stays up to date
448+
def _monitor_faithlife_product_pids():
449+
last_state = copy.copy(self.logos.logos_state)
450+
while True:
451+
if self.is_installed():
452+
self.logos.monitor()
453+
time.sleep(1)
454+
else:
455+
# Will probably be some time before we need to monitor.
456+
time.sleep(30)
457+
# If our state changed, we need to update our button.
458+
if last_state != self.logos.logos_state:
459+
self.update_app_button()
460+
last_state = copy.copy(self.logos.logos_state)
461+
self.start_thread(_monitor_faithlife_product_pids)
444462
self.gui.update_lli_label.config(text=text)
445463
self.gui.run_indexing_radio.config(
446464
command=self.on_action_radio_clicked
@@ -512,6 +530,9 @@ def run_installer(self, evt=None):
512530
installer_window_top = Toplevel()
513531
InstallerWindow(installer_window_top, self.root, app=self, class_=classname)
514532

533+
def stop_logos(self):
534+
self.start_thread(self.logos.stop)
535+
515536
def run_logos(self, evt=None):
516537
self.start_thread(self.logos.start)
517538

@@ -630,8 +651,12 @@ def update_logging_button(self, evt=None):
630651
def update_app_button(self, evt=None):
631652
self.gui.app_button.state(['!disabled'])
632653
if self.is_installed():
633-
self.gui.app_buttonvar.set(f"Run {self.conf.faithlife_product}")
634-
self.gui.app_button.config(command=self.run_logos)
654+
if self.logos.logos_state == ou_dedetai.logos.State.RUNNING:
655+
self.gui.app_buttonvar.set(f"Stop {self.conf.faithlife_product}")
656+
self.gui.app_button.config(command=self.stop_logos)
657+
else:
658+
self.gui.app_buttonvar.set(f"Run {self.conf.faithlife_product}")
659+
self.gui.app_button.config(command=self.run_logos)
635660
self.gui.logging_button.state(['!disabled'])
636661
self.gui.app_install_advanced.grid_forget()
637662
self.gui.actions_button.state(['!disabled'])

0 commit comments

Comments
 (0)