Activity setting from a dialog once again

This commit is contained in:
Piotr Gaczkowski 2007-03-31 09:09:16 +00:00
parent 9f9a662c84
commit 6917ab7ff5
4 changed files with 255 additions and 0 deletions

View File

@ -0,0 +1,158 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkDialog" id="change_activity_dialog">
<property name="border_width">6</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">270</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<signal name="key_press_event" handler="on_change_status_message_dialog_key_press_event" last_modification_time="Wed, 16 Mar 2005 00:53:06 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox5">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Sat, 31 Mar 2007 07:58:52 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_ok_button_clicked" last_modification_time="Sat, 31 Mar 2007 07:57:55 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame38">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment107">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkVBox" id="vbox112">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkComboBox" id="combobox1">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="combobox2">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -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')

View File

@ -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):

View File

@ -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()