save pep things (activity and mood) in preset status messages.
This commit is contained in:
		
							parent
							
								
									ad125ecaac
								
							
						
					
					
						commit
						44e0ec913a
					
				
					 6 changed files with 75 additions and 34 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
AC_INIT([Gajim - A Jabber Instant Messager],
 | 
			
		||||
		[0.12.1.2-svn],[http://trac.gajim.org/],[gajim])
 | 
			
		||||
		[0.12.1.3-svn],[http://trac.gajim.org/],[gajim])
 | 
			
		||||
AC_PREREQ([2.59])
 | 
			
		||||
 | 
			
		||||
AC_CONFIG_HEADER(config.h)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -350,6 +350,11 @@ class Config:
 | 
			
		|||
		}, {}),
 | 
			
		||||
		'statusmsg': ({
 | 
			
		||||
			'message': [ opt_str, '' ],
 | 
			
		||||
			'activity': [ opt_str, '' ],
 | 
			
		||||
			'subactivity': [ opt_str, '' ],
 | 
			
		||||
			'activity_text': [ opt_str, '' ],
 | 
			
		||||
			'mood': [ opt_str, '' ],
 | 
			
		||||
			'mood_text': [ opt_str, '' ],
 | 
			
		||||
		}, {}),
 | 
			
		||||
		'defaultstatusmsg': ({
 | 
			
		||||
			'enabled': [ opt_bool, False ],
 | 
			
		||||
| 
						 | 
				
			
			@ -430,13 +435,13 @@ class Config:
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	statusmsg_default = {
 | 
			
		||||
		_('Sleeping'): 'ZZZZzzzzzZZZZZ',
 | 
			
		||||
		_('Back soon'): _('Back in some minutes.'),
 | 
			
		||||
		_('Eating'): _("I'm eating, so leave me a message."),
 | 
			
		||||
		_('Movie'): _("I'm watching a movie."),
 | 
			
		||||
		_('Working'): _("I'm working."),
 | 
			
		||||
		_('Phone'): _("I'm on the phone."),
 | 
			
		||||
		_('Out'): _("I'm out enjoying life."),
 | 
			
		||||
		_('Sleeping'): [ 'ZZZZzzzzzZZZZZ', 'inactive', 'sleeping', '', 'sleepy', '' ],
 | 
			
		||||
		_('Back soon'): [ _('Back in some minutes.'), '', '', '', '', '' ],
 | 
			
		||||
		_('Eating'): [ _("I'm eating, so leave me a message."), 'eating', 'other', '', '', '' ],
 | 
			
		||||
		_('Movie'): [ _("I'm watching a movie."), 'relaxing', 'watching_a_movie', '', '', '' ],
 | 
			
		||||
		_('Working'): [ _("I'm working."), 'working', 'other', '', '', '' ],
 | 
			
		||||
		_('Phone'): [ _("I'm on the phone."), 'talking', 'on_the_phone', '', '', '' ],
 | 
			
		||||
		_('Out'): [ _("I'm out enjoying life."), 'relaxing', 'going_out', '', '', '' ],
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defaultstatusmsg_default = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ docdir = '../'
 | 
			
		|||
datadir = '../'
 | 
			
		||||
localedir = '../po'
 | 
			
		||||
 | 
			
		||||
version = '0.12.1.2-svn'
 | 
			
		||||
version = '0.12.1.3-svn'
 | 
			
		||||
 | 
			
		||||
import sys, os.path
 | 
			
		||||
for base in ('.', 'common'):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -191,6 +191,8 @@ class OptionsParser:
 | 
			
		|||
			self.update_config_to_01211()
 | 
			
		||||
		if old < [0, 12, 1, 2] and new >= [0, 12, 1, 2]:
 | 
			
		||||
			self.update_config_to_01212()
 | 
			
		||||
		if old < [0, 12, 1, 3] and new >= [0, 12, 1, 3]:
 | 
			
		||||
			self.update_config_to_01213()
 | 
			
		||||
 | 
			
		||||
		gajim.logger.init_vars()
 | 
			
		||||
		gajim.config.set('version', new_version)
 | 
			
		||||
| 
						 | 
				
			
			@ -629,4 +631,20 @@ class OptionsParser:
 | 
			
		|||
					gajim.config.set_per('accounts', account, opt, val)
 | 
			
		||||
		gajim.config.set('version', '0.12.1.2')
 | 
			
		||||
 | 
			
		||||
	def update_config_to_01213(self):
 | 
			
		||||
		msgs = gajim.config.statusmsg_default
 | 
			
		||||
		for msg_name in gajim.config.get_per('statusmsg'):
 | 
			
		||||
			if msg_name in msgs:
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'activity',
 | 
			
		||||
					msgs[msg_name][1])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'subactivity',
 | 
			
		||||
					msgs[msg_name][2])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'activity_text',
 | 
			
		||||
					msgs[msg_name][3])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'mood',
 | 
			
		||||
					msgs[msg_name][4])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'mood_text',
 | 
			
		||||
					msgs[msg_name][5])
 | 
			
		||||
		gajim.config.set('version', '0.12.1.3')
 | 
			
		||||
 | 
			
		||||
