Commit 6b25151a authored by Sebastian Spaeth's avatar Sebastian Spaeth

simplify scrolled_page.made_database_changes

Rather than using a getter and a setter function which is only ever queried
in a single code place, make "made_dabase_changes" an attribute "is_dirty"
which is queried when needed. Simpler AND shorter.
parent 798d3baa
Pipeline #216893 failed with stage
in 7 minutes and 6 seconds
......@@ -400,7 +400,7 @@ class EntryPage:
entry_uuid = self.unlocked_database.database_manager.get_entry_uuid_from_entry_object(self.unlocked_database.current_group)
scrolled_page = self.unlocked_database.stack.get_child_by_name(self.unlocked_database.database_manager.get_entry_uuid_from_entry_object(self.unlocked_database.current_group).urn)
scrolled_page.set_made_database_changes(True)
scrolled_page.is_dirty = True
if type == "name":
self.unlocked_database.database_manager.set_entry_name(entry_uuid, widget.get_text())
......@@ -433,7 +433,7 @@ class EntryPage:
if str(self.unlocked_database.database_manager.get_entry_icon_from_entry_uuid(entry_uuid)) == button.get_name():
return
scrolled_page.set_made_database_changes(True)
scrolled_page.is_dirty = True
self.unlocked_database.database_manager.set_entry_icon(entry_uuid, button.get_name())
def on_entry_color_button_toggled(self, button):
......@@ -458,7 +458,7 @@ class EntryPage:
btn.get_children()[0].hide()
button.get_children()[0].show_all()
scrolled_page.set_made_database_changes(True)
scrolled_page.is_dirty = True
self.unlocked_database.database_manager.set_entry_color(entry_uuid, button.get_name())
def on_link_secondary_button_clicked(self, widget, position, eventbutton):
......@@ -520,7 +520,7 @@ class EntryPage:
self.unlocked_database.database_manager.set_entry_attribute(entry_uuid, key, value)
self.add_attribute_property_row(key, value)
scrolled_page.set_made_database_changes(True)
scrolled_page.is_dirty = True
def on_attribute_remove_button_clicked(self, button):
entry_uuid = self.unlocked_database.database_manager.get_entry_uuid_from_entry_object(self.unlocked_database.current_group)
......
......@@ -232,17 +232,16 @@ class Pathbar(Gtk.HBox):
return edit_page
def check_update_needed(self):
"""Returns True if the pathbar needs updating"""
current_group = self.unlocked_database.get_current_group()
scrolled_page = NotImplemented
made_database_changes = NotImplemented
if self.check_is_edit_page_from_group() is True:
scrolled_page = self.unlocked_database.stack.get_child_by_name(self.database_manager.get_group_uuid_from_group_object(current_group).urn)
else:
scrolled_page = self.unlocked_database.stack.get_child_by_name(self.database_manager.get_entry_uuid_from_entry_object(current_group).urn)
made_database_changes = scrolled_page.get_made_database_changes()
return made_database_changes
return scrolled_page.is_dirty
def check_is_edit_page_from_group(self):
current_group = self.unlocked_database.get_current_group()
......
......@@ -3,7 +3,7 @@ from gi.repository import Gtk
class ScrolledPage(Gtk.ScrolledWindow):
edit_page = False
made_database_changes = False
is_dirty = False # Whether the database needs saving
all_properties_revealed = False
show_all_properties_button = NotImplemented
......@@ -70,9 +70,3 @@ class ScrolledPage(Gtk.ScrolledWindow):
def check_is_edit_page(self):
return self.edit_page
def get_made_database_changes(self):
return self.made_database_changes
def set_made_database_changes(self, bool):
self.made_database_changes = bool
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment