[commit-gajim] r11225 - in trunk: data/glade src src/common

asterix at gajim.org asterix at gajim.org
Sun Apr 12 20:13:37 CEST 2009


Author: asterix
Date: 2009-04-12 20:13:37 +0200 (Sun, 12 Apr 2009)
New Revision: 11225

Modified:
   trunk/data/glade/change_status_message_dialog.glade
   trunk/src/common/helpers.py
   trunk/src/common/pep.py
   trunk/src/dialogs.py
   trunk/src/gajim.py
   trunk/src/roster_window.py
   trunk/src/systray.py
Log:
add activity / mood in change status dialog. Fixes #4419


Modified: trunk/data/glade/change_status_message_dialog.glade
===================================================================
--- trunk/data/glade/change_status_message_dialog.glade	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/data/glade/change_status_message_dialog.glade	2009-04-12 18:13:37 UTC (rev 11225)
@@ -1,312 +1,296 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkDialog" id="change_status_message_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="default_height">175</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="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>
-	    </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>
-	    </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="GtkScrolledWindow" id="scrolledwindow24">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-		      <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-		      <property name="shadow_type">GTK_SHADOW_IN</property>
-		      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
-		      <child>
-			<widget class="GtkTextView" id="message_textview">
-			  <property name="visible">True</property>
-			  <property name="can_focus">True</property>
-			  <property name="has_focus">True</property>
-			  <property name="editable">True</property>
-			  <property name="overwrite">False</property>
-			  <property name="accepts_tab">True</property>
-			  <property name="justification">GTK_JUSTIFY_LEFT</property>
-			  <property name="wrap_mode">GTK_WRAP_WORD</property>
-			  <property name="cursor_visible">True</property>
-			  <property name="pixels_above_lines">0</property>
-			  <property name="pixels_below_lines">0</property>
-			  <property name="pixels_inside_wrap">0</property>
-			  <property name="left_margin">0</property>
-			  <property name="right_margin">0</property>
-			  <property name="indent">0</property>
-			  <property name="text" translatable="yes"></property>
-			</widget>
-		      </child>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">True</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkHButtonBox" id="hbuttonbox33">
-		      <property name="visible">True</property>
-		      <property name="layout_style">GTK_BUTTONBOX_END</property>
-		      <property name="spacing">0</property>
-
-		      <child>
-			<widget class="GtkButton" id="save_as_preset_button">
-			  <property name="visible">True</property>
-			  <property name="sensitive">False</property>
-			  <property name="can_default">True</property>
-			  <property name="can_focus">True</property>
-			  <property name="relief">GTK_RELIEF_NORMAL</property>
-			  <property name="focus_on_click">True</property>
-			  <signal name="clicked" handler="on_save_as_preset_button_clicked" last_modification_time="Thu, 26 Jan 2006 17:31:47 GMT"/>
-
-			  <child>
-			    <widget class="GtkAlignment" id="alignment106">
-			      <property name="visible">True</property>
-			      <property name="xalign">0.5</property>
-			      <property name="yalign">0.5</property>
-			      <property name="xscale">0</property>
-			      <property name="yscale">0</property>
-			      <property name="top_padding">0</property>
-			      <property name="bottom_padding">0</property>
-			      <property name="left_padding">0</property>
-			      <property name="right_padding">0</property>
-
-			      <child>
-				<widget class="GtkHBox" id="hbox3021">
-				  <property name="visible">True</property>
-				  <property name="homogeneous">False</property>
-				  <property name="spacing">2</property>
-
-				  <child>
-				    <widget class="GtkImage" id="image1369">
-				      <property name="visible">True</property>
-				      <property name="stock">gtk-save-as</property>
-				      <property name="icon_size">4</property>
-				      <property name="xalign">0.5</property>
-				      <property name="yalign">0.5</property>
-				      <property name="xpad">0</property>
-				      <property name="ypad">0</property>
-				    </widget>
-				    <packing>
-				      <property name="padding">0</property>
-				      <property name="expand">False</property>
-				      <property name="fill">False</property>
-				    </packing>
-				  </child>
-
-				  <child>
-				    <widget class="GtkLabel" id="label380">
-				      <property name="visible">True</property>
-				      <property name="label" translatable="yes">Save as Preset...</property>
-				      <property name="use_underline">True</property>
-				      <property name="use_markup">False</property>
-				      <property name="justify">GTK_JUSTIFY_LEFT</property>
-				      <property name="wrap">False</property>
-				      <property name="selectable">False</property>
-				      <property name="xalign">0.5</property>
-				      <property name="yalign">0.5</property>
-				      <property name="xpad">0</property>
-				      <property name="ypad">0</property>
-				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-				      <property name="width_chars">-1</property>
-				      <property name="single_line_mode">False</property>
-				      <property name="angle">0</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>
-		      </child>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">False</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkHBox" id="hbox3022">
-		      <property name="visible">True</property>
-		      <property name="homogeneous">False</property>
-		      <property name="spacing">6</property>
-
-		      <child>
-			<widget class="GtkLabel" id="label165">
-			  <property name="visible">True</property>
-			  <property name="label" translatable="yes">Preset messages:</property>
-			  <property name="use_underline">False</property>
-			  <property name="use_markup">False</property>
-			  <property name="justify">GTK_JUSTIFY_LEFT</property>
-			  <property name="wrap">False</property>
-			  <property name="selectable">False</property>
-			  <property name="xalign">0</property>
-			  <property name="yalign">0.5</property>
-			  <property name="xpad">0</property>
-			  <property name="ypad">0</property>
-			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-			  <property name="width_chars">-1</property>
-			  <property name="single_line_mode">False</property>
-			  <property name="angle">0</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="message_combobox">
-			  <property name="visible">True</property>
-			  <property name="add_tearoffs">False</property>
-			  <property name="focus_on_click">True</property>
-			  <signal name="changed" handler="on_message_combobox_changed" last_modification_time="Tue, 07 Mar 2006 13:25:23 GMT"/>
-			</widget>
-			<packing>
-			  <property name="padding">0</property>
-			  <property name="expand">True</property>
-			  <property name="fill">True</property>
-			</packing>
-		      </child>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-		</widget>
-	      </child>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label383">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">&lt;b&gt;Type your new status message&lt;/b&gt;</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">True</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0.5</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-	      <property name="width_chars">-1</property>
-	      <property name="single_line_mode">False</property>
-	      <property name="angle">0</property>
-	    </widget>
-	    <packing>
-	      <property name="type">label_item</property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkDialog" id="change_status_message_dialog">
+    <property name="border_width">6</property>
+    <property name="default_width">270</property>
+    <property name="default_height">175</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <signal name="key_press_event" handler="on_change_status_message_dialog_key_press_event"/>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox5">
+        <property name="visible">True</property>
+        <property name="spacing">6</property>
+        <child>
+          <widget class="GtkFrame" id="frame38">
+            <property name="visible">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">GTK_SHADOW_NONE</property>
+            <child>
+              <widget class="GtkAlignment" id="alignment107">
+                <property name="visible">True</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <widget class="GtkVBox" id="vbox112">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <widget class="GtkScrolledWindow" id="scrolledwindow24">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                        <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                        <property name="shadow_type">GTK_SHADOW_IN</property>
+                        <child>
+                          <widget class="GtkTextView" id="message_textview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="has_focus">True</property>
+                            <property name="wrap_mode">GTK_WRAP_WORD</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkHButtonBox" id="hbuttonbox33">
+                        <property name="visible">True</property>
+                        <property name="layout_style">GTK_BUTTONBOX_END</property>
+                        <child>
+                          <widget class="GtkButton" id="save_as_preset_button">
+                            <property name="visible">True</property>
+                            <property name="sensitive">False</property>
+                            <property name="can_focus">True</property>
+                            <property name="can_default">True</property>
+                            <property name="response_id">0</property>
+                            <signal name="clicked" handler="on_save_as_preset_button_clicked"/>
+                            <child>
+                              <widget class="GtkAlignment" id="alignment106">
+                                <property name="visible">True</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <widget class="GtkHBox" id="hbox3021">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">2</property>
+                                    <child>
+                                      <widget class="GtkImage" id="image1369">
+                                        <property name="visible">True</property>
+                                        <property name="stock">gtk-save-as</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkLabel" id="label380">
+                                        <property name="visible">True</property>
+                                        <property name="label" translatable="yes">Save as Preset...</property>
+                                        <property name="use_underline">True</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkTable" id="under_table">
+                        <property name="visible">True</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>
+                        <child>
+                          <widget class="GtkButton" id="mood_button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="response_id">0</property>
+                            <signal name="clicked" handler="on_mood_button_clicked"/>
+                            <child>
+                              <widget class="GtkHBox" id="hbox2">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <widget class="GtkImage" id="mood_image">
+                                    <property name="visible">True</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="mood_button_label">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="wrap">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </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>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkButton" id="activity_button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="response_id">0</property>
+                            <signal name="clicked" handler="on_activity_button_clicked"/>
+                            <child>
+                              <widget class="GtkHBox" id="hbox1">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <widget class="GtkImage" id="activity_image">
+                                    <property name="visible">True</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="activity_button_label">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="wrap">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </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>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="mood_label">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Mood:</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="activity_label">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Activity:</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="message_combobox">
+                            <property name="visible">True</property>
+                            <signal name="changed" handler="on_message_combobox_changed"/>
+                          </widget>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label165">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Preset messages:</property>
+                          </widget>
+                          <packing>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label383">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Type your new status message&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 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_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="ok_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="label">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-5</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: trunk/src/common/helpers.py
===================================================================
--- trunk/src/common/helpers.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/common/helpers.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -45,6 +45,7 @@
 from i18n import Q_
 from i18n import ngettext
 import xmpp
