the old self.plugin variable becomes gajim.interface, no need to pass it to every functions/classes

This commit is contained in:
Yann Leboulanger 2005-10-20 11:17:17 +00:00
parent 0b1bf176e9
commit 726640ef4b
18 changed files with 523 additions and 557 deletions

View File

@ -41,9 +41,7 @@ C_TYPE
GTKGUI_GLADE = 'gtkgui.glade'
class AdvancedConfigurationWindow:
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'advanced_configuration_window', APP)
self.window = self.xml.get_widget('advanced_configuration_window')
self.entry = self.xml.get_widget('advanced_entry')
@ -86,7 +84,7 @@ class AdvancedConfigurationWindow:
self.xml.signal_autoconnect(self)
self.window.show_all()
self.plugin.windows['advanced_config'] = self
gajim.interface.windows['advanced_config'] = self
def cb_value_column_data(self, col, cell, model, iter):
optname = model[iter][C_PREFNAME]
@ -123,7 +121,7 @@ class AdvancedConfigurationWindow:
gajim.config.set_per(optname, key, option, newval)
else:
gajim.config.set(option, newval)
self.plugin.save_config()
gajim.interface.save_config()
modelrow[1] = newval
def on_config_edited(self, cell, path, text):
@ -140,13 +138,13 @@ class AdvancedConfigurationWindow:
gajim.config.set_per(optname, key, option, text)
else:
gajim.config.set(option, text)
self.plugin.save_config()
gajim.interface.save_config()
modelrow[1] = text
def on_advanced_configuration_window_destroy(self, widget):
# update ui of preferences window to get possible changes we did
self.plugin.windows['preferences'].update_preferences_window()
del self.plugin.windows['advanced_config']
gajim.interface.windows['preferences'].update_preferences_window()
del gajim.interface.windows['advanced_config']
def on_advanced_close_button_clicked(self, widget):
self.window.destroy()

View File

