[roidelapluie & I] ability to send custom status to contacts. fixes #342

This commit is contained in:
Yann Leboulanger 2007-04-21 11:29:55 +00:00
parent 36f4bb14bd
commit 68e2c7ddd3
3 changed files with 65 additions and 20 deletions

View File

@ -12,7 +12,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1511"> <widget class="GtkImage" id="image1569">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-jump-to</property> <property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -25,6 +25,26 @@
</widget> </widget>
</child> </child>
<child>
<widget class="GtkImageMenuItem" id="send_custom_status_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">Send cus_tom status</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1570">
<property name="visible">True</property>
<property name="stock">gtk-go-up</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child> <child>
<widget class="GtkImageMenuItem" id="send_single_message_menuitem"> <widget class="GtkImageMenuItem" id="send_single_message_menuitem">
<property name="visible">True</property> <property name="visible">True</property>
@ -32,7 +52,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1512"> <widget class="GtkImage" id="image1571">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-new</property> <property name="stock">gtk-new</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -52,7 +72,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1513"> <widget class="GtkImage" id="image1572">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-go-back</property> <property name="stock">gtk-go-back</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -71,7 +91,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1514"> <widget class="GtkImage" id="image1573">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-refresh</property> <property name="stock">gtk-refresh</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -104,7 +124,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1515"> <widget class="GtkImage" id="image1574">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-file</property> <property name="stock">gtk-file</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -124,7 +144,7 @@
<signal name="activate" handler="on_assign_openpgp_key_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 22:57:59 GMT"/> <signal name="activate" handler="on_assign_openpgp_key_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 22:57:59 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1516"> <widget class="GtkImage" id="image1575">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-dialog-authentication</property> <property name="stock">gtk-dialog-authentication</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -144,7 +164,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1517"> <widget class="GtkImage" id="image1576">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-info</property> <property name="stock">gtk-info</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -164,7 +184,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1467"> <widget class="GtkImage" id="image1577">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-execute</property> <property name="stock">gtk-execute</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -189,7 +209,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1518"> <widget class="GtkImage" id="image1578">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-dialog-question</property> <property name="stock">gtk-dialog-question</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -210,7 +230,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1519"> <widget class="GtkImage" id="image1579">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-go-up</property> <property name="stock">gtk-go-up</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -230,7 +250,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1520"> <widget class="GtkImage" id="image1580">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-go-down</property> <property name="stock">gtk-go-down</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -250,7 +270,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1521"> <widget class="GtkImage" id="image1581">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-stop</property> <property name="stock">gtk-stop</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -273,7 +293,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1522"> <widget class="GtkImage" id="image1582">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-add</property> <property name="stock">gtk-add</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -292,7 +312,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1523"> <widget class="GtkImage" id="image1583">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-remove</property> <property name="stock">gtk-remove</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -324,7 +344,7 @@
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1524"> <widget class="GtkImage" id="image1584">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-justify-fill</property> <property name="stock">gtk-justify-fill</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>

View File

@ -731,7 +731,7 @@ class Connection(ConnectionHandlers):
self.awaiting_answers[id] = (PRIVACY_ARRIVED, ) self.awaiting_answers[id] = (PRIVACY_ARRIVED, )
self.connection.send(iq) self.connection.send(iq)
def change_status(self, show, msg, auto = False): def change_status(self, show, msg, auto = False, to = None):
if not show in STATUS_LIST: if not show in STATUS_LIST:
return -1 return -1
sshow = helpers.get_xmpp_show(show) sshow = helpers.get_xmpp_show(show)
@ -780,7 +780,8 @@ class Connection(ConnectionHandlers):
self.connection.send(iq) self.connection.send(iq)
self.activate_privacy_rule('visible') self.activate_privacy_rule('visible')
priority = unicode(gajim.get_priority(self.name, sshow)) priority = unicode(gajim.get_priority(self.name, sshow))
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow) p = common.xmpp.Presence(typ = None, priority = priority, show = sshow,
to = to)
p = self.add_sha(p) p = self.add_sha(p)
if msg: if msg:
p.setStatus(msg) p.setStatus(msg)
@ -789,6 +790,7 @@ class Connection(ConnectionHandlers):
if self.connection: if self.connection:
self.connection.send(p) self.connection.send(p)
self.priority = priority self.priority = priority
if not to:
self.dispatch('STATUS', show) self.dispatch('STATUS', show)
def _on_disconnected(self): def _on_disconnected(self):

View File

@ -1733,6 +1733,8 @@ class RosterWindow:
'roster_contact_context_menu') 'roster_contact_context_menu')
start_chat_menuitem = xml.get_widget('start_chat_menuitem') start_chat_menuitem = xml.get_widget('start_chat_menuitem')
send_custom_status_menuitem = xml.get_widget(
'send_custom_status_menuitem')
send_single_message_menuitem = xml.get_widget( send_single_message_menuitem = xml.get_widget(
'send_single_message_menuitem') 'send_single_message_menuitem')
invite_menuitem = xml.get_widget('invite_menuitem') invite_menuitem = xml.get_widget('invite_menuitem')
@ -1802,6 +1804,20 @@ class RosterWindow:
item = gtk.SeparatorMenuItem() # separator item = gtk.SeparatorMenuItem() # separator
invite_to_submenu.append(item) invite_to_submenu.append(item)
# One or several resource, we do the same for send_custom_status
status_menuitems = gtk.Menu()
send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset')
path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']:
# icon MUST be different instance for every item
state_images = self.load_iconset(path)
status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s))
status_menuitem.connect('activate', self.on_send_custom_status,
account, contact.jid, s)
icon = state_images[s]
status_menuitem.set_image(icon)
status_menuitems.append(status_menuitem)
if len(contacts) > 1: # several resources if len(contacts) > 1: # several resources
def resources_submenu(action, room_jid = None, room_account = None): def resources_submenu(action, room_jid = None, room_account = None):
''' Build a submenu with contact's resources. ''' Build a submenu with contact's resources.
@ -2721,7 +2737,7 @@ class RosterWindow:
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('connecting') gajim.interface.systray.change_status('connecting')
def send_status(self, account, status, txt, auto = False): def send_status(self, account, status, txt, auto = False, to = None):
model = self.tree.get_model() model = self.tree.get_model()
accountIter = self.get_account_iter(account) accountIter = self.get_account_iter(account)
if status != 'offline': if status != 'offline':
@ -2812,7 +2828,7 @@ class RosterWindow:
gajim.sleeper_state[account] = 'online' gajim.sleeper_state[account] = 'online'
elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa'): elif gajim.sleeper_state[account] not in ('autoaway', 'autoxa'):
gajim.sleeper_state[account] = 'off' gajim.sleeper_state[account] = 'off'
gajim.connections[account].change_status(status, txt, auto) gajim.connections[account].change_status(status, txt, auto, to = to)
for gc_control in gajim.interface.msg_win_mgr.get_controls( for gc_control in gajim.interface.msg_win_mgr.get_controls(
message_control.TYPE_GC): message_control.TYPE_GC):
@ -2864,6 +2880,13 @@ class RosterWindow:
else: else:
change(None, account, status) change(None, account, status)
def on_send_custom_status(self, widget, account, jid, show):
'''send custom status'''
dlg = dialogs.ChangeStatusMessageDialog(show)
message = dlg.run()
if message is not None: # None if user pressed Cancel
self.send_status(account, show, message, to = jid)
def on_status_combobox_changed(self, widget): def on_status_combobox_changed(self, widget):
'''When we change our status via the combobox''' '''When we change our status via the combobox'''
model = self.status_combobox.get_model() model = self.status_combobox.get_model()