+import pep
 
 try:
 	import winsound # windows-only built-in module for playing wav
@@ -800,7 +801,7 @@
 	maxi = 0
 	for account in gajim.connections:
 		if not gajim.config.get_per('accounts', account,
-			'sync_with_global_status'):
+		'sync_with_global_status'):
 			continue
 		connected = gajim.connections[account].connected
 		if connected > maxi:
@@ -811,7 +812,7 @@
 	maxi = 0
 	for account in gajim.connections:
 		if not gajim.config.get_per('accounts', account,
-			'sync_with_global_status'):
+		'sync_with_global_status'):
 			continue
 		connected = gajim.connections[account].connected
 		if connected > maxi:
@@ -819,6 +820,54 @@
 			status = gajim.connections[account].status
 	return status
 
+def get_pep_dict(account):
+	pep_dict = {}
+	con = gajim.connections[account]
+	# activity
+	if 'activity' in con.activity and con.activity['activity'] in pep.ACTIVITIES:
+		activity = con.activity['activity']
+		if 'subactivity' in con.activity and con.activity['subactivity'] in \
+		pep.ACTIVITIES[activity]:
+			subactivity = con.activity['subactivity']
+		else:
+			subactivity = 'other'
+	else:
+		activity = ''
+		subactivity = ''
+	if 'text' in con.activity:
+		text = con.activity['text']
+	else:
+		text = ''
+	pep_dict['activity'] = activity
+	pep_dict['subactivity'] = subactivity
+	pep_dict['activity_text'] = text
+
+	# mood
+	if 'mood' in con.mood and con.mood['mood'] in pep.MOODS:
+		mood = con.mood['mood']
+	else:
+		mood = ''
+	if 'text' in con.mood:
+		text = con.mood['text']
+	else:
+		text = ''
+	pep_dict['mood'] = mood
+	pep_dict['mood_text'] = text
+	return pep_dict
+
+def get_global_pep():
+	maxi = 0
+	pep_dict = {'activity': '', 'mood': ''}
+	for account in gajim.connections:
+		if not gajim.config.get_per('accounts', account,
+		'sync_with_global_status'):
+			continue
+		connected = gajim.connections[account].connected
+		if connected > maxi:
+			maxi = connected
+			pep_dict = get_pep_dict(account)
+	return pep_dict
+
 def statuses_unified():
 	'''testing if all statuses are the same.'''
 	reference = None

