Skip to content

Commit

Permalink
fixed save settings action not being disabled, changed flag name, oth…
Browse files Browse the repository at this point in the history
…er minor changes
  • Loading branch information
Nokse22 committed Jul 31, 2024
1 parent 1977cc4 commit 6424ea2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self, application=None, startup_filepath=None):

# Flags
self.applying_breakpoint = False
self.loading_file_manually = False
self.loading_file = False

# Defining all the actions
self.save_as_action = self.create_action('save-as-image', self.open_save_file_chooser)
Expand Down Expand Up @@ -408,7 +408,7 @@ def _on_factory_bind(_factory, list_item, what):
self.window_settings.sync_all_settings()

if startup_filepath:
self.loading_file_manually = True
self.loading_file = True
self.window_settings.set_setting("load-type", None, False)
self.logger.info(f"startup file detected: {startup_filepath}")
self.load_file(filepath=startup_filepath)
Expand Down Expand Up @@ -498,7 +498,7 @@ def on_scivis_component_combo_changed(self, *args):
# an action like reloading.

def reload_file(self, *args):
if not self.loading_file_manually:
if not self.loading_file:
self.logger.info("Loading file because load type or up changed")
self.load_file(filepath=self.filepath, override=True)

Expand Down Expand Up @@ -638,6 +638,9 @@ def set_settings_from_name(self, name):
self.window_settings.set_setting(key, value)

def check_for_options_change(self):
if self.loading_file:
return

state_name = self.settings_action.get_state().get_string()
if state_name == "custom":
return
Expand All @@ -658,7 +661,6 @@ def check_for_options_change(self):
if current_settings[key] != value:
self.logger.info(f"current key: {key}'s value is {current_settings[key]} != {value}")
self.change_setting_state(GLib.Variant("s", "custom"))
self.save_settings_action.set_enabled(True)
return

def periodic_check_for_file_change(self):
Expand Down Expand Up @@ -692,12 +694,12 @@ def change_setting_state(self, state):
self.settings_action.set_state(state)
return

self.save_settings_action.set_enabled(False)

self.set_settings_from_name(state.get_string())

self.settings_action.set_state(state)

self.save_settings_action.set_enabled(False)

self.update_background_color()

def get_gimble_limit(self):
Expand Down Expand Up @@ -725,7 +727,7 @@ def on_open_file_response(self, dialog, response):

if file:
filepath = file.get_path()
self.loading_file_manually = True
self.loading_file = True
self.window_settings.set_setting("load-type", None, False)
self.logger.info("open file response")
self.load_file(filepath=filepath)
Expand Down Expand Up @@ -842,7 +844,7 @@ def on_file_opened(self):

self.update_background_color()

self.loading_file_manually = False
self.loading_file = False
GLib.timeout_add(100, self.f3d_viewer.done)

def on_file_not_opened(self, filepath):
Expand All @@ -857,7 +859,7 @@ def on_file_not_opened(self, filepath):

self.update_background_color()

self.loading_file_manually = False
self.loading_file = False

def send_toast(self, message):
toast = Adw.Toast(title=message, timeout=2)
Expand Down Expand Up @@ -921,7 +923,7 @@ def on_drop_received(self, drop, value, x, y):
if extension in image_patterns:
self.load_hdri(filepath)
elif extension in file_patterns:
self.loading_file_manually = True
self.loading_file = True

self.window_settings.set_setting("load-type", None, False)
self.logger.info("drop received")
Expand Down

0 comments on commit 6424ea2

Please sign in to comment.