Skip to content

Commit

Permalink
Do not (de)activate non-existing options in menus/toolbars
Browse files Browse the repository at this point in the history
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
  • Loading branch information
vojtechtrefny committed May 5, 2015
1 parent 8a71099 commit f9ab5f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions blivetgui/actions_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def activate_menu_items(self, menu_item_names):
"""

for item in menu_item_names:
self.menu_items[item].set_sensitive(True)
if item in self.menu_items.keys():
self.menu_items[item].set_sensitive(True)

def deactivate_menu_items(self, menu_item_names):
""" Deactivate selected buttons
Expand All @@ -87,7 +88,8 @@ def deactivate_menu_items(self, menu_item_names):
"""

for item in menu_item_names:
self.menu_items[item].set_sensitive(True)
if item in self.menu_items.keys():
self.menu_items[item].set_sensitive(False)

def deactivate_all(self):
""" Deactivate all partition based buttons
Expand Down
6 changes: 4 additions & 2 deletions blivetgui/actions_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def activate_buttons(self, button_names):
"""

for button in button_names:
self.buttons[button].set_sensitive(True)
if button in self.buttons.keys():
self.buttons[button].set_sensitive(True)

def deactivate_buttons(self, button_names):
""" Deactivate selected buttons
Expand All @@ -96,7 +97,8 @@ def deactivate_buttons(self, button_names):
"""

for button in button_names:
self.buttons[button].set_sensitive(False)
if button in self.buttons.keys():
self.buttons[button].set_sensitive(False)

def deactivate_all(self):
""" Deactivate all partition based buttons
Expand Down
8 changes: 2 additions & 6 deletions blivetgui/blivetgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ def activate_options(self, activate_list):
for item in activate_list:
self.toolbar.activate_buttons([item])
self.main_menu.activate_menu_items([item])

if item not in ("apply", "clear", "undo"):
self.popup_menu.activate_menu_items([item])
self.popup_menu.activate_menu_items([item])

def deactivate_options(self, deactivate_list):
""" Deactivate toolbar buttons and menu items
Expand All @@ -176,9 +174,7 @@ def deactivate_options(self, deactivate_list):
for item in deactivate_list:
self.toolbar.deactivate_buttons([item])
self.main_menu.deactivate_menu_items([item])

if item not in ("apply", "clear", "undo"):
self.popup_menu.deactivate_menu_items([item])
self.popup_menu.deactivate_menu_items([item])

def deactivate_all_options(self):
""" Deactivate all partition-based buttons/menu items
Expand Down
6 changes: 4 additions & 2 deletions blivetgui/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def activate_menu_items(self, menu_item_names):
"""

for item in menu_item_names:
self.menu_items[item].set_sensitive(True)
if item in self.menu_items.keys():
self.menu_items[item].set_sensitive(True)

def deactivate_menu_items(self, menu_item_names):
""" Deactivate selected buttons
Expand All @@ -176,7 +177,8 @@ def deactivate_menu_items(self, menu_item_names):
"""

for item in menu_item_names:
self.menu_items[item].set_sensitive(False)
if item in self.menu_items.keys():
self.menu_items[item].set_sensitive(False)

def deactivate_all(self):
""" Deactivate all partition based buttons
Expand Down

0 comments on commit f9ab5f8

Please sign in to comment.