diff --git a/data/glade/change_activity_dialog.glade b/data/glade/change_activity_dialog.glade new file mode 100644 index 000000000..7665916fd --- /dev/null +++ b/data/glade/change_activity_dialog.glade @@ -0,0 +1,158 @@ + + + + + + + 6 + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 270 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + 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 + False + True + + + 0 + False + False + + + + + + True + False + True + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + + False + + + 0 + False + False + + + + + + + + + 0 + True + True + + + + + + + diff --git a/src/common/pep.py b/src/common/pep.py index b820d4478..8762b8602 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -52,3 +52,14 @@ def user_send_mood(account, mood, message = ''): i.addData(message) gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0') + +def user_send_activity(account, activity, subactivity = '', message = ''): + item = xmpp.Node('activity', {'xmlns': xmpp.NS_ACTIVITY}) + i = item.addChild(activity) + if subactivity != '': + i.addChild(subactivity) + if message != '': + i = item.addChild('text') + i.addData(message) + + gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0') diff --git a/src/dialogs.py b/src/dialogs.py index cb3486b91..b7503eb15 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -307,6 +307,86 @@ class ChooseGPGKeyDialog: self.keys_treeview.set_cursor(path) +class ChangeActivityDialog: + activities = [_('doing_chores'), _('drinking'), _('eating'), + _('excercising'), _('grooming'), _('having_appointment'), + _('inactive'), _('relaxing'), _('talking'), _('traveling'), + _('working'), ] + subactivities = [_('at_the_spa'), _('brushing_teeth'), + _('buying_groceries'), _('cleaning'), _('coding'), + _('commuting'), _('cooking'), _('cycling'), _('day_off'), + _('doing_maintenance'), _('doing_the_dishes'), + _('doing_the_laundry'), _('driving'), _('gaming'), + _('gardening'), _('getting_a_haircut'), _('going_out'), + _('hanging_out'), _('having_a_beer'), _('having_a_snack'), + _('having_breakfast'), _('having_coffee'), + _('having_dinner'), _('having_lunch'), _('having_tea'), + _('hiking'), _('in_a_car'), _('in_a_meeting'), + _('in_real_life'), _('jogging'), _('on_a_bus'), + _('on_a_plane'), _('on_a_train'), _('on_a_trip'), + _('on_the_phone'), _('on_vacation'), _('other'), + _('partying'), _('playing_sports'), _('reading'), + _('rehearsing'), _('running'), _('running_an_errand'), + _('scheduled_holiday'), _('shaving'), _('shopping'), + _('skiing'), _('sleeping'), _('socializing'), + _('studying'), _('sunbathing'), _('swimming'), + _('taking_a_bath'), _('taking_a_shower'), _('walking'), + _('walking_the_dog'), _('watching_tv'), + _('watching_a_movie'), _('working_out'), _('writing'), ] + def __init__(self, account): + self.account = account + self.xml = gtkgui_helpers.get_glade('change_activity_dialog.glade') + self.window = self.xml.get_widget('change_activity_dialog') + self.window.set_transient_for(gajim.interface.roster.window) + self.window.set_title(_('Activity')) + + self.entry = self.xml.get_widget('entry') + + self.combo1 = self.xml.get_widget('combobox1') + self.liststore1 = gtk.ListStore(str) + self.combo1.set_model(self.liststore1) + + for activity in self.activities: + self.liststore1.append((activity,)) + + cellrenderertext = gtk.CellRendererText() + self.combo1.pack_start(cellrenderertext, True) + self.combo1.add_attribute(cellrenderertext, 'text', 0) + + self.combo2 = self.xml.get_widget('combobox2') + self.liststore2 = gtk.ListStore(str) + self.combo2.set_model(self.liststore2) + + for subactivity in self.subactivities: + self.liststore2.append((subactivity,)) + + cellrenderertext = gtk.CellRendererText() + self.combo2.pack_start(cellrenderertext, True) + self.combo2.add_attribute(cellrenderertext, 'text', 0) + + self.xml.signal_autoconnect(self) + self.window.show_all() + + def on_ok_button_clicked(self, widget): + '''Return activity and messsage (None if no activity selected)''' + activity = None + subactivity = None + message = None + active1 = self.combo1.get_active() + active2 = self.combo2.get_active() + if active1 > -1: + activity = self.liststore1[active1][0].decode('utf-8') + if active2 > -1: + subactivity = self.liststore2[active2][0].decode('utf-8') + message = self.entry.get_text().decode('utf-8') + from common import pep + pep.user_send_activity(self.account, activity, + subactivity, message) + self.window.destroy() + + def on_cancel_button_clicked(self, widget): + self.window.destroy() + class ChangeMoodDialog: moods = [_('afraid'), _('amazed'), _('angry'), _('annoyed'), _('anxious'), _('aroused'), _('ashamed'), _('bored'), _('brave'), _('calm'), _('cold'), _('confused'), _('contented'), _('cranky'), _('curious'), _('depressed'), _('disappointed'), _('disgusted'), _('distracted'), _('embarrassed'), _('excited'), _('flirtatious'), _('frustrated'), _('grumpy'), _('guilty'), _('happy'), _('hot'), _('humbled'), _('humiliated'), _('hungry'), _('hurt'), _('impressed'), _('in_awe'), _('in_love'), _('indignant'), _('interested'), _('intoxicated'), _('invincible'), _('jealous'), _('lonely'), _('mean'), _('moody'), _('nervous'), _('neutral'), _('offended'), _('playful'), _('proud'), _('relieved'), _('remorseful'), _('restless'), _('sad'), _('sarcastic'), _('serious'), _('shocked'), _('shy'), _('sick'), _('sleepy'), _('stressed'), _('surprised'), _('thirsty'), _('worried')] def __init__(self, account): diff --git a/src/roster_window.py b/src/roster_window.py index 94e5b9a1d..f94fb59df 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2268,6 +2268,9 @@ class RosterWindow: gajim.config.get_per('accounts', account, 'name')) helpers.launch_browser_mailer('url', url) + def on_change_activity_activate(self, widget, account): + dlg = dialogs.ChangeActivityDialog(account) + def on_change_mood_activate(self, widget, account): dlg = dialogs.ChangeMoodDialog(account) @@ -2340,6 +2343,9 @@ class RosterWindow: item = gtk.MenuItem('Mood') pep_submenu.append(item) item.connect('activate', self.on_change_mood_activate, account) + item = gtk.MenuItem('Activity') + pep_submenu.append(item) + item.connect('activate', self.on_change_activity_activate, account) else: pep_menuitem.set_no_show_all(True) pep_menuitem.hide()