Skip to content

Commit

Permalink
[GTK] Fix error in setting active button
Browse files Browse the repository at this point in the history
The comparison for system_state was incorrect and raised unhandled error
when system_state was None.
  • Loading branch information
cas-- committed Sep 12, 2018
1 parent d9d378b commit 6e81305
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions autoshutdown/data/config.glade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-requires gtk+ 2.24 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="window1">
<property name="can_focus">False</property>
Expand All @@ -26,6 +26,7 @@
<property name="receives_default">False</property>
<property name="border_width">10</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">button_shutdown</property>
</widget>
Expand All @@ -43,7 +44,6 @@
<property name="receives_default">False</property>
<property name="border_width">10</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
Expand Down
19 changes: 13 additions & 6 deletions autoshutdown/gtkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ def on_show_prefs(self):
def cb_get_config(self, config):
"callback for on show_prefs"
log.debug("callback for on show_prefs")
self.glade.get_widget("button_shutdown").set_active("shutdown" in config["system_state"])
self.glade.get_widget("button_hibernate").set_active("hibernate" in config["system_state"])
self.glade.get_widget("button_suspend").set_active("suspend" in config["system_state"])

self.glade.get_widget("button_shutdown").set_active(
"shutdown" == config["system_state"])
self.glade.get_widget("button_hibernate").set_active(
"hibernate" == config["system_state"])
self.glade.get_widget("button_suspend").set_active(
"suspend" == config["system_state"])
self.glade.get_widget("once_check").set_active(config["once"])
self.glade.get_widget("button_disable").set_active(not config["enabled"])
self.glade.get_widget("button_hibernate").set_sensitive(config["can_hibernate"])
self.glade.get_widget("button_suspend").set_sensitive(config["can_suspend"])
self.glade.get_widget("button_disable").set_active(
not config["enabled"] or not config["system_state"])
self.glade.get_widget("button_hibernate").set_sensitive(
config["can_hibernate"])
self.glade.get_widget("button_suspend").set_sensitive(
config["can_suspend"])

0 comments on commit 6e81305

Please sign in to comment.