if user removes sth, ask him on quiting about VACUUM and if he likes that do it (sqlite docs say it can take sometime one large db (I cannot test, YANN?) and it is why I do not do it automatically; also fix a bug on massively deleteing contact logs
This commit is contained in:
parent
321d2239c0
commit
72d49e951e
3 changed files with 32 additions and 7 deletions
|
@ -7,7 +7,7 @@
|
|||
##
|
||||
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2003-2004 Vincent Hanquez <tab@snarc.org>
|
||||
## Copyright (C) 2005 Nikos Kouremenos <nkour@jabber.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <nkour@jabber.org>
|
||||
## Copyright (C) 2005 Dimitur Kirov <dkirov@gmail.com>
|
||||
## Copyright (C) 2005-2006 Travis Shirk <travis@pobox.com>
|
||||
## Copyright (C) 2005 Norman Rasmussen <norman@rasmussen.co.za>
|
||||
|
@ -561,6 +561,13 @@ class ErrorDialog(HigDialog):
|
|||
HigDialog.__init__( self, None,
|
||||
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, pritext, sectext)
|
||||
|
||||
|
||||
class YesNoDialog(HigDialog):
|
||||
def __init__(self, pritext, sectext=''):
|
||||
'''HIG compliant YesNo dialog.'''
|
||||
HigDialog.__init__( self, None,
|
||||
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext)
|
||||
|
||||
class ConfirmationDialogCheck(ConfirmationDialog):
|
||||
'''HIG compliant confirmation dialog with checkbutton.'''
|
||||
def __init__(self, pritext, sectext='', checktext = ''):
|
||||
|
|
|
@ -74,7 +74,9 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><big>Welcome to Gajim History Logs Manager</big>
|
||||
|
||||
You can select logs from the left and/or search database from below.</property>
|
||||
You can select logs from the left and/or search database from below.
|
||||
|
||||
<b>NOTE:</b> If you plan to do massive deletions, please make sure Gajim is not running.</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
|
|
|
@ -70,6 +70,7 @@ class HistoryManager:
|
|||
self.search_results_scrolledwindow.set_no_show_all(True)
|
||||
|
||||
self.jids_already_in = [] # holds jids that we already have in DB
|
||||
self.AT_LEAST_ONE_DELETION_DONE = False
|
||||
|
||||
self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
|
||||
isolation_level = 'IMMEDIATE')
|
||||
|
@ -154,6 +155,17 @@ class HistoryManager:
|
|||
self.search_results_listview.append_column(col)
|
||||
|
||||
def on_history_manager_window_delete_event(self, widget, event):
|
||||
if self.AT_LEAST_ONE_DELETION_DONE:
|
||||
dialog = dialogs.YesNoDialog(
|
||||
_('Do you want to clean up the database?'),
|
||||
_('Normally allocated database size will not be freed, '
|
||||
'it will just become reusable. If you really want to reduce '
|
||||
'database filesize, click YES, else click NO.'
|
||||
'\n\nIn case you click YES, please wait...'))
|
||||
if dialog.get_response() == gtk.RESPONSE_YES:
|
||||
self.cur.execute('VACUUM')
|
||||
self.con.commit()
|
||||
|
||||
gtk.main_quit()
|
||||
|
||||
def _fill_jids_listview(self):
|
||||
|
@ -324,6 +336,8 @@ class HistoryManager:
|
|||
|
||||
self.con.commit()
|
||||
|
||||
self.AT_LEAST_ONE_DELETION_DONE = True
|
||||
|
||||
def on_jids_listview_key_press_event(self, widget, event):
|
||||
liststore, list_of_paths = self.jids_listview.get_selection()\
|
||||
.get_selected_rows()
|
||||
|
@ -358,13 +372,15 @@ class HistoryManager:
|
|||
WHERE jid_id = ?
|
||||
''', (jid_id,))
|
||||
|
||||
# now delete "jid, jid_id" row from jids table
|
||||
self.cur.execute('''
|
||||
DELETE FROM jids
|
||||
WHERE jid_id = ?
|
||||
''', (jid_id,))
|
||||
# now delete "jid, jid_id" row from jids table
|
||||
self.cur.execute('''
|
||||
DELETE FROM jids
|
||||
WHERE jid_id = ?
|
||||
''', (jid_id,))
|
||||
|
||||
self.con.commit()
|
||||
|
||||
self.AT_LEAST_ONE_DELETION_DONE = True
|
||||
|
||||
def on_search_db_button_clicked(self, widget):
|
||||
text = self.search_entry.get_text()
|
||||
|
|
Loading…
Add table
Reference in a new issue