@ -1,4 +1,4 @@
## plugins/tabbed_chat_window.py
## chat.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
@ -45,13 +45,12 @@ GTKGUI_GLADE = 'gtkgui.glade'
class Chat:
'''Class for chat/groupchat windows'''
def __init__(self, plugin, account, widget_name):
def __init__(self, account, widget_name):
self.xml = gtk.glade.XML(GTKGUI_GLADE, widget_name, APP)
self.window = self.xml.get_widget(widget_name)
self.widget_name = widget_name
self.plugin = plugin
self.account = account
self.change_cursor = None
self.xmls = {}
@ -264,16 +263,16 @@ class Chat:
return 'pm'
def on_window_destroy(self, widget, kind): #kind is 'chats' or 'gc'
'''clean self.plugin.windows[self.account][kind]'''
'''clean gajim.interface.windows[self.account][kind]'''
for jid in self.xmls:
windows = self.plugin.windows[self.account][kind]
windows = gajim.interface.windows[self.account][kind]
if kind == 'chats':
# send 'gone' chatstate to every tabbed chat tab
windows[jid].send_chatstate('gone', jid)
gobject.source_remove(self.possible_paused_timeout_id[jid])
gobject.source_remove(self.possible_inactive_timeout_id[jid])
if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
self.plugin.systray.remove_jid(jid, self.account,
if gajim.interface.systray_enabled and self.nb_unread[jid] > 0:
gajim.interface.systray.remove_jid(jid, self.account,
self.get_message_type(jid))
del windows[jid]
if self.print_time_timeout_id.has_key(jid):
@ -299,11 +298,11 @@ class Chat:
'''When history menuitem is pressed: call history window'''
if jid is None:
jid = self.get_active_jid()
if self.plugin.windows['logs'].has_key(jid):
self.plugin.windows['logs'][jid].window.present()
if gajim.interface.windows['logs'].has_key(jid):
gajim.interface.windows['logs'][jid].window.present()
else:
self.plugin.windows['logs'][jid] = history_window.HistoryWindow(
self.plugin, jid, self.account)
gajim.interface.windows['logs'][jid] = history_window.HistoryWindow(jid,
self.account)
def on_chat_window_focus_in_event(self, widget, event):
'''When window gets focus'''
@ -319,8 +318,8 @@ class Chat:
if self.nb_unread[jid] > 0:
self.nb_unread[jid] = 0 + self.get_specific_unread(jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account,
if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, self.account,
self.get_message_type(jid))
'''TC/GC window received focus, so if we had urgency REMOVE IT
@ -483,8 +482,8 @@ class Chat:
self.nb_unread[new_jid] = 0 + self.get_specific_unread(new_jid)
self.redraw_tab(new_jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(new_jid, self.account,
if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(new_jid, self.account,
self.get_message_type(new_jid))
conversation_textview.grab_focus()
@ -520,8 +519,8 @@ class Chat:
else:
if self.nb_unread[jid] > 0:
self.nb_unread[jid] = 0
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account,
if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, self.account,
self.get_message_type(jid))
if self.print_time_timeout_id.has_key(jid):
gobject.source_remove(self.print_time_timeout_id[jid])
@ -529,8 +528,8 @@ class Chat:
self.notebook.remove_page(self.notebook.page_num(self.childs[jid]))
if self.plugin.windows[self.account][kind].has_key(jid):
del self.plugin.windows[self.account][kind][jid]
if gajim.interface.windows[self.account][kind].has_key(jid):
del gajim.interface.windows[self.account][kind][jid]
del self.nb_unread[jid]
del gajim.last_message_time[self.account][jid]
del self.last_time_printout[jid]
@ -842,8 +841,8 @@ class Chat:
self.nb_unread[jid] = 0 + self.get_specific_unread(jid)
self.redraw_tab(jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account,
if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, self.account,
self.get_message_type(jid))
def on_conversation_textview_motion_notify_event(self, widget, event):
@ -1016,24 +1015,24 @@ class Chat:
clip.set_text(text)
def on_start_chat_activate(self, widget, jid):
self.plugin.roster.new_chat_from_jid(self.account, jid)
gajim.interface.roster.new_chat_from_jid(self.account, jid)
def on_join_group_chat_menuitem_activate(self, widget, jid):
room, server = jid.split('@')
if self.plugin.windows[self.account].has_key('join_gc'):
instance = self.plugin.windows[self.account]['join_gc']
if gajim.interface.windows[self.account].has_key('join_gc'):
instance = gajim.interface.windows[self.account]['join_gc']
instance.xml.get_widget('server_entry').set_text(server)
instance.xml.get_widget('room_entry').set_text(room)
self.plugin.windows[self.account]['join_gc'].window.present()
gajim.interface.windows[self.account]['join_gc'].window.present()
else:
try:
self.plugin.windows[self.account]['join_gc'] = \
dialogs.JoinGroupchatWindow(self.plugin, self.account, server, room)
gajim.interface.windows[self.account]['join_gc'] = \
dialogs.JoinGroupchatWindow(self.account, server, room)
except RuntimeError:
pass
def on_add_to_roster_activate(self, widget, jid):
dialogs.AddNewContactWindow(self.plugin, self.account, jid)
dialogs.AddNewContactWindow(self.account, jid)
def make_link_menu(self, event, kind, text):
xml = gtk.glade.XML(GTKGUI_GLADE, 'chat_context_menu', APP)
@ -1102,9 +1101,9 @@ class Chat:
# basic: links + mail + formatting is always checked (we like that)
if gajim.config.get('useemoticons'): # search for emoticons & urls
iterator = self.plugin.emot_and_basic_re.finditer(otext)
iterator = gajim.interface.emot_and_basic_re.finditer(otext)
else: # search for just urls + mail + formatting
iterator = self.plugin.basic_pattern_re.finditer(otext)
iterator = gajim.interface.basic_pattern_re.finditer(otext)
for match in iterator:
start, end = match.span()
special_text = otext[start:end]
@ -1127,13 +1126,13 @@ class Chat:
buffer = textview.get_buffer()
possible_emot_ascii_caps = special_text.upper() # emoticons keys are CAPS
if possible_emot_ascii_caps in self.plugin.emoticons.keys():
if possible_emot_ascii_caps in gajim.interface.emoticons.keys():
#it's an emoticon
emot_ascii = possible_emot_ascii_caps
end_iter = buffer.get_end_iter()
anchor = buffer.create_child_anchor(end_iter)
img = gtk.Image()
img.set_from_file(self.plugin.emoticons[emot_ascii])
img.set_from_file(gajim.interface.emoticons[emot_ascii])
img.show()
#add with possible animation
textview.add_child_at_anchor(img, anchor)
@ -1141,7 +1140,7 @@ class Chat:
#it's a mail
tags.append('mail')
use_other_tags = False
elif self.plugin.sth_at_sth_dot_sth_re.match(special_text):
elif gajim.interface.sth_at_sth_dot_sth_re.match(special_text):
#it's a mail
tags.append('mail')
use_other_tags = False
@ -1309,9 +1308,9 @@ class Chat:
if not gajim.config.get('notify_on_all_muc_messages'):
return
self.nb_unread[jid] += 1
if self.plugin.systray_enabled and gajim.config.get(
if gajim.interface.systray_enabled and gajim.config.get(
'trayicon_notification_on_new_messages'):
self.plugin.systray.add_jid(jid, self.account, self.get_message_type(jid))
gajim.interface.systray.add_jid(jid, self.account, self.get_message_type(jid))
self.redraw_tab(jid)
self.show_title(urgent)

View File

@ -32,8 +32,7 @@ gtk.glade.textdomain(APP)
GTKGUI_GLADE='gtkgui.glade'
class Check_for_new_version_dialog:
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
try:
self.check_for_new_version()
except:

View File

@ -24,6 +24,7 @@ import mutex
import common.config
import common.logger
interface = None # The actual interface (the gtk one for the moment)
version = '0.9'
config = common.config.Config()
connections = {}

View File

@ -67,11 +67,10 @@ class PreferencesWindow:
def on_close_button_clicked(self, widget):
self.window.hide()
def __init__(self, plugin):
def __init__(self):
'''Initialize Preferences window'''
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'preferences_window', APP)
self.window = self.xml.get_widget('preferences_window')
self.plugin = plugin
self.iconset_combobox = self.xml.get_widget('iconset_combobox')
self.notify_on_new_message_radiobutton = self.xml.get_widget \
('notify_on_new_message_radiobutton')
@ -96,7 +95,7 @@ class PreferencesWindow:
self.notebook = self.xml.get_widget('preferences_notebook')
#trayicon
if self.plugin.systray_capabilities:
if gajim.interface.systray_capabilities:
st = gajim.config.get('trayicon')
self.trayicon_checkbutton.set_active(st)
else:
@ -450,38 +449,38 @@ class PreferencesWindow:
if change_sensitivity_widgets:
for w in change_sensitivity_widgets:
w.set_sensitive(widget.get_active())
self.plugin.save_config()
gajim.interface.save_config()
def on_trayicon_checkbutton_toggled(self, widget):
if widget.get_active():
gajim.config.set('trayicon', True)
self.plugin.show_systray()
self.plugin.roster.update_status_comboxbox()
gajim.interface.show_systray()
gajim.interface.roster.update_status_comboxbox()
else:
gajim.config.set('trayicon', False)
self.plugin.hide_systray()
gajim.interface.hide_systray()
gajim.config.set('show_roster_on_startup', True) # no tray, show roster!
self.plugin.roster.draw_roster()
self.plugin.save_config()
gajim.interface.roster.draw_roster()
gajim.interface.save_config()
def on_save_position_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'saveposition')
def on_merge_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'mergeaccounts')
self.plugin.roster.regroup = gajim.config.get('mergeaccounts')
self.plugin.roster.draw_roster()
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
gajim.interface.roster.draw_roster()
def on_sort_by_show_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sort_by_show')
self.plugin.roster.draw_roster()
gajim.interface.roster.draw_roster()
def on_use_emoticons_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'useemoticons',
[self.xml.get_widget('add_remove_emoticons_button')])
def on_add_remove_emoticons_button_clicked(self, widget):
window = self.plugin.windows['add_remove_emoticons'].window
window = gajim.interface.windows['add_remove_emoticons'].window
if window.get_property('visible'):
window.present()
else:
@ -492,15 +491,15 @@ class PreferencesWindow:
active = widget.get_active()
icon_string = model[active][1].decode('utf-8')
gajim.config.set('iconset', icon_string)
self.plugin.roster.reload_jabber_state_images()
self.plugin.save_config()
gajim.interface.roster.reload_jabber_state_images()
gajim.interface.save_config()
def on_transports_iconsets_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'use_transports_iconsets')
self.plugin.roster.draw_roster()
gajim.interface.roster.draw_roster()
def on_manage_theme_button_clicked(self, widget):
dialogs.GajimThemesWindow(self.plugin)
dialogs.GajimThemesWindow()
def on_theme_combobox_changed(self, widget):
model = widget.get_model()
@ -510,9 +509,9 @@ class PreferencesWindow:
gajim.config.set('roster_theme', config_theme)
# begin repainting themed widgets throughout
self.plugin.roster.repaint_themed_widgets()
self.plugin.roster.change_roster_style(None)
self.plugin.save_config()
gajim.interface.roster.repaint_themed_widgets()
gajim.interface.roster.change_roster_style(None)
gajim.interface.save_config()
def merge_windows(self, kind):
for acct in gajim.connections:
@ -520,7 +519,7 @@ class PreferencesWindow:
buf1 = {}
buf2 = {}
saved_var = {}
windows = self.plugin.windows[acct][kind]
windows = gajim.interface.windows[acct][kind]
jids = windows.keys()
for jid in jids:
window = windows[jid]
@ -534,9 +533,9 @@ class PreferencesWindow:
for jid in jids:
if kind == 'chats':
c = gajim.get_contact_instance_with_highest_priority(acct, jid)
self.plugin.roster.new_chat(c, acct)
gajim.interface.roster.new_chat(c, acct)
if kind == 'gc':
self.plugin.roster.new_room(jid, saved_var[jid]['nick'], acct)
gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct)
window = windows[jid]
window.xmls[jid].get_widget('conversation_textview').set_buffer(
buf1[jid])
@ -550,7 +549,7 @@ class PreferencesWindow:
buf1 = {}
buf2 = {}
saved_var = {}
windows = self.plugin.windows[acct][kind]
windows = gajim.interface.windows[acct][kind]
jids = windows.keys()
if not 'tabbed' in jids:
continue
@ -567,9 +566,9 @@ class PreferencesWindow:
for jid in jids:
if kind == 'chats':
c = gajim.get_contact_instance_with_highest_priority(acct, jid)
self.plugin.roster.new_chat(c, acct)
gajim.interface.roster.new_chat(c, acct)
if kind == 'gc':
self.plugin.roster.new_room(jid, saved_var[jid]['nick'], acct)
gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct)
window = windows[jid]
window.xmls[jid].get_widget('conversation_textview').set_buffer(
buf1[jid])
@ -589,11 +588,11 @@ class PreferencesWindow:
else:
self.split_windows('chats')
self.split_windows('gc')
self.plugin.save_config()
gajim.interface.save_config()
def apply_speller(self, kind):
for acct in gajim.connections:
windows = self.plugin.windows[acct][kind]
windows = gajim.interface.windows[acct][kind]
jids = windows.keys()
for jid in jids:
if jid == 'tabbed':
@ -604,7 +603,7 @@ class PreferencesWindow:
def remove_speller(self, kind):
for acct in gajim.connections:
windows = self.plugin.windows[acct][kind]
windows = gajim.interface.windows[acct][kind]
jids = windows.keys()
for jid in jids:
if jid == 'tabbed':
@ -618,7 +617,7 @@ class PreferencesWindow:
def on_speller_checkbutton_toggled(self, widget):
active = widget.get_active()
gajim.config.set('use_speller', active)
self.plugin.save_config()
gajim.interface.save_config()
if active:
self.apply_speller('chats')
self.apply_speller('gc')
@ -629,7 +628,7 @@ class PreferencesWindow:
def update_print_time(self):
'''Update time in Opened Chat Windows'''
for a in gajim.connections:
window = self.plugin.windows[a]['chats']
window = gajim.interface.windows[a]['chats']
if window.has_key('tabbed'):
window['tabbed'].update_print_time()
else:
@ -640,41 +639,41 @@ class PreferencesWindow:
if widget.get_active():
gajim.config.set('print_time', 'never')
self.update_print_time()
self.plugin.save_config()
gajim.interface.save_config()
def on_time_sometimes_radiobutton_toggled(self, widget):
if widget.get_active():
gajim.config.set('print_time', 'sometimes')
self.update_print_time()
self.plugin.save_config()
gajim.interface.save_config()
def on_time_always_radiobutton_toggled(self, widget):
if widget.get_active():
gajim.config.set('print_time', 'always')
self.update_print_time()
self.plugin.save_config()
gajim.interface.save_config()
def on_before_time_entry_focus_out_event(self, widget, event):
gajim.config.set('before_time', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_after_time_entry_focus_out_event(self, widget, event):
gajim.config.set('after_time', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_before_nickname_entry_focus_out_event(self, widget, event):
gajim.config.set('before_nickname', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_after_nickname_entry_focus_out_event(self, widget, event):
gajim.config.set('after_nickname', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def update_text_tags(self):
'''Update color tags in Opened Chat Windows'''
for a in gajim.connections:
for kind in ['chats', 'gc']:
windows = self.plugin.windows[a][kind]
windows = gajim.interface.windows[a][kind]
if windows.has_key('tabbed'):
windows['tabbed'].update_tags()
else:
@ -685,7 +684,7 @@ class PreferencesWindow:
'''Update text font in Opened Chat Windows'''
for a in gajim.connections:
for kind in ['chats', 'gc']:
windows = self.plugin.windows[a][kind]
windows = gajim.interface.windows[a][kind]
if windows.has_key('tabbed'):
windows['tabbed'].update_font()
else:
@ -697,13 +696,13 @@ class PreferencesWindow:
color_string = mk_color_string(color)
gajim.config.set(text, color_string)
self.update_text_tags()
self.plugin.save_config()
gajim.interface.save_config()
def on_preference_widget_font_set(self, widget, text):
font = widget.get_font_name()
gajim.config.set(text, font)
self.update_text_font()
self.plugin.save_config()
gajim.interface.save_config()
def on_incoming_msg_colorbutton_color_set(self, widget):
self.on_preference_widget_color_set(widget, 'inmsgcolor')
@ -719,7 +718,7 @@ class PreferencesWindow:
def on_reset_colors_button_clicked(self, widget):
for i in ['inmsgcolor', 'outmsgcolor', 'statusmsgcolor']:
gajim.config.set(i, self.plugin.default_values[i])
gajim.config.set(i, gajim.interface.default_values[i])
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('inmsgcolor')))
@ -728,7 +727,7 @@ class PreferencesWindow:
self.xml.get_widget('status_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('statusmsgcolor')))
self.update_text_tags()
self.plugin.save_config()
gajim.interface.save_config()
def on_notify_on_new_message_radiobutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_message',
@ -772,7 +771,7 @@ class PreferencesWindow:
def on_soundplayer_entry_changed(self, widget):
gajim.config.set('soundplayer', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_prompt_online_status_message_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ask_online_status')
@ -786,7 +785,7 @@ class PreferencesWindow:
bool(model[path][1]))
gajim.config.set_per('soundevents', sound_event, 'path',
model[iter][2].decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_auto_away_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autoaway',
@ -795,10 +794,10 @@ class PreferencesWindow:
def on_auto_away_time_spinbutton_value_changed(self, widget):
aat = widget.get_value_as_int()
gajim.config.set('autoawaytime', aat)
self.plugin.sleeper = common.sleepy.Sleepy(
gajim.interface.sleeper = common.sleepy.Sleepy(
gajim.config.get('autoawaytime') * 60,
gajim.config.get('autoxatime') * 60)
self.plugin.save_config()
gajim.interface.save_config()
def on_auto_away_message_entry_changed(self, widget):
gajim.config.set('autoaway_message', widget.get_text().decode('utf-8'))
@ -810,10 +809,10 @@ class PreferencesWindow:
def on_auto_xa_time_spinbutton_value_changed(self, widget):
axt = widget.get_value_as_int()
gajim.config.set('autoxatime', axt)
self.plugin.sleeper = common.sleepy.Sleepy(
gajim.interface.sleeper = common.sleepy.Sleepy(
gajim.config.get('autoawaytime') * 60,
gajim.config.get('autoxatime') * 60)
self.plugin.save_config()
gajim.interface.save_config()
def on_auto_xa_message_entry_changed(self, widget):
gajim.config.set('autoxa_message', widget.get_text().decode('utf-8'))
@ -828,7 +827,7 @@ class PreferencesWindow:
gajim.config.set_per('statusmsg', val, 'message',
model[iter][1].decode('utf-8'))
iter = model.iter_next(iter)
self.plugin.save_config()
gajim.interface.save_config()
def on_msg_treemodel_row_changed(self, model, path, iter):
self.save_status_messages(model)
@ -849,35 +848,35 @@ class PreferencesWindow:
elif widget.get_active() == 2:
gajim.config.set('openwith', 'kfmclient exec')
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
self.plugin.save_config()
gajim.interface.save_config()
def on_custom_browser_entry_changed(self, widget):
gajim.config.set('custombrowser', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_custom_mail_client_entry_changed(self, widget):
gajim.config.set('custommailapp', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_custom_file_manager_entry_changed(self, widget):
gajim.config.set('custom_file_manager', widget.get_text().decode('utf-8'))
self.plugin.save_config()
gajim.interface.save_config()
def on_log_in_contact_checkbutton_toggled(self, widget):
gajim.config.set('log_notif_in_user_file', widget.get_active())
self.plugin.save_config()
gajim.interface.save_config()
def on_log_in_extern_checkbutton_toggled(self, widget):
gajim.config.set('log_notif_in_sep_file', widget.get_active())
self.plugin.save_config()
gajim.interface.save_config()
def on_send_os_info_checkbutton_toggled(self, widget):
gajim.config.set('send_os_info', widget.get_active())
self.plugin.save_config()
gajim.interface.save_config()
def on_check_for_new_version_checkbutton_toggled(self, widget):
gajim.config.set('check_for_new_version', widget.get_active())
self.plugin.save_config()
gajim.interface.save_config()
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
@ -1008,31 +1007,30 @@ class PreferencesWindow:
model.set_value(iter, 1, 1)
def on_open_advanced_editor_button_clicked(self, widget, data = None):
if self.plugin.windows.has_key('advanced_config'):
self.plugin.windows['advanced_config'].window.present()
if gajim.interface.windows.has_key('advanced_config'):
gajim.interface.windows['advanced_config'].window.present()
else:
self.plugin.windows['advanced_config'] = \
dialogs.AdvancedConfigurationWindow(self.plugin)
gajim.interface.windows['advanced_config'] = \
dialogs.AdvancedConfigurationWindow(gajim.interface)
#---------- AccountModificationWindow class -------------#
class AccountModificationWindow:
'''Class for account informations'''
def on_account_modification_window_destroy(self, widget):
'''close window'''
if self.plugin.windows.has_key(self.account):
if self.plugin.windows[self.account].has_key('account_modification'):
del self.plugin.windows[self.account]['account_modification']
if gajim.interface.windows.has_key(self.account):
if gajim.interface.windows[self.account].has_key('account_modification'):
del gajim.interface.windows[self.account]['account_modification']
return
if self.plugin.windows.has_key('account_modification'):
del self.plugin.windows['account_modification']
if gajim.interface.windows.has_key('account_modification'):
del gajim.interface.windows['account_modification']
def on_cancel_button_clicked(self, widget):
self.window.destroy()
def __init__(self, plugin, account = ''):
def __init__(self, account = ''):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'account_modification_window', APP)
self.window = self.xml.get_widget('account_modification_window')
self.plugin = plugin
self.account = account
self.modify = False # if we 're modifying an existing or creating a new account
@ -1262,7 +1260,7 @@ _('To change the account name, you must be disconnected.')).get_response()
#if we modify the name of the account
if name != self.account:
#update variables
self.plugin.windows[name] = self.plugin.windows[self.account]
gajim.interface.windows[name] = gajim.interface.windows[self.account]
gajim.awaiting_events[name] = gajim.awaiting_events[self.account]
gajim.nicks[name] = gajim.nicks[self.account]
gajim.allow_notifications[name] = \
@ -1283,16 +1281,16 @@ _('To change the account name, you must be disconnected.')).get_response()
#upgrade account variable in opened windows
for kind in ['infos', 'chats', 'gc', 'gc_config']:
for j in self.plugin.windows[name][kind]:
self.plugin.windows[name][kind][j].account = name
for j in gajim.interface.windows[name][kind]:
gajim.interface.windows[name][kind][j].account = name
#upgrade account in systray
if self.plugin.systray_enabled:
for list in self.plugin.systray.jids:
if gajim.interface.systray_enabled:
for list in gajim.interface.systray.jids:
if list[0] == self.account:
list[0] = name
del self.plugin.windows[self.account]
del gajim.interface.windows[self.account]
del gajim.awaiting_events[self.account]
del gajim.nicks[self.account]
del gajim.allow_notifications[self.account]
@ -1319,11 +1317,11 @@ _('To change the account name, you must be disconnected.')).get_response()
if config['savepass']:
gajim.connections[name].password = config['password']
#refresh accounts window
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()
if gajim.interface.windows.has_key('accounts'):
gajim.interface.windows['accounts'].init_accounts()
#refresh roster
self.plugin.roster.draw_roster()
self.plugin.save_config()
gajim.interface.roster.draw_roster()
gajim.interface.save_config()
self.window.destroy()
return
#if it's a new account
@ -1332,7 +1330,7 @@ _('To change the account name, you must be disconnected.')).get_response()
_('You already have an account using this name.')).get_response()
return
con = connection.Connection(name)
self.plugin.register_handlers(con)
gajim.interface.register_handlers(con)
#if we need to register a new account
if new_account:
gajim.events_for_ui[name] = []
@ -1346,10 +1344,10 @@ _('To change the account name, you must be disconnected.')).get_response()
if config['savepass']:
gajim.connections[name].password = config['password']
#update variables
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, \
gajim.interface.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, \
'gc_config': {}}
self.plugin.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(self.plugin, name)
gajim.interface.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(name)
gajim.awaiting_events[name] = {}
gajim.connections[name].connected = 0
gajim.groups[name] = {}
@ -1366,16 +1364,16 @@ _('To change the account name, you must be disconnected.')).get_response()
gajim.status_before_autoaway[name] = ''
gajim.events_for_ui[name] = []
#refresh accounts window
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()
if gajim.interface.windows.has_key('accounts'):
gajim.interface.windows['accounts'].init_accounts()
#refresh roster
self.plugin.roster.draw_roster()
self.plugin.save_config()
gajim.interface.roster.draw_roster()
gajim.interface.save_config()
self.window.destroy()
def on_change_password_button_clicked(self, widget):
try:
dialog = dialogs.ChangePasswordDialog(self.plugin, self.account)
dialog = dialogs.ChangePasswordDialog(self.account)
except RuntimeError:
#if we showed ErrorDialog, there will not be dialog instance
return
@ -1394,7 +1392,7 @@ _('To change the account name, you must be disconnected.')).get_response()
self.account = acct
def on_edit_details_button_clicked(self, widget):
if not self.plugin.windows.has_key(self.account):
if not gajim.interface.windows.has_key(self.account):
dialogs.ErrorDialog(_('No such account available'),
_('You must create your account before editing your personal information.')).get_response()
return
@ -1407,17 +1405,17 @@ _('To change the account name, you must be disconnected.')).get_response()
_('Without a connection, you can not edit your personal information.')
).get_response()
return
if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
self.plugin.windows[self.account]['infos'][jid] = \
dialogs.VcardWindow(jid, self.plugin, self.account, True)
if not gajim.interface.windows[self.account]['infos'].has_key('vcard'):
gajim.interface.windows[self.account]['infos'][jid] = \
dialogs.VcardWindow(jid, self.account, True)
gajim.connections[self.account].request_vcard(jid)
def on_manage_proxies_button_clicked(self, widget):
if self.plugin.windows.has_key('manage_proxies'):
self.plugin.windows['manage_proxies'].window.present()
if gajim.interface.windows.has_key('manage_proxies'):
gajim.interface.windows['manage_proxies'].window.present()
else:
self.plugin.windows['manage_proxies'] = \
ManageProxiesWindow(self.plugin)
gajim.interface.windows['manage_proxies'] = \
ManageProxiesWindow()
def on_gpg_choose_button_clicked(self, widget, data = None):
if gajim.connections.has_key(self.account):
@ -1498,8 +1496,7 @@ _('There was a problem retrieving your OpenPGP secret keys.')).get_response()
#---------- ManageProxiesWindow class -------------#
class ManageProxiesWindow:
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_proxies_window', APP)
self.window = self.xml.get_widget('manage_proxies_window')
self.proxies_treeview = self.xml.get_widget('proxies_treeview')
@ -1533,12 +1530,12 @@ class ManageProxiesWindow:
def on_manage_proxies_window_destroy(self, widget):
for account in gajim.connections:
if self.plugin.windows[account].has_key('account_modification'):
self.plugin.windows[account]['account_modification'].\
if gajim.interface.windows[account].has_key('account_modification'):
gajim.interface.windows[account]['account_modification'].\
update_proxy_list()
if self.plugin.windows.has_key('account_modification'):
self.plugin.windows['account_modification'].update_proxy_list()
del self.plugin.windows['manage_proxies']
if gajim.interface.windows.has_key('account_modification'):
gajim.interface.windows['account_modification'].update_proxy_list()
del gajim.interface.windows['manage_proxies']
def on_add_proxy_button_clicked(self, widget):
model = self.proxies_treeview.get_model()
@ -1658,13 +1655,12 @@ class ManageProxiesWindow:
class AccountsWindow:
'''Class for accounts window: list of accounts'''
def on_accounts_window_destroy(self, widget):
del self.plugin.windows['accounts']
del gajim.interface.windows['accounts']
def on_close_button_clicked(self, widget):
self.window.destroy()
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'accounts_window', APP)
self.window = self.xml.get_widget('accounts_window')
self.accounts_treeview = self.xml.get_widget('accounts_treeview')
@ -1705,11 +1701,11 @@ class AccountsWindow:
def on_new_button_clicked(self, widget):
'''When new button is clicked: open an account information window'''
if self.plugin.windows.has_key('account_modification'):
self.plugin.windows['account_modification'].window.present()
if gajim.interface.windows.has_key('account_modification'):
gajim.interface.windows['account_modification'].window.present()
else:
self.plugin.windows['account_modification'] = \
AccountModificationWindow(self.plugin, '')
gajim.interface.windows['account_modification'] = \
AccountModificationWindow('')
def on_remove_button_clicked(self, widget):
'''When delete button is clicked:
@ -1719,11 +1715,11 @@ class AccountsWindow:
if not iter:
return
account = model.get_value(iter, 0).decode('utf-8')
if self.plugin.windows[account].has_key('remove_account'):
self.plugin.windows[account]['remove_account'].window.present()
if gajim.interface.windows[account].has_key('remove_account'):
gajim.interface.windows[account]['remove_account'].window.present()
else:
self.plugin.windows[account]['remove_account'] = \
RemoveAccountWindow(self.plugin, account)
gajim.interface.windows[account]['remove_account'] = \
RemoveAccountWindow(account)
def on_modify_button_clicked(self, widget):
'''When modify button is clicked:
@ -1742,15 +1738,14 @@ class AccountsWindow:
self.show_modification_window(account)
def show_modification_window(self, account):
if self.plugin.windows[account].has_key('account_modification'):
self.plugin.windows[account]['account_modification'].window.present()
if gajim.interface.windows[account].has_key('account_modification'):
gajim.interface.windows[account]['account_modification'].window.present()
else:
self.plugin.windows[account]['account_modification'] = \
AccountModificationWindow(self.plugin, account)
gajim.interface.windows[account]['account_modification'] = \
AccountModificationWindow(account)
class DataFormWindow:
def __init__(self, plugin, account, config):
self.plugin = plugin
def __init__(self, account, config):
self.account = account
self.config = config
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'data_form_window', APP)
@ -1907,7 +1902,7 @@ class ServiceRegistrationWindow(DataFormWindow):
groups = [_('Transports')], show = 'offline', status = 'offline',
sub = 'from')
gajim.contacts[self.account][self.service] = [user1]
self.plugin.roster.add_contact_to_roster(self.service, self.account)
gajim.interface.roster.add_contact_to_roster(self.service, self.account)
def on_ok_button_clicked(self, widget):
'''When Ok button is clicked:
@ -1933,13 +1928,12 @@ class ServiceRegistrationWindow(DataFormWindow):
True) # True is for is_form
self.window.destroy()
def __init__(self, service, infos, plugin, account, is_form):
def __init__(self, service, infos, account, is_form):
self.service = service
self.infos = infos
self.plugin = plugin
self.account = account
if is_form:
DataFormWindow.__init__(self, plugin, account, infos)
DataFormWindow.__init__(self, account, infos)
else:
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'service_registration_window', APP)
self.window = self.xml.get_widget('service_registration_window')
@ -1956,10 +1950,9 @@ class ServiceRegistrationWindow(DataFormWindow):
#---------- ManageEmoticonsWindow class -------------#
class ManageEmoticonsWindow:
def __init__(self, plugin):
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_emoticons_window', APP)
self.window = self.xml.get_widget('manage_emoticons_window')
self.plugin = plugin
#emoticons
self.emot_tree = self.xml.get_widget('emoticons_treeview')
@ -1984,12 +1977,11 @@ class ManageEmoticonsWindow:
self.emot_tree.get_model().connect('row-changed',
self.on_emoticons_treemodel_row_changed)
self.plugin = plugin
self.xml.signal_autoconnect(self)
def on_add_remove_emoticons_window_delete_event(self, widget, event):
self.window.hide()
self.plugin.init_regexp() # update regexp [emoticons included]
gajim.interface.init_regexp() # update regexp [emoticons included]
return True # do NOT destroy the window
def on_close_button_clicked(self, widget):
@ -2000,12 +1992,12 @@ class ManageEmoticonsWindow:
emot = model.get_value(iter, 0).decode('utf-8').upper()
if not emot in emots:
gajim.config.add_per('emoticons', emot)
self.plugin.init_regexp() # update regexp [emoticons included]
gajim.interface.init_regexp() # update regexp [emoticons included]
image = model[iter][1]
if image:
image = image.decode('utf-8')
gajim.config.set_per('emoticons', emot, 'path', image)
self.plugin.save_config()
gajim.interface.save_config()
def image_is_ok(self, image):
if not os.path.exists(image):
@ -2060,11 +2052,11 @@ class ManageEmoticonsWindow:
model.remove(iter)
else:
gajim.config.add_per('emoticons', emot)
self.plugin.init_regexp() # update regexp (emoticons included)
gajim.interface.init_regexp() # update regexp (emoticons included)
gajim.config.set_per('emoticons', emot, 'path',
model[iter][1].decode('utf-8'))
model[iter][0] = emot
self.plugin.save_config()
gajim.interface.save_config()
def update_preview(self, widget):
path_to_file = widget.get_preview_filename()
@ -2157,8 +2149,8 @@ class ManageEmoticonsWindow:
if not iter:
return
gajim.config.del_per('emoticons', model.get_value(iter, 0).decode('utf-8'))
self.plugin.init_regexp() # update regexp [emoticons included]
self.plugin.save_config()
gajim.interface.init_regexp() # update regexp [emoticons included]
gajim.interface.save_config()
model.remove(iter)
def on_emoticons_treeview_key_press_event(self, widget, event):
@ -2171,13 +2163,12 @@ class ServiceDiscoveryWindow:
'''Class for Service Discovery Window:
to know the services on a server'''
def on_service_discovery_window_destroy(self, widget):
del self.plugin.windows[self.account]['disco']
del gajim.interface.windows[self.account]['disco']
def on_close_button_clicked(self, widget):
self.window.destroy()
def __init__(self, plugin, account):
self.plugin = plugin
def __init__(self, account):
self.account = account
self.agent_infos = {}
self.items_asked = [] #we already asked items to these jids
@ -2395,10 +2386,10 @@ _('Without a connection, you can not browse available services')).get_response()
services = service.split('@')
room = services[0]
service = services[1]
if not self.plugin.windows[self.account].has_key('join_gc'):
dialogs.JoinGroupchatWindow(self.plugin, self.account, service, room)
if not gajim.interface.windows[self.account].has_key('join_gc'):
dialogs.JoinGroupchatWindow(self.account, service, room)
else:
self.plugin.windows[self.account]['join_gc'].window.present()
gajim.interface.windows[self.account]['join_gc'].window.present()
def on_register_button_clicked(self, widget):
'''When we want to register an agent:
@ -2473,16 +2464,16 @@ _('Without a connection, you can not browse available services')).get_response()
self.services_treeview.get_model().clear()
self.items_asked = []
self.browse(server_address)
self.plugin.save_config()
gajim.interface.save_config()
class GroupchatConfigWindow(DataFormWindow):
'''GroupchatConfigWindow class'''
def __init__(self, plugin, account, room_jid, config):
DataFormWindow.__init__(self, plugin, account, config)
def __init__(self, account, room_jid, config):
DataFormWindow.__init__(self, account, config)
self.room_jid = room_jid
def on_data_form_window_destroy(self, widget):
del self.plugin.windows[self.account]['gc_config'][self.room_jid]
del gajim.interface.windows[self.account]['gc_config'][self.room_jid]
def on_apply_button_clicked(self, widget):
gajim.connections[self.account].send_gc_config(self.room_jid, self.config)
@ -2494,14 +2485,13 @@ class RemoveAccountWindow:
and do removing of the account given'''
def on_remove_account_window_destroy(self, widget):
if self.plugin.windows.has_key(self.account):
del self.plugin.windows[self.account]['remove_account']
if gajim.interface.windows.has_key(self.account):
del gajim.interface.windows[self.account]['remove_account']
def on_cancel_button_clicked(self, widget):
self.window.destroy()
def __init__(self, plugin, account):
self.plugin = plugin
def __init__(self, account):
self.account = account
xml = gtk.glade.XML(GTKGUI_GLADE, 'remove_account_window', APP)
self.window = xml.get_widget('remove_account_window')
@ -2524,8 +2514,8 @@ class RemoveAccountWindow:
gajim.connections[self.account].unregister_account()
del gajim.connections[self.account]
gajim.config.del_per('accounts', self.account)
self.plugin.save_config()
del self.plugin.windows[self.account]
gajim.interface.save_config()
del gajim.interface.windows[self.account]
del gajim.awaiting_events[self.account]
del gajim.nicks[self.account]
del gajim.allow_notifications[self.account]
@ -2540,15 +2530,14 @@ class RemoveAccountWindow:
del gajim.last_message_time[self.account]
del gajim.status_before_autoaway[self.account]
del gajim.events_for_ui[self.account]
self.plugin.roster.draw_roster()
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()
gajim.interface.roster.draw_roster()
if gajim.interface.windows.has_key('accounts'):
gajim.interface.windows['accounts'].init_accounts()
self.window.destroy()
#---------- ManageBookmarksWindow class -------------#
class ManageBookmarksWindow:
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_bookmarks_window', APP)
self.window = self.xml.get_widget('manage_bookmarks_window')
@ -2620,7 +2609,7 @@ class ManageBookmarksWindow:
return not self.check_valid_bookmark()
def on_manage_bookmarks_window_destroy(self, widget, event):
del self.plugin.windows['manage_bookmarks']
del gajim.interface.windows['manage_bookmarks']
def on_add_bookmark_button_clicked(self,widget):
'''
@ -2704,7 +2693,7 @@ _('Please be sure to fill out server and room fields or remove this bookmark.'))
gajim.connections[account_unicode].bookmarks.append(bmdict)
gajim.connections[account_unicode].store_bookmarks()
self.plugin.roster.make_menu()
gajim.interface.roster.make_menu()
self.window.destroy()
def on_cancel_button_clicked(self, widget):
@ -2796,8 +2785,7 @@ _('Please be sure to fill out server and room fields or remove this bookmark.'))
self.autojoin_checkbutton.set_active(False)
class FirstTimeWizardWindow:
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'wizard_window', APP)
self.window = self.xml.get_widget('wizard_window')
self.xml.signal_autoconnect(self)
@ -2993,7 +2981,7 @@ _('You need to enter a valid server address to continue.')).get_response()
_('You already have an account using this name.')).get_response()
return
con = connection.Connection(name)
self.plugin.register_handlers(con)
gajim.interface.register_handlers(con)
if new_account:
gajim.events_for_ui[name] = []
con.new_account(name, config)
@ -3006,10 +2994,10 @@ _('You need to enter a valid server address to continue.')).get_response()
if config['savepass']:
gajim.connections[name].password = config['password']
# update variables
self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {},
gajim.interface.windows[name] = {'infos': {}, 'chats': {}, 'gc': {},
'gc_config': {}}
self.plugin.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(self.plugin, name)
gajim.interface.windows[name]['xml_console'] = \
dialogs.XMLConsoleWindow(name)
gajim.awaiting_events[name] = {}
gajim.connections[name].connected = 0
gajim.groups[name] = {}
@ -3026,8 +3014,8 @@ _('You need to enter a valid server address to continue.')).get_response()
gajim.status_before_autoaway[name] = ''
gajim.events_for_ui[name] = []
# refresh accounts window
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].init_accounts()
if gajim.interface.windows.has_key('accounts'):
gajim.interface.windows['accounts'].init_accounts()
# refresh roster
self.plugin.roster.draw_roster()
self.plugin.save_config()
gajim.interface.roster.draw_roster()
gajim.interface.save_config()

View File

@ -43,10 +43,9 @@ GTKGUI_GLADE = 'gtkgui.glade'
class EditGroupsDialog:
'''Class for the edit group dialog window'''
def __init__(self, user, account, plugin):
def __init__(self, user, account):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'edit_groups_dialog', APP)
self.dialog = self.xml.get_widget('edit_groups_dialog')
self.plugin = plugin
self.account = account
self.user = user
self.changes_made = False
@ -70,8 +69,8 @@ class EditGroupsDialog:
self.dialog.destroy()
def update_contact(self):
self.plugin.roster.remove_contact(self.user, self.account)
self.plugin.roster.add_contact_to_roster(self.user.jid, self.account)
gajim.interface.roster.remove_contact(self.user, self.account)
gajim.interface.roster.add_contact_to_roster(self.user.jid, self.account)
gajim.connections[self.account].update_contact(self.user.jid,
self.user.name, self.user.groups)
@ -204,7 +203,7 @@ class ChooseGPGKeyDialog:
class ChangeStatusMessageDialog:
def __init__(self, plugin, show = None):
def __init__(self, show = None):
self.show = show
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP)
self.window = self.xml.get_widget('change_status_message_dialog')
@ -269,8 +268,7 @@ class ChangeStatusMessageDialog:
class AddNewContactWindow:
'''Class for AddNewContactWindow'''
def __init__(self, plugin, account, jid = None):
self.plugin = plugin
def __init__(self, account, jid = None):
self.account = account
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'add_new_contact_window', APP)
self.window = self.xml.get_widget('add_new_contact_window')
@ -364,7 +362,7 @@ _('Contact names must be of the form "user@servername".')).get_response()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter).decode('utf-8')
group = self.group_comboboxentry.child.get_text().decode('utf-8')
self.plugin.roster.req_sub(self, jid, message, self.account,
gajim.interface.roster.req_sub(self, jid, message, self.account,
group = group, pseudo = nickname)
if self.xml.get_widget('auto_authorize_checkbutton').get_active():
gajim.connections[self.account].send_authorization(jid)
@ -568,10 +566,9 @@ ok_handler = None):
class SubscriptionRequestWindow:
def __init__(self, plugin, jid, text, account):
def __init__(self, jid, text, account):
xml = gtk.glade.XML(GTKGUI_GLADE, 'subscription_request_window', APP)
self.window = xml.get_widget('subscription_request_window')
self.plugin = plugin
self.jid = jid
self.account = account
if len(gajim.connections) >= 2:
@ -592,17 +589,17 @@ class SubscriptionRequestWindow:
gajim.connections[self.account].send_authorization(self.jid)
self.window.destroy()
if not gajim.contacts[self.account].has_key(self.jid):
AddNewContactWindow(self.plugin, self.account, self.jid)
AddNewContactWindow(self.account, self.jid)
def on_contact_info_button_clicked(self, widget):
'''ask vcard'''
if self.plugin.windows[self.account]['infos'].has_key(self.jid):
self.plugin.windows[self.account]['infos'][self.jid].window.present()
if gajim.interface.windows[self.account]['infos'].has_key(self.jid):
gajim.interface.windows[self.account]['infos'][self.jid].window.present()
else:
self.plugin.windows[self.account]['infos'][self.jid] = \
VcardWindow(self.jid, self.plugin, self.account, True)
gajim.interface.windows[self.account]['infos'][self.jid] = \
VcardWindow(self.jid, self.account, True)
#remove the publish / retrieve buttons
vcard_xml = self.plugin.windows[self.account]['infos'][self.jid].xml
vcard_xml = gajim.interface.windows[self.account]['infos'][self.jid].xml
hbuttonbox = vcard_xml.get_widget('information_hbuttonbox')
children = hbuttonbox.get_children()
hbuttonbox.remove(children[0])
@ -616,8 +613,7 @@ class SubscriptionRequestWindow:
self.window.destroy()
class JoinGroupchatWindow:
def __init__(self, plugin, account, server = '', room = '', nick = ''):
self.plugin = plugin
def __init__(self, account, server = '', room = '', nick = ''):
self.account = account
if nick == '':
nick = gajim.nicks[self.account]
@ -632,7 +628,7 @@ _('You can not join a group chat unless you are connected.')).get_response()
self.xml.get_widget('room_entry').set_text(room)
self.xml.get_widget('nickname_entry').set_text(nick)
self.xml.signal_autoconnect(self)
self.plugin.windows[account]['join_gc'] = self #now add us to open windows
gajim.interface.windows[account]['join_gc'] = self #now add us to open windows
our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
gajim.config.get_per('accounts', self.account, 'hostname')
if len(gajim.connections) > 1:
@ -659,7 +655,7 @@ _('You can not join a group chat unless you are connected.')).get_response()
def on_join_groupchat_window_destroy(self, widget):
'''close window'''
# remove us from open windows
del self.plugin.windows[self.account]['join_gc']
del gajim.interface.windows[self.account]['join_gc']
def on_join_groupchat_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: # ESCAPE
@ -690,13 +686,12 @@ _('You can not join a group chat unless you are connected.')).get_response()
self.recently_groupchat = self.recently_groupchat[0:10]
gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat))
self.plugin.roster.join_gc_room(self.account, jid, nickname, password)
gajim.interface.roster.join_gc_room(self.account, jid, nickname, password)
self.window.destroy()
class NewMessageDialog:
def __init__(self, plugin, account):
self.plugin = plugin
def __init__(self, account):
self.account = account
our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
@ -724,16 +719,15 @@ class NewMessageDialog:
_('Contact ID must be of the form "username@servername".')).get_response()
return
self.plugin.roster.new_chat_from_jid(self.account, jid)
gajim.interface.roster.new_chat_from_jid(self.account, jid)
class ChangePasswordDialog:
def __init__(self, plugin, account):
def __init__(self, account):
# 'account' can be None if we are about to create our first one
if not account or gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not change your password.')).get_response()
raise RuntimeError, 'You are not connected to the server'
self.plugin = plugin
self.account = account
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_password_dialog', APP)
self.dialog = self.xml.get_widget('change_password_dialog')
@ -767,8 +761,7 @@ _('Without a connection, you can not change your password.')).get_response()
class PopupNotificationWindow:
def __init__(self, plugin, event_type, jid, account, msg_type = '', file_props = None):
self.plugin = plugin
def __init__(self, event_type, jid, account, msg_type = '', file_props = None):
self.account = account
self.jid = jid
self.msg_type = msg_type
@ -849,9 +842,9 @@ class PopupNotificationWindow:
event_description_label.set_text(txt)
# position the window to bottom-right of screen
window_width, self.window_height = self.window.get_size()
self.plugin.roster.popups_notification_height += self.window_height
gajim.interface.roster.popups_notification_height += self.window_height
self.window.move(gtk.gdk.screen_width() - window_width,
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
gtk.gdk.screen_height() - gajim.interface.roster.popups_notification_height)
xml.signal_autoconnect(self)
self.window.show_all()
@ -865,20 +858,20 @@ class PopupNotificationWindow:
def adjust_height_and_move_popup_notification_windows(self):
#remove
self.plugin.roster.popups_notification_height -= self.window_height
gajim.interface.roster.popups_notification_height -= self.window_height
self.window.destroy()
if len(self.plugin.roster.popup_notification_windows) > 0:
if len(gajim.interface.roster.popup_notification_windows) > 0:
# we want to remove the first window added in the list
self.plugin.roster.popup_notification_windows.pop(0) # remove 1st item
gajim.interface.roster.popup_notification_windows.pop(0) # remove 1st item
# move the rest of popup windows
self.plugin.roster.popups_notification_height = 0
for window_instance in self.plugin.roster.popup_notification_windows:
gajim.interface.roster.popups_notification_height = 0
for window_instance in gajim.interface.roster.popup_notification_windows:
window_width, window_height = window_instance.window.get_size()
self.plugin.roster.popups_notification_height += window_height
gajim.interface.roster.popups_notification_height += window_height
window_instance.window.move(gtk.gdk.screen_width() - window_width,
gtk.gdk.screen_height() - self.plugin.roster.popups_notification_height)
gtk.gdk.screen_height() - gajim.interface.roster.popups_notification_height)
def on_popup_notification_window_button_press_event(self, widget, event):
# use Contact class, new_chat expects it that way
@ -903,23 +896,23 @@ class PopupNotificationWindow:
groups = [_('not in the roster')], show = 'not in the roster',
status = _('not in the roster'), sub = 'none', keyID = keyID)
gajim.contacts[self.account][self.jid] = [contact]
self.plugin.roster.add_contact_to_roster(contact.jid,
gajim.interface.roster.add_contact_to_roster(contact.jid,
self.account)
if self.msg_type == 'pm': # It's a private message
self.plugin.roster.new_chat(contact, self.account)
chats_window = self.plugin.windows[self.account]['chats'][self.jid]
gajim.interface.roster.new_chat(contact, self.account)
chats_window = gajim.interface.windows[self.account]['chats'][self.jid]
chats_window.set_active_tab(self.jid)
chats_window.window.present()
elif self.msg_type in ('normal', 'file-request', 'file-request-error',
'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
# Get the first single message event
ev = gajim.get_first_event(self.account, self.jid, self.msg_type)
self.plugin.roster.open_event(self.account, self.jid, ev)
gajim.interface.roster.open_event(self.account, self.jid, ev)
else: # 'chat'
self.plugin.roster.new_chat(contact, self.account)
chats_window = self.plugin.windows[self.account]['chats'][self.jid]
gajim.interface.roster.new_chat(contact, self.account)
chats_window = gajim.interface.windows[self.account]['chats'][self.jid]
chats_window.set_active_tab(self.jid)
chats_window.window.present()
@ -929,9 +922,8 @@ class PopupNotificationWindow:
class SingleMessageWindow:
'''SingleMessageWindow can send or show a received
singled message depending on action argument'''
def __init__(self, plugin, account, to = '', action = '', from_whom = '',
def __init__(self, account, to = '', action = '', from_whom = '',
subject = '', message = ''):
self.plugin = plugin
self.account = account
self.action = action
@ -1086,7 +1078,7 @@ class SingleMessageWindow:
self.subject = _('RE: %s') % self.subject
self.message = _('\n\n\n== Original Message ==\n%s') % self.message
self.window.destroy()
SingleMessageWindow(self.plugin, self.account, to = self.from_whom,
SingleMessageWindow(self.account, to = self.from_whom,
action = 'send', from_whom = self.from_whom, subject = self.subject,
message = self.message)
@ -1101,8 +1093,7 @@ class SingleMessageWindow:
self.window.destroy()
class XMLConsoleWindow:
def __init__(self, plugin, account):
self.plugin = plugin
def __init__(self, account):
self.account = account
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'xml_console_window', APP)
@ -1206,7 +1197,7 @@ class XMLConsoleWindow:
self.input_textview.grab_focus()
class InvitationReceivedDialog:
def __init__(self, plugin, account, room_jid, contact_jid, password = None, comment = None):
def __init__(self, account, room_jid, contact_jid, password = None, comment = None):
xml = gtk.glade.XML(GTKGUI_GLADE, 'invitation_received_dialog', APP)
dialog = xml.get_widget('invitation_received_dialog')
@ -1223,5 +1214,5 @@ class InvitationReceivedDialog:
dialog.destroy()
if response == gtk.RESPONSE_YES:
room, server = gajim.get_room_name_and_server_from_room_jid(room_jid)
JoinGroupchatWindow(plugin, account, server = server, room = room)
JoinGroupchatWindow(account, server = server, room = room)

View File

@ -51,9 +51,8 @@ C_SID = 6
class FileTransfersWindow:
def __init__(self, plugin):
def __init__(self):
self.files_props = {'r' : {}, 's': {}}
self.plugin = plugin
self.height_diff = 0
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'file_transfers_window', APP)
self.window = self.xml.get_widget('file_transfers_window')

View File

@ -526,7 +526,7 @@ class Interface:
def handle_event_subscribe(self, account, array):
#('SUBSCRIBE', account, (jid, text))
dialogs.SubscriptionRequestWindow(self, array[0], array[1], account)
dialogs.SubscriptionRequestWindow(array[0], array[1], account)
if self.remote and self.remote.is_enabled():
self.remote.raise_signal('Subscribe', (account, array))
@ -577,7 +577,7 @@ class Interface:
def handle_event_register_agent_info(self, account, array):
#('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
if array[1].has_key('instructions'):
config.ServiceRegistrationWindow(array[0], array[1], self, account,
config.ServiceRegistrationWindow(array[0], array[1], account,
array[2])
else:
dialogs.ErrorDialog(_('Contact with "%s" cannot be established'\
@ -606,7 +606,7 @@ class Interface:
if self.windows.has_key('account_modification'):
self.windows['account_modification'].account_is_ok(array[0])
self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}, 'gc_config': {}}
self.windows[name]['xml_console'] = dialogs.XMLConsoleWindow(self, name)
self.windows[name]['xml_console'] = dialogs.XMLConsoleWindow(name)
gajim.awaiting_events[name] = {}
# disconnect from server - our status in roster is offline
gajim.connections[name].connected = 1
@ -633,7 +633,7 @@ class Interface:
self.remote.raise_signal('NewAccount', (account, array))
def handle_event_quit(self, p1, p2):
self.roster.quit_gtkgui_plugin()
self.roster.quit_gtkgui_interface()
def handle_event_myvcard(self, account, array):
nick = ''
@ -732,11 +732,11 @@ class Interface:
jid = array[0].split('/')[0]
if not self.windows[account]['gc_config'].has_key(jid):
self.windows[account]['gc_config'][jid] = \
config.GroupchatConfigWindow(self, account, jid, array[1])
config.GroupchatConfigWindow(account, jid, array[1])
def handle_event_gc_invitation(self, account, array):
#('GC_INVITATION', (room_jid, jid_from, reason, password))
dialogs.InvitationReceivedDialog(self, account, array[0], array[1],
dialogs.InvitationReceivedDialog(account, array[0], array[1],
array[3], array[2])
def handle_event_bad_passphrase(self, account, array):
@ -910,7 +910,7 @@ class Interface:
if gajim.config.get('notify_on_file_complete') and \
gajim.config.get('autopopupaway') or \
gajim.connections[account].connected in (2, 3):
instance = dialogs.PopupNotificationWindow(self, event_type,
instance = dialogs.PopupNotificationWindow(event_type,
jid, account, msg_type, file_props)
self.roster.popup_notification_windows.append(instance)
@ -1192,7 +1192,7 @@ class Interface:
import remote_control
if not hasattr(self, 'remote') or not self.remote:
try:
self.remote = remote_control.Remote(self)
self.remote = remote_control.Remote()
except remote_control.DbusNotSupported:
self.remote = None
return False
@ -1212,6 +1212,7 @@ class Interface:
self.remote = None
def __init__(self):
gajim.interface = self
self.default_values = {
'inmsgcolor': gajim.config.get('inmsgcolor'),
'outmsgcolor': gajim.config.get('outmsgcolor'),
@ -1292,7 +1293,7 @@ class Interface:
gajim.status_before_autoaway[a] = ''
gajim.events_for_ui[a] = []
self.roster = roster_window.RosterWindow(self)
self.roster = roster_window.RosterWindow()
if gajim.config.get('use_dbus'):
self.enable_dbus()
else:
@ -1316,7 +1317,7 @@ class Interface:
pass
else:
self.systray_capabilities = True
self.systray = systraywin32.SystrayWin32(self)
self.systray = systraywin32.SystrayWin32()
else:
try:
import egg.trayicon # use gnomepythonextras trayicon
@ -1327,28 +1328,28 @@ class Interface:
pass
else:
self.systray_capabilities = True
self.systray = systray.Systray(self)
self.systray = systray.Systray()
else:
self.systray_capabilities = True
self.systray = systray.Systray(self)
self.systray = systray.Systray()
if self.systray_capabilities and gajim.config.get('trayicon'):
self.show_systray()
if gajim.config.get('check_for_new_version'):
check_for_new_version.Check_for_new_version_dialog(self)
check_for_new_version.Check_for_new_version_dialog()
self.init_regexp()
# get instances for windows/dialogs that will show_all()/hide()
self.windows['file_transfers'] = dialogs.FileTransfersWindow(self)
self.windows['preferences'] = config.PreferencesWindow(self)
self.windows['file_transfers'] = dialogs.FileTransfersWindow()
self.windows['preferences'] = config.PreferencesWindow()
self.windows['add_remove_emoticons'] = \
config.ManageEmoticonsWindow(self)
config.ManageEmoticonsWindow()
self.windows['roster'] = self.roster
for account in gajim.connections:
self.windows[account]['xml_console'] = \
dialogs.XMLConsoleWindow(self, account)
dialogs.XMLConsoleWindow(account)
self.register_handlers(gajim.connections[account])
gobject.timeout_add(100, self.autoconnect)

View File

@ -36,10 +36,9 @@ GTKGUI_GLADE = 'gtkgui.glade'
class GajimThemesWindow:
def __init__(self, plugin):
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'gajim_themes_window', APP)
self.window = self.xml.get_widget('gajim_themes_window')
self.plugin = plugin
self.options = ['account', 'group', 'contact', 'banner', 'lastmessage']
self.options_combobox = self.xml.get_widget('options_combobox')
@ -102,7 +101,7 @@ class GajimThemesWindow:
gajim.config.set('roster_theme', new_config_name)
model.set_value(iter, 0, new_name)
self.current_theme = new_name
self.plugin.windows['preferences'].update_preferences_window()
gajim.interface.windows['preferences'].update_preferences_window()
def fill_themes_treeview(self):
self.xml.get_widget('remove_button').set_sensitive(False)
@ -144,7 +143,7 @@ class GajimThemesWindow:
col = self.themes_tree.get_column(0)
path = model.get_path(iter)
self.themes_tree.set_cursor(path, col, True)
self.plugin.windows['preferences'].update_preferences_window()
gajim.interface.windows['preferences'].update_preferences_window()
def on_remove_button_clicked(self, widget):
(model, iter) = self.themes_tree.get_selection().get_selected()
@ -157,7 +156,7 @@ class GajimThemesWindow:
self.theme_options_vbox.set_sensitive(False)
gajim.config.del_per('themes', self.current_theme)
model.remove(iter)
self.plugin.windows['preferences'].update_preferences_window()
gajim.interface.windows['preferences'].update_preferences_window()
def set_theme_options(self, theme, option = 'account'):
self.no_update = True
@ -193,7 +192,7 @@ class GajimThemesWindow:
self.textfont_checkbutton.set_active(state)
self.text_fontbutton.set_sensitive(state)
self.no_update = False
self.plugin.roster.change_roster_style(None)
gajim.interface.roster.change_roster_style(None)
def on_textcolor_checkbutton_toggled(self, widget):
state = widget.get_active()
@ -248,13 +247,13 @@ class GajimThemesWindow:
self.current_option + option, color_string)
# use faster functions for this
if self.current_option == 'banner':
self.plugin.roster.repaint_themed_widgets()
self.plugin.save_config()
gajim.interface.roster.repaint_themed_widgets()
gajim.interface.save_config()
return
if self.no_update:
return
self.plugin.roster.change_roster_style(self.current_option)
self.plugin.save_config()
gajim.interface.roster.change_roster_style(self.current_option)
gajim.interface.save_config()
def _set_font(self):
''' set font value in prefs and update the UI '''
@ -270,11 +269,11 @@ class GajimThemesWindow:
self.current_option + 'fontattrs', font_attrs)
# use faster functions for this
if self.current_option == 'banner':
self.plugin.roster.repaint_themed_widgets()
gajim.interface.roster.repaint_themed_widgets()
if self.no_update:
return
self.plugin.roster.change_roster_style(self.current_option)
self.plugin.save_config()
gajim.interface.roster.change_roster_style(self.current_option)
gajim.interface.save_config()
def _toggle_font_widgets(self, font_props):
''' toggle font buttons with the bool values of font_props tuple'''

View File

@ -56,10 +56,10 @@ GTKGUI_GLADE = 'gtkgui.glade'
class GroupchatWindow(chat.Chat):
'''Class for Groupchat window'''
def __init__(self, room_jid, nick, plugin, account):
def __init__(self, room_jid, nick, account):
# we check that on opening new windows
self.always_compact_view = gajim.config.get('always_compact_view_gc')
chat.Chat.__init__(self, plugin, account, 'groupchat_window')
chat.Chat.__init__(self, account, 'groupchat_window')
# alphanum sorted
self.muc_cmds = ['ban', 'chat', 'query', 'clear', 'close', 'compact', 'help', 'invite',
@ -82,7 +82,8 @@ class GroupchatWindow(chat.Chat):
self.gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char')
self.new_room(room_jid, nick)
self.show_title()
self.tooltip = tooltips.GCTooltip(plugin)
self.tooltip = tooltips.GCTooltip()
self.line_tooltip = tooltips.BaseTooltip()
# NOTE: if it not a window event, connect in new_room function
@ -351,7 +352,7 @@ class GroupchatWindow(chat.Chat):
def add_contact_to_roster(self, room_jid, nick, show, role, jid, affiliation, status):
model = self.list_treeview[room_jid].get_model()
image = self.plugin.roster.jabber_state_images[show]
image = gajim.interface.roster.jabber_state_images[show]
resource = ''
role_name = helpers.get_uf_role(role, plural = True)
@ -365,7 +366,7 @@ class GroupchatWindow(chat.Chat):
role_iter = self.get_role_iter(room_jid, role)
if not role_iter:
role_iter = model.append(None,
(self.plugin.roster.jabber_state_images['closed'], 'role', role,
(gajim.interface.roster.jabber_state_images['closed'], 'role', role,
'<b>%s</b>' % role_name))
iter = model.append(role_iter, (image, 'contact', nick,
self.escape(nick)))
@ -385,7 +386,7 @@ class GroupchatWindow(chat.Chat):
return 'visitor'
def update_state_images(self):
roster = self.plugin.roster
roster = gajim.interface.roster
for room_jid in self.list_treeview:
model = self.list_treeview[room_jid].get_model()
role_iter = model.get_iter_root()
@ -472,7 +473,7 @@ class GroupchatWindow(chat.Chat):
c.show = show
c.affiliation = affiliation
c.status = status
roster = self.plugin.roster
roster = gajim.interface.roster
state_images = roster.get_appropriate_state_images(jid)
image = state_images[show]
model[iter][C_IMG] = image
@ -567,7 +568,7 @@ class GroupchatWindow(chat.Chat):
gajim.connections[self.account].bookmarks.append(bm)
gajim.connections[self.account].store_bookmarks()
self.plugin.roster.make_menu()
gajim.interface.roster.make_menu()
dialogs.InformationDialog(
_('Bookmark has been added successfully'),
@ -810,14 +811,13 @@ class GroupchatWindow(chat.Chat):
server = servernick
nick = ''
#join_gc window is needed in order to provide for password entry.
if self.plugin.windows[self.account].has_key('join_gc'):
self.plugin.windows[self.account]['join_gc'].\
if gajim.interface.windows[self.account].has_key('join_gc'):
gajim.interface.windows[self.account]['join_gc'].\
window.present()
else:
try:
self.plugin.windows[self.account]['join_gc'] =\
dialogs.JoinGroupchatWindow(self.plugin,
self.account,
gajim.interface.windows[self.account]['join_gc'] =\
dialogs.JoinGroupchatWindow(self.account,
server = server, room = room, nick = nick)
except RuntimeError:
pass
@ -1090,15 +1090,15 @@ current room topic.') % command, room_jid)
else:
fjid = gajim.construct_fjid(room_jid, nick)
jid = fjid
if self.plugin.windows[self.account]['infos'].has_key(jid):
self.plugin.windows[self.account]['infos'][jid].window.present()
if gajim.interface.windows[self.account]['infos'].has_key(jid):
gajim.interface.windows[self.account]['infos'][jid].window.present()
else:
# we copy contact because c.jid must contain the fakeJid for vcard
c2 = Contact(jid = jid, name = c.name, groups = c.groups,
show = c.show, status = c.status, sub = c.sub,
resource = c.resource, role = c.role, affiliation = c.affiliation)
self.plugin.windows[self.account]['infos'][jid] = \
dialogs.VcardWindow(c2, self.plugin, self.account, False)
gajim.interface.windows[self.account]['infos'][jid] = \
dialogs.VcardWindow(c2, self.account, False)
def on_history(self, widget, room_jid, nick):
c = gajim.gc_contacts[self.account][room_jid][nick]
@ -1112,7 +1112,7 @@ current room topic.') % command, room_jid)
self.on_history_menuitem_clicked(jid = jid)
def on_add_to_roster(self, widget, jid):
dialogs.AddNewContactWindow(self.plugin, self.account, jid)
dialogs.AddNewContactWindow(self.account, jid)
def on_send_pm(self, widget=None, model=None, iter=None, nick=None, msg=None):
'''opens a chat window and msg is not None sends private message to a
@ -1121,18 +1121,18 @@ current room topic.') % command, room_jid)
nick = model[iter][C_NICK].decode('utf-8')
room_jid = self.get_active_jid()
fjid = gajim.construct_fjid(room_jid, nick) # 'fake' jid
if not self.plugin.windows[self.account]['chats'].has_key(fjid):
if not gajim.interface.windows[self.account]['chats'].has_key(fjid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
u = Contact(jid = fjid, name = nick, groups = ['none'], show = show,
sub = 'none')
self.plugin.roster.new_chat(u, self.account)
gajim.interface.roster.new_chat(u, self.account)
#make active here in case we need to send a message
self.plugin.windows[self.account]['chats'][fjid].set_active_tab(fjid)
gajim.interface.windows[self.account]['chats'][fjid].set_active_tab(fjid)
if msg:
self.plugin.windows[self.account]['chats'][fjid].send_message(msg)
self.plugin.windows[self.account]['chats'][fjid].window.present()
gajim.interface.windows[self.account]['chats'][fjid].send_message(msg)
gajim.interface.windows[self.account]['chats'][fjid].window.present()
def on_voice_checkmenuitem_activate(self, widget, room_jid, nick):
if widget.get_active():
@ -1373,8 +1373,8 @@ current room topic.') % command, room_jid)
no_queue = False
# We print if window is opened
if self.plugin.windows[self.account]['chats'].has_key(fjid):
chat_win = self.plugin.windows[self.account]['chats'][fjid]
if gajim.interface.windows[self.account]['chats'].has_key(fjid):
chat_win = gajim.interface.windows[self.account]['chats'][fjid]
chat_win.print_conversation(msg, fjid, tim = tim)
return
@ -1391,17 +1391,17 @@ current room topic.') % command, room_jid)
gajim.connections[self.account].connected > 2):
if no_queue: # We didn't have a queue: we change icons
model = self.list_treeview[room_jid].get_model()
state_images = self.plugin.roster.get_appropriate_state_images(room_jid)
state_images = gajim.interface.roster.get_appropriate_state_images(room_jid)
image = state_images['message']
model[iter][C_IMG] = image
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(fjid, self.account, 'pm')
if gajim.interface.systray_enabled:
gajim.interface.systray.add_jid(fjid, self.account, 'pm')
self.show_title()
else:
show = gajim.gc_contacts[self.account][room_jid][nick].show
c = Contact(jid = fjid, name = nick, groups = ['none'], show = show,
ask = 'none')
self.plugin.roster.new_chat(c, self.account)
gajim.interface.roster.new_chat(c, self.account)
# Scroll to line
self.list_treeview[room_jid].expand_row(path[0:1], False)
self.list_treeview[room_jid].scroll_to_cell(path)
@ -1506,13 +1506,13 @@ current room topic.') % command, room_jid)
if len(path) == 2:
nick = model[iter][C_NICK].decode('utf-8')
fjid = gajim.construct_fjid(room_jid, nick)
if not self.plugin.windows[self.account]['chats'].has_key(fjid):
if not gajim.interface.windows[self.account]['chats'].has_key(fjid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
u = Contact(jid = fjid, name = nick, groups = ['none'],
show = show, sub = 'none')
self.plugin.roster.new_chat(u, self.account)
self.plugin.windows[self.account]['chats'][fjid].set_active_tab(fjid)
self.plugin.windows[self.account]['chats'][fjid].window.present()
gajim.interface.roster.new_chat(u, self.account)
gajim.interface.windows[self.account]['chats'][fjid].set_active_tab(fjid)
gajim.interface.windows[self.account]['chats'][fjid].window.present()
return True
elif event.button == 1: # left click
@ -1550,22 +1550,22 @@ current room topic.') % command, room_jid)
room_jid = self.get_active_jid()
nick = model[iter][C_NICK].decode('utf-8')
fjid = gajim.construct_fjid(room_jid, nick)
if not self.plugin.windows[self.account]['chats'].has_key(fjid):
if not gajim.interface.windows[self.account]['chats'].has_key(fjid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
u = Contact(jid = fjid, name = nick, groups = ['none'], show = show,
sub = 'none')
self.plugin.roster.new_chat(u, self.account)
self.plugin.windows[self.account]['chats'][fjid].set_active_tab(fjid)
self.plugin.windows[self.account]['chats'][fjid].window.present()
gajim.interface.roster.new_chat(u, self.account)
gajim.interface.windows[self.account]['chats'][fjid].set_active_tab(fjid)
gajim.interface.windows[self.account]['chats'][fjid].window.present()
def on_list_treeview_row_expanded(self, widget, iter, path):
'''When a row is expanded: change the icon of the arrow'''
model = widget.get_model()
image = self.plugin.roster.jabber_state_images['opened']
image = gajim.interface.roster.jabber_state_images['opened']
model[iter][C_IMG] = image
def on_list_treeview_row_collapsed(self, widget, iter, path):
'''When a row is collapsed: change the icon of the arrow'''
model = widget.get_model()
image = self.plugin.roster.jabber_state_images['closed']
image = gajim.interface.roster.jabber_state_images['closed']
model[iter][C_IMG] = image

View File

@ -34,8 +34,7 @@ GTKGUI_GLADE = 'gtkgui.glade'
class HistoryWindow:
'''Class for browsing logs of conversations with contacts'''
def __init__(self, plugin, jid, account):
self.plugin = plugin
def __init__(self, jid, account):
self.jid = jid
self.account = account
self.no_of_lines = gajim.logger.get_no_of_lines(jid)
@ -80,7 +79,7 @@ class HistoryWindow:
self.window.show_all()
def on_history_window_destroy(self, widget):
del self.plugin.windows['logs'][self.jid]
del gajim.interface.windows['logs'][self.jid]
def on_close_button_clicked(self, widget):
self.window.destroy()

View File

@ -49,7 +49,7 @@ OBJ_PATH = '/org/gajim/dbus/RemoteObject'
SERVICE = 'org.gajim.dbus'
class Remote:
def __init__(self, plugin):
def __init__(self):
self.signal_object = None
if 'dbus' not in globals() and not os.name == 'nt':
print _('D-Bus python bindings are missing in this computer')
@ -66,10 +66,10 @@ class Remote:
if _version[1] >= 41:
service = dbus.service.BusName(SERVICE, bus=session_bus)
self.signal_object = SignalObject(service, plugin)
self.signal_object = SignalObject(service)
elif _version[1] <= 40 and _version[1] >= 20:
service=dbus.Service(SERVICE, session_bus)
self.signal_object = SignalObject(service, plugin)
self.signal_object = SignalObject(service)
def set_enabled(self, status):
self.signal_object.disabled = not status
@ -86,8 +86,7 @@ class SignalObject(DbusPrototype):
''' Local object definition for /org/gajim/dbus/RemoteObject. This doc must
not be visible, because the clients can access only the remote object. '''
def __init__(self, service, plugin):
self.plugin = plugin
def __init__(self, service):
self.first_show = True
self.vcard_account = None
self.disabled = False
@ -162,7 +161,7 @@ class SignalObject(DbusPrototype):
if connected_account:
if os.path.isfile(file_path): # is it file?
self.plugin.windows['file_transfers'].send_file(account,
gajim.interface.windows['file_transfers'].send_file(account,
contact, file_path)
return True
return False
@ -220,7 +219,7 @@ class SignalObject(DbusPrototype):
first_connected_acct = None
for acct in accounts:
if gajim.connections[acct].connected > 1: # account is online
if self.plugin.windows[acct]['chats'].has_key(jid):
if gajim.interface.windows[acct]['chats'].has_key(jid):
connected_account = acct
break
# jid is in roster
@ -239,9 +238,9 @@ class SignalObject(DbusPrototype):
connected_account = first_connected_acct
if connected_account:
self.plugin.roster.new_chat_from_jid(connected_account, jid)
gajim.interface.roster.new_chat_from_jid(connected_account, jid)
# preserve the 'steal focus preservation'
win = self.plugin.windows[connected_account]['chats'][jid].window
win = gajim.interface.windows[connected_account]['chats'][jid].window
if win.get_property('visible'):
win.window.focus()
return True
@ -258,12 +257,12 @@ class SignalObject(DbusPrototype):
# FIXME: raise exception for bad status (dbus0.35)
return None
if account:
gobject.idle_add(self.plugin.roster.send_status, account,
gobject.idle_add(gajim.interface.roster.send_status, account,
status, message)
else:
# account not specified, so change the status of all accounts
for acc in gajim.contacts.keys():
gobject.idle_add(self.plugin.roster.send_status, acc,
gobject.idle_add(gajim.interface.roster.send_status, acc,
status, message)
return None
@ -273,17 +272,17 @@ class SignalObject(DbusPrototype):
return
#FIXME: when systray is disabled this method does nothing.
#FIXME: show message from GC that refer to us (like systray does)
if len(self.plugin.systray.jids) != 0:
account = self.plugin.systray.jids[0][0]
jid = self.plugin.systray.jids[0][1]
acc = self.plugin.windows[account]
if len(gajim.interface.systray.jids) != 0:
account = gajim.interface.systray.jids[0][0]
jid = gajim.interface.systray.jids[0][1]
acc = gajim.interface.windows[account]
jid_tab = None
if acc['gc'].has_key(jid):
jid_tab = acc['gc'][jid]
elif acc['chats'].has_key(jid):
jid_tab = acc['chats'][jid]
else:
self.plugin.roster.new_chat(
gajim.interface.roster.new_chat(
gajim.contacts[account][jid][0], account)
jid_tab = acc['chats'][jid]
if jid_tab:
@ -365,7 +364,7 @@ class SignalObject(DbusPrototype):
''' shows/hides the roster window '''
if self.disabled:
return
win = self.plugin.roster.window
win = gajim.interface.roster.window
if win.get_property('visible'):
gobject.idle_add(win.hide)
else:
@ -392,7 +391,7 @@ class SignalObject(DbusPrototype):
def prefs_store(self, *args):
try:
self.plugin.save_config()
gajim.interface.save_config()
except Exception, e:
return False
return True
@ -426,7 +425,7 @@ class SignalObject(DbusPrototype):
def add_contact(self, *args):
[account] = self._get_real_arguments(args, 1)
if gajim.contacts.has_key(account):
AddNewContactWindow(self.plugin, account)
AddNewContactWindow(account)
return True
return False
@ -444,7 +443,7 @@ class SignalObject(DbusPrototype):
if gajim.contacts[account].has_key(jid):
gajim.connections[account].unsubscribe(jid)
for contact in gajim.contacts[account][jid]:
self.plugin.roster.remove_contact(contact, account)
gajim.interface.roster.remove_contact(contact, account)
del gajim.contacts[account][jid]
contact_exists = True
return contact_exists

View File

@ -60,7 +60,7 @@ C_SECPIXBUF, # econdary_pixbuf
GTKGUI_GLADE = 'gtkgui.glade'
class RosterWindow:
'''Class for main window of gtkgui plugin'''
'''Class for main window of gtkgui interface'''
def get_account_iter(self, name):
if self.regroup:
@ -248,7 +248,7 @@ class RosterWindow:
#FIXME: add avatar
def join_gc_room(self, account, room_jid, nick, password):
if room_jid in self.plugin.windows[account]['gc'] and \
if room_jid in gajim.interface.windows[account]['gc'] and \
gajim.gc_connected[account][room_jid]:
dialogs.ErrorDialog(_('You are already in room %s') %room_jid
).get_response()
@ -259,10 +259,10 @@ class RosterWindow:
).get_response()
return
room, server = room_jid.split('@')
if not room_jid in self.plugin.windows[account]['gc']:
if not room_jid in gajim.interface.windows[account]['gc']:
self.new_room(room_jid, nick, account)
self.plugin.windows[account]['gc'][room_jid].set_active_tab(room_jid)
self.plugin.windows[account]['gc'][room_jid].window.present()
gajim.interface.windows[account]['gc'][room_jid].set_active_tab(room_jid)
gajim.interface.windows[account]['gc'][room_jid].window.present()
gajim.connections[account].join_gc(nick, room, server, password)
def on_bookmark_menuitem_activate(self, widget, account, bookmark):
@ -275,23 +275,23 @@ class RosterWindow:
def on_send_server_message_menuitem_activate(self, widget, account):
server = gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/online'
dialogs.SingleMessageWindow(self.plugin, account, server, 'send')
dialogs.SingleMessageWindow(account, server, 'send')
def on_xml_console_menuitem_activate(self, widget, account):
if self.plugin.windows[account].has_key('xml_console'):
self.plugin.windows[account]['xml_console'].window.present()
if gajim.interface.windows[account].has_key('xml_console'):
gajim.interface.windows[account]['xml_console'].window.present()
else:
self.plugin.windows[account]['xml_console'].window.show_all()
gajim.interface.windows[account]['xml_console'].window.show_all()
def on_set_motd_menuitem_activate(self, widget, account):
server = gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd'
dialogs.SingleMessageWindow(self.plugin, account, server, 'send')
dialogs.SingleMessageWindow(account, server, 'send')
def on_update_motd_menuitem_activate(self, widget, account):
server = gajim.config.get_per('accounts', account, 'hostname')
server += '/announce/motd/update'
dialogs.SingleMessageWindow(self.plugin, account, server, 'send')
dialogs.SingleMessageWindow(account, server, 'send')
def on_delete_motd_menuitem_activate(self, widget, account):
server = gajim.config.get_per('accounts', account, 'hostname')
@ -628,28 +628,27 @@ class RosterWindow:
self.add_contact_to_roster(contact.jid, account)
self.draw_contact(contact.jid, account)
# print status in chat window and update status/GPG image
if self.plugin.windows[account]['chats'].has_key(contact.jid):
if gajim.interface.windows[account]['chats'].has_key(contact.jid):
jid = contact.jid
self.plugin.windows[account]['chats'][jid].set_state_image(jid)
gajim.interface.windows[account]['chats'][jid].set_state_image(jid)
name = contact.name
if contact.resource != '':
name += '/' + contact.resource
uf_show = helpers.get_uf_show(show)
self.plugin.windows[account]['chats'][jid].print_conversation(
gajim.interface.windows[account]['chats'][jid].print_conversation(
_('%s is now %s (%s)') % (name, uf_show, status), jid, 'status')
if contact == gajim.get_contact_instance_with_highest_priority(\
account, contact.jid):
self.plugin.windows[account]['chats'][jid].draw_name_banner(contact)
gajim.interface.windows[account]['chats'][jid].draw_name_banner(contact)
def on_info(self, widget, user, account):
'''Call vcard_information_window class to display user's information'''
info = self.plugin.windows[account]['infos']
info = gajim.interface.windows[account]['infos']
if info.has_key(user.jid):
info[user.jid].window.present()
else:
info[user.jid] = dialogs.VcardWindow(user, self.plugin,
account)
info[user.jid] = dialogs.VcardWindow(user, account)
def show_tooltip(self, contact):
pointer = self.tree.get_pointer()
@ -800,24 +799,24 @@ class RosterWindow:
keys[user.jid] = keyID[0]
for u in gajim.contacts[account][user.jid]:
u.keyID = keyID[0]
if self.plugin.windows[account]['chats'].has_key(user.jid):
self.plugin.windows[account]['chats'][user.jid].draw_widgets(user)
if gajim.interface.windows[account]['chats'].has_key(user.jid):
gajim.interface.windows[account]['chats'][user.jid].draw_widgets(user)
keys_str = ''
for jid in keys:
keys_str += jid + ' ' + keys[jid] + ' '
gajim.config.set_per('accounts', account, 'attached_gpg_keys', keys_str)
def on_edit_groups(self, widget, user, account):
dlg = dialogs.EditGroupsDialog(user, account, self.plugin)
dlg = dialogs.EditGroupsDialog(user, account)
dlg.run()
def on_history(self, widget, contact, account):
'''When history menuitem is activated: call log window'''
if self.plugin.windows['logs'].has_key(contact.jid):
self.plugin.windows['logs'][contact.jid].window.present()
if gajim.interface.windows['logs'].has_key(contact.jid):
gajim.interface.windows['logs'][contact.jid].window.present()
else:
self.plugin.windows['logs'][contact.jid] = history_window.\
HistoryWindow(self.plugin, contact.jid, account)
gajim.interface.windows['logs'][contact.jid] = history_window.\
HistoryWindow(contact.jid, account)
def on_send_single_message_menuitem_activate(self, wiget, account,
contact = None):
@ -827,7 +826,7 @@ class RosterWindow:
dialogs.SingleMessageWindow(self, account, contact.jid, 'send')
def on_send_file_menuitem_activate(self, widget, account, contact):
self.plugin.windows['file_transfers'].show_file_send_request(
gajim.interface.windows['file_transfers'].show_file_send_request(
account, contact)
def mk_menu_user(self, event, iter):
@ -990,11 +989,11 @@ class RosterWindow:
menu.show_all()
def on_edit_account(self, widget, account):
if self.plugin.windows[account].has_key('account_modification'):
self.plugin.windows[account]['account_modification'].window.present()
if gajim.interface.windows[account].has_key('account_modification'):
gajim.interface.windows[account]['account_modification'].window.present()
else:
self.plugin.windows[account]['account_modification'] = \
config.AccountModificationWindow(self.plugin, account)
gajim.interface.windows[account]['account_modification'] = \
config.AccountModificationWindow(account)
def get_possible_button_event(self, event):
'''mouse or keyboard caused the event?'''
@ -1007,7 +1006,7 @@ class RosterWindow:
def on_change_status_message_activate(self, widget, account):
show = gajim.SHOW_LIST[gajim.connections[account].connected]
dlg = dialogs.ChangeStatusMessageDialog(self.plugin, show)
dlg = dialogs.ChangeStatusMessageDialog(show)
message = dlg.run()
if message is not None: # None is if user pressed Cancel
self.send_status(account, show, message)
@ -1099,7 +1098,7 @@ class RosterWindow:
account_context_menu.show_all()
def on_add_to_roster(self, widget, user, account):
dialogs.AddNewContactWindow(self.plugin, account, user.jid)
dialogs.AddNewContactWindow(account, user.jid)
def authorize(self, widget, jid, account):
'''Authorize a user (by re-sending auth menuitem)'''
@ -1228,13 +1227,13 @@ _('If "%s" accepts this request you will know his status.') %jid)
if type in ('agent', 'contact'):
account = model[iter][C_ACCOUNT].decode('utf-8')
jid = model[iter][C_JID].decode('utf-8')
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
if gajim.interface.windows[account]['chats'].has_key(jid):
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
elif gajim.contacts[account].has_key(jid):
c = gajim.get_contact_instance_with_highest_priority(account, jid)
self.new_chat(c, account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
self.plugin.windows[account]['chats'][jid].window.present()
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
gajim.interface.windows[account]['chats'][jid].window.present()
elif type == 'account':
account = model[iter][C_ACCOUNT]
show = gajim.connections[account].connected
@ -1275,7 +1274,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
for u in gajim.contacts[account][user.jid]:
self.remove_contact(u, account)
del gajim.contacts[account][u.jid]
if user.jid in self.plugin.windows[account]['chats']:
if user.jid in gajim.interface.windows[account]['chats']:
user1 = Contact(jid = user.jid, name = user.name,
groups = [_('not in the roster')], show = 'not in the roster',
status = '', ask = 'none', keyID = user.keyID)
@ -1292,8 +1291,8 @@ _('If "%s" accepts this request you will know his status.') %jid)
accountIter = self.get_account_iter(account)
if accountIter:
model[accountIter][0] = self.jabber_state_images['connecting']
if self.plugin.systray_enabled:
self.plugin.systray.change_status('connecting')
if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('connecting')
def send_status(self, account, status, txt, sync = False, auto = False):
model = self.tree.get_model()
@ -1313,8 +1312,8 @@ _('If "%s" accepts this request you will know his status.') %jid)
if passphrase == -1:
if accountIter:
model[accountIter][0] = self.jabber_state_images['offline']
if self.plugin.systray_enabled:
self.plugin.systray.change_status('offline')
if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('offline')
self.update_status_comboxbox()
return
gajim.connections[account].password = passphrase
@ -1361,12 +1360,12 @@ _('If "%s" accepts this request you will know his status.') %jid)
gajim.connections[account].gpg_passphrase(passphrase)
gajim.connections[account].change_status(status, txt, sync, auto)
for room_jid in self.plugin.windows[account]['gc']:
for room_jid in gajim.interface.windows[account]['gc']:
if room_jid != 'tabbed':
nick = self.plugin.windows[account]['gc'][room_jid].nicks[room_jid]
nick = gajim.interface.windows[account]['gc'][room_jid].nicks[room_jid]
gajim.connections[account].send_gc_status(nick, room_jid, status,
txt)
if status == 'online' and self.plugin.sleeper.getState() != \
if status == 'online' and gajim.interface.sleeper.getState() != \
common.sleepy.STATE_UNKNOWN:
gajim.sleeper_state[account] = 'online'
else:
@ -1376,7 +1375,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
if (show == 'online' and not gajim.config.get('ask_online_status')) or \
(show == 'offline' and not gajim.config.get('ask_offline_status')):
return ''
dlg = dialogs.ChangeStatusMessageDialog(self.plugin, show)
dlg = dialogs.ChangeStatusMessageDialog(show)
message = dlg.run()
return message
@ -1423,7 +1422,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
).get_response()
self.update_status_comboxbox()
return
dlg = dialogs.ChangeStatusMessageDialog(self.plugin)
dlg = dialogs.ChangeStatusMessageDialog()
message = dlg.run()
if message is not None: # None if user pressed Cancel
for acct in accounts:
@ -1467,7 +1466,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
self.send_status(acct, status, message)
def update_status_comboxbox(self):
# table to change index in plugin.connected to index in combobox
# table to change index in connection.connected to index in combobox
table = {0:9, 1:9, 2:0, 3:1, 4:2, 5:3, 6:4, 7:5}
maxi = 0
for account in gajim.connections:
@ -1480,8 +1479,8 @@ _('If "%s" accepts this request you will know his status.') %jid)
self.status_combobox.handler_unblock(self.id_signal_cb)
statuss = ['offline', 'connecting', 'online', 'chat', 'away',
'xa', 'dnd', 'invisible']
if self.plugin.systray_enabled:
self.plugin.systray.change_status(statuss[maxi])
if gajim.interface.systray_enabled:
gajim.interface.systray.change_status(statuss[maxi])
def on_status_changed(self, account, status):
'''the core tells us that our status has changed'''
@ -1506,17 +1505,17 @@ _('If "%s" accepts this request you will know his status.') %jid)
def new_chat(self, contact, account):
if gajim.config.get('usetabbedchat'):
if not self.plugin.windows[account]['chats'].has_key('tabbed'):
self.plugin.windows[account]['chats']['tabbed'] = \
tabbed_chat_window.TabbedChatWindow(contact, self.plugin, account)
if not gajim.interface.windows[account]['chats'].has_key('tabbed'):
gajim.interface.windows[account]['chats']['tabbed'] = \
tabbed_chat_window.TabbedChatWindow(contact, account)
else:
self.plugin.windows[account]['chats']['tabbed'].new_tab(contact)
self.plugin.windows[account]['chats'][contact.jid] = \
self.plugin.windows[account]['chats']['tabbed']
gajim.interface.windows[account]['chats']['tabbed'].new_tab(contact)
gajim.interface.windows[account]['chats'][contact.jid] = \
gajim.interface.windows[account]['chats']['tabbed']
else:
self.plugin.windows[account]['chats'][contact.jid] = \
tabbed_chat_window.TabbedChatWindow(contact, self.plugin, account)
gajim.interface.windows[account]['chats'][contact.jid] = \
tabbed_chat_window.TabbedChatWindow(contact, account)
def new_chat_from_jid(self, account, jid):
if gajim.contacts[account].has_key(jid):
@ -1533,24 +1532,23 @@ _('If "%s" accepts this request you will know his status.') %jid)
gajim.contacts[account][jid] = [contact]
self.add_contact_to_roster(contact.jid, account)
if not self.plugin.windows[account]['chats'].has_key(jid):
if not gajim.interface.windows[account]['chats'].has_key(jid):
self.new_chat(contact, account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
self.plugin.windows[account]['chats'][jid].window.present()
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
gajim.interface.windows[account]['chats'][jid].window.present()
def new_room(self, jid, nick, account):
if gajim.config.get('usetabbedchat'):
if not self.plugin.windows[account]['gc'].has_key('tabbed'):
self.plugin.windows[account]['gc']['tabbed'] = \
groupchat_window.GroupchatWindow(jid, nick, self.plugin,
account)
if not gajim.interface.windows[account]['gc'].has_key('tabbed'):
gajim.interface.windows[account]['gc']['tabbed'] = \
groupchat_window.GroupchatWindow(jid, nick, account)
else:
self.plugin.windows[account]['gc']['tabbed'].new_room(jid, nick)
self.plugin.windows[account]['gc'][jid] = \
self.plugin.windows[account]['gc']['tabbed']
gajim.interface.windows[account]['gc']['tabbed'].new_room(jid, nick)
gajim.interface.windows[account]['gc'][jid] = \
gajim.interface.windows[account]['gc']['tabbed']
else:
self.plugin.windows[account]['gc'][jid] = \
groupchat_window.GroupchatWindow(jid, nick, self.plugin, account)
gajim.interface.windows[account]['gc'][jid] = \
groupchat_window.GroupchatWindow(jid, nick, account)
def on_message(self, jid, msg, tim, account, encrypted = False,
msg_type = '', subject = None, resource = ''):
@ -1589,18 +1587,18 @@ _('If "%s" accepts this request you will know his status.') %jid)
if msg_type == 'normal': # it's single message
if popup:
contact = gajim.contacts[account][jid][0]
dialogs.SingleMessageWindow(self.plugin, account, contact.jid,
dialogs.SingleMessageWindow(account, contact.jid,
action = 'receive', from_whom = jid, subject = subject,
message = msg)
return
# We print if window is opened and it's not a single message
if self.plugin.windows[account]['chats'].has_key(jid) and \
if gajim.interface.windows[account]['chats'].has_key(jid) and \
msg_type != 'normal':
typ = ''
if msg_type == 'error':
typ = 'status'
self.plugin.windows[account]['chats'][jid].print_conversation(msg,
gajim.interface.windows[account]['chats'][jid].print_conversation(msg,
jid, typ, tim = tim, encrypted = encrypted, subject = subject)
return
@ -1613,7 +1611,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
qs[jid].append((kind, (msg, subject, msg_type, tim, encrypted)))
self.nb_unread += 1
if popup:
if not self.plugin.windows[account]['chats'].has_key(jid):
if not gajim.interface.windows[account]['chats'].has_key(jid):
c = gajim.get_contact_instance_with_highest_priority(account, jid)
self.new_chat(c, account)
if path:
@ -1624,8 +1622,8 @@ _('If "%s" accepts this request you will know his status.') %jid)
else:
if no_queue: # We didn't have a queue: we change icons
self.draw_contact(jid, account)
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(jid, account, kind)
if gajim.interface.systray_enabled:
gajim.interface.systray.add_jid(jid, account, kind)
self.show_title() # we show the * or [n]
if not path:
self.add_contact_to_roster(jid, account)
@ -1637,13 +1635,13 @@ _('If "%s" accepts this request you will know his status.') %jid)
self.tree.set_cursor(path)
def on_preferences_menuitem_activate(self, widget):
if self.plugin.windows['preferences'].window.get_property('visible'):
self.plugin.windows['preferences'].window.present()
if gajim.interface.windows['preferences'].window.get_property('visible'):
gajim.interface.windows['preferences'].window.present()
else:
self.plugin.windows['preferences'].window.show_all()
gajim.interface.windows['preferences'].window.show_all()
def on_add_new_contact(self, widget, account):
dialogs.AddNewContactWindow(self.plugin, account)
dialogs.AddNewContactWindow(account)
def on_join_gc_activate(self, widget, account):
invisible_show = gajim.SHOW_LIST.index('invisible')
@ -1651,17 +1649,18 @@ _('If "%s" accepts this request you will know his status.') %jid)
dialogs.ErrorDialog(_('You cannot join a room while you are invisible')
).get_response()
return
if self.plugin.windows[account].has_key('join_gc'):
self.plugin.windows[account]['join_gc'].window.present()
if gajim.interface.windows[account].has_key('join_gc'):
gajim.interface.windows[account]['join_gc'].window.present()
else:
# c http://nkour.blogspot.com/2005/05/pythons-init-return-none-doesnt-return.html
try:
self.plugin.windows[account]['join_gc'] = dialogs.JoinGroupchatWindow(self.plugin, account)
gajim.interface.windows[account]['join_gc'] = \
dialogs.JoinGroupchatWindow(account)
except RuntimeError:
pass
def on_new_message_menuitem_activate(self, widget, account):
dialogs.NewMessageDialog(self.plugin, account)
dialogs.NewMessageDialog(account)
def on_contents_menuitem_activate(self, widget):
helpers.launch_browser_mailer('url', 'http://trac.gajim.org/wiki')
@ -1673,19 +1672,19 @@ _('If "%s" accepts this request you will know his status.') %jid)
dialogs.AboutDialog()
def on_accounts_menuitem_activate(self, widget):
if self.plugin.windows.has_key('accounts'):
self.plugin.windows['accounts'].window.present()
if gajim.interface.windows.has_key('accounts'):
gajim.interface.windows['accounts'].window.present()
else:
self.plugin.windows['accounts'] = config.AccountsWindow(self.plugin)
gajim.interface.windows['accounts'] = config.AccountsWindow()
def on_file_transfers_menuitem_activate(self, widget):
if self.plugin.windows['file_transfers'].window.get_property('visible'):
self.plugin.windows['file_transfers'].window.present()
if gajim.interface.windows['file_transfers'].window.get_property('visible'):
gajim.interface.windows['file_transfers'].window.present()
else:
self.plugin.windows['file_transfers'].window.show_all()
gajim.interface.windows['file_transfers'].window.show_all()
def on_manage_bookmarks_menuitem_activate(self, widget):
config.ManageBookmarksWindow(self.plugin)
config.ManageBookmarksWindow()
def close_all(self, dic):
'''close all the windows in the given dictionary'''
@ -1697,7 +1696,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
def on_roster_window_delete_event(self, widget, event):
'''When we want to close the window'''
if self.plugin.systray_enabled and not gajim.config.get('quit_on_roster_x_button'):
if gajim.interface.systray_enabled and not gajim.config.get('quit_on_roster_x_button'):
self.tooltip.hide_tooltip()
self.window.hide()
else:
@ -1714,7 +1713,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
for acct in accounts:
if gajim.connections[acct].connected:
self.send_status(acct, 'offline', message, True)
self.quit_gtkgui_plugin()
self.quit_gtkgui_interface()
return True # do NOT destory the window
def on_roster_window_focus_in_event(self, widget, event):
@ -1729,12 +1728,12 @@ _('If "%s" accepts this request you will know his status.') %jid)
if event.keyval == gtk.keysyms.Escape:
treeselection = self.tree.get_selection()
model, iter = treeselection.get_selected()
if not iter and self.plugin.systray_enabled and not gajim.config.get('quit_on_roster_x_button'):
if not iter and gajim.interface.systray_enabled and not gajim.config.get('quit_on_roster_x_button'):
self.tooltip.hide_tooltip()
self.window.hide()
def quit_gtkgui_plugin(self):
'''When we quit the gtk plugin :
def quit_gtkgui_interface(self):
'''When we quit the gtk interface :
tell that to the core and exit gtk'''
if gajim.config.get('saveposition'):
# in case show_roster_on_start is False and roster is never shown
@ -1748,12 +1747,12 @@ _('If "%s" accepts this request you will know his status.') %jid)
gajim.config.set('roster_height', height)
gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows))
self.plugin.save_config()
gajim.interface.save_config()
for account in gajim.connections:
gajim.connections[account].quit(True)
self.close_all(self.plugin.windows)
if self.plugin.systray_enabled:
self.plugin.hide_systray()
self.close_all(gajim.interface.windows)
if gajim.interface.systray_enabled:
gajim.interface.hide_systray()
gtk.main_quit()
def on_quit_menuitem_activate(self, widget):
@ -1773,10 +1772,10 @@ _('If "%s" accepts this request you will know his status.') %jid)
if self.nb_unread > 0:
unread = True
for account in accounts:
if self.plugin.windows[account]['chats'].has_key('tabbed'):
wins = [self.plugin.windows[account]['chats']['tabbed']]
if gajim.interface.windows[account]['chats'].has_key('tabbed'):
wins = [gajim.interface.windows[account]['chats']['tabbed']]
else:
wins = self.plugin.windows[account]['chats'].values()
wins = gajim.interface.windows[account]['chats'].values()
for win in wins:
unrd = 0
for jid in win.nb_unread:
@ -1803,16 +1802,16 @@ _('If "%s" accepts this request you will know his status.') %jid)
if gajim.connections[acct].connected:
# send status asynchronously
self.send_status(acct, 'offline', message, True)
self.quit_gtkgui_plugin()
self.quit_gtkgui_interface()
def open_event(self, account, jid, event):
'''If an event was handled, return True, else return False'''
typ = event[0]
data = event[1]
ft = self.plugin.windows['file_transfers']
self.plugin.remove_first_event(account, jid, typ)
ft = gajim.interface.windows['file_transfers']
gajim.interface.remove_first_event(account, jid, typ)
if typ == 'normal':
dialogs.SingleMessageWindow(self.plugin, account, jid,
dialogs.SingleMessageWindow(account, jid,
action = 'receive', from_whom = jid, subject = data[1],
message = data[0])
return True
@ -1849,13 +1848,13 @@ _('If "%s" accepts this request you will know his status.') %jid)
if self.open_event(account, jid, first_ev):
return
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
if gajim.interface.windows[account]['chats'].has_key(jid):
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
elif gajim.contacts[account].has_key(jid):
c = gajim.get_contact_instance_with_highest_priority(account, jid)
self.new_chat(c, account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
self.plugin.windows[account]['chats'][jid].window.present()
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
gajim.interface.windows[account]['chats'][jid].window.present()
def on_roster_treeview_row_expanded(self, widget, iter, path):
'''When a row is expanded change the icon of the arrow'''
@ -1975,13 +1974,13 @@ _('If "%s" accepts this request you will know his status.') %jid)
model.set_value(iter, 5, False)
def on_service_disco_menuitem_activate(self, widget, account):
if self.plugin.windows[account].has_key('disco'):
self.plugin.windows[account]['disco'].window.present()
if gajim.interface.windows[account].has_key('disco'):
gajim.interface.windows[account]['disco'].window.present()
else:
# c http://nkour.blogspot.com/2005/05/pythons-init-return-none-doesnt-return.html
try:
self.plugin.windows[account]['disco'] = \
config.ServiceDiscoveryWindow(self.plugin, account)
gajim.interface.windows[account]['disco'] = \
config.ServiceDiscoveryWindow(account)
except RuntimeError:
pass
@ -2027,27 +2026,27 @@ _('If "%s" accepts this request you will know his status.') %jid)
model[iter][1] = self.jabber_state_images[model[iter][2]]
iter = model.iter_next(iter)
# Update the systray
if self.plugin.systray_enabled:
self.plugin.systray.set_img()
if gajim.interface.systray_enabled:
gajim.interface.systray.set_img()
for account in gajim.connections:
# Update opened chat windows
for jid in self.plugin.windows[account]['chats']:
for jid in gajim.interface.windows[account]['chats']:
if jid != 'tabbed':
self.plugin.windows[account]['chats'][jid].set_state_image(jid)
gajim.interface.windows[account]['chats'][jid].set_state_image(jid)
# Update opened groupchat windows
for jid in self.plugin.windows[account]['gc']:
for jid in gajim.interface.windows[account]['gc']:
if jid != 'tabbed':
self.plugin.windows[account]['gc'][jid].update_state_images()
gajim.interface.windows[account]['gc'][jid].update_state_images()
self.update_status_comboxbox()
def repaint_themed_widgets(self):
"""Notify windows that contain themed widgets to repaint them"""
for account in gajim.connections:
# Update opened chat windows/tabs
for jid in self.plugin.windows[account]['chats']:
self.plugin.windows[account]['chats'][jid].repaint_colored_widgets()
for jid in self.plugin.windows[account]['gc']:
self.plugin.windows[account]['gc'][jid].repaint_colored_widgets()
for jid in gajim.interface.windows[account]['chats']:
gajim.interface.windows[account]['chats'][jid].repaint_colored_widgets()
for jid in gajim.interface.windows[account]['gc']:
gajim.interface.windows[account]['gc'][jid].repaint_colored_widgets()
def on_show_offline_contacts_menuitem_activate(self, widget):
'''when show offline option is changed:
@ -2323,11 +2322,10 @@ _('If "%s" accepts this request you will know his status.') %jid)
return True
return False
def __init__(self, plugin):
def __init__(self):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_window', APP)
self.window = self.xml.get_widget('roster_window')
self.tree = self.xml.get_widget('roster_treeview')
self.plugin = plugin
self.nb_unread = 0
self.last_save_dir = None
self.editing_path = None # path of row with cell in edit mode
@ -2467,7 +2465,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
self.on_status_combobox_changed)
self.collapsed_rows = gajim.config.get('collapsed_rows').split('\t')
self.tooltip = tooltips.RosterTooltip(self.plugin)
self.tooltip = tooltips.RosterTooltip()
self.make_menu()
self.draw_roster()
@ -2480,5 +2478,5 @@ _('If "%s" accepts this request you will know his status.') %jid)
gajim.config.set('show_roster_on_startup', True)
if len(gajim.connections) == 0: # if we have no account
self.plugin.windows['wizard_window'] = \
config.FirstTimeWizardWindow(self.plugin)
gajim.interface.windows['wizard_window'] = \
config.FirstTimeWizardWindow()

