summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2009-05-10 19:40:47 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2009-05-10 19:40:47 +0200
commit4bc9b503fa6070e491062d35967d20b37e9c94e0 (patch)
tree9d0d647a4a006db8adf18240418f72b80b4bd0bd /ui
parent91e7bba27adccc2d9815afed104b678366ecb62a (diff)
downloadtodolist-4bc9b503fa6070e491062d35967d20b37e9c94e0.tar.gz
todolist-4bc9b503fa6070e491062d35967d20b37e9c94e0.tar.xz
todolist-4bc9b503fa6070e491062d35967d20b37e9c94e0.zip
add/remove support
change db layout to version 0.4, with removed column only display items, that are not removed created events for add, remove buttons remove, __delitem__, contains in itemList as proxy to itemList.data added default constructor (if nothing is set) for item to create a new
Diffstat (limited to 'ui')
-rw-r--r--ui/todolist.glade6
-rw-r--r--ui/ui_pygtk.py26
2 files changed, 28 insertions, 4 deletions
diff --git a/ui/todolist.glade b/ui/todolist.glade
index 1b1a732..ee8c46c 100644
--- a/ui/todolist.glade
+++ b/ui/todolist.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 Fri May 8 22:04:24 2009 -->
+<!--Generated with glade3 3.4.5 on Sat May 9 23:38:34 2009 -->
<glade-interface>
<widget class="GtkWindow" id="main_window">
<property name="title" translatable="yes">ToDo</property>
@@ -141,6 +141,7 @@
<property name="label" translatable="yes">gtk-add</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
+ <signal name="clicked" handler="on_add_clicked"/>
</widget>
</child>
<child>
@@ -151,6 +152,7 @@
<property name="label" translatable="yes">gtk-remove</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
+ <signal name="clicked" handler="on_remove_clicked"/>
</widget>
<packing>
<property name="position">1</property>
@@ -270,7 +272,7 @@
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
- <widget class="GtkEntry" id="entry2">
+ <widget class="GtkEntry" id="entry1">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
diff --git a/ui/ui_pygtk.py b/ui/ui_pygtk.py
index d41d34d..9c86382 100644
--- a/ui/ui_pygtk.py
+++ b/ui/ui_pygtk.py
@@ -8,6 +8,8 @@ import gtk.glade
import gobject
import item
import time
+import inspect
+import os
from license import version, gpl_3
class ui_pygtk:
@@ -15,7 +17,8 @@ class ui_pygtk:
self.itemList = itemList
# load ui from glade file
- glade = gtk.glade.XML ("todolist.glade")
+ c=inspect.currentframe()
+ glade = gtk.glade.XML (os.path.dirname(c.f_code.co_filename) + "/todolist.glade")
self.main_window = glade.get_widget('main_window')
self.edit_dialog = glade.get_widget('edit_dialog')
@@ -29,7 +32,9 @@ class ui_pygtk:
"on_menu_quit_clicked" : gtk.main_quit,
"on_main_window_destroy" : gtk.main_quit,
"on_treeview_row_activated" : self.item_double_clicked_callback,
- "on_edit_clicked" : self.edit_clicked_callback}
+ "on_edit_clicked" : self.edit_clicked_callback,
+ "on_remove_clicked" : self.remove_clicked_callback,
+ "on_add_clicked" : self.add_clicked_callback}
glade.signal_autoconnect(dic)
# fill the treeview with data
@@ -130,6 +135,23 @@ class ui_pygtk:
apply(model.set_sort_column_id, sort)
return
+ def remove_clicked_callback(self, widget, data=None):
+ # remove the selected element
+ treeview = self.main_window.todolist
+ if (treeview.get_selection().count_selected_rows() == 1):
+ item = treeview.get_model().get_value(treeview.get_selection().get_selected()[1], 0)
+ self.main_window.todolist.get_model().remove(treeview.get_selection().get_selected()[1])
+ self.itemList.remove(item)
+ return
+
+ def add_clicked_callback(self, widget, data=None):
+ # add a new element
+ new_item = item.item()
+ if self.edit_item(new_item):
+ self.main_window.todolist.get_model().append([new_item])
+ self.itemList.append(new_item)
+ return
+
#########################################################
# helper methods
#########################################################