Commit ab26867f authored by Piotr Gaczkowski's avatar Piotr Gaczkowski

Setting mood now supported (crappy).

parent c02eb73b
......@@ -25,6 +25,26 @@
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="pep_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Personal Events</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1235">
<property name="visible">True</property>
<property name="stock">gtk-home</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>
<widget class="GtkImageMenuItem" id="join_group_chat_menuitem">
<property name="visible">True</property>
......
This diff is collapsed.
from common import gajim
#from common import helpers
from common import gajim, xmpp
def user_mood(items, name, jid):
#FIXME: text deletion
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
print 'User: %s, Resource: %s' % (user, resource)
contacts = gajim.contacts.get_contact(name, user, resource=resource)
for item in items.getTags('item'):
child = item.getTag('mood')
......@@ -23,6 +22,7 @@ def user_geoloc(items, name, jid):
pass
def user_activity(items, name, jid):
#FIXME: text deletion
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource)
for item in items.getTags('item'):
......@@ -38,3 +38,12 @@ def user_activity(items, name, jid):
else:
for contact in contacts:
contact.activity['text'] = ch.getData()
def user_send_mood(account, mood, message = ''):
item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})
item.addChild(mood)
if message != '':
i = item.addChild('text')
i.addData(message)
gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0')
......@@ -307,6 +307,33 @@ class ChooseGPGKeyDialog:
self.keys_treeview.set_cursor(path)
class ChangeMoodDialog:
def __init__(self):
self.xml = gtkgui_helpers.get_glade('change_mood_dialog.glade')
self.window = self.xml.get_widget('change_mood_dialog')
self.window.set_transient_for(gajim.interface.roster.window)
self.window.set_title('Mood')
message_textview = self.xml.get_widget('message_textview')
self.message_buffer = message_textview.get_buffer()
#self.message_buffer.connect('changed',
# self.toggle_sensitiviy_of_save_as_preset)
def run(self):
'''Wait for OK or Cancel button to be pressed and return mood
and messsage (None if users pressed Cancel or x button of WM'''
rep = self.window.run()
mood = None
message = None
if rep == gtk.RESPONSE_OK:
beg, end = self.message_buffer.get_bounds()
message = self.message_buffer.get_text(beg, end).decode('utf-8')\
.strip()
msg = helpers.to_one_line(message)
self.window.destroy()
return (mood, message)
class ChangeStatusMessageDialog:
def __init__(self, show = None):
self.show = show
......
......@@ -39,6 +39,7 @@ from common import helpers
from common import passwords
from common.exceptions import GajimGeneralException
from common import i18n
from common import pep
from message_window import MessageWindowMgr
from chat_control import ChatControl
......@@ -2268,6 +2269,14 @@ class RosterWindow:
gajim.config.get_per('accounts', account, 'name'))
helpers.launch_browser_mailer('url', url)
def on_change_mood_activate(self, widget, account):
dlg = dialogs.ChangeMoodDialog()
(mood, message) = dlg.run()
mood = 'happy'
print account, mood, message
if mood is not None: # None is if user pressed Cancel
self.send_mood(account, mood, message)
def on_change_status_message_activate(self, widget, account):
show = gajim.SHOW_LIST[gajim.connections[account].connected]
dlg = dialogs.ChangeStatusMessageDialog(show)
......@@ -2330,6 +2339,17 @@ class RosterWindow:
sub_menu.append(item)
item.connect('activate', self.change_status, account, 'offline')
pep_menuitem = xml.get_widget('pep_menuitem')
if gajim.connections[account].pep_supported:
pep_submenu = gtk.Menu()
pep_menuitem.set_submenu(pep_submenu)
item = gtk.MenuItem('Mood')
pep_submenu.append(item)
item.connect('activate', self.on_change_mood_activate, account)
else:
pep_menuitem.set_no_show_all(True)
pep_menuitem.hide()
if gajim.config.get_per('accounts', account, 'hostname') not in \
gajim.gmail_domains:
open_gmail_inbox_menuitem.set_no_show_all(True)
......@@ -2359,7 +2379,7 @@ class RosterWindow:
if gajim.connections[account].connected < 2:
for widget in [add_contact_menuitem, service_discovery_menuitem,
join_group_chat_menuitem, new_message_menuitem,
execute_command_menuitem]:
execute_command_menuitem, pep_menuitem]:
widget.set_sensitive(False)
else:
xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade')
......@@ -2722,6 +2742,9 @@ class RosterWindow:
if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('connecting')
def send_mood(self, account, mood, message):
pep.user_send_mood(account, mood, message)
def send_status(self, account, status, txt, auto = False):
model = self.tree.get_model()
accountIter = self.get_account_iter(account)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment