we can now delete a row or more from db. TODO: update UI on the fly
This commit is contained in:
parent
ec03a1d853
commit
c966ab9e6f
|
@ -83,6 +83,7 @@
|
|||
<property name="fixed_height_mode">False</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
<signal name="key_press_event" handler="on_logs_listview_key_press_event" last_modification_time="Sat, 04 Feb 2006 15:01:22 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
|
|
@ -91,6 +91,7 @@ class HistoryManager:
|
|||
# log_line_id (HIDDEN), jid_id (HIDDEN), time, message, subject
|
||||
self.logs_liststore = gtk.ListStore(str, str, str, str, str)
|
||||
self.logs_listview.set_model(self.logs_liststore)
|
||||
self.logs_listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
|
||||
|
||||
renderer_text = gtk.CellRendererText() # holds time
|
||||
col = gtk.TreeViewColumn('Time', renderer_text, text = C_UNIXTIME)
|
||||
|
@ -187,6 +188,33 @@ class HistoryManager:
|
|||
else:
|
||||
self.logs_liststore.append((row[0], row[1], time_, row[4], row[5]))
|
||||
|
||||
def on_logs_listview_key_press_event(self, widget, event):
|
||||
liststore, list_of_paths = self.logs_listview.get_selection()\
|
||||
.get_selected_rows()
|
||||
if list_of_paths == []: # nothing is selected
|
||||
return
|
||||
|
||||
if event.keyval == gtk.keysyms.Delete:
|
||||
dialog = dialogs.ConfirmationDialog(
|
||||
_('Do you really want to delete the selected messages?'),
|
||||
_('This is an irreversible operation.'))
|
||||
if dialog.get_response() != gtk.RESPONSE_OK:
|
||||
return
|
||||
|
||||
# delete rows from db (using log_line_id)
|
||||
for path in list_of_paths:
|
||||
log_line_id = liststore[path][0]
|
||||
self.cur.execute('''
|
||||
DELETE FROM logs
|
||||
WHERE log_line_id = %s
|
||||
''' % (log_line_id,))
|
||||
|
||||
self.con.commit()
|
||||
|
||||
|
||||
def delete_messages_from_log(self, selection):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application
|
||||
HistoryManager()
|
||||
|
|
Loading…
Reference in New Issue