View File

@ -52,8 +52,7 @@ class Systray:
This class is both base class (for systraywin32.py) and normal class
for trayicon in GNU/Linux'''
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
self.jids = [] # Contain things like [account, jid, type_of_msg]
self.new_message_handler_id = None
self.t = None
@ -68,7 +67,7 @@ class Systray:
state = 'message'
else:
state = self.status
image = self.plugin.roster.jabber_state_images[state]
image = gajim.interface.roster.jabber_state_images[state]
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
self.img_tray.set_from_animation(image.get_animation())
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
@ -95,18 +94,18 @@ class Systray:
self.set_img()
def start_chat(self, widget, account, jid):
if self.plugin.windows[account]['chats'].has_key(jid):
self.plugin.windows[account]['chats'][jid].window.present()
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
if gajim.interface.windows[account]['chats'].has_key(jid):
gajim.interface.windows[account]['chats'][jid].window.present()
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
elif gajim.contacts[account].has_key(jid):
self.plugin.roster.new_chat(
gajim.interface.roster.new_chat(
gajim.contacts[account][jid][0], account)
self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
gajim.interface.windows[account]['chats'][jid].set_active_tab(jid)
def on_new_message_menuitem_activate(self, widget, account):
"""When new message menuitem is activated:
call the NewMessageDialog class"""
dialogs.NewMessageDialog(self.plugin, account)
dialogs.NewMessageDialog(account)
def make_menu(self, event = None):
'''create chat with and new message (sub) menus/menuitems
@ -130,7 +129,7 @@ class Systray:
if not iconset:
iconset = 'sun'
path = os.path.join(gajim.DATA_DIR, 'iconsets/' + iconset + '/16x16/')
state_images = self.plugin.roster.load_iconset(path)
state_images = gajim.interface.roster.load_iconset(path)
for show in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible']:
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
@ -211,13 +210,13 @@ class Systray:
self.systray_context_menu.show_all()
def on_preferences_menuitem_activate(self, widget):
if self.plugin.windows['preferences'].window.get_property('visible'):
self.plugin.windows['preferences'].window.present()
if gajim.interface.windows['preferences'].window.get_property('visible'):
gajim.interface.windows['preferences'].window.present()
else:
self.plugin.windows['preferences'].window.show_all()
gajim.interface.windows['preferences'].window.show_all()
def on_quit_menuitem_activate(self, widget):
self.plugin.roster.on_quit_menuitem_activate(widget)
gajim.interface.roster.on_quit_menuitem_activate(widget)
def make_groups_submenus_for_chat_with(self, account):
groups_menu = gtk.Menu()
@ -252,7 +251,7 @@ class Systray:
return groups_menu
def on_left_click(self):
win = self.plugin.roster.window
win = gajim.interface.roster.window
if len(self.jids) == 0:
if win.get_property('visible'):
win.hide()
@ -262,7 +261,7 @@ class Systray:
account = self.jids[0][0]
jid = self.jids[0][1]
typ = self.jids[0][2]
wins = self.plugin.windows[account]
wins = gajim.interface.windows[account]
w = None
if typ == 'gc':
if wins['gc'].has_key(jid):
@ -271,7 +270,7 @@ class Systray:
if wins['chats'].has_key(jid):
w = wins['chats'][jid]
else:
self.plugin.roster.new_chat(
gajim.interface.roster.new_chat(
gajim.contacts[account][jid][0], account)
w = wins['chats'][jid]
elif typ == 'pm':
@ -282,14 +281,14 @@ class Systray:
show = gajim.gc_contacts[account][room_jid][nick].show
c = Contact(jid = jid, name = nick, groups = ['none'],
show = show, ask = 'none')
self.plugin.roster.new_chat(c, account)
gajim.interface.roster.new_chat(c, account)
w = wins['chats'][jid]
elif typ in ('normal', 'file-request', 'file-request-error',
'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
# Get the first single message event
ev = gajim.get_first_event(account, jid, typ)
# Open the window
self.plugin.roster.open_event(account, jid, ev)
gajim.interface.roster.open_event(account, jid, ev)
if w:
w.set_active_tab(jid)
w.window.present()
@ -297,7 +296,7 @@ class Systray:
w.scroll_to_end(tv)
def on_middle_click(self):
win = self.plugin.roster.window
win = gajim.interface.roster.window
if win.is_active():
win.hide()
else:
@ -315,10 +314,10 @@ class Systray:
def on_show_menuitem_activate(self, widget, show):
l = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'offline']
index = l.index(show)
self.plugin.roster.status_combobox.set_active(index)
gajim.interface.roster.status_combobox.set_active(index)
def on_change_status_message_activate(self, widget):
dlg = dialogs.ChangeStatusMessageDialog(self.plugin)
dlg = dialogs.ChangeStatusMessageDialog()
message = dlg.run()
if message is not None: # None if user press Cancel
accounts = gajim.connections.keys()
@ -327,7 +326,7 @@ class Systray:
'sync_with_global_status'):
continue
show = gajim.SHOW_LIST[gajim.connections[acct].connected]
self.plugin.roster.send_status(acct, show, message)
gajim.interface.roster.send_status(acct, show, message)
def show_tooltip(self, widget):
position = widget.window.get_origin()
@ -364,7 +363,7 @@ class Systray:
eb.connect('button-press-event', self.on_clicked)
eb.connect('motion-notify-event', self.on_tray_motion_notify_event)
eb.connect('leave-notify-event', self.on_tray_leave_notify_event)
self.tooltip = tooltips.NotificationAreaTooltip(self.plugin)
self.tooltip = tooltips.NotificationAreaTooltip()
self.img_tray = gtk.Image()
eb.add(self.img_tray)