# vim: se ts=3:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -435,12 +435,6 @@ class ChangeActivityDialog:
 | 
			
		|||
				self.entry.get_text().decode('utf-8'))
 | 
			
		||||
		else:
 | 
			
		||||
			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):
 | 
			
		||||
| 
						 | 
				
			
			@ -523,10 +517,6 @@ class ChangeMoodDialog:
 | 
			
		|||
		'''Return mood and messsage (None if no mood selected)'''
 | 
			
		||||
		message = self.entry.get_text().decode('utf-8')
 | 
			
		||||
		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):
 | 
			
		||||
| 
						 | 
				
			
			@ -559,11 +549,14 @@ class ChangeStatusMessageDialog:
 | 
			
		|||
		self.message_buffer.set_text(msg)
 | 
			
		||||
 | 
			
		||||
		# have an empty string selectable, so user can clear msg
 | 
			
		||||
		self.preset_messages_dict = {'': ''}
 | 
			
		||||
		self.preset_messages_dict = {'': ['', '', '', '', '', '']}
 | 
			
		||||
		for msg_name in gajim.config.get_per('statusmsg'):
 | 
			
		||||
			msg_text = gajim.config.get_per('statusmsg', msg_name, 'message')
 | 
			
		||||
			msg_text = helpers.from_one_line(msg_text)
 | 
			
		||||
			self.preset_messages_dict[msg_name] = msg_text
 | 
			
		||||
			opts = []
 | 
			
		||||
			for opt in ['message', 'activity', 'subactivity', 'activity_text',
 | 
			
		||||
			'mood', 'mood_text']:
 | 
			
		||||
				opts.append(gajim.config.get_per('statusmsg', msg_name, opt))
 | 
			
		||||
			opts[0] = helpers.from_one_line(opts[0])
 | 
			
		||||
			self.preset_messages_dict[msg_name] = opts
 | 
			
		||||
		sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict)
 | 
			
		||||
 | 
			
		||||
		countdown_time = gajim.config.get('change_status_window_timeout')
 | 
			
		||||
| 
						 | 
				
			
			@ -671,7 +664,14 @@ class ChangeStatusMessageDialog:
 | 
			
		|||
		if active < 0:
 | 
			
		||||
			return None
 | 
			
		||||
		name = model[active][0].decode('utf-8')
 | 
			
		||||
		self.message_buffer.set_text(self.preset_messages_dict[name])
 | 
			
		||||
		self.message_buffer.set_text(self.preset_messages_dict[name][0])
 | 
			
		||||
		self.pep_dict['activity'] = self.preset_messages_dict[name][1]
 | 
			
		||||
		self.pep_dict['subactivity'] = self.preset_messages_dict[name][2]
 | 
			
		||||
		self.pep_dict['activity_text'] = self.preset_messages_dict[name][3]
 | 
			
		||||
		self.pep_dict['mood'] = self.preset_messages_dict[name][4]
 | 
			
		||||
		self.pep_dict['mood_text'] = self.preset_messages_dict[name][5]
 | 
			
		||||
		self.draw_activity()
 | 
			
		||||
		self.draw_mood()
 | 
			
		||||
 | 
			
		||||
	def on_change_status_message_dialog_key_press_event(self, widget, event):
 | 
			
		||||
		self.countdown_enabled = False
 | 
			
		||||
