Skip to content

Commit

Permalink
Basic functionality for the preferences dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Sokolow authored and Stephan Sokolow committed Jun 14, 2009
1 parent 008cdaa commit 004c5b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion timeclock.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Thu Jun 11 00:23:53 2009 -->
<!--Generated with glade3 3.4.5 on Sun Jun 14 03:15:32 2009 -->
<glade-interface>
<widget class="GtkWindow" id="mainWin">
<property name="visible">True</property>
Expand Down Expand Up @@ -390,6 +390,7 @@
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_prefs_cancel"/>
</widget>
</child>
<child>
Expand All @@ -400,6 +401,7 @@
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_prefs_commit"/>
</widget>
<packing>
<property name="position">1</property>
Expand Down
21 changes: 20 additions & 1 deletion timeclock.py
Expand Up @@ -4,6 +4,7 @@
A simple application to help lazy procrastinators (me) to manage their time.
@todo: Planned improvements:
- Clicking the preferences button while the dialog is shown should do nothing.
- Rework the design to minimize dependence on GTK+ (in case I switch to Qt for
Phonon)
- Make the preferences dialog functional and hook up the button for it.
Expand Down Expand Up @@ -111,6 +112,8 @@ def __init__(self):
dic = { "on_mode_toggled" : self.playmode_changed,
"on_reset_clicked" : self.reset_clicked,
"on_prefs_clicked" : self.prefs_clicked,
"on_prefs_commit" : self.prefs_commit,
"on_prefs_cancel" : self.prefs_cancel,
"on_mainWin_destroy" : gtk.main_quit }
self.wTree.signal_autoconnect(dic)
gobject.timeout_add(1000, self.tick)
Expand Down Expand Up @@ -160,7 +163,23 @@ def reset_clicked(self, widget):

def prefs_clicked(self, widget):
"""Callback for the preferences button"""
logging.error("TODO: Implement this")
for widget_name in self.total:
widget_spin = 'spinBtn_%s' % widget_name.lstrip('btn_')
widget = self.wTree.get_widget(widget_spin)
widget.set_value(self.total[widget_name] / 3600.0)
self.wTree.get_widget('prefsDlg').show()

def prefs_cancel(self, widget):
"""Callback for cancelling changes the preferences"""
self.wTree.get_widget('prefsDlg').hide()

def prefs_commit(self, widget):
"""Callback for OKing changes to the preferences"""
for widget_name in self.total:
widget_newname = 'spinBtn_%s' % widget_name.lstrip('btn_')
widget = self.wTree.get_widget(widget_newname)
self.total[widget_name] = (widget.get_value() * 3600)
self.wTree.get_widget('prefsDlg').hide()

def tick(self):
"""Once-per-second timeout callback for updating progress bars."""
Expand Down

0 comments on commit 004c5b0

Please sign in to comment.