[rOOt & Asterix] use get_uf_activity/mood to translate them. store subactivities according to selected activity. fixes #3809

This commit is contained in:
Yann Leboulanger 2008-04-07 11:17:33 +00:00
parent 855a72855d
commit 05218db68a
3 changed files with 86 additions and 78 deletions

View File

@ -21,48 +21,14 @@
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<widget class="GtkComboBox" id="activity_combobox"> <widget class="GtkLabel" id="label4">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="subactivity_combobox">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="description_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">General:</property> <property name="label" translatable="yes">Message:</property>
</widget> </widget>
<packing> <packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
@ -81,18 +47,52 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label4"> <widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Message:</property> <property name="label" translatable="yes">General:</property>
</widget> </widget>
<packing> <packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkEntry" id="description_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="subactivity_combobox">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="activity_combobox">
<property name="visible">True</property>
<signal name="changed" handler="on_activity_combobox_changed"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="position">2</property> <property name="position">2</property>

View File

@ -371,31 +371,27 @@ class ChooseGPGKeyDialog:
class ChangeActivityDialog: class ChangeActivityDialog:
activities = ['doing_chores', 'drinking', 'eating', activities = \
'excercising', 'grooming', 'having_appointment', {'doing_chores': ['buying_groceries', 'cleaning', 'cooking',
'inactive', 'relaxing', 'talking', 'traveling', 'doing_maintenance', 'doing_the_dishes' 'doing_the_laundry',
'working', ] 'gardening', 'running_an_errand', 'walking_the_dog'],
subactivities = ['at_the_spa', 'brushing_teeth', 'drinking': ['having_a_beer', 'having_coffee', 'having_tea'],
'buying_groceries', 'cleaning', 'coding', 'eating': ['having_a_snack', 'having_breakfast', 'having_dinner',
'commuting', 'cooking', 'cycling', 'day_off', 'having_lunch'],
'doing_maintenance', 'doing_the_dishes', 'excercising': ['cycling', 'hiking', 'jogging', 'playing_sports',
'doing_the_laundry', 'driving', 'gaming', 'running', 'skiing', 'swimming', 'working_out'],
'gardening', 'getting_a_haircut', 'going_out', 'grooming': ['at_the_spa', 'brushing_teeth', 'getting_a_haircut',
'hanging_out', 'having_a_beer', 'having_a_snack', 'shaving','taking_a_bath', 'taking_a_shower'],
'having_breakfast', 'having_coffee', 'having_appointment': [],
'having_dinner', 'having_lunch', 'having_tea', 'inactive': ['day_off', 'hanging_out', 'on_vacation', 'scheduled_holiday',
'hiking', 'in_a_car', 'in_a_meeting', 'sleeping'],
'in_real_life', 'jogging', 'on_a_bus', 'relaxing': ['gaming', 'going_out', 'partying', 'reading', 'rehearsing',
'on_a_plane', 'on_a_train', 'on_a_trip', 'shopping', 'socializing', 'sunbathing', 'watching_tv',
'on_the_phone', 'on_vacation', 'other', 'watching_a_movie'],
'partying', 'playing_sports', 'reading', 'talking': ['in_real_life', 'on_the_phone', 'on_video_phone'],
'rehearsing', 'running', 'running_an_errand', 'traveling': ['commuting', 'cycling', 'driving', 'in_a_car', 'on_a_bus',
'scheduled_holiday', 'shaving', 'shopping', 'on_a_plane', 'on_a_train', 'on_a_trip', 'walking'],
'skiing', 'sleeping', 'socializing', 'working': ['coding', 'in_a_meeting', 'studying', 'writing']}
'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): def __init__(self, account):
self.account = account self.account = account
self.xml = gtkgui_helpers.get_glade('change_activity_dialog.glade') self.xml = gtkgui_helpers.get_glade('change_activity_dialog.glade')
@ -405,23 +401,20 @@ class ChangeActivityDialog:
self.entry = self.xml.get_widget('description_entry') self.entry = self.xml.get_widget('description_entry')
self.activity_combo = self.xml.get_widget('activity_combobox') self.activity_combo = self.xml.get_widget('activity_combobox')
self.liststore1 = gtk.ListStore(str) self.liststore1 = gtk.ListStore(str, str) # translated, english
self.activity_combo.set_model(self.liststore1) self.activity_combo.set_model(self.liststore1)
for activity in self.activities: for activity in self.activities:
self.liststore1.append((activity,)) self.liststore1.append((helpers.get_uf_activity(activity), activity))
cellrenderertext = gtk.CellRendererText() cellrenderertext = gtk.CellRendererText()
self.activity_combo.pack_start(cellrenderertext, True) self.activity_combo.pack_start(cellrenderertext, True)
self.activity_combo.add_attribute(cellrenderertext, 'text', 0) self.activity_combo.add_attribute(cellrenderertext, 'text', 0)
self.subactivity_combo = self.xml.get_widget('subactivity_combobox') self.subactivity_combo = self.xml.get_widget('subactivity_combobox')
self.liststore2 = gtk.ListStore(str) self.liststore2 = gtk.ListStore(str, str) # translated, english
self.subactivity_combo.set_model(self.liststore2) self.subactivity_combo.set_model(self.liststore2)
for subactivity in self.subactivities:
self.liststore2.append((subactivity,))
cellrenderertext = gtk.CellRendererText() cellrenderertext = gtk.CellRendererText()
self.subactivity_combo.pack_start(cellrenderertext, True) self.subactivity_combo.pack_start(cellrenderertext, True)
self.subactivity_combo.add_attribute(cellrenderertext, 'text', 0) self.subactivity_combo.add_attribute(cellrenderertext, 'text', 0)
@ -429,6 +422,15 @@ class ChangeActivityDialog:
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
self.window.show_all() self.window.show_all()
def on_activity_combobox_changed(self, widget):
self.liststore2.clear()
selected_activity = self.activity_combo.get_active()
if selected_activity > -1:
selected_activity = self.liststore1[selected_activity][1]
for subactivity in self.activities[selected_activity]:
self.liststore2.append((helpers.get_uf_activity(subactivity),
subactivity))
def on_ok_button_clicked(self, widget): def on_ok_button_clicked(self, widget):
'''Return activity and messsage (None if no activity selected)''' '''Return activity and messsage (None if no activity selected)'''
activity = None activity = None
@ -437,9 +439,9 @@ class ChangeActivityDialog:
active1 = self.activity_combo.get_active() active1 = self.activity_combo.get_active()
active2 = self.subactivity_combo.get_active() active2 = self.subactivity_combo.get_active()
if active1 > -1: if active1 > -1:
activity = self.liststore1[active1][0].decode('utf-8') activity = self.liststore1[active1][1].decode('utf-8')
if active2 > -1: if active2 > -1:
subactivity = self.liststore2[active2][0].decode('utf-8') subactivity = self.liststore2[active2][1].decode('utf-8')
message = self.entry.get_text().decode('utf-8') message = self.entry.get_text().decode('utf-8')
from common import pep from common import pep
pep.user_send_activity(self.account, activity, pep.user_send_activity(self.account, activity,
@ -473,11 +475,11 @@ class ChangeMoodDialog:
self.entry = self.xml.get_widget('description_entry') self.entry = self.xml.get_widget('description_entry')
self.combo = self.xml.get_widget('type_combobox') self.combo = self.xml.get_widget('type_combobox')
self.liststore = gtk.ListStore(str) self.liststore = gtk.ListStore(str, str) # translated, english
self.combo.set_model(self.liststore) self.combo.set_model(self.liststore)
for mood in self.moods: for mood in self.moods:
self.liststore.append((mood,)) self.liststore.append((helpers.get_uf_mood(mood), mood))
cellrenderertext = gtk.CellRendererText() cellrenderertext = gtk.CellRendererText()
self.combo.pack_start(cellrenderertext, True) self.combo.pack_start(cellrenderertext, True)
@ -491,7 +493,7 @@ class ChangeMoodDialog:
message = None message = None
active = self.combo.get_active() active = self.combo.get_active()
if active > -1: if active > -1:
mood = self.liststore[active][0].decode('utf-8') mood = self.liststore[active][1].decode('utf-8')
message = self.entry.get_text().decode('utf-8') message = self.entry.get_text().decode('utf-8')
from common import pep from common import pep
pep.user_send_mood(self.account, mood, message) pep.user_send_mood(self.account, mood, message)

View File

@ -501,6 +501,8 @@ class RosterTooltip(NotificationAreaTooltip):
if contact.mood.has_key('mood'): if contact.mood.has_key('mood'):
mood = contact.mood['mood'].strip() mood = contact.mood['mood'].strip()
# translate it
mood = helpers.get_uf_mood(mood)
mood = gobject.markup_escape_text(mood) mood = gobject.markup_escape_text(mood)
mood_string = _('Mood:') + ' <b>%s</b>' % mood mood_string = _('Mood:') + ' <b>%s</b>' % mood
if contact.mood.has_key('text') and contact.mood['text'] != '': if contact.mood.has_key('text') and contact.mood['text'] != '':
@ -511,10 +513,14 @@ class RosterTooltip(NotificationAreaTooltip):
if contact.activity.has_key('activity'): if contact.activity.has_key('activity'):
activity = contact.activity['activity'].strip() activity = contact.activity['activity'].strip()
# translate it
activity = helpers.get_uf_activity(activity)
activity = gobject.markup_escape_text(activity) activity = gobject.markup_escape_text(activity)
activity_string = _('Activity:') + ' <b>%s' % activity activity_string = _('Activity:') + ' <b>%s' % activity
if contact.activity.has_key('subactivity'): if contact.activity.has_key('subactivity'):
activity_sub = contact.activity['subactivity'].strip() activity_sub = contact.activity['subactivity'].strip()
# translate it
activity_sub = helpers.get_uf_activity(activity_sub)
activity_sub = gobject.markup_escape_text(activity_sub) activity_sub = gobject.markup_escape_text(activity_sub)
activity_string += ' (%s)</b>' % activity_sub activity_string += ' (%s)</b>' % activity_sub
else: else: