billreminder r678 - in trunk: . src/gui src/gui/widgets
- From: ogmaciel svn gnome org
- To: svn-commits-list gnome org
- Subject: billreminder r678 - in trunk: . src/gui src/gui/widgets
- Date: Wed, 19 Nov 2008 00:56:57 +0000 (UTC)
Author: ogmaciel
Date: Wed Nov 19 00:56:57 2008
New Revision: 678
URL: http://svn.gnome.org/viewvc/billreminder?rev=678&view=rev
Log:
Made the new DatePicker widget work with the add/edit dialog. Need to handle multiple ocurrences.
Modified:
trunk/ChangeLog
trunk/src/gui/adddialog.py
trunk/src/gui/categoriesdialog.py
trunk/src/gui/widgets/datepicker.py
Modified: trunk/src/gui/adddialog.py
==============================================================================
--- trunk/src/gui/adddialog.py (original)
+++ trunk/src/gui/adddialog.py Wed Nov 19 00:56:57 2008
@@ -70,8 +70,11 @@
self.repeatSpinner.set_sensitive(False)
self.frequency.set_sensitive(False)
self.repeatlabel.set_sensitive(False)
+ self.endDateLabel.set_sensitive(False)
+ self.endDate.set_sensitive(False)
else:
+ self.dueDate.set_date(self.selectedDate)
# Use alarm values from preferences
if self.gconf_client.get_bool(GCONF_ALARM_PATH + 'show_alarm') == 'true':
atime = self.gconf_client.get_string(GCONF_ALARM_PATH + 'show_alarm_at_time')
@@ -102,6 +105,15 @@
self.repeatSpinner.set_update_policy(gtk.UPDATE_IF_VALID)
self.repeatSpinner.set_snap_to_ticks(True)
+ # Datepickers
+ self.dueDateLabel = gtk.Label()
+ self.dueDateLabel.set_markup_with_mnemonic(_("<b>Due Date:</b>"))
+ self.dueDate = DatePicker()
+ self.endDateLabel = gtk.Label()
+ #TRANSLATORS: This is the end date for repeating bills.
+ self.endDateLabel.set_markup_with_mnemonic(_("<b>End Date:</b>"))
+ self.endDate = DatePicker()
+
## Repeating bills
self.frequency = gtk.combo_box_new_text()
self.repeatlabel.set_mnemonic_widget(self.frequency)
@@ -186,15 +198,6 @@
self.alarmlabel.set_mnemonic_widget(self.alarmbutton)
self.alarmbutton.set_tooltip_text(_("Select Date and Time"))
- # Datepickers
- self.dueDateLabel = gtk.Label()
- self.dueDateLabel.set_markup_with_mnemonic(_("<b>Due Date:</b>"))
- self.dueDate = DatePicker()
- self.endDatelabel = gtk.Label()
- #TRANSLATORS: This is the end date for repeating bills.
- self.endDatelabel.set_markup_with_mnemonic(_("<b>End:</b>"))
- self.endDate = DatePicker()
-
## Pack it all into the table
### Label widgets
self.table.attach(self.payeelabel, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
@@ -202,7 +205,7 @@
self.table.attach(self.dueDateLabel, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
self.table.attach(self.categorylabel, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
self.table.attach(self.repeatlabel, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
- self.table.attach(self.endDatelabel, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
+ self.table.attach(self.endDateLabel, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
### "Value" widgets
self.table.attach(self.payee, 1, 2, 0, 1, gtk.FILL, gtk.FILL)
self.table.attach(self.amount, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
@@ -259,8 +262,7 @@
self.amount.set_text("")
# Format the dueDate field
dt = scheduler.datetime_from_timestamp(self.currentrecord.DueDate)
- self.dueDate.calendar.select_day(dt.day)
- self.dueDate.calendar.select_month(dt.month - 1, dt.year)
+ self.dueDate.set_date(dt)
utils.select_combo_text(self.payee, self.currentrecord.Payee)
actions = Actions()
records = actions.get_categories({'id': self.currentrecord.Category})
@@ -381,7 +383,12 @@
frequency = self.frequency.get_active_text()
# Extracts the date off the calendar widget
# Create datetime object
- selectedDate = scheduler.time_from_calendar(self.dueDate.calendar.get_date())
+ selectedDate = scheduler.timestamp_from_datetime(self.dueDate.get_date())
+ # End date
+ if frequency != scheduler.SC_ONCE:
+ endDate = scheduler.timestamp_from_datetime(self.endDate.currentDate)
+ else:
+ endDate = None
#buffer = self.txtNotes.get_buffer()
startiter, enditer = self.txtbuffer.get_bounds()
@@ -442,8 +449,12 @@
if frequency == scheduler.SC_ONCE:
self.repeatSpinner.set_value(1)
self.repeatSpinner.set_sensitive(False)
+ self.endDateLabel.set_sensitive(False)
+ self.endDate.set_sensitive(False)
else:
self.repeatSpinner.set_sensitive(True)
+ self.endDateLabel.set_sensitive(True)
+ self.endDate.set_sensitive(True)
def _on_categoriesbutton_clicked(self, button, new=False):
# if new == True, a simpler categories dialog pops up
Modified: trunk/src/gui/categoriesdialog.py
==============================================================================
--- trunk/src/gui/categoriesdialog.py (original)
+++ trunk/src/gui/categoriesdialog.py Wed Nov 19 00:56:57 2008
@@ -140,7 +140,9 @@
found = path
path += 1
- self.list.set_cursor(found)
+ # Only select an item if we have data
+ if len(self.list):
+ self.list.set_cursor(found)
return
Modified: trunk/src/gui/widgets/datepicker.py
==============================================================================
--- trunk/src/gui/widgets/datepicker.py (original)
+++ trunk/src/gui/widgets/datepicker.py Wed Nov 19 00:56:57 2008
@@ -31,13 +31,13 @@
# Create a new calendar
self.calendar = gtk.Calendar()
- self.calendar.connect("day-selected-double-click", self.on_day_selected)
self.calendar.select_month(date.month, date.year)
self.calendar.select_day(date.day)
# Label to display the date selected
- #TRANSLATORS: This is the date that is selected from the calendar. Try to keep it small.
- self.entry = gtk.Label(self.currentDate.strftime(_('%m/%d/%Y').encode('ASCII')))
+ self.entry = gtk.Label()
+ # Update the date label
+ self.__update_label()
# Expander for the calendar
self.expander = gtk.Expander()
@@ -49,6 +49,10 @@
self.expander.add(vbox)
+ # Connect events
+ self.calendar.connect("day-selected-double-click", self.on_day_selected)
+ self.calendar.connect("day-selected", self.on_day_selected)
+
self.pack_start(self.expander)
def emit_date_changed_signal(self):
@@ -60,12 +64,29 @@
def on_day_selected(self, calendar):
(year, month, day) = self.calendar.get_date()
self.currentDate = datetime.datetime(year, month+1, day)
+
+ # Update the date label
+ self.__update_label()
+
+ #self.emit_date_changed_signal()
+
+ def set_date(self, dt):
+ self.calendar.select_day(dt.day)
+ self.calendar.select_month(dt.month - 1, dt.year)
+
+ self.currentDate = dt
+
+ # Update the date label
+ self.__update_label()
+
+ def get_date(self):
+ return self.currentDate
+
+ def __update_label(self):
#TRANSLATORS: This is the date that is selected from the calendar. Try to keep it small.
self.entry.set_label(self.currentDate.strftime(_('%m/%d/%Y').encode('ASCII')))
- self.emit_date_changed_signal()
-
class BasicWindow(object):
# close the window and quit
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]