add an option to override incoming message type. fixes #2804
This commit is contained in:
parent
bf35cab4fc
commit
7433835994
|
@ -485,6 +485,61 @@ Per type</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
<child>
|
||||||
<widget class="GtkHBox" id="hbox2947">
|
<widget class="GtkHBox" id="hbox2947">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -38,6 +38,7 @@ opt_str = [ 'string', 0 ]
|
||||||
opt_bool = [ 'boolean', 0 ]
|
opt_bool = [ 'boolean', 0 ]
|
||||||
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
|
opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
|
||||||
opt_one_window_types = ['never', 'always', 'peracct', 'pertype']
|
opt_one_window_types = ['never', 'always', 'peracct', 'pertype']
|
||||||
|
opt_treat_incoming_messages = ['', 'chat', 'normal']
|
||||||
|
|
||||||
class Config:
|
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.')],
|
'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.')],
|
'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.')],
|
'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 = {
|
__options_per_key = {
|
||||||
|
|
|
@ -1446,6 +1446,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
subject = subject)
|
subject = subject)
|
||||||
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
|
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
|
||||||
tim))
|
tim))
|
||||||
|
return
|
||||||
elif mtype == 'groupchat':
|
elif mtype == 'groupchat':
|
||||||
has_timestamp = False
|
has_timestamp = False
|
||||||
if msg.timestamp:
|
if msg.timestamp:
|
||||||
|
@ -1459,9 +1460,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if not self.last_history_line.has_key(jid):
|
if not self.last_history_line.has_key(jid):
|
||||||
return
|
return
|
||||||
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
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))) <= \
|
if self.name not in no_log_for and not int(float(time.mktime(tim)))\
|
||||||
self.last_history_line[jid] and msgtxt:
|
<= self.last_history_line[jid] and msgtxt:
|
||||||
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
||||||
|
return
|
||||||
elif mtype == 'chat': # it's type 'chat'
|
elif mtype == 'chat': # it's type 'chat'
|
||||||
if not msg.getTag('body') and chatstate is None: #no <body>
|
if not msg.getTag('body') and chatstate is None: #no <body>
|
||||||
return
|
return
|
||||||
|
@ -1469,8 +1471,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
no_log_for and msgtxt:
|
no_log_for and msgtxt:
|
||||||
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
|
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
|
||||||
subject = subject)
|
subject = subject)
|
||||||
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, subject,
|
|
||||||
chatstate, msg_id, composing_jep, user_nick, msghtml))
|
|
||||||
else: # it's single message
|
else: # it's single message
|
||||||
if invite is not None:
|
if invite is not None:
|
||||||
item = invite.getTag('invite')
|
item = invite.getTag('invite')
|
||||||
|
@ -1483,8 +1483,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if self.name not in no_log_for and jid not in no_log_for and msgtxt:
|
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,
|
gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim,
|
||||||
subject = subject)
|
subject = subject)
|
||||||
self.dispatch('MSG', (frm, msgtxt, tim, encrypted, 'normal',
|
mtype = 'normal'
|
||||||
subject, chatstate, msg_id, composing_jep, user_nick, msghtml))
|
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
|
# END messageCB
|
||||||
|
|
||||||
def _pubsubEventCB(self, con, msg):
|
def _pubsubEventCB(self, con, msg):
|
||||||
|
|
|
@ -84,6 +84,8 @@ class PreferencesWindow:
|
||||||
self.notebook = self.xml.get_widget('preferences_notebook')
|
self.notebook = self.xml.get_widget('preferences_notebook')
|
||||||
self.one_window_type_combobox =\
|
self.one_window_type_combobox =\
|
||||||
self.xml.get_widget('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
|
#FIXME: remove when ANC will be implemented
|
||||||
w = self.xml.get_widget('hbox3020')
|
w = self.xml.get_widget('hbox3020')
|
||||||
|
@ -140,7 +142,7 @@ class PreferencesWindow:
|
||||||
if not gajim.config.get('emoticons_theme'):
|
if not gajim.config.get('emoticons_theme'):
|
||||||
emoticons_combobox.set_active(len(l)-1)
|
emoticons_combobox.set_active(len(l)-1)
|
||||||
|
|
||||||
#iconset
|
# iconset
|
||||||
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
|
||||||
# new model, image in 0, string in 1
|
# new model, image in 0, string in 1
|
||||||
model = gtk.ListStore(gtk.Image, str)
|
model = gtk.ListStore(gtk.Image, str)
|
||||||
|
@ -182,6 +184,14 @@ class PreferencesWindow:
|
||||||
else:
|
else:
|
||||||
self.one_window_type_combobox.set_active(0)
|
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
|
# Use transports iconsets
|
||||||
st = gajim.config.get('use_transports_iconsets')
|
st = gajim.config.get('use_transports_iconsets')
|
||||||
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
|
self.xml.get_widget('transports_iconsets_checkbutton').set_active(st)
|
||||||
|
@ -353,7 +363,7 @@ class PreferencesWindow:
|
||||||
gajim.config.set('soundplayer', command)
|
gajim.config.set('soundplayer', command)
|
||||||
break
|
break
|
||||||
|
|
||||||
#sounds treeview
|
# sounds treeview
|
||||||
self.sound_tree = self.xml.get_widget('sounds_treeview')
|
self.sound_tree = self.xml.get_widget('sounds_treeview')
|
||||||
|
|
||||||
# active, event ui name, path to sound file, event_config_name
|
# active, event ui name, path to sound file, event_config_name
|
||||||
|
@ -380,31 +390,31 @@ class PreferencesWindow:
|
||||||
st = gajim.config.get('autoaway')
|
st = gajim.config.get('autoaway')
|
||||||
self.auto_away_checkbutton.set_active(st)
|
self.auto_away_checkbutton.set_active(st)
|
||||||
|
|
||||||
#Autoawaytime
|
# Autoawaytime
|
||||||
st = gajim.config.get('autoawaytime')
|
st = gajim.config.get('autoawaytime')
|
||||||
self.auto_away_time_spinbutton.set_value(st)
|
self.auto_away_time_spinbutton.set_value(st)
|
||||||
self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))
|
self.auto_away_time_spinbutton.set_sensitive(gajim.config.get('autoaway'))
|
||||||
|
|
||||||
#autoaway message
|
# autoaway message
|
||||||
st = gajim.config.get('autoaway_message')
|
st = gajim.config.get('autoaway_message')
|
||||||
self.auto_away_message_entry.set_text(st)
|
self.auto_away_message_entry.set_text(st)
|
||||||
self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway'))
|
self.auto_away_message_entry.set_sensitive(gajim.config.get('autoaway'))
|
||||||
|
|
||||||
#Autoxa
|
# Autoxa
|
||||||
st = gajim.config.get('autoxa')
|
st = gajim.config.get('autoxa')
|
||||||
self.auto_xa_checkbutton.set_active(st)
|
self.auto_xa_checkbutton.set_active(st)
|
||||||
|
|
||||||
#Autoxatime
|
# Autoxatime
|
||||||
st = gajim.config.get('autoxatime')
|
st = gajim.config.get('autoxatime')
|
||||||
self.auto_xa_time_spinbutton.set_value(st)
|
self.auto_xa_time_spinbutton.set_value(st)
|
||||||
self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))
|
self.auto_xa_time_spinbutton.set_sensitive(gajim.config.get('autoxa'))
|
||||||
|
|
||||||
#autoxa message
|
# autoxa message
|
||||||
st = gajim.config.get('autoxa_message')
|
st = gajim.config.get('autoxa_message')
|
||||||
self.auto_xa_message_entry.set_text(st)
|
self.auto_xa_message_entry.set_text(st)
|
||||||
self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa'))
|
self.auto_xa_message_entry.set_sensitive(gajim.config.get('autoxa'))
|
||||||
|
|
||||||
#ask_status when online / offline
|
# ask_status when online / offline
|
||||||
st = gajim.config.get('ask_online_status')
|
st = gajim.config.get('ask_online_status')
|
||||||
self.xml.get_widget('prompt_online_status_message_checkbutton').\
|
self.xml.get_widget('prompt_online_status_message_checkbutton').\
|
||||||
set_active(st)
|
set_active(st)
|
||||||
|
@ -438,7 +448,7 @@ class PreferencesWindow:
|
||||||
renderer.connect('toggled', self.default_msg_toggled_cb)
|
renderer.connect('toggled', self.default_msg_toggled_cb)
|
||||||
self.fill_default_msg_treeview()
|
self.fill_default_msg_treeview()
|
||||||
|
|
||||||
#Status messages
|
# Status messages
|
||||||
self.msg_tree = self.xml.get_widget('msg_treeview')
|
self.msg_tree = self.xml.get_widget('msg_treeview')
|
||||||
model = gtk.ListStore(str, str)
|
model = gtk.ListStore(str, str)
|
||||||
self.msg_tree.set_model(model)
|
self.msg_tree.set_model(model)
|
||||||
|
@ -453,7 +463,7 @@ class PreferencesWindow:
|
||||||
buf = self.xml.get_widget('msg_textview').get_buffer()
|
buf = self.xml.get_widget('msg_textview').get_buffer()
|
||||||
buf.connect('changed', self.on_msg_textview_changed)
|
buf.connect('changed', self.on_msg_textview_changed)
|
||||||
|
|
||||||
#open links with
|
# open links with
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
applications_frame = self.xml.get_widget('applications_frame')
|
applications_frame = self.xml.get_widget('applications_frame')
|
||||||
applications_frame.set_no_show_all(True)
|
applications_frame.set_no_show_all(True)
|
||||||
|
@ -650,6 +660,11 @@ class PreferencesWindow:
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
gajim.interface.msg_win_mgr.reconfig()
|
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):
|
def apply_speller(self):
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
for ctrl in gajim.interface.msg_win_mgr.controls():
|
for ctrl in gajim.interface.msg_win_mgr.controls():
|
||||||
|
|
Loading…
Reference in New Issue