Permalink
Browse files

Basic functionality for the preferences dialog.

  • Loading branch information...
1 parent 008cdaa commit 004c5b020227cfb0144ed32abd3dd12118647d2c Stephan Sokolow committed Jun 14, 2009
Showing with 23 additions and 2 deletions.
  1. +3 −1 timeclock.glade
  2. +20 −1 timeclock.py
View
@@ -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>
@@ -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>
@@ -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>
View
@@ -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.
@@ -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)
@@ -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."""

0 comments on commit 004c5b0

Please sign in to comment.