New activity dialog.

This commit is contained in:
js 2008-07-28 20:57:56 +00:00
parent 5502b68828
commit f7d8631a5c
9 changed files with 671 additions and 138 deletions

View File

@ -1,4 +1,4 @@
SUBDIRS = glade emoticons pixmaps iconsets moods
SUBDIRS = glade emoticons pixmaps iconsets moods activities
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications

View File

@ -13,89 +13,528 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkTable" id="table1">
<widget class="GtkCheckButton" id="enable_checkbutton">
<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="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Set an activity</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_enable_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkLabel" id="label4">
<widget class="GtkFrame" id="frame1">
<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="label" translatable="yes">Message:</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="working_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Working&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkImage" id="working_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="type">tab</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<widget class="GtkFrame" id="frame2">
<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="label" translatable="yes">Specific:</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="eating_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Eating&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<widget class="GtkImage" id="eating_image">
<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="label" translatable="yes">General:</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="type">tab</property>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="exercising_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Exercising&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="exercising_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="relaxing_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Relaxing&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="relaxing_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="talking_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Talking&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="talking_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame6">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="doing_chores_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Doing Chores&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">5</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="doing_chores_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">5</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame7">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="inactive_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Inactive&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">6</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="inactive_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">6</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame8">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="traveling_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Traveling&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">7</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="traveling_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">7</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame9">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="having_appointment_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Having an Appointment&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">8</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="having_appointment_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">8</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame10">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="drinking_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Drinking&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">9</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="drinking_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">9</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame11">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="grooming_vbox">
<property name="visible">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Grooming&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">10</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="grooming_image">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
<property name="icon_size">1</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">10</property>
<property name="tab_fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Message:&lt;/b&gt; </property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="description_entry">
<property name="visible">True</property>
<property name="sensitive">False</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>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child internal-child="action_area">

View File

@ -52,6 +52,7 @@ class Config:
DEFAULT_ICONSET = 'dcraven'
DEFAULT_MOOD_ICONSET = 'default'
DEFAULT_ACTIVITY_ICONSET = 'default'
if sys.platform == 'darwin':
DEFAULT_OPENWITH = 'open'
DEFAULT_BROWSER = 'open -a Safari'
@ -94,6 +95,7 @@ class Config:
'trayicon': [ opt_bool, True, '', True ],
'iconset': [ opt_str, DEFAULT_ICONSET, '', True ],
'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ],
'activity_iconset': [ opt_str, DEFAULT_ACTIVITY_ICONSET, '', True ],
'use_transports_iconsets': [ opt_bool, True, '', True ],
'inmsgcolor': [ opt_color, '#a34526', '', True ],
'outmsgcolor': [ opt_color, '#164e6f', '', True ],

View File

@ -79,9 +79,10 @@ class ConfigPaths:
# LOG is deprecated
k = ( 'LOG', 'LOG_DB', 'VCARD', 'AVATAR', 'MY_EMOTS',
'MY_ICONSETS', 'MY_MOOD_ICONSETS', 'MY_CACERTS')
'MY_ICONSETS', 'MY_MOOD_ICONSETS',
'MY_ACTIVITY_ICONSETS', 'MY_CACERTS')
v = (u'logs', u'logs.db', u'vcards', u'avatars', u'emoticons',
u'iconsets', u'moods', u'cacerts.pem')
u'iconsets', u'moods', u'activities', u'cacerts.pem')
if os.name == 'nt':
v = map(lambda x: x.capitalize(), v)

View File

@ -82,6 +82,7 @@ AVATAR_PATH = gajimpaths['AVATAR']
MY_EMOTS_PATH = gajimpaths['MY_EMOTS']
MY_ICONSETS_PATH = gajimpaths['MY_ICONSETS']
MY_MOOD_ICONSETS_PATH = gajimpaths['MY_MOOD_ICONSETS']
MY_ACTIVITY_ICONSETS_PATH = gajimpaths['MY_ACTIVITY_ICONSETS']
MY_CACERTS = gajimpaths['MY_CACERTS']
TMP = gajimpaths['TMP']
DATA_DIR = gajimpaths['DATA']