View File

@ -214,10 +214,9 @@ class NotifyIcon:
class SystrayWin32(systray.Systray):
def __init__(self, plugin):
def __init__(self):
# Note: gtk window must be realized before installing extensions.
systray.Systray.__init__(self, plugin)
self.plugin = plugin
systray.Systray.__init__(self)
self.jids = []
self.status = 'offline'
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'systray_context_menu', APP)
@ -226,14 +225,14 @@ class SystrayWin32(systray.Systray):
self.tray_ico_imgs = self.load_icos()
#self.plugin.roster.window.realize()
#self.plugin.roster.window.show_all()
#gajim.interface.roster.window.realize()
#gajim.interface.roster.window.show_all()
w = gtk.Window() # just a window to pass
w.realize() # realize it so gtk window exists
self.systray_winapi = SystrayWINAPI(w)
# this fails if you move the window
#self.systray_winapi = SystrayWINAPI(self.plugin.roster.window)
#self.systray_winapi = SystrayWINAPI(gajim.interface.roster.window)
self.xml.signal_autoconnect(self)
@ -266,11 +265,11 @@ class SystrayWin32(systray.Systray):
def add_jid(self, jid, account, typ):
systray.Systray.add_jid(self, jid, account, typ)
nb = self.plugin.roster.nb_unread
nb = gajim.interface.roster.nb_unread
for acct in gajim.connections:
# in chat / groupchat windows
for kind in ['chats', 'gc']:
jids = self.plugin.windows[acct][kind]
jids = gajim.interface.windows[acct][kind]
for jid in jids:
if jid != 'tabbed':
nb += jids[jid].nb_unread[jid]
@ -285,13 +284,13 @@ class SystrayWin32(systray.Systray):
def remove_jid(self, jid, account, typ):
systray.Systray.remove_jid(self, jid, account, typ)
nb = self.plugin.roster.nb_unread
nb = gajim.interface.roster.nb_unread
for acct in gajim.connections:
# in chat / groupchat windows
for kind in ['chats', 'gc']:
for jid in self.plugin.windows[acct][kind]:
for jid in gajim.interface.windows[acct][kind]:
if jid != 'tabbed':
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid]
nb += gajim.interface.windows[acct][kind][jid].nb_unread[jid]
if nb > 0:
text = i18n.ngettext(

View File

@ -43,10 +43,10 @@ GTKGUI_GLADE = 'gtkgui.glade'
class TabbedChatWindow(chat.Chat):
'''Class for tabbed chat window'''
def __init__(self, contact, plugin, account):
def __init__(self, contact, account):
# we check that on opening new windows
self.always_compact_view = gajim.config.get('always_compact_view_chat')
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
chat.Chat.__init__(self, account, 'tabbed_chat_window')
self.contacts = {}
# keep check for possible paused timeouts per jid
self.possible_paused_timeout_id = {}
@ -123,14 +123,14 @@ class TabbedChatWindow(chat.Chat):
for uri in uri_splitted:
path = helpers.get_file_path_from_dnd_dropped_uri(uri)
if os.path.isfile(path): # is it file?
self.plugin.windows['file_transfers'].send_file(self.account,
gajim.interface.windows['file_transfers'].send_file(self.account,
contact, path)
def on_avatar_eventbox_enter_notify_event(self, widget, event):
'''we enter the eventbox area so we under conditions add a timeout
to show a bigger avatar after 0.5 sec'''
jid = self.get_active_jid()
avatar_pixbuf = self.plugin.avatar_pixbufs[jid]
avatar_pixbuf = gajim.interface.avatar_pixbufs[jid]
avatar_w = avatar_pixbuf.get_width()
avatar_h = avatar_pixbuf.get_height()
@ -154,7 +154,7 @@ class TabbedChatWindow(chat.Chat):
'''resizes the avatar, if needed, so it has at max half the screen size
and shows it'''
jid = self.get_active_jid()
avatar_pixbuf = self.plugin.avatar_pixbufs[jid]
avatar_pixbuf = gajim.interface.avatar_pixbufs[jid]
screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
avatar_w = avatar_pixbuf.get_width()
@ -289,11 +289,11 @@ class TabbedChatWindow(chat.Chat):
if not xml:
return
if self.plugin.avatar_pixbufs[jid] is None:
if gajim.interface.avatar_pixbufs[jid] is None:
# contact has no avatar
scaled_buf = None
else:
pixbuf = self.plugin.avatar_pixbufs[jid]
pixbuf = gajim.interface.avatar_pixbufs[jid]
# resize to a width / height for the avatar not to have distortion
# (keep aspect ratio)
@ -330,7 +330,7 @@ class TabbedChatWindow(chat.Chat):
child = self.childs[jid]
hb = self.notebook.get_tab_label(child).get_children()[0]
status_image = hb.get_children()[0]
state_images = self.plugin.roster.get_appropriate_state_images(jid)
state_images = gajim.interface.roster.get_appropriate_state_images(jid)
# Set banner image
banner_image = state_images[show]
@ -379,7 +379,7 @@ class TabbedChatWindow(chat.Chat):
gajim.config.set('chat-height', height)
def on_tabbed_chat_window_destroy(self, widget):
#clean self.plugin.windows[self.account]['chats']
#clean gajim.interface.windows[self.account]['chats']
chat.Chat.on_window_destroy(self, widget, 'chats')
def on_tabbed_chat_window_focus_in_event(self, widget, event):
@ -393,12 +393,12 @@ class TabbedChatWindow(chat.Chat):
def on_send_file_menuitem_activate(self, widget):
jid = self.get_active_jid()
contact = gajim.get_first_contact_instance_from_jid(self.account, jid)
self.plugin.windows['file_transfers'].show_file_send_request(
gajim.interface.windows['file_transfers'].show_file_send_request(
self.account, contact)
def on_add_to_roster_menuitem_activate(self, widget):
jid = self.get_active_jid()
dialogs.AddNewContactWindow(self.plugin, self.account, jid)
dialogs.AddNewContactWindow(self.account, jid)
def on_send_button_clicked(self, widget):
'''When send button is pressed: send the current message'''
@ -439,7 +439,7 @@ class TabbedChatWindow(chat.Chat):
# this is to prove cache code works:
# should we ask vcard? (only the first time we should ask)
if not self.plugin.avatar_pixbufs.has_key(contact.jid):
if not gajim.interface.avatar_pixbufs.has_key(contact.jid):
# it's the first time, so we should ask vcard
gajim.connections[self.account].request_vcard(contact.jid)
#please do not remove this commented print until I'm done with showing
@ -780,7 +780,7 @@ class TabbedChatWindow(chat.Chat):
def on_contact_information_menuitem_clicked(self, widget):
jid = self.get_active_jid()
contact = self.contacts[jid]
self.plugin.roster.on_info(widget, contact, self.account)
gajim.interface.roster.on_info(widget, contact, self.account)
def read_queue(self, jid):
'''read queue and print messages containted in it'''
@ -789,7 +789,7 @@ class TabbedChatWindow(chat.Chat):
# Is it a pm ?
is_pm = False
room_jid = jid.split('/', 1)[0]
gcs = self.plugin.windows[self.account]['gc']
gcs = gajim.interface.windows[self.account]['gc']
if gcs.has_key(room_jid):
is_pm = True
events_to_keep = []
@ -811,12 +811,12 @@ class TabbedChatWindow(chat.Chat):
if is_pm:
gcs[room_jid].nb_unread[room_jid] -= 1
else:
self.plugin.roster.nb_unread -= 1
gajim.interface.roster.nb_unread -= 1
if is_pm:
gcs[room_jid].show_title()
else:
self.plugin.roster.show_title()
gajim.interface.roster.show_title()
# Keep only non-messages events
if len(events_to_keep):
gajim.awaiting_events[self.account][jid] = events_to_keep
@ -825,19 +825,19 @@ class TabbedChatWindow(chat.Chat):
typ = 'chat' # Is it a normal chat or a pm ?
# reset to status image in gc if it is a pm
room_jid = jid.split('/', 1)[0]
gcs = self.plugin.windows[self.account]['gc']
gcs = gajim.interface.windows[self.account]['gc']
if gcs.has_key(room_jid):
gcs[room_jid].update_state_images()
typ = 'pm'
self.plugin.roster.draw_contact(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account, typ)
gajim.interface.roster.draw_contact(jid, self.account)
if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, self.account, typ)
showOffline = gajim.config.get('showoffline')
if (contact.show == 'offline' or contact.show == 'error') and \
not showOffline:
if len(gajim.contacts[self.account][jid]) == 1:
self.plugin.roster.really_remove_contact(contact, self.account)
gajim.interface.roster.really_remove_contact(contact, self.account)
def print_conversation(self, text, jid, frm = '', tim = None,
encrypted = False, subject = None):

View File

@ -173,8 +173,7 @@ class StatusTable:
class NotificationAreaTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the notification area '''
def __init__(self, plugin):
self.plugin = plugin
def __init__(self):
BaseTooltip.__init__(self)
StatusTable.__init__(self)
@ -204,14 +203,14 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
accounts.append({'name': account, 'status_line': single_line,
'show': status, 'message': message})
unread_chat = self.plugin.roster.nb_unread
unread_chat = gajim.interface.roster.nb_unread
unread_single_chat = 0
unread_gc = 0
unread_pm = 0
for acct in gajim.connections:
# we count unread chat/pm messages
chat_wins = self.plugin.windows[acct]['chats']
chat_wins = gajim.interface.windows[acct]['chats']
for jid in chat_wins:
if jid != 'tabbed':
if gajim.contacts[acct].has_key(jid):
@ -219,7 +218,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
else:
unread_pm += chat_wins[jid].nb_unread[jid]
# we count unread gc/pm messages
gc_wins = self.plugin.windows[acct]['gc']
gc_wins = gajim.interface.windows[acct]['gc']
for jid in gc_wins:
if jid != 'tabbed':
pm_msgs = gc_wins[jid].get_specific_unread(jid)
@ -291,9 +290,8 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
class GCTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the GC treeview '''
def __init__(self, plugin):
def __init__(self):
self.account = None
self.plugin = plugin
self.text_lable = gtk.Label()
self.text_lable.set_line_wrap(True)
@ -339,9 +337,8 @@ class GCTooltip(BaseTooltip, StatusTable):
class RosterTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the roster treeview '''
def __init__(self, plugin):
def __init__(self):
self.account = None
self.plugin = plugin
self.image = gtk.Image()
self.image.set_alignment(0., 0.)

View File

@ -42,7 +42,7 @@ GTKGUI_GLADE = 'gtkgui.glade'
class VcardWindow:
'''Class for contact's information window'''
def __init__(self, contact, plugin, account, vcard = False):
def __init__(self, contact, account, vcard = False):
#the contact variable is the jid if vcard is true
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard_information_window', APP)
self.window = self.xml.get_widget('vcard_information_window')
@ -53,7 +53,6 @@ class VcardWindow:
self.publish_button.set_no_show_all(True)
self.retrieve_button.set_no_show_all(True)
self.plugin = plugin
self.contact = contact #don't use it if vcard is true
self.account = account
self.vcard = vcard
@ -74,7 +73,7 @@ class VcardWindow:
self.window.show_all()
def on_vcard_information_window_destroy(self, widget = None):
del self.plugin.windows[self.account]['infos'][self.jid]
del gajim.interface.windows[self.account]['infos'][self.jid]
def on_vcard_information_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape:
@ -90,8 +89,9 @@ class VcardWindow:
new_name = name_entry.get_text().decode('utf-8')
if new_name != self.contact.name and new_name != '':
self.contact.name = new_name
for i in self.plugin.roster.get_contact_iter(self.contact.jid, self.account):
self.plugin.roster.tree.get_model().set_value(i, 1, new_name)
for i in gajim.interface.roster.get_contact_iter(self.contact.jid,
self.account):
gajim.interface.roster.tree.get_model().set_value(i, 1, new_name)
gajim.connections[self.account].update_contact(self.contact.jid,
self.contact.name, self.contact.groups)
#log history ?