hamster-applet r743 - in trunk: data hamster
- From: tbaugis svn gnome org
- To: svn-commits-list gnome org
- Subject: hamster-applet r743 - in trunk: data hamster
- Date: Wed, 18 Feb 2009 21:46:52 +0000 (UTC)
Author: tbaugis
Date: Wed Feb 18 21:46:52 2009
New Revision: 743
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=743&view=rev
Log:
hooray for basic validation and actually allowing to add tasks!
Modified:
trunk/data/add_custom_fact.glade
trunk/hamster/add_custom_fact.py
Modified: trunk/data/add_custom_fact.glade
==============================================================================
--- trunk/data/add_custom_fact.glade (original)
+++ trunk/data/add_custom_fact.glade Wed Feb 18 21:46:52 2009
@@ -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 Wed Feb 18 12:23:02 2009 -->
+<!--Generated with glade3 3.4.5 on Wed Feb 18 21:16:49 2009 -->
<glade-interface>
<widget class="GtkWindow" id="custom_fact_window">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -21,24 +21,75 @@
<property name="column_spacing">4</property>
<property name="row_spacing">8</property>
<child>
- <widget class="GtkAlignment" id="alignment2">
+ <widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkComboBoxEntry" id="activity_combo">
+ <widget class="GtkTextView" id="description">
+ <property name="height_request">50</property>
<property name="visible">True</property>
- <child internal-child="entry">
- <widget class="GtkEntry" id="activity_text">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </widget>
- </child>
+ <property name="can_focus">True</property>
+ <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Activity:</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Time:</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkLabel" id="Description:">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Description:</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
<child>
@@ -147,75 +198,25 @@
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="yalign">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkLabel" id="Description:">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Description:</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
- <widget class="GtkAlignment" id="alignment4">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="xscale">0</property>
- <child>
- <widget class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Time:</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkAlignment" id="alignment5">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Activity:</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="xalign">0</property>
<child>
- <widget class="GtkTextView" id="description">
- <property name="height_request">50</property>
+ <widget class="GtkComboBoxEntry" id="activity_combo">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
+ <signal name="changed" handler="on_activity_combo_changed"/>
+ <child internal-child="entry">
+ <widget class="GtkEntry" id="activity_text">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
</packing>
</child>
</widget>
Modified: trunk/hamster/add_custom_fact.py
==============================================================================
--- trunk/hamster/add_custom_fact.py (original)
+++ trunk/hamster/add_custom_fact.py Wed Feb 18 21:46:52 2009
@@ -48,7 +48,6 @@
self.refresh_menu()
self.get_widget("in_progress").set_active(False)
- self.get_widget("save_button").set_sensitive(False)
if fact_id:
fact = storage.get_fact(fact_id)
@@ -65,7 +64,6 @@
if not fact["end_time"] and fact["start_time"].date() == datetime.datetime.today():
self.get_widget("in_progress").set_active(True)
- self.get_widget("save_button").set_sensitive(True)
self.get_widget("save_button").set_label("gtk-save")
self.window.set_title(_("Update activity"))
@@ -101,6 +99,7 @@
self.get_widget('end_date').set_text(self.format_date(end_date))
self.get_widget('end_time').set_text(self.format_time(end_date))
+ self.validate_fields()
self.init_calendar_window()
self.init_time_window()
@@ -141,6 +140,7 @@
widget.set_text(self.format_date(date))
self.calendar_window.hide()
+ self.validate_fields()
def format_date(self, date):
if not date:
@@ -277,31 +277,6 @@
def show(self):
self.window.show()
-
- def on_end_time_mode_changed(self, widget):
- selected = widget.get_active()
-
- #those will get handy, when user changes end time condition
- self.get_widget("fact_end_until").hide()
- self.get_widget("fact_end_for").hide()
-
- if selected == 1:
- # selected to enter end date and time
- start_date = datetime.datetime.fromtimestamp(self.get_widget('start_date').get_time())
- if start_date.date() == datetime.date.today(): #in case of today let's add the end time as right now
- end_time = time.strftime("%H:%M")
- else: #otherwise settle to the one we have in start time
- end_time = self.get_widget('start_time').get_text()
-
- # and set end_time only if it has not been specified before
- if self.get_widget('end_time').get_text() == '':
- self.get_widget('end_time').set_text(end_time)
-
- self.get_widget("fact_end_until").show()
-
- elif selected == 2:
- # selected to enter duration
- self.get_widget("fact_end_for").show()
def _get_datetime(self, prefix):
# adds symbolic time to date in seconds
@@ -390,6 +365,7 @@
def on_date_focus_out_event(self, event, something):
self.calendar_window.hide()
+ self.validate_fields()
def on_start_time_focus_in_event(self, entry, event):
@@ -397,18 +373,20 @@
def on_start_time_focus_out_event(self, event, something):
self.time_window.hide()
+ self.validate_fields()
def on_end_time_focus_in_event(self, entry, event):
start_time = self.figure_time(self.get_widget("start_time").get_text())
-
self.show_time_window(entry, start_time)
def on_end_time_focus_out_event(self, event, something):
self.time_window.hide()
+ self.validate_fields()
def on_in_progress_toggled(self, check):
self.get_widget("end_time").set_sensitive(not check.get_active())
self.get_widget("end_date").set_sensitive(not check.get_active())
+ self.validate_fields()
def show_time_window(self, widget, start_time = None):
@@ -542,6 +520,7 @@
widget.set_position(len(time_text))
self.time_window.hide()
+ self.validate_fields()
@@ -581,10 +560,25 @@
def on_cancel_clicked(self, button):
self.window.destroy()
- def on_combo_changed(self, combo):
+ def on_activity_combo_changed(self, combo):
+ self.validate_fields()
+
+ def validate_fields(self):
# do not allow empty tasks
- activity = self.get_widget("activity-list").get_child().get_text()
- self.get_widget("ok").set_sensitive(activity != '')
+
+ activity_text = self.get_widget("activity_text").get_text()
+ start_time = self._get_datetime("start")
+
+ end_time = self._get_datetime("end")
+ if self.get_widget("in_progress").get_active():
+ end_time = datetime.datetime.now()
+
+ looks_good = False
+ if activity_text != "" and start_time and end_time and \
+ (end_time - start_time).days == 0:
+ looks_good = True
+
+ self.get_widget("save_button").set_sensitive(looks_good)
def on_window_key_pressed(self, tree, event_key):
if (event_key.keyval == gtk.keysyms.Escape
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]