View File

@ -1185,6 +1185,13 @@ def get_mood_iconset_path(iconset):
elif os.path.isdir(os.path.join(gajim.MY_MOOD_ICONSETS_PATH, iconset)):
return os.path.join(gajim.MY_MOOD_ICONSETS_PATH, iconset)
def get_activity_iconset_path(iconset):
if os.path.isdir(os.path.join(gajim.DATA_DIR, 'activities', iconset)):
return os.path.join(gajim.DATA_DIR, 'activities', iconset)
elif os.path.isdir(os.path.join(gajim.MY_ACTIVITY_ICONSETS_PATH,
iconset)):
return os.path.join(gajim.MY_ACTIVITY_ICONSETS_PATH, iconset)
def get_transport_path(transport):
if os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', 'transports',
transport)):

View File

@ -11,6 +11,80 @@ MOODS = ['afraid', 'amazed', 'angry', 'annoyed', 'anxious', 'aroused',
'remorseful', 'restless', 'sad', 'sarcastic', 'serious', 'shocked',
'shy', 'sick', 'sleepy', 'stressed', 'surprised', 'thirsty', 'worried']
ACTIVITIES = {
'doing_chores': {
'buying_groceries': _('Buying Groceries'),
'cleaning': _('Cleaning'),
'cooking': _('Cooking'),
'doing_maintenance': _('Doing Maintenance'),
'doing_the_dishes': _('Doing the Dishes'),
'doing_the_laundry': _('Doing the Laundry'),
'gardening': _('Gardening'),
'running_an_errand': _('Running an Errand'),
'walking_the_dog': _('Walking the Dog')},
'drinking': {
'having_a_beer': _('Having a Beer'),
'having_coffee': _('Having Coffee'),
'having_tea': _('Having Tea')},
'eating': {
'having_a_snack': _('Having a Snack'),
'having_breakfast': _('Having Breakfast'),
'having_dinner': _('Having Dinner'),
'having_lunch': _('Having Lunch')},
'exercising': {
'cycling': _('Cycling'),
'hiking': _('Hiking'),
'jogging': _('Jogging'),
'playing_sports': _('Playing Sports'),
'running': _('Running'),
'skiing': _('Skiing'),
'swimming': _('Swimming'),
'working_out': _('Working out')},
'grooming': {
'at_the_spa': _('At the Spa'),
'brushing_teeth': _('Brushing Teeth'),
'getting_a_haircut': _('Getting a Haircut'),
'shaving': _('Shaving'),
'taking_a_bath': _('Taking a Bath'),
'taking_a_shower': _('Taking a Shower')},
'having_appointment': {},
'inactive': {
'day_off': _('Day Off'),
'hanging_out': _('Haning out'),
'on_vacation': _('On Vacation'),
'scheduled_holiday': _('Scheduled Holiday'),
'sleeping': _('Sleeping')},
'relaxing': {
'gaming': _('Gaming'),
'going_out': _('Going out'),
'partying': _('Partying'),
'reading': _('Reading'),
'rehearsing': _('Rehearsing'),
'shopping': _('Shopping'),
'socializing': _('Socializing'),
'sunbathing': _('Sunbathing'),
'watching_tv': _('Watching TV'),
'watching_a_movie': _('Watching a Movie')},
'talking': {
'in_real_life': _('In Real Life'),
'on_the_phone': _('On the Phone'),
'on_video_phone': _('On Video Phone')},
'traveling': {
'commuting': _('Commuting'),
'cycling': _('Cycling'),
'driving': _('Driving'),
'in_a_car': _('In a Car'),
'on_a_bus': _('On a Bus'),
'on_a_plane': _('On a Plane'),
'on_a_train': _('On a Train'),
'on_a_trip': _('On a Trip'),
'walking': _('Walking')},
'working': {
'coding': _('Coding'),
'in_a_meeting': _('In a Meeting'),
'studying': _('Studying'),
'writing': _('Writing')}}
def user_mood(items, name, jid):
has_child = False
retract = False

View File

@ -332,63 +332,81 @@ class ChooseGPGKeyDialog:
class ChangeActivityDialog:
activities = \
{'None': [],
'doing_chores': ['buying_groceries', 'cleaning', 'cooking',
'doing_maintenance', 'doing_the_dishes', 'doing_the_laundry',
'gardening', 'running_an_errand', 'walking_the_dog', 'other'],
'drinking': ['having_a_beer', 'having_coffee', 'having_tea', 'other'],
'eating': ['having_a_snack', 'having_breakfast', 'having_dinner',
'having_lunch', 'other'],
'excercising': ['cycling', 'hiking', 'jogging', 'playing_sports',
'running', 'skiing', 'swimming', 'working_out', 'other'],
'grooming': ['at_the_spa', 'brushing_teeth', 'getting_a_haircut',
'shaving','taking_a_bath', 'taking_a_shower', 'other'],
'having_appointment': [],
'inactive': ['day_off', 'hanging_out', 'on_vacation', 'scheduled_holiday',
'sleeping', 'other'],
'relaxing': ['gaming', 'going_out', 'partying', 'reading', 'rehearsing',
'shopping', 'socializing', 'sunbathing', 'watching_tv',
'watching_a_movie', 'other'],
'talking': ['in_real_life', 'on_the_phone', 'on_video_phone', 'other'],
'traveling': ['commuting', 'cycling', 'driving', 'in_a_car', 'on_a_bus',
'on_a_plane', 'on_a_train', 'on_a_trip', 'walking', 'other'],
'working': ['coding', 'in_a_meeting', 'studying', 'writing', 'other']}
PAGELIST = ['working', 'eating', 'exercising', 'relaxing', 'talking',
'doing_chores', 'inactive', 'traveling', 'having_appointment',
'drinking', 'grooming']
def __init__(self, account):
self.account = account
self.xml = gtkgui_helpers.get_glade('change_activity_dialog.glade')
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.checkbutton = self.xml.get_widget('enable_checkbutton')
self.notebook = self.xml.get_widget('notebook')
self.entry = self.xml.get_widget('description_entry')
self.activity_combo = self.xml.get_widget('activity_combobox')
self.liststore1 = gtk.ListStore(str, str) # translated, english
self.activity_combo.set_model(self.liststore1)
self.activity = None
self.subactivity = None
for activity in self.activities:
self.liststore1.append((helpers.get_uf_activity(activity), activity))
rbtns = {}
group = None
for category in pep.ACTIVITIES:
item = self.xml.get_widget(category + '_image')
item.set_from_pixbuf(
gtkgui_helpers.load_activity_icon(
category).get_pixbuf())
cellrenderertext = gtk.CellRendererText()
self.activity_combo.pack_start(cellrenderertext, True)
self.activity_combo.add_attribute(cellrenderertext, 'text', 0)
vbox = self.xml.get_widget(category + '_vbox')
for activity in pep.ACTIVITIES[category]:
act = category + '_' + activity
self.subactivity_combo = self.xml.get_widget('subactivity_combobox')
self.liststore2 = gtk.ListStore(str, str) # translated, english
self.subactivity_combo.set_model(self.liststore2)
if group:
rbtns[act] = gtk.RadioButton(group)
else:
rbtns[act] = group = gtk.RadioButton()
cellrenderertext = gtk.CellRendererText()
self.subactivity_combo.pack_start(cellrenderertext, True)
self.subactivity_combo.add_attribute(cellrenderertext, 'text', 0)
rbtns[act].set_label(
pep.ACTIVITIES[category][activity])
rbtns[act].connect('toggled',
self.on_rbtn_toggled,
[category, activity])
vbox.pack_start(rbtns[act], False, False, 0)
# Other
act = category + '_other'
if group:
rbtns[act] = gtk.RadioButton(group)
else:
rbtns[act] = group = gtk.RadioButton()
rbtns[act].set_label(_('Other'))
rbtns[act].connect('toggled', self.on_rbtn_toggled,
[category, 'other'])
vbox.pack_start(rbtns[act], False, False, 0)
con = gajim.connections[account]
if 'activity' in con.activity and con.activity['activity'] in \
self.activities:
self.activity_combo.set_active(self.activities.keys().index(
con.activity['activity']))
self.on_activity_combobox_changed(self.activity_combo)
else:
self.activity_combo.set_active(0)
if 'activity' in con.activity \
and con.activity['activity'] in pep.ACTIVITIES:
if 'subactivity' in con.activity \
and pep.ACTIVITIES[con.activity['activity']].has_key(
con.activity['subactivity']):
subactivity = con.activity['subactivity']
else:
subactivity = 'other'
rbtns[con.activity['activity'] + '_' + subactivity]. \
set_active(True)
self.checkbutton.set_active(True)
self.notebook.set_sensitive(True)
self.entry.set_sensitive(True)
self.notebook.set_current_page(
self.PAGELIST.index(con.activity['activity']))
if 'text' in con.activity:
self.entry.set_text(con.activity['text'])
@ -396,47 +414,30 @@ class ChangeActivityDialog:
self.xml.signal_autoconnect(self)
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]
if self.activities[selected_activity]:
for subactivity in self.activities[selected_activity]:
self.liststore2.append((helpers.get_uf_activity(subactivity),
subactivity))
self.subactivity_combo.set_sensitive(True)
con = gajim.connections[self.account]
if 'subactivity' in con.activity and con.activity['subactivity'] in\
self.activities[selected_activity]:
self.subactivity_combo.set_active(self.activities[
selected_activity].index(con.activity['subactivity']))
else:
self.subactivity_combo.set_active(0)
def on_enable_checkbutton_toggled(self, widget):
self.notebook.set_sensitive(widget.get_active())
self.entry.set_sensitive(widget.get_active())
else:
self.subactivity_combo.set_sensitive(False)
def on_rbtn_toggled(self, widget, data):
if widget.get_active():
self.activity = data[0]
self.subactivity = data[1]
def on_ok_button_clicked(self, widget):
'''Return activity and messsage (None if no activity selected)'''
activity = None
subactivity = None
'''
Return activity and messsage (None if no activity selected)
'''
message = None
active1 = self.activity_combo.get_active()
active2 = self.subactivity_combo.get_active()
if active1 > -1:
activity = self.liststore1[active1][1].decode('utf-8')
if active2 > -1:
subactivity = self.liststore2[active2][1].decode('utf-8')
message = self.entry.get_text().decode('utf-8')
if subactivity is None:
subactivity = ''
if activity == 'None':
pep.user_retract_activity(self.account)
else:
pep.user_send_activity(self.account, activity,
subactivity, message)
self.window.destroy()
if self.checkbutton.get_active():
if self.subactivity is 'other':
self.subactivity = ''
pep.user_send_activity(self.account, self.activity,
self.subactivity,
self.entry.get_text().decode('utf-8'))
else:
pep.user_retract_activity(self.account)
self.window.destroy()
def on_cancel_button_clicked(self, widget):
self.window.destroy()

View File

@ -898,6 +898,14 @@ def load_mood_icon(icon_name):
icon_list = _load_icon_list([icon_name], path)
return icon_list[icon_name]
def load_activity_icon(activity, sub_activity = None):
'''load an icon from the activity iconset in 16x16'''
iconset = gajim.config.get('activity_iconset')
path = os.path.join(helpers.get_activity_iconset_path(iconset),
activity, '')
icon_list = _load_icon_list(['category'], path)
return icon_list['category']
def load_icons_meta():
'''load and return - AND + small icons to put on top left of an icon
for meta contacts.'''