Window and control lookup functions, and set_Active_tab
This commit is contained in:
parent
fb5ca97eba
commit
1102356937
2 changed files with 46 additions and 11 deletions
|
@ -197,9 +197,20 @@ class MessageWindow:
|
||||||
if urgent:
|
if urgent:
|
||||||
gtkgui_helpers.set_unset_urgency_hint(self.window, unread)
|
gtkgui_helpers.set_unset_urgency_hint(self.window, unread)
|
||||||
|
|
||||||
|
def set_active_tab(self, jid):
|
||||||
|
ctl = self._controls[jid]
|
||||||
|
ctl_page = self.notebook.page_num(ctl.widget)
|
||||||
|
self.notebook.set_current_page(ctl_page)
|
||||||
|
|
||||||
def remove_tab(self, contact):
|
def remove_tab(self, contact):
|
||||||
# TODO
|
|
||||||
print "MessageWindow.remove_tab"
|
print "MessageWindow.remove_tab"
|
||||||
|
if len(self._controls) == 1:
|
||||||
|
# There is only one tab
|
||||||
|
# FIXME: Should we assert on contact?
|
||||||
|
self.window.destroy()
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
# TODO
|
||||||
|
|
||||||
def redraw_tab(self, contact, chatstate = None):
|
def redraw_tab(self, contact, chatstate = None):
|
||||||
ctl = self._controls[contact.jid]
|
ctl = self._controls[contact.jid]
|
||||||
|
@ -273,6 +284,12 @@ class MessageWindow:
|
||||||
for ctl in self._controls.values():
|
for ctl in self._controls.values():
|
||||||
ctl.update_tags()
|
ctl.update_tags()
|
||||||
|
|
||||||
|
def get_control_from_jid(self, jid):
|
||||||
|
for ctl in self._controls.values():
|
||||||
|
if ctl.contact.jid == jid:
|
||||||
|
return ctl
|
||||||
|
return None
|
||||||
|
|
||||||
class MessageWindowMgr:
|
class MessageWindowMgr:
|
||||||
'''A manager and factory for MessageWindow objects'''
|
'''A manager and factory for MessageWindow objects'''
|
||||||
|
|
||||||
|
@ -317,7 +334,16 @@ class MessageWindowMgr:
|
||||||
print "MessageWindowMgr._on_window_destroy:", win
|
print "MessageWindowMgr._on_window_destroy:", win
|
||||||
# TODO: Clean up windows
|
# TODO: Clean up windows
|
||||||
|
|
||||||
def get_window(self, contact, acct, type):
|
def get_window(self, jid):
|
||||||
|
for win in self.windows.values():
|
||||||
|
if win.get_control_from_jid(jid):
|
||||||
|
return win
|
||||||
|
return None
|
||||||
|
|
||||||
|
def has_window(self, jid):
|
||||||
|
return self.get_window(jid)
|
||||||
|
|
||||||
|
def create_window(self, contact, acct, type):
|
||||||
key = None
|
key = None
|
||||||
if self.mode == self.CONFIG_NEVER:
|
if self.mode == self.CONFIG_NEVER:
|
||||||
key = contact.jid
|
key = contact.jid
|
||||||
|
@ -336,6 +362,7 @@ class MessageWindowMgr:
|
||||||
print "Creating tabbed chat window for '%s'" % str(key)
|
print "Creating tabbed chat window for '%s'" % str(key)
|
||||||
win = self._new_window()
|
win = self._new_window()
|
||||||
self.windows[key] = win
|
self.windows[key] = win
|
||||||
|
|
||||||
assert(win)
|
assert(win)
|
||||||
return win
|
return win
|
||||||
|
|
||||||
|
|
|
@ -315,6 +315,7 @@ class RosterWindow:
|
||||||
|
|
||||||
def join_gc_room(self, account, room_jid, nick, password):
|
def join_gc_room(self, account, room_jid, nick, password):
|
||||||
'''joins the room immediatelly'''
|
'''joins the room immediatelly'''
|
||||||
|
# FIXME
|
||||||
if room_jid in gajim.interface.instances[account]['gc'] and \
|
if room_jid in gajim.interface.instances[account]['gc'] and \
|
||||||
gajim.gc_connected[account][room_jid]:
|
gajim.gc_connected[account][room_jid]:
|
||||||
dialogs.ErrorDialog(_('You are already in room %s') % room_jid
|
dialogs.ErrorDialog(_('You are already in room %s') % room_jid
|
||||||
|
@ -1355,6 +1356,7 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
iter = model.get_iter(path)
|
iter = model.get_iter(path)
|
||||||
type = model[iter][C_TYPE]
|
type = model[iter][C_TYPE]
|
||||||
|
# FIXME
|
||||||
if type in ('agent', 'contact'):
|
if type in ('agent', 'contact'):
|
||||||
account = model[iter][C_ACCOUNT].decode('utf-8')
|
account = model[iter][C_ACCOUNT].decode('utf-8')
|
||||||
jid = model[iter][C_JID].decode('utf-8')
|
jid = model[iter][C_JID].decode('utf-8')
|
||||||
|
@ -1649,7 +1651,9 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
||||||
|
|
||||||
def new_chat(self, contact, account):
|
def new_chat(self, contact, account):
|
||||||
# Get target window, create a control, and associate it with the window
|
# Get target window, create a control, and associate it with the window
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
mw = gajim.interface.msg_win_mgr.get_window(contact.jid)
|
||||||
|
if not mw:
|
||||||
|
mw = gajim.interface.msg_win_mgr.create_window(contact, account,
|
||||||
ChatControl.TYPE_ID)
|
ChatControl.TYPE_ID)
|
||||||
chat_control = ChatControl(mw, contact, account)
|
chat_control = ChatControl(mw, contact, account)
|
||||||
mw.new_tab(chat_control)
|
mw.new_tab(chat_control)
|
||||||
|
@ -1680,7 +1684,9 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
||||||
def new_room(self, jid, nick, account):
|
def new_room(self, jid, nick, account):
|
||||||
# FIXME: Not contact. Use jid and nick
|
# FIXME: Not contact. Use jid and nick
|
||||||
# Get target window, create a control, and associate it with the window
|
# Get target window, create a control, and associate it with the window
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
mw = gajim.interface.msg_win_mgr.get_window(contact.jid)
|
||||||
|
if not mw:
|
||||||
|
mw = gajim.interface.msg_win_mgr.create_window(contact, account,
|
||||||
GroupchatControl.TYPE_ID)
|
GroupchatControl.TYPE_ID)
|
||||||
gc_control = ChatControl(mw, contact, account)
|
gc_control = ChatControl(mw, contact, account)
|
||||||
mw.new_tab(gc_control)
|
mw.new_tab(gc_control)
|
||||||
|
@ -2006,14 +2012,16 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
||||||
if first_ev:
|
if first_ev:
|
||||||
if self.open_event(account, jid, first_ev):
|
if self.open_event(account, jid, first_ev):
|
||||||
return
|
return
|
||||||
chats = gajim.interface.instances[account]['chats']
|
# Get the window containing the chat
|
||||||
if chats.has_key(jid):
|
win = gajim.interface.msg_win_mgr.get_window(jid)
|
||||||
chats[jid].set_active_tab(jid)
|
if win:
|
||||||
|
win.set_active_tab(jid)
|
||||||
elif gajim.contacts[account].has_key(jid):
|
elif gajim.contacts[account].has_key(jid):
|
||||||
c = gajim.get_contact_instance_with_highest_priority(account, jid)
|
contact = gajim.get_contact_instance_with_highest_priority(account, jid)
|
||||||
self.new_chat(c, account)
|
self.new_chat(contact, account)
|
||||||
chats[jid].set_active_tab(jid)
|
win = gajim.interface.msg_win_mgr.get_window(jid)
|
||||||
chats[jid].window.present()
|
win.set_active_tab(jid)
|
||||||
|
win.window.present()
|
||||||
|
|
||||||
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
def on_roster_treeview_row_expanded(self, widget, iter, path):
|
||||||
'''When a row is expanded change the icon of the arrow'''
|
'''When a row is expanded change the icon of the arrow'''
|
||||||
|
|
Loading…
Add table
Reference in a new issue