| 
						 | 
				
			
			@ -700,21 +700,32 @@ class ChangeStatusMessageDialog:
 | 
			
		|||
			if not msg_name: # msg_name was ''
 | 
			
		||||
				msg_name = msg_text_1l.decode('utf-8')
 | 
			
		||||
 | 
			
		||||
			if msg_name in self.preset_messages_dict:
 | 
			
		||||
			def on_ok2():
 | 
			
		||||
					self.preset_messages_dict[msg_name] = msg_text
 | 
			
		||||
					gajim.config.set_per('statusmsg', msg_name, 'message',
 | 
			
		||||
						msg_text_1l)
 | 
			
		||||
				self.preset_messages_dict[msg_name] = [msg_text, self.pep_dict.get(
 | 
			
		||||
					'activity'), self.pep_dict.get('subactivity'), self.pep_dict.get(
 | 
			
		||||
					'activity_text'), self.pep_dict.get('mood'), self.pep_dict.get(
 | 
			
		||||
					'mood_text')]
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l)
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'activity',
 | 
			
		||||
					self.pep_dict.get('activity'))
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'subactivity',
 | 
			
		||||
					self.pep_dict.get('subactivity'))
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'activity_text',
 | 
			
		||||
					self.pep_dict.get('activity_text'))
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'mood',
 | 
			
		||||
					self.pep_dict.get('mood'))
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg_name, 'mood_text',
 | 
			
		||||
					self.pep_dict.get('mood_text'))
 | 
			
		||||
			if msg_name in self.preset_messages_dict:
 | 
			
		||||
				ConfirmationDialog(_('Overwrite Status Message?'),
 | 
			
		||||
					_('This name is already used. Do you want to overwrite this '
 | 
			
		||||
					'status message?'), on_response_ok=on_ok2)
 | 
			
		||||
				return
 | 
			
		||||
			self.preset_messages_dict[msg_name] = msg_text
 | 
			
		||||
			iter_ = self.message_liststore.append((msg_name,))
 | 
			
		||||
			gajim.config.add_per('statusmsg', msg_name)
 | 
			
		||||
			on_ok2()
 | 
			
		||||
			iter_ = self.message_liststore.append((msg_name,))
 | 
			
		||||
			# select in combobox the one we just saved
 | 
			
		||||
			self.message_combobox.set_active_iter(iter_)
 | 
			
		||||
			gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l)
 | 
			
		||||
		InputDialog(_('Save as Preset Status Message'),
 | 
			
		||||
			_('Please type a name for this status message'), is_modal=False,
 | 
			
		||||
			ok_handler=on_ok)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								src/gajim.py
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/gajim.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -3264,10 +3264,17 @@ class Interface:
 | 
			
		|||
			pass
 | 
			
		||||
		# add default status messages if there is not in the config file
 | 
			
		||||
		if len(gajim.config.get_per('statusmsg')) == 0:
 | 
			
		||||
			for msg in gajim.config.statusmsg_default:
 | 
			
		||||
			default = gajim.config.statusmsg_default
 | 
			
		||||
			for msg in default:
 | 
			
		||||
				gajim.config.add_per('statusmsg', msg)
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'message',
 | 
			
		||||
					gajim.config.statusmsg_default[msg])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'message', default[msg][0])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'activity', default[msg][1])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'subactivity',
 | 
			
		||||
					default[msg][2])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'activity_text',
 | 
			
		||||
					default[msg][3])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'mood', default[msg][4])
 | 
			
		||||
				gajim.config.set_per('statusmsg', msg, 'mood_text', default[msg][5])
 | 
			
		||||
		#add default themes if there is not in the config file
 | 
			
		||||
		theme = gajim.config.get('roster_theme')
 | 
			
		||||
		if not theme in gajim.config.get_per('themes'):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue