Moving to a touch selector for moving categories
[quicknote] / src / history.py
1 #!/usr/bin/env python2.5
2 # -*- coding: utf-8 -*-
3
4 """
5  Copyright (C) 2007 Christoph Würstle
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation.
10 """
11
12
13 import logging
14
15 import gtk
16
17
18 try:
19         _
20 except NameError:
21         _ = lambda x: x
22
23
24 _moduleLogger = logging.getLogger("history")
25
26
27 class Dialog(gtk.Dialog):
28
29         def __init__(self, daten = None):
30                 super(Dialog, self).__init__(
31                         _("History:"),
32                         None,
33                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
34                         (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),
35                 )
36                 self.set_position(gtk.WIN_POS_CENTER)
37
38                 self.noteHistory = gtk.ListStore(
39                         int, #pcdatum
40                         str, #datum
41                         str, #sql
42                         str, #param
43                         str #param schön
44                 )
45
46                 # create the TreeView using liststore
47                 self._historyView = gtk.TreeView(self.noteHistory)
48                 self._historyView.set_rules_hint(True)
49                 # create a CellRenderers to render the data
50                 self._timestampCell = gtk.CellRendererText()
51                 self._noteCell = gtk.CellRendererText()
52
53                 # create the TreeViewColumns to display the data
54                 self._timestampColumn = gtk.TreeViewColumn(_('Timestamp'))
55                 self._noteColumn = gtk.TreeViewColumn(_('Note'))
56                 # add columns to treeview
57                 self._historyView.append_column(self._timestampColumn)
58                 self._historyView.append_column(self._noteColumn)
59
60                 # add the cells to the columns - 2 in the first
61                 self._timestampColumn.pack_start(self._timestampCell, True)
62                 self._noteColumn.pack_start(self._noteCell, True)
63                 self._timestampColumn.set_attributes(self._timestampCell, text = 1) #Spalten setzten hier!!!!
64                 self._noteColumn.set_attributes(self._noteCell, text = 4)
65
66                 self._historyView.set_reorderable(False)
67
68                 scrolled_window = gtk.ScrolledWindow()
69                 scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
70                 scrolled_window.add(self._historyView)
71                 self.vbox.pack_start(scrolled_window, expand = True, fill = True, padding = 0)
72
73                 self.noteHistory.clear()
74
75                 if daten is not None:
76                         for data in daten:
77                                 self.noteHistory.append(data)
78
79         def get_selected_row(self):
80                 path = self._historyView.get_cursor()[0]
81                 if path is None or path == "":
82                         return None
83
84                 iter1 = self._historyView.get_model().get_iter(path)
85                 return self._historyView.get_model().get(iter1, 0, 1, 2, 3, 4)