Modified: trunk/src/common/pep.py
===================================================================
--- trunk/src/common/pep.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/common/pep.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -5,7 +5,7 @@
 ## Copyright (C) 2007-2008 Yann Leboulanger <asterix AT lagaule.org>
 ## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
 ##                    Jean-Marie Traissard <jim AT lapin.org>
-##                    Jonathan Schleifer <js-gajim AT webkeks.org>
+##                    Jonathan Schleifer <js-common.gajim AT webkeks.org>
 ##                    Stephan Erb <steve-e AT h3c.de>
 ##
 ## This file is part of Gajim.
@@ -23,7 +23,8 @@
 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 ##
 
-from common import gajim, xmpp
+import common.gajim
+from common import xmpp
 
 MOODS = {
 	'afraid':			_('Afraid'),
@@ -208,8 +209,8 @@
 	if items.getTag('retract') is not None:
 		retract = True
 
-	if jid == gajim.get_jid_from_account(name):
-		acc = gajim.connections[name]
+	if jid == common.gajim.get_jid_from_account(name):
+		acc = common.gajim.connections[name]
 		if has_child:
 			if 'mood' in acc.mood:
 				del acc.mood['mood']
@@ -225,8 +226,8 @@
 			if 'text' in acc.mood:
 				del acc.mood['text']
 
-	(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
-	for contact in gajim.contacts.get_contacts(name, user):
+	(user, resource) = common.gajim.get_room_and_nick_from_fjid(jid)
+	for contact in common.gajim.contacts.get_contacts(name, user):
 		if has_child:
 			if 'mood' in contact.mood:
 				del contact.mood['mood']
@@ -242,10 +243,10 @@
 			if 'text' in contact.mood:
 				del contact.mood['text']
 
-	if jid == gajim.get_jid_from_account(name):
-		gajim.interface.roster.draw_account(name)
-	gajim.interface.roster.draw_mood(user, name)
-	ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
+	if jid == common.gajim.get_jid_from_account(name):
+		common.gajim.interface.roster.draw_account(name)
+	common.gajim.interface.roster.draw_mood(user, name)
+	ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
 	if ctrl:
 		ctrl.update_mood()
 
@@ -276,8 +277,8 @@
 	if items.getTag('retract') is not None:
 		retract = True
 
-	if jid == gajim.get_jid_from_account(name):
-		acc = gajim.connections[name]
+	if jid == common.gajim.get_jid_from_account(name):
+		acc = common.gajim.connections[name]
 		if has_child:
 			if 'artist' in acc.tune:
 				del acc.tune['artist']
@@ -311,8 +312,8 @@
 			if 'length' in acc.tune:
 				del acc.tune['length']
 
-	user = gajim.get_room_and_nick_from_fjid(jid)[0]
-	for contact in gajim.contacts.get_contacts(name, user):
+	user = common.gajim.get_room_and_nick_from_fjid(jid)[0]
+	for contact in common.gajim.contacts.get_contacts(name, user):
 		if has_child:
 			if 'artist' in contact.tune:
 				del contact.tune['artist']
@@ -346,10 +347,10 @@
 			if 'length' in contact.tune:
 				del contact.tune['length']
 
-	if jid == gajim.get_jid_from_account(name):
-		gajim.interface.roster.draw_account(name)
-	gajim.interface.roster.draw_tune(user, name)
-	ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
+	if jid == common.gajim.get_jid_from_account(name):
+		common.gajim.interface.roster.draw_account(name)
+	common.gajim.interface.roster.draw_tune(user, name)
+	ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
 	if ctrl:
 		ctrl.update_tune()
 
@@ -377,8 +378,8 @@
 	if items.getTag('retract') is not None:
 		retract = True
 
-	if jid == gajim.get_jid_from_account(name):
-		acc = gajim.connections[name]
+	if jid == common.gajim.get_jid_from_account(name):
+		acc = common.gajim.connections[name]
 		if has_child:
 			if 'activity' in acc.activity:
 				del acc.activity['activity']
@@ -400,8 +401,8 @@
 			if 'text' in acc.activity:
 				del acc.activity['text']
 
-	user = gajim.get_room_and_nick_from_fjid(jid)[0]
-	for contact in gajim.contacts.get_contacts(name, user):
+	user = common.gajim.get_room_and_nick_from_fjid(jid)[0]
+	for contact in common.gajim.contacts.get_contacts(name, user):
 		if has_child:
 			if 'activity' in contact.activity:
 				del contact.activity['activity']
@@ -423,10 +424,10 @@
 			if 'text' in contact.activity:
 				del contact.activity['text']
 
-	if jid == gajim.get_jid_from_account(name):
-		gajim.interface.roster.draw_account(name)
-	gajim.interface.roster.draw_activity(user, name)
-	ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
+	if jid == common.gajim.get_jid_from_account(name):
+		common.gajim.interface.roster.draw_account(name)
+	common.gajim.interface.roster.draw_activity(user, name)
+	ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
 	if ctrl:
 		ctrl.update_activity()
 
@@ -445,21 +446,21 @@
 	if items.getTag('retract') is not None:
 		retract = True
 
-	if jid == gajim.get_jid_from_account(name):
+	if jid == common.gajim.get_jid_from_account(name):
 		if has_child:
-			gajim.nicks[name] = nick
+			common.gajim.nicks[name] = nick
 		if retract:
-			gajim.nicks[name] = gajim.config.get_per('accounts',
+			common.gajim.nicks[name] = common.gajim.config.get_per('accounts',
 				name, 'name')
 
-	user = gajim.get_room_and_nick_from_fjid(jid)[0]
+	user = common.gajim.get_room_and_nick_from_fjid(jid)[0]
 	if has_child:
 		if nick is not None:
-			for contact in gajim.contacts.get_contacts(name, user):
+			for contact in common.gajim.contacts.get_contacts(name, user):
 				contact.contact_name = nick
-			gajim.interface.roster.draw_contact(user, name)
+			common.gajim.interface.roster.draw_contact(user, name)
 
-			ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
+			ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
 			if ctrl:
 				ctrl.update_ui()
 				win = ctrl.parent_win
@@ -469,7 +470,7 @@
 		contact.contact_name = ''
 
 def user_send_mood(account, mood, message=''):
-	if not gajim.connections[account].pep_supported:
+	if not common.gajim.connections[account].pep_supported:
 		return
 	item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})
 	if mood != '':
@@ -478,10 +479,11 @@
 		i = item.addChild('text')
 		i.addData(message)
 
-	gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0')
+	common.gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item,
+		'0')
 
 def user_send_activity(account, activity, subactivity='', message=''):
