Setting mood now supported (crappy).
This commit is contained in:
		
							parent
							
								
									c02eb73bd0
								
							
						
					
					
						commit
						ab26867fb2
					
				
					 5 changed files with 395 additions and 4 deletions
				
			
		|  | @ -25,6 +25,26 @@ | |||
|     </widget> | ||||
|   </child> | ||||
| 
 | ||||
|   <child> | ||||
|     <widget class="GtkImageMenuItem" id="pep_menuitem"> | ||||
|       <property name="visible">True</property> | ||||
|       <property name="label" translatable="yes">_Personal Events</property> | ||||
|       <property name="use_underline">True</property> | ||||
| 
 | ||||
|       <child internal-child="image"> | ||||
| 	<widget class="GtkImage" id="image1235"> | ||||
| 	  <property name="visible">True</property> | ||||
| 	  <property name="stock">gtk-home</property> | ||||
| 	  <property name="icon_size">1</property> | ||||
| 	  <property name="xalign">0.5</property> | ||||
| 	  <property name="yalign">0.5</property> | ||||
| 	  <property name="xpad">0</property> | ||||
| 	  <property name="ypad">0</property> | ||||
| 	</widget> | ||||
|       </child> | ||||
|     </widget> | ||||
|   </child> | ||||
| 
 | ||||
|   <child> | ||||
|     <widget class="GtkImageMenuItem" id="join_group_chat_menuitem"> | ||||
|       <property name="visible">True</property> | ||||
|  |  | |||
							
								
								
									
										312
									
								
								data/glade/change_mood_dialog.glade
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										312
									
								
								data/glade/change_mood_dialog.glade
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,312 @@ | |||
| <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> | ||||
| <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> | ||||
| 
 | ||||
| <glade-interface> | ||||
| 
 | ||||
| <widget class="GtkDialog" id="change_mood_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">False</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">False</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">False</property> | ||||
| 	      <property name="label" translatable="yes"><b>Type your new status message</b></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> | ||||
| 
 | ||||
| </glade-interface> | ||||
|  | @ -1,9 +1,8 @@ | |||
| from common import gajim | ||||
| #from common import helpers | ||||
| from common import gajim, xmpp | ||||
| 
 | ||||
| def user_mood(items, name, jid): | ||||
| 	#FIXME: text deletion | ||||
| 	(user, resource) = gajim.get_room_and_nick_from_fjid(jid) | ||||
| 	print 'User: %s, Resource: %s' % (user, resource) | ||||
| 	contacts = gajim.contacts.get_contact(name, user, resource=resource) | ||||
| 	for item in items.getTags('item'): | ||||
| 		child = item.getTag('mood') | ||||
|  | @ -23,6 +22,7 @@ def user_geoloc(items, name, jid): | |||
| 	pass | ||||
| 
 | ||||
| def user_activity(items, name, jid): | ||||
| 	#FIXME: text deletion | ||||
| 	(user, resource) = gajim.get_room_and_nick_from_fjid(jid) | ||||
| 	contacts = gajim.contacts.get_contact(name, user, resource=resource) | ||||
| 	for item in items.getTags('item'): | ||||
|  | @ -38,3 +38,12 @@ def user_activity(items, name, jid): | |||
| 				else: | ||||
| 					for contact in contacts: | ||||
| 						contact.activity['text'] = ch.getData() | ||||
| 
 | ||||
| def user_send_mood(account, mood, message = ''): | ||||
| 	item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD}) | ||||
| 	item.addChild(mood) | ||||
| 	if message != '': | ||||
| 		i = item.addChild('text') | ||||
| 		i.addData(message) | ||||
| 
 | ||||
| 	gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0') | ||||
|  |  | |||
|  | @ -307,6 +307,33 @@ class ChooseGPGKeyDialog: | |||
| 				self.keys_treeview.set_cursor(path) | ||||
| 
 | ||||
| 
 | ||||
| class ChangeMoodDialog: | ||||
| 	def __init__(self): | ||||
| 		self.xml = gtkgui_helpers.get_glade('change_mood_dialog.glade') | ||||
| 		self.window = self.xml.get_widget('change_mood_dialog') | ||||
| 		self.window.set_transient_for(gajim.interface.roster.window) | ||||
| 		self.window.set_title('Mood') | ||||
| 
 | ||||
| 		message_textview = self.xml.get_widget('message_textview') | ||||
| 		self.message_buffer = message_textview.get_buffer() | ||||
| 		#self.message_buffer.connect('changed', | ||||
| 		#	self.toggle_sensitiviy_of_save_as_preset) | ||||
| 
 | ||||
| 	def run(self): | ||||
| 		'''Wait for OK or Cancel button to be pressed and return mood | ||||
| 		and messsage (None if users pressed Cancel or x button of WM''' | ||||
| 		rep = self.window.run() | ||||
| 		mood = None  | ||||
| 		message = None | ||||
| 		if rep == gtk.RESPONSE_OK: | ||||
| 			beg, end = self.message_buffer.get_bounds() | ||||
| 			message = self.message_buffer.get_text(beg, end).decode('utf-8')\ | ||||
| 				.strip() | ||||
| 			msg = helpers.to_one_line(message) | ||||
| 		self.window.destroy() | ||||
| 		return (mood, message) | ||||
| 
 | ||||
| 
 | ||||
| class ChangeStatusMessageDialog: | ||||
| 	def __init__(self, show = None): | ||||
| 		self.show = show | ||||
|  |  | |||
|  | @ -39,6 +39,7 @@ from common import helpers | |||
| from common import passwords | ||||
| from common.exceptions import GajimGeneralException | ||||
| from common import i18n | ||||
| from common import pep | ||||
| 
 | ||||
| from message_window import MessageWindowMgr | ||||
| from chat_control import ChatControl | ||||
|  | @ -2268,6 +2269,14 @@ class RosterWindow: | |||
| 			gajim.config.get_per('accounts', account, 'name')) | ||||
| 		helpers.launch_browser_mailer('url', url) | ||||
| 
 | ||||
| 	def on_change_mood_activate(self, widget, account): | ||||
| 		dlg = dialogs.ChangeMoodDialog() | ||||
| 		(mood, message) = dlg.run() | ||||
| 		mood = 'happy' | ||||
| 		print account, mood, message | ||||
| 		if mood is not None: # None is if user pressed Cancel | ||||
| 			self.send_mood(account, mood, message) | ||||
| 
 | ||||
| 	def on_change_status_message_activate(self, widget, account): | ||||
| 		show = gajim.SHOW_LIST[gajim.connections[account].connected] | ||||
| 		dlg = dialogs.ChangeStatusMessageDialog(show) | ||||
|  | @ -2330,6 +2339,17 @@ class RosterWindow: | |||
| 			sub_menu.append(item) | ||||
| 			item.connect('activate', self.change_status, account, 'offline') | ||||
| 
 | ||||
| 			pep_menuitem = xml.get_widget('pep_menuitem') | ||||
| 			if gajim.connections[account].pep_supported: | ||||
| 				pep_submenu = gtk.Menu() | ||||
| 				pep_menuitem.set_submenu(pep_submenu) | ||||
| 				item = gtk.MenuItem('Mood') | ||||
| 				pep_submenu.append(item) | ||||
| 				item.connect('activate', self.on_change_mood_activate, account) | ||||
| 			else: | ||||
| 				pep_menuitem.set_no_show_all(True) | ||||
| 				pep_menuitem.hide() | ||||
| 
 | ||||
| 			if gajim.config.get_per('accounts', account, 'hostname') not in \ | ||||
| 			gajim.gmail_domains: | ||||
| 				open_gmail_inbox_menuitem.set_no_show_all(True) | ||||
|  | @ -2359,7 +2379,7 @@ class RosterWindow: | |||
| 			if gajim.connections[account].connected < 2: | ||||
| 				for widget in [add_contact_menuitem, service_discovery_menuitem, | ||||
| 				join_group_chat_menuitem, new_message_menuitem, | ||||
| 				execute_command_menuitem]: | ||||
| 				execute_command_menuitem, pep_menuitem]: | ||||
| 					widget.set_sensitive(False) | ||||
| 		else: | ||||
| 			xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade') | ||||
|  | @ -2722,6 +2742,9 @@ class RosterWindow: | |||
| 		if gajim.interface.systray_enabled: | ||||
| 			gajim.interface.systray.change_status('connecting') | ||||
| 
 | ||||
| 	def send_mood(self, account, mood, message): | ||||
| 		pep.user_send_mood(account, mood, message) | ||||
| 
 | ||||
| 	def send_status(self, account, status, txt, auto = False): | ||||
| 		model = self.tree.get_model() | ||||
| 		accountIter = self.get_account_iter(account) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue