new_message changed to open_chat.

You can start chat and send message to not in
roster users
This commit is contained in:
Dimitur Kirov 2005-07-20 13:27:27 +00:00
parent 86ff362c5c
commit ad5edf6657
2 changed files with 24 additions and 26 deletions

View file

@ -95,7 +95,7 @@ class SignalObject(DbusPrototype):
self.list_contacts, self.list_contacts,
self.list_accounts, self.list_accounts,
self.change_status, self.change_status,
self.new_message, self.open_chat,
self.send_message, self.send_message,
self.contact_info self.contact_info
]) ])
@ -134,19 +134,20 @@ class SignalObject(DbusPrototype):
else: else:
for account in gajim.contacts.keys(): for account in gajim.contacts.keys():
if gajim.contacts[account].has_key(jid): if gajim.contacts[account].has_key(jid):
gajim.connections[account].send_message(jid, break
message, keyID) if account:
return True res = gajim.connections[account].send_message(jid, message, keyID)
return True
return False return False
def new_message(self, *args): def open_chat(self, *args):
''' new_message(jid, account=None) -> shows the tabbed window for new ''' start_chat(jid, account=None) -> shows the tabbed window for new
message to 'jid', using account(optional) 'account ' ''' message to 'jid', using account(optional) 'account ' '''
if self.disabled: if self.disabled:
return return
jid, account = self._get_real_arguments(args, 2) jid, account = self._get_real_arguments(args, 2)
if not jid: if not jid:
# FIXME: raise exception for missing argument (dbus0.3+) # FIXME: raise exception for missing argument (dbus0.35+ - released last week)
return None return None
if account: if account:
accounts = [account] accounts = [account]
@ -158,17 +159,13 @@ class SignalObject(DbusPrototype):
self.plugin.windows[account]['chats'][jid].set_active_tab(jid) self.plugin.windows[account]['chats'][jid].set_active_tab(jid)
break break
elif gajim.contacts[account].has_key(jid): elif gajim.contacts[account].has_key(jid):
self.plugin.roster.new_chat(gajim.contacts[account][jid][0],
account)
jid_data = self.plugin.windows[account]['chats'][jid]
jid_data.set_active_tab(jid)
jid_data.window.present()
# preserve the "steal focus preservation"
if self._is_first():
jid_data.window.window.focus()
else:
jid_data.window.window.focus(long(time()))
break break
self.plugin.roster.new_chat_from_jid(account, jid)
# preserve the 'steal focus preservation'
win = self.plugin.windows[account]['chats'][jid].window
if win.get_property('visible'):
win.window.focus()
def change_status(self, *args, **keywords): def change_status(self, *args, **keywords):
''' change_status(status, message, account). account is optional - ''' change_status(status, message, account). account is optional -
@ -178,7 +175,7 @@ class SignalObject(DbusPrototype):
status, message, account = self._get_real_arguments(args, 3) status, message, account = self._get_real_arguments(args, 3)
if status not in ('offline', 'online', 'chat', if status not in ('offline', 'online', 'chat',
'away', 'xa', 'dnd', 'invisible'): 'away', 'xa', 'dnd', 'invisible'):
# FIXME: raise exception for bad status (dbus0.3+) # FIXME: raise exception for bad status (dbus0.35)
return None return None
if account: if account:
gobject.idle_add(self.plugin.roster.send_status, account, gobject.idle_add(self.plugin.roster.send_status, account,
@ -212,7 +209,7 @@ class SignalObject(DbusPrototype):
if jid_tab: if jid_tab:
jid_tab.set_active_tab(jid) jid_tab.set_active_tab(jid)
jid_tab.window.present() jid_tab.window.present()
# preserve the "steal focus preservation" # preserve the 'steal focus preservation'
if self._is_first(): if self._is_first():
jid_tab.window.window.focus() jid_tab.window.window.focus()
else: else:
@ -269,7 +266,7 @@ class SignalObject(DbusPrototype):
if item: if item:
result.append(item) result.append(item)
else: else:
# "for_account: is not recognised:", # 'for_account: is not recognised:',
# FIXME: there can be a return status for this [0.3+] # FIXME: there can be a return status for this [0.3+]
return None return None
else: else:
@ -292,7 +289,7 @@ class SignalObject(DbusPrototype):
gobject.idle_add(win.hide) gobject.idle_add(win.hide)
else: else:
win.present() win.present()
# preserve the "steal focus preservation" # preserve the 'steal focus preservation'
if self._is_first(): if self._is_first():
win.window.focus() win.window.focus()
else: else:
@ -318,7 +315,7 @@ class SignalObject(DbusPrototype):
repr(array)) repr(array))
def _get_real_arguments(self, args, desired_length): def _get_real_arguments(self, args, desired_length):
# supresses the first "message" argument, which is set in dbus 0.23 # supresses the first 'message' argument, which is set in dbus 0.23
if _version[1] == 20: if _version[1] == 20:
args=args[1:] args=args[1:]
if desired_length > 0: if desired_length > 0:
@ -371,7 +368,7 @@ class SignalObject(DbusPrototype):
list_accounts = method(INTERFACE)(list_accounts) list_accounts = method(INTERFACE)(list_accounts)
show_next_unread = method(INTERFACE)(show_next_unread) show_next_unread = method(INTERFACE)(show_next_unread)
change_status = method(INTERFACE)(change_status) change_status = method(INTERFACE)(change_status)
new_message = method(INTERFACE)(new_message) open_chat = method(INTERFACE)(open_chat)
contact_info = method(INTERFACE)(contact_info) contact_info = method(INTERFACE)(contact_info)
send_message = method(INTERFACE)(send_message) send_message = method(INTERFACE)(send_message)
VcardInfo = signal(INTERFACE)(VcardInfo) VcardInfo = signal(INTERFACE)(VcardInfo)
@ -382,7 +379,7 @@ class SessionBusNotPresent(Exception):
Exception.__init__(self) Exception.__init__(self)
def __str__(self): def __str__(self):
return _("Session bus is not available") return _('Session bus is not available')
class DbusNotSupported(Exception): class DbusNotSupported(Exception):
''' D-Bus is not installed or python bindings are missing ''' ''' D-Bus is not installed or python bindings are missing '''
@ -390,4 +387,4 @@ class DbusNotSupported(Exception):
Exception.__init__(self) Exception.__init__(self)
def __str__(self): def __str__(self):
return _("D-Bus is not present on this machine") return _('D-Bus is not present on this machine')

View file

@ -226,7 +226,8 @@ class TabbedChatWindow(chat.Chat):
def check_window_state(self, widget): def check_window_state(self, widget):
''' we want: "minimized" or "focus-out" ''' we want: "minimized" or "focus-out"
not "focus-out, minimized" or "focus-out" ''' not "focus-out, minimized" or "focus-out" '''
widget.realize()
new_state = widget.window.get_state() new_state = widget.window.get_state()
if new_state & gtk.gdk.WINDOW_STATE_ICONIFIED: if new_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
print 'iconify' print 'iconify'