diff --git a/data/glade/account_context_menu.glade b/data/glade/account_context_menu.glade index 4e424c5f3..900db4ff8 100644 --- a/data/glade/account_context_menu.glade +++ b/data/glade/account_context_menu.glade @@ -25,6 +25,26 @@ + + + True + _Personal Events + True + + + + True + gtk-home + 1 + 0.5 + 0.5 + 0 + 0 + + + + + True diff --git a/data/glade/change_mood_dialog.glade b/data/glade/change_mood_dialog.glade new file mode 100644 index 000000000..f8e1e6f0f --- /dev/null +++ b/data/glade/change_mood_dialog.glade @@ -0,0 +1,312 @@ + + + + + + + 6 + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 270 + 175 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + True + + + + + True + False + 6 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + False + GTK_PACK_END + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + False + 6 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + + False + GTK_BUTTONBOX_END + 0 + + + + True + False + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-save-as + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Save as Preset... + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + False + + + + + + False + False + 6 + + + + True + Preset messages: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + True + + + + 0 + True + True + + + + + 0 + False + True + + + + + + + + + + False + <b>Type your new status message</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + + diff --git a/src/common/pep.py b/src/common/pep.py index 1cc3bfd74..8e965f256 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -1,9 +1,8 @@ -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') diff --git a/src/dialogs.py b/src/dialogs.py index 85dad7c10..1eb2f5dd0 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -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 diff --git a/src/roster_window.py b/src/roster_window.py index e995e858d..fe7417dd4 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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)