Skip to content

Commit

Permalink
Issue 54 unapplied indication (#105)
Browse files Browse the repository at this point in the history
* Accepted rebase merge suggestion

* Resolve rebase conflicts

* Remove Quit menubtn handler

* Remove development code

* Initial CI of State Mgr class

* Add doctests

* Remove reference to StateManager

* Remove EventType enums

* Remove whitespace

* Fix lint error

* Simplify conditional

Co-authored-by: Thomas Archambault <toma@son-o-wimpy.com>
  • Loading branch information
tparchambault and Thomas Archambault committed Apr 23, 2021
1 parent 0813f5d commit d19ecd9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions python/fapolicy_analyzer/ui/main_window.py
Expand Up @@ -16,6 +16,11 @@ def __init__(self):
self.window = self.builder.get_object("mainWindow")
self.window.show_all()

# To support unapplied/unsaved changeset status in UI
# Maintain original title, toplevel reference
self.windowTopLevel = self.window.get_toplevel()
self.strTopLevelTitle = self.windowTopLevel.get_title()

def __unapplied_changes(self):
# Check backend for unapplied changes
if not stateManager.is_dirty_queue():
Expand Down Expand Up @@ -56,10 +61,16 @@ def on_start(self, *args):
mainContent = self.builder.get_object("mainContent")
mainContent.pack_start(page, True, True, 0)

def set_modified_titlebar(self, bModified=True):
"""Adds leading '*' to titlebar text with True or default argument"""
if bModified:
# Prefix title with '*'
self.windowTopLevel.set_title("*" + self.strTopLevelTitle)
else:
# Reset title to original text
self.windowTopLevel.set_title(self.strTopLevelTitle)

def on_changeset_updated(self):
"""The callback function invoked from the StateManager when
state changes."""
if stateManager.is_dirty_queue():
print("main_window -> There are undeployed changes!")
else:
print("main_window -> There are no undeployed changes...")
self.set_modified_titlebar(stateManager.is_dirty_queue())

0 comments on commit d19ecd9

Please sign in to comment.