-	if not gajim.connections[account].pep_supported:
+	if not common.gajim.connections[account].pep_supported:
 		return
 	item = xmpp.Node('activity', {'xmlns': xmpp.NS_ACTIVITY})
 	if activity != '':
@@ -492,12 +494,13 @@
 		i = item.addChild('text')
 		i.addData(message)
 
-	gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item, '0')
+	common.gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY, item,
+		'0')
 
 def user_send_tune(account, artist='', title='', source='', track=0, length=0,
 items=None):
-	if not (gajim.config.get_per('accounts', account, 'publish_tune') and \
-	gajim.connections[account].pep_supported):
+	if not (common.gajim.config.get_per('accounts', account, 'publish_tune') and\
+	common.gajim.connections[account].pep_supported):
 		return
 	item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
 	if artist != '':
@@ -518,33 +521,35 @@
 	if items is not None:
 		item.addChild(payload=items)
 
-	gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
+	common.gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item,
+		'0')
 
 def user_send_nickname(account, nick):
-	if not gajim.connections[account].pep_supported:
+	if not common.gajim.connections[account].pep_supported:
 		return
 	item = xmpp.Node('nick', {'xmlns': xmpp.NS_NICK})
 	item.addData(nick)
 
-	gajim.connections[account].send_pb_publish('', xmpp.NS_NICK, item, '0')
+	common.gajim.connections[account].send_pb_publish('', xmpp.NS_NICK, item,
+		'0')
 
 def user_retract_mood(account):
-	gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
+	common.gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
 
 def user_retract_activity(account):
-	gajim.connections[account].send_pb_retract('', xmpp.NS_ACTIVITY, '0')
+	common.gajim.connections[account].send_pb_retract('', xmpp.NS_ACTIVITY, '0')
 
 def user_retract_tune(account):
-	gajim.connections[account].send_pb_retract('', xmpp.NS_TUNE, '0')
+	common.gajim.connections[account].send_pb_retract('', xmpp.NS_TUNE, '0')
 
 def user_retract_nickname(account):
-	gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
+	common.gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
 
 def delete_pep(jid, name):
-	user = gajim.get_room_and_nick_from_fjid(jid)[0]
+	user = common.gajim.get_room_and_nick_from_fjid(jid)[0]
 
-	if jid == gajim.get_jid_from_account(name):
-		acc = gajim.connections[name]
+	if jid == common.gajim.get_jid_from_account(name):
+		acc = common.gajim.connections[name]
 		del acc.activity
 		acc.activity = {}
 		user_send_tune(name)
@@ -553,7 +558,7 @@
 		del acc.mood
 		acc.mood = {}
 
-	for contact in gajim.contacts.get_contacts(name, user):
+	for contact in common.gajim.contacts.get_contacts(name, user):
 		del contact.activity
 		contact.activity = {}
 		del contact.tune
@@ -561,13 +566,13 @@
 		del contact.mood
 		contact.mood = {}
 
-	if jid == gajim.get_jid_from_account(name):
-		gajim.interface.roster.draw_account(name)
+	if jid == common.gajim.get_jid_from_account(name):
+		common.gajim.interface.roster.draw_account(name)
 
-	gajim.interface.roster.draw_activity(user, name)
-	gajim.interface.roster.draw_tune(user, name)
-	gajim.interface.roster.draw_mood(user, name)
-	ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
+	common.gajim.interface.roster.draw_activity(user, name)
+	common.gajim.interface.roster.draw_tune(user, name)
+	common.gajim.interface.roster.draw_mood(user, name)
+	ctrl = common.gajim.interface.msg_win_mgr.get_control(user, name)
 	if ctrl:
 		ctrl.update_activity()
 		ctrl.update_tune()

Modified: trunk/src/dialogs.py
===================================================================
--- trunk/src/dialogs.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/dialogs.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -323,8 +323,11 @@
 		'having_appointment', 'inactive', 'relaxing', 'talking', 'traveling',
 		'working']
 
-	def __init__(self, account):
-		self.account = account
+	def __init__(self, on_response, activity=None, subactivity=None, text=''):
+		self.on_response = on_response
+		self.activity = activity
+		self.subactivity = subactivity
+		self.text = text
 		self.xml = gtkgui_helpers.get_glade(
 			'change_activity_dialog.glade')
 		self.window = self.xml.get_widget('change_activity_dialog')
