2014-11-25 12:30:00 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import storage
|
|
|
|
import wx
|
2014-12-01 15:21:25 -06:00
|
|
|
import config
|
2014-11-25 12:30:00 -06:00
|
|
|
import wx_settings
|
2014-12-09 17:56:43 -06:00
|
|
|
import manage
|
2014-11-25 12:30:00 -06:00
|
|
|
import output
|
|
|
|
from mysc.thread_utils import call_threaded
|
|
|
|
|
|
|
|
class autocompletionSettings(object):
|
|
|
|
def __init__(self, window):
|
|
|
|
super(autocompletionSettings, self).__init__()
|
|
|
|
self.window = window
|
|
|
|
self.dialog = wx_settings.autocompletionSettingsDialog()
|
2014-12-01 15:21:25 -06:00
|
|
|
self.dialog.friends_buffer.SetValue(config.main["mysc"]["save_friends_in_autocompletion_db"])
|
|
|
|
self.dialog.followers_buffer.SetValue(config.main["mysc"]["save_followers_in_autocompletion_db"])
|
2014-12-09 17:56:43 -06:00
|
|
|
self.dialog.viewList.Bind(wx.EVT_BUTTON, self.view_list)
|
2014-11-25 12:30:00 -06:00
|
|
|
if self.dialog.ShowModal() == wx.ID_OK:
|
|
|
|
call_threaded(self.add_users_to_database)
|
|
|
|
|
|
|
|
def add_users_to_database(self):
|
2014-12-01 15:21:25 -06:00
|
|
|
config.main["mysc"]["save_friends_in_autocompletion_db"] = self.dialog.friends_buffer.GetValue()
|
|
|
|
config.main["mysc"]["save_followers_in_autocompletion_db"] = self.dialog.friends_buffer.GetValue()
|
2014-11-25 12:30:00 -06:00
|
|
|
output.speak(_(u"Updating database... You can close this window now. A message will tell you when the process finishes."))
|
|
|
|
database = storage.storage()
|
|
|
|
if self.dialog.followers_buffer.GetValue() == True:
|
|
|
|
buffer = self.window.search_buffer("people", "followers")
|
|
|
|
for i in buffer.db.settings[buffer.name_buffer]:
|
2014-12-01 15:21:25 -06:00
|
|
|
database.set_user(i["screen_name"], i["name"], 1)
|
|
|
|
else:
|
|
|
|
database.remove_by_buffer(1)
|
2014-11-25 12:30:00 -06:00
|
|
|
if self.dialog.friends_buffer.GetValue() == True:
|
|
|
|
buffer = self.window.search_buffer("people", "friends")
|
|
|
|
for i in buffer.db.settings[buffer.name_buffer]:
|
2014-12-01 15:21:25 -06:00
|
|
|
database.set_user(i["screen_name"], i["name"], 2)
|
|
|
|
else:
|
|
|
|
database.remove_by_buffer(2)
|
2014-11-25 12:30:00 -06:00
|
|
|
wx_settings.show_success_dialog()
|
|
|
|
self.dialog.Destroy()
|
2014-12-05 16:23:54 -06:00
|
|
|
|
2014-12-09 17:56:43 -06:00
|
|
|
def view_list(self, ev):
|
|
|
|
q = manage.autocompletionManage(self.window)
|
|
|
|
|
|
|
|
|
2014-12-05 16:23:54 -06:00
|
|
|
def execute_at_startup(window):
|
|
|
|
database = storage.storage()
|
2014-12-15 09:53:13 -06:00
|
|
|
if config.main["mysc"]["save_followers_in_autocompletion_db"] == True and config.main["other_buffers"]["show_followers"] == True:
|
2014-12-05 16:23:54 -06:00
|
|
|
buffer = window.search_buffer("people", "followers")
|
|
|
|
for i in buffer.db.settings[buffer.name_buffer]:
|
|
|
|
database.set_user(i["screen_name"], i["name"], 1)
|
|
|
|
else:
|
|
|
|
database.remove_by_buffer(1)
|
2014-12-15 09:53:13 -06:00
|
|
|
if config.main["mysc"]["save_friends_in_autocompletion_db"] == True and config.main["other_buffers"]["show_friends"] == True:
|
2014-12-05 16:23:54 -06:00
|
|
|
buffer = window.search_buffer("people", "friends")
|
|
|
|
for i in buffer.db.settings[buffer.name_buffer]:
|
|
|
|
database.set_user(i["screen_name"], i["name"], 2)
|
|
|
|
else:
|
|
|
|
database.remove_by_buffer(2)
|