add an option to override incoming message type. fixes #2804

This commit is contained in:
Yann Leboulanger 2007-01-05 20:38:36 +00:00
parent bf35cab4fc
commit 7433835994
4 changed files with 92 additions and 16 deletions

View file

@ -485,6 +485,61 @@ Per type</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox3024">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label387">
<property name="visible">True</property>
<property name="label" translatable="yes">Treat incoming and single messages as:</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.5</property>
<property name="yalign">0.5</property>
<property name="xpad">1</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="treat_incoming_messages_combobox">
<property name="visible">True</property>
<property name="items" translatable="yes">Determined by sender
Chat message
Single message</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_treat_incoming_messages_combobox_changed" last_modification_time="Fri, 05 Jan 2007 20:16:54 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2947">
<property name="visible">True</property>

View file

@ -38,6 +38,7 @@ opt_str = [ 'string', 0 ]
opt_bool = [ 'boolean', 0 ]
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
opt_one_window_types = ['never', 'always', 'peracct', 'pertype']
opt_treat_incoming_messages = ['', 'chat', 'normal']
class Config:
@ -223,6 +224,7 @@ class Config:
'enable_negative_priority': [ opt_bool, False, _('If True, you will be able to set a negative priority to your account in account modification window. BE CAREFUL, when you are logged in with a negative priority, you will NOT receive any message from your server.')],
'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')],
'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')],
'treat_incoming_messages': [ opt_str, '', _('Can be empty, \'chat\' or \'normal\'. If not empty, treat all incoming messages as if they were of this type')],
}
__options_per_key = {

View file

@ -1446,6 +1446,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
subject = subject)
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
tim))
return
elif mtype == 'groupchat':
has_timestamp = False
if msg.timestamp:
@ -1459,9 +1460,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if not self.last_history_line.has_key(jid):
return
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
if self.name not in no_log_for and not int(float(time.mktime(tim))) <= \
self.last_history_line[jid] and msgtxt:
if self.name not in no_log_for and not int(float(time.mktime(tim)))\
<= self.last_history_line[jid] and msgtxt:
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
return
elif mtype == 'chat': # it's type 'chat'
if not msg.getTag('body') and chatstate is None: #no <body>
return
@ -1469,8 +1471,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
no_log_for and msgtxt:
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
subject = subject)
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, subject,
chatstate, msg_id, composing_jep, user_nick, msghtml))
else: # it's single message
if invite is not None:
item = invite.getTag('invite')
@ -1483,7 +1483,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
if self.name not in no_log_for and jid not in no_log_for and msgtxt:
gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim,
subject = subject)
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, 'normal',
mtype = 'normal'
treat_as = gajim.config.get('treat_incoming_messages')
if treat_as:
mtype = treat_as
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype,
subject, chatstate, msg_id, composing_jep, user_nick, msghtml))
# END messageCB

View file

@ -84,6 +84,8 @@ class PreferencesWindow:
self.notebook = self.xml.get_widget('preferences_notebook')
self.one_window_type_combobox =\
self.xml.get_widget('one_window_type_combobox')
self.treat_incoming_messages_combobox =\
self.xml.get_widget('treat_incoming_messages_combobox')
#FIXME: remove when ANC will be implemented
w = self.xml.get_widget('hbox3020')
@ -182,6 +184,14 @@ class PreferencesWindow:
else:
self.one_window_type_combobox.set_active(0)
# Set default for treat incoming messages
choices = common.config.opt_treat_incoming_messages
type = gajim.config.get('treat_incoming_messages')
if type in choices:
self.treat_incoming_messages_combobox.set_active(choices.index(type))
else:
self.treat_incoming_messages_combobox.set_active(0)
# Use transports iconsets
st = gajim.config.get('use_transports_iconsets')
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
@ -650,6 +660,11 @@ class PreferencesWindow:
gajim.interface.save_config()
gajim.interface.msg_win_mgr.reconfig()
def on_treat_incoming_messages_combobox_changed(self, widget):
active = widget.get_active()
config_type = common.config.opt_treat_incoming_messages[active]
gajim.config.set('treat_incoming_messages', config_type)
def apply_speller(self):
for acct in gajim.connections:
for ctrl in gajim.interface.msg_win_mgr.controls():