@@ -334,9 +337,6 @@
 		self.notebook = self.xml.get_widget('notebook')
 		self.entry = self.xml.get_widget('description_entry')
 
-		self.activity = 'working'
-		self.subactivity = 'other'
-
 		rbtns = {}
 		group = None
 
@@ -394,31 +394,25 @@
 				rbtns[act].add(hbox)
 				vbox.pack_start(rbtns[act], False, False, 0)
 
-		rbtns['working_other'].set_active(True)
 
-		con = gajim.connections[account]
+		if self.activity in pep.ACTIVITIES:
+			if not self.subactivity in pep.ACTIVITIES[self.activity]:
+				self.subactivity = 'other'
 
-		if 'activity' in con.activity \
-		and con.activity['activity'] in pep.ACTIVITIES:
-			if 'subactivity' in con.activity \
-			and con.activity['subactivity'] in pep.ACTIVITIES[con.activity['activity']]:
-				subactivity = con.activity['subactivity']
-			else:
-				subactivity = 'other'
+			rbtns[self.activity + '_' + self.subactivity].set_active(True)
 
-			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']))
+				self.PAGELIST.index(self.activity))
 
-		if 'text' in con.activity:
-			self.entry.set_text(con.activity['text'])
+			self.entry.set_text(text)
 
+		else:
+			self.checkbutton.set_active(False)
+
 		self.xml.signal_autoconnect(self)
 		self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
 		self.window.show_all()
@@ -437,11 +431,16 @@
 		Return activity and messsage (None if no activity selected)
 		'''
 		if self.checkbutton.get_active():
-			pep.user_send_activity(self.account, self.activity,
-				self.subactivity,
+			self.on_response(self.activity, self.subactivity,
 				self.entry.get_text().decode('utf-8'))
 		else:
-			pep.user_send_activity(self.account, '')
+			self.on_response(None, None, '')
+#		if self.checkbutton.get_active():
+#			pep.user_send_activity(self.account, self.activity,
+#				self.subactivity,
+#				self.entry.get_text().decode('utf-8'))
+#		else:
+#			pep.user_send_activity(self.account, '')
 		self.window.destroy()
 
 	def on_cancel_button_clicked(self, widget):
@@ -450,10 +449,11 @@
 class ChangeMoodDialog:
 	COLS = 11
 
-	def __init__(self, account):
-		self.account = account
+	def __init__(self, on_response, mood=None, text=''):
+		self.on_response = on_response
+		self.mood = mood
+		self.text = text
 		self.xml = gtkgui_helpers.get_glade('change_mood_dialog.glade')
-		self.mood = None
 
 		self.window = self.xml.get_widget('change_mood_dialog')
 		self.window.set_transient_for(gajim.interface.roster.window)
@@ -494,23 +494,17 @@
 				x = 0
 				y += 1
 
-		con = gajim.connections[account]
-		if 'mood' in con.mood:
-			self.mood = con.mood['mood']
-			if self.mood in pep.MOODS:
-				self.mood_buttons[self.mood].set_active(True)
-				self.label.set_text(pep.MOODS[self.mood])
-			else:
-				self.label.set_text(self.mood)
-
-		if self.mood:
+		if self.mood in pep.MOODS:
+			self.mood_buttons[self.mood].set_active(True)
+			self.label.set_text(pep.MOODS[self.mood])
 			self.entry.set_sensitive(True)
+			if self.text:
+				self.entry.set_text(self.text)
 		else:
+			self.label.set_text(_('None'))
+			self.entry.set_text('')
 			self.entry.set_sensitive(False)
 
-		if 'text' in con.mood:
-			self.entry.set_text(con.mood['text'])
-
 		self.xml.signal_autoconnect(self)
 		self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
 		self.window.show_all()
@@ -528,25 +522,29 @@
 	def on_ok_button_clicked(self, widget):
 		'''Return mood and messsage (None if no mood selected)'''
 		message = self.entry.get_text().decode('utf-8')
-		if self.mood is None:
-			pep.user_send_mood(self.account, '')
-		else:
-			pep.user_send_mood(self.account, self.mood, message)
+		self.on_response(self.mood, message)
+#		if self.mood is None:
+#			pep.user_send_mood(self.account, '')
+#		else:
+#			pep.user_send_mood(self.account, self.mood, message)
 		self.window.destroy()
 
 	def on_cancel_button_clicked(self, widget):
 		self.window.destroy()
 
 class ChangeStatusMessageDialog:
-	def __init__(self, on_response, show=None):
+	def __init__(self, on_response, show=None, pep_dict=None):
 		self.show = show
+		self.pep_dict = pep_dict
 		self.on_response = on_response
 		self.xml = gtkgui_helpers.get_glade('change_status_message_dialog.glade')
 		self.window = self.xml.get_widget('change_status_message_dialog')
 		self.window.set_transient_for(gajim.interface.roster.window)
+		msg = None
 		if show:
 			uf_show = helpers.get_uf_show(show)
 			self.title_text = _('%s Status Message') % uf_show
+			msg = gajim.config.get('last_status_msg_' + show)
 		else:
 			self.title_text = _('Status Message')
 		self.window.set_title(self.title_text)
@@ -555,9 +553,6 @@
 		self.message_buffer = message_textview.get_buffer()
 		self.message_buffer.connect('changed',
 			self.toggle_sensitiviy_of_save_as_preset)
-		msg = None
-		if show:
-			msg = gajim.config.get('last_status_msg_' + show)
 		if not msg:
 			msg = ''
 		msg = helpers.from_one_line(msg)
@@ -571,8 +566,8 @@
 			self.preset_messages_dict[msg_name] = msg_text
 		sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict)
 
-		self.countdown_time = gajim.config.get('change_status_window_timeout')
-		self.countdown_left = self.countdown_time
+		countdown_time = gajim.config.get('change_status_window_timeout')
+		self.countdown_left = countdown_time
 		self.countdown_enabled = True
 
 		self.message_liststore = gtk.ListStore(str) # msg_name
@@ -583,14 +578,63 @@
 		self.message_combobox.add_attribute(cellrenderertext, 'text', 0)
 		for msg_name in sorted_keys_list:
 			self.message_liststore.append((msg_name,))
+
+		if pep_dict:
+			self.draw_activity()
+			self.draw_mood()
+		else:
+			# remove acvtivity / mood lines
+			self.xml.get_widget('activity_label').set_no_show_all(True)
+			self.xml.get_widget('activity_button').set_no_show_all(True)
+			self.xml.get_widget('mood_label').set_no_show_all(True)
+			self.xml.get_widget('mood_button').set_no_show_all(True)
+			self.xml.get_widget('activity_label').hide()
+			self.xml.get_widget('activity_button').hide()
+			self.xml.get_widget('mood_label').hide()
+			self.xml.get_widget('mood_button').hide()
+
 		self.xml.signal_autoconnect(self)
-		if self.countdown_time > 0:
+		if countdown_time > 0:
 			self.countdown()
 			gobject.timeout_add(1000, self.countdown)
 		self.window.connect('response', self.on_dialog_response)
 		self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
 		self.window.show_all()
 
+	def draw_activity(self):
+		'''Set activity button'''
+		img = self.xml.get_widget('activity_image')
+		label = self.xml.get_widget('activity_button_label')
+		if 'activity' in self.pep_dict and self.pep_dict['activity'] in \
+		pep.ACTIVITIES:
+			if 'subactivity' in self.pep_dict and self.pep_dict['subactivity'] in \
+			pep.ACTIVITIES[self.pep_dict['activity']]:
+				img.set_from_pixbuf(gtkgui_helpers.load_activity_icon(
+					self.pep_dict['activity'], self.pep_dict['subactivity']).\
+					get_pixbuf())
+			else:
+				img.set_from_pixbuf(gtkgui_helpers.load_activity_icon(
+					self.pep_dict['activity']).get_pixbuf())
+#			gtk.Tooltips().set_tip(item, pep.ACTIVITIES[category]['category'])
+			if self.pep_dict['activity_text']:
+				label.set_text(self.pep_dict['activity_text'])
+		else:
+			img.set_from_pixbuf(None)
+			label.set_text('')
+
+	def draw_mood(self):
+		'''Set mood button'''
+		img = self.xml.get_widget('mood_image')
+		label = self.xml.get_widget('mood_button_label')
+		if self.pep_dict['mood'] in pep.MOODS:
+			img.set_from_pixbuf(gtkgui_helpers.load_mood_icon(
+				self.pep_dict['mood']).get_pixbuf())
+			if self.pep_dict['mood_text']:
+				label.set_text(self.pep_dict['mood_text'])
+		else:
+			img.set_from_pixbuf(None)
+			label.set_text('')
+
 	def countdown(self):
 		if self.countdown_enabled:
 			if self.countdown_left <= 0:
@@ -618,7 +662,7 @@
 		else:
 			message = None # user pressed Cancel button or X wm button
 		self.window.destroy()
-		self.on_response(message)
+		self.on_response(message, self.pep_dict)
 
 	def on_message_combobox_changed(self, widget):
 		self.countdown_enabled = False
@@ -675,6 +719,25 @@
 			_('Please type a name for this status message'), is_modal=False,
 			ok_handler=on_ok)
 
+	def on_activity_button_clicked(self, widget):
+		self.countdown_enabled = False
+		def on_response(activity, subactivity, text):
+			self.pep_dict['activity'] = activity
+			self.pep_dict['subactivity'] = subactivity
+			self.pep_dict['activity_text'] = text
+			self.draw_activity()
+		ChangeActivityDialog(on_response, self.pep_dict['activity'],
+			self.pep_dict['subactivity'], self.pep_dict['activity_text'])
+
+	def on_mood_button_clicked(self, widget):
+		self.countdown_enabled = False
+		def on_response(mood, text):
+			self.pep_dict['mood'] = mood
+			self.pep_dict['mood_text'] = text
+			self.draw_mood()
+		ChangeMoodDialog(on_response, self.pep_dict['mood'],
+			self.pep_dict['mood_text'])
+
 class AddNewContactWindow:
 	'''Class for AddNewContactWindow'''
 	uid_labels = {'jabber': _('Jabber ID:'),

Modified: trunk/src/gajim.py
===================================================================
--- trunk/src/gajim.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/gajim.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -3014,13 +3014,18 @@
 					shows[show] = [a]
 				else:
 					shows[show].append(a)
-		def on_message(message):
+		def on_message(message, pep_dict):
 			if message is None:
 				return
 			for a in shows[show]:
 				self.roster.send_status(a, show, message)
+				self.roster.send_pep(a, pep_dict)
 		for show in shows:
-			message = self.roster.get_status_message(show, on_message)
+			if len(shows[show]) == 1:
+				pep_dict = helpers.get_pep_dict(shows[show][0])
+			else:
+				pep_dict = helpers.get_global_pep()
+			message = self.roster.get_status_message(show, pep_dict, on_message)
 		return False
 
 	def show_systray(self):

Modified: trunk/src/roster_window.py
===================================================================
--- trunk/src/roster_window.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/roster_window.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -1932,6 +1932,37 @@
 
 		self.send_status_continue(account, status, txt, auto, to)
 
+	def send_pep(self, account, pep_dict=None):
+		'''Sends pep information (activity, mood)'''
+		if not pep_dict:
+			return
+		# activity
+		if 'activity' in pep_dict and pep_dict['activity'] in pep.ACTIVITIES:
+			activity = pep_dict['activity']
+			if 'subactivity' in pep_dict and \
+			pep_dict['subactivity'] in pep.ACTIVITIES[activity]:
+				subactivity = pep_dict['subactivity']
+			else:
+				subactivity = 'other'
+			if 'activity_text' in pep_dict:
+				activity_text = pep_dict['activity_text']
+			else:
+				activity_text = ''
+			pep.user_send_activity(account, activity, subactivity, activity_text)
+		else:
+			pep.user_send_activity(account, '')
+
+		# mood
+		if 'mood' in pep_dict and pep_dict['mood'] in pep.MOODS:
+			mood = pep_dict['mood']
+			if 'mood_text' in pep_dict:
+				mood_text = pep_dict['mood_text']
+			else:
+				mood_text = ''
+			pep.user_send_mood(account, mood, mood_text)
+		else:
+			pep.user_send_mood(account, '')
+
 	def send_status_continue(self, account, status, txt, auto, to):
 		if gajim.account_is_connected(account) and not to:
 			if status == 'online' and gajim.interface.sleeper.getState() != \
@@ -2060,34 +2091,37 @@
 		if sys.platform == 'darwin':
 			self.make_menu(force=True)
 
-	def get_status_message(self, show, on_response, always_ask=False):
+	def get_status_message(self, show, pep_dict, on_response, always_ask=False):
 		''' get the status message by:
 		1/ looking in default status message
 		2/ asking to user if needed depending on ask_on(ff)line_status and
 			always_ask
+		pep_dict can be None to hide pep things from status message or a dict
 		'''
 		if show in gajim.config.get_per('defaultstatusmsg'):
 			if gajim.config.get_per('defaultstatusmsg', show, 'enabled'):
 				on_response(gajim.config.get_per('defaultstatusmsg', show,
-					'message'))
+					'message'), pep_dict)
 				return
 		if not always_ask and ((show == 'online' and not gajim.config.get(
 		'ask_online_status')) or (show in ('offline', 'invisible') and not \
 		gajim.config.get('ask_offline_status'))):
-			on_response('')
+			on_response('', pep_dict)
 			return
 
-		dlg = dialogs.ChangeStatusMessageDialog(on_response, show)
+		dlg = dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict)
 		dlg.window.present() # show it on current workspace
 
 	def change_status(self, widget, account, status):
 		def change(account, status):
-			def on_response(message):
+			def on_response(message, pep_dict):
 				if message is None:
 					# user pressed Cancel to change status message dialog
 					return
 				self.send_status(account, status, message)
-			self.get_status_message(status, on_response)
+				self.send_pep(account, pep_dict)
+			pep_dict = helpers.get_pep_dict(account)
+			self.get_status_message(status, pep_dict, on_response)
 
 		if status == 'invisible' and self.connected_rooms(account):
 			dialogs.ConfirmationDialog(
@@ -2217,7 +2251,7 @@
 				get_msg = True
 				break
 
-		def on_continue2(message):
+		def on_continue2(message, pep_dict):
 			self.quit_on_next_offline = 0
 			accounts_to_disconnect = []
 			for acct in accounts:
@@ -2227,11 +2261,12 @@
 
 			for acct in accounts_to_disconnect:
 				self.send_status(acct, 'offline', message)
+				self.send_pep(acct, pep_dict)
 
 			if not self.quit_on_next_offline:
 				self.quit_gtkgui_interface()
 
-		def on_continue(message):
+		def on_continue(message, pep_dict):
 			if message is None:
 				# user pressed Cancel to change status message dialog
 				return
@@ -2259,12 +2294,12 @@
 				dialogs.ConfirmationDialog(_('You have unread messages'),
 					_('Messages will only be available for reading them later if you'
 					' have history enabled and contact is in your roster.'),
-					on_response_ok=(on_continue2, message))
+					on_response_ok=(on_continue2, message, pep_dict))
 				return
-			on_continue2(message)
+			on_continue2(message, pep_dict)
 
 		if get_msg:
-			self.get_status_message('offline', on_continue)
+			self.get_status_message('offline', None, on_continue)
 		else:
 			on_continue('')
 
@@ -2514,7 +2549,7 @@
 	def on_block(self, widget, list_, group=None):
 		''' When clicked on the 'block' button in context menu.
 		list_ is a list of (contact, account)'''
-		def on_continue(msg):
+		def on_continue(msg, pep_dict):
 			if msg is None:
 				# user pressed Cancel to change status message dialog
 				return
@@ -2556,7 +2591,7 @@
 					connection.set_default_list('block')
 				connection.get_privacy_list('block')
 
-		self.get_status_message('offline', on_continue)
+		self.get_status_message('offline', None, on_continue)
 
 	def on_unblock(self, widget, list_, group=None):
 		''' When clicked on the 'unblock' button in context menu. '''
@@ -2907,18 +2942,15 @@
 		if url:
 			helpers.launch_browser_mailer('url', url)
 
-	def on_change_activity_activate(self, widget, account):
-		dialogs.ChangeActivityDialog(account)
-
-	def on_change_mood_activate(self, widget, account):
-		dialogs.ChangeMoodDialog(account)
-
 	def on_change_status_message_activate(self, widget, account):
 		show = gajim.SHOW_LIST[gajim.connections[account].connected]
-		def on_response(message):
-			if message is not None: # None is if user pressed Cancel
-				self.send_status(account, show, message)
-		dialogs.ChangeStatusMessageDialog(on_response, show)
+		pep_dict = helpers.get_pep_dict(account)
+		def on_response(message, pep_dict):
+			if message is None: # None is if user pressed Cancel
+				return
+			self.send_status(account, show, message)
+			self.send_pep(account, pep_dict)
+		dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict)
 
 	def on_add_to_roster(self, widget, contact, account):
 		dialogs.AddNewContactWindow(account, contact.jid, contact.name)
@@ -3023,7 +3055,8 @@
 				show = helpers.get_global_show()
 				if show == 'offline':
 					return True
-				def on_response(message):
+				pep_dict = helpers.get_global_pep()
+				def on_response(message, pep_dict):
 					if message is None:
 						return True
 					for acct in gajim.connections:
@@ -3033,7 +3066,8 @@
 						current_show = gajim.SHOW_LIST[gajim.connections[acct].\
 							connected]
 						self.send_status(acct, current_show, message)
-				dialogs.ChangeStatusMessageDialog(on_response, show)
+						self.send_pep(acct, pep_dict)
+				dialogs.ChangeStatusMessageDialog(on_response, show, pep_dict)
 			return True
 
 		elif event.button == 1: # Left click
@@ -3135,7 +3169,7 @@
 	def on_send_custom_status(self, widget, contact_list, show, group=None):
 		'''send custom status'''
 		# contact_list has only one element except if group != None
-		def on_response(message):
+		def on_response(message, pep_dict):
 			if message is None: # None if user pressed Cancel
 				return
 			account_list = []
@@ -3168,7 +3202,7 @@
 					jid += '/' + contact.resource
 				self.send_status(account, show, message, to=jid)
 
-		self.get_status_message(show, on_response, always_ask=True)
+		self.get_status_message(show, None, on_response, always_ask=True)
 
 	def on_status_combobox_changed(self, widget):
 		'''When we change our status via the combobox'''
@@ -3192,7 +3226,8 @@
 			# 'Change status message' selected:
 			# do not change show, just show change status dialog
 			status = model[self.previous_status_combobox_active][2].decode('utf-8')
-			def on_response(message):
+			pep_dict = helpers.get_global_pep()
+			def on_response(message, pep_dict):
 				if message is not None: # None if user pressed Cancel
 					for account in accounts:
 						if not gajim.config.get_per('accounts', account,
@@ -3201,11 +3236,12 @@
 						current_show = gajim.SHOW_LIST[
 							gajim.connections[account].connected]
 						self.send_status(account, current_show, message)
+						self.send_pep(account, pep_dict)
 				self.combobox_callback_active = False
 				self.status_combobox.set_active(
 					self.previous_status_combobox_active)
 				self.combobox_callback_active = True
-			dialogs.ChangeStatusMessageDialog(on_response, status)
+			dialogs.ChangeStatusMessageDialog(on_response, status, pep_dict)
 			return
 		# we are about to change show, so save this new show so in case
 		# after user chooses "Change status message" menuitem
@@ -3213,7 +3249,7 @@
 		self.previous_status_combobox_active = active
 		connected_accounts = gajim.get_number_of_connected_accounts()
 
-		def on_continue(message):
+		def on_continue(message, pep_dict):
 			if message is None:
 				# user pressed Cancel to change status message dialog
 				self.update_status_combobox()
@@ -3236,6 +3272,7 @@
 				if not global_sync_connected_accounts > 0 or \
 				gajim.connections[account].connected > 0:
 					self.send_status(account, status, message)
+					self.send_pep(account, pep_dict)
 			self.update_status_combobox()
 
 		if status == 'invisible':
@@ -3251,7 +3288,7 @@
 						break
 			if bug_user:
 				def on_ok():
-					self.get_status_message(status, on_continue)
+					self.get_status_message(status, None, on_continue)
 
 				def on_cancel():
 					self.update_status_combobox()
@@ -3264,7 +3301,8 @@
 					on_response_cancel=on_cancel)
 				return
 
-		self.get_status_message(status, on_continue)
+		pep_dict = helpers.get_global_pep()
+		self.get_status_message(status, pep_dict, on_continue)
 
 	def on_preferences_menuitem_activate(self, widget):
 		if 'preferences' in gajim.interface.instances:
@@ -4907,14 +4945,6 @@
 				else:
 					item.set_active(have_tune)
 					item.connect('toggled', self.on_publish_tune_toggled, account)
-				item = gtk.CheckMenuItem(_('Mood'))
-				pep_submenu.append(item)
-				item.set_active(len(gajim.connections[account].mood) > 0)
-				item.connect('activate', self.on_change_mood_activate, account)
-				item = gtk.CheckMenuItem(_('Activity'))
-				pep_submenu.append(item)
-				item.set_active(len(gajim.connections[account].activity) > 0)
-				item.connect('activate', self.on_change_activity_activate, account)
 
 				pep_config = gtk.ImageMenuItem(_('Configure Services...'))
 				item = gtk.SeparatorMenuItem()

Modified: trunk/src/systray.py
===================================================================
--- trunk/src/systray.py	2009-04-12 10:14:27 UTC (rev 11224)
+++ trunk/src/systray.py	2009-04-12 18:13:37 UTC (rev 11225)
@@ -38,6 +38,7 @@
 
 from common import gajim
 from common import helpers
+from common import pep
 
 HAS_SYSTRAY_CAPABILITIES = True
 
@@ -385,7 +386,7 @@
 		model = gajim.interface.roster.status_combobox.get_model()
 		active = gajim.interface.roster.status_combobox.get_active()
 		status = model[active][2].decode('utf-8')
-		def on_response(message):
+		def on_response(message, pep_dict):
 			if message is None: # None if user press Cancel
 				return
 			accounts = gajim.connections.keys()
@@ -395,6 +396,7 @@
 					continue
 				show = gajim.SHOW_LIST[gajim.connections[acct].connected]
 				gajim.interface.roster.send_status(acct, show, message)
+				gajim.interface.roster.send_pep(acct, pep_dict)
 		dlg = dialogs.ChangeStatusMessageDialog(on_response, status)
 		dlg.window.present()
 



More information about the Commits mailing list