Commit e4016315 authored by Yann Leboulanger's avatar Yann Leboulanger

begining of normal control work: get single message patch from #1041 and begin...

begining of normal control work: get single message patch from #1041 and begin to make it a MessageControl subclass
parent e7d711e7
This diff is collapsed.
......@@ -122,7 +122,7 @@
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">6</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
......@@ -149,8 +149,8 @@
<property name="mnemonic_widget">one_window_type_combobox</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
......@@ -182,8 +182,8 @@ Per type</property>
<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>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
......@@ -199,8 +199,8 @@ Per type</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
......@@ -217,8 +217,8 @@ Per type</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
......@@ -233,8 +233,8 @@ Per type</property>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
......@@ -266,6 +266,34 @@ Per type</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Default outgoing messages type:</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="GtkComboBox" id="default_outgoing_messages_type_combobox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="items" translatable="yes">Chat message
Single message</property>
<signal name="changed" handler="on_default_outgoing_messages_type_combobox_changed"/>
</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>
</widget>
</child>
</widget>
......
This diff is collapsed.
......@@ -1623,7 +1623,7 @@ class ChatControl(ChatControlBase):
def prepare_context_menu(self):
'''sets compact view menuitem active state
sets active and sensitivity state for toggle_gpg_menuitem
sets sensitivity for history_menuitem (False for tranasports)
sets sensitivity for history_menuitem (False for transports)
and file_transfer_menuitem
and hide()/show() for add_to_roster_menuitem
'''
......
......@@ -47,6 +47,7 @@ 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']
opt_default_outgoing_messages_type = ['chat', 'normal']
class Config:
......@@ -246,6 +247,7 @@ class Config:
'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')],
'default_outgoing_messages_type': [ opt_str, 'chat', _('Can be \'chat\' or \'normal\'. Default type of outgoing messages.')],
'scroll_roster_to_last_message': [opt_bool, True, _('If True, Gajim will scroll and select the contact who sent you the last message, if chat window is not already opened.')],
'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')],
'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
......
......@@ -72,6 +72,8 @@ class PreferencesWindow:
self.notebook = self.xml.get_widget('preferences_notebook')
self.treat_incoming_messages_combobox =\
self.xml.get_widget('treat_incoming_messages_combobox')
self.default_outgoing_messages_type_combobox =\
self.xml.get_widget('default_outgoing_messages_type_combobox')
self.one_window_type_combobox =\
self.xml.get_widget('one_window_type_combobox')
self.iconset_combobox = self.xml.get_widget('iconset_combobox')
......@@ -141,6 +143,15 @@ class PreferencesWindow:
else:
self.treat_incoming_messages_combobox.set_active(0)
# Set default for send outgoing messages
choices = common.config.opt_default_outgoing_messages_type
type = gajim.config.get('default_outgoing_messages_type')
if type in choices:
self.default_outgoing_messages_type_combobox.set_active(
choices.index(type))
else:
self.default_outgoing_messages_type_combobox.set_active(0)
# Set default for single window type
choices = common.config.opt_one_window_types
type = gajim.config.get('one_message_window')
......@@ -642,6 +653,11 @@ class PreferencesWindow:
config_type = common.config.opt_treat_incoming_messages[active]
gajim.config.set('treat_incoming_messages', config_type)
def on_default_outgoing_messages_type_combobox_changed(self, widget):
active = widget.get_active()
config_type = common.config.opt_default_outgoing_messages_type[active]
gajim.config.set('default_outgoing_messages_type', config_type)
def on_one_window_type_combo_changed(self, widget):
active = widget.get_active()
config_type = common.config.opt_one_window_types[active]
......
This diff is collapsed.
This diff is collapsed.
......@@ -2006,14 +2006,16 @@ class RosterWindow:
self.draw_account(account)
def on_send_single_message_menuitem_activate(self, widget, account,
contact = None):
contact=None, resource=None):
if contact is None:
dialogs.SingleMessageWindow(account, action = 'send')
elif type(contact) == type([]):
dialogs.SingleMessageWindow(account, contact, 'send')
else:
jid = contact.jid
if contact.jid == gajim.get_jid_from_account(account):
if resource:
jid += '/' + resource
elif contact.jid == gajim.get_jid_from_account(account):
jid += '/' + contact.resource
dialogs.SingleMessageWindow(account, jid, 'send')
......@@ -4435,6 +4437,7 @@ class RosterWindow:
else:
child_iter = model.iter_next(child_iter)
session = None
chat_messages_waiting = False
if first_ev:
if first_ev.type_ in ('chat', 'normal'):
session = first_ev.parameters[8]
......@@ -4443,12 +4446,22 @@ class RosterWindow:
fjid += '/' + resource
if self.open_event(account, fjid, first_ev):
return
elif first_ev.type_ == 'chat':
chat_messages_waiting = True
c = gajim.contacts.get_contact(account, jid, resource)
if not c or isinstance(c, list):
c = gajim.contacts.get_contact_with_highest_priority(account, jid)
if jid == gajim.get_jid_from_account(account):
resource = c.resource
self.on_open_chat_window(widget, c, account, resource = resource, session = session)
default_outgoing_messages_type = gajim.config.get(
'default_outgoing_messages_type')
if default_outgoing_messages_type == 'normal' and not \
chat_messages_waiting:
self.on_send_single_message_menuitem_activate(widget, account, c,
resource=resource)
else:
self.on_open_chat_window(widget, c, account, resource=resource,
session=session)
def on_roster_treeview_row_activated(self, widget, path, col = 0):
'''When an iter is double clicked: open the first event window'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment