chatstate by default only are about composing. chatstates ready for 0.8
This commit is contained in:
parent
94c2922909
commit
5a054fd790
|
@ -120,7 +120,7 @@ class Config:
|
|||
'always_english_wikipedia': [opt_bool, False],
|
||||
'always_english_wiktionary': [opt_bool, False],
|
||||
'use_dbus': [opt_bool, True], # allow control via dbus service
|
||||
'send_receive_chat_state_notifications': [opt_bool, True],
|
||||
'chat_state_notifications': [opt_str, 'composing_only'], # 'all', 'all', 'disabled'
|
||||
'autodetect_browser_mailer': [opt_bool, True],
|
||||
'print_ichat_every_foo_minutes': [opt_int, 5],
|
||||
'confirm_close_muc': [opt_bool, True], # confirm closing MUC window
|
||||
|
|
|
@ -88,7 +88,7 @@ def get_contact_instances_from_jid(account, jid):
|
|||
return contacts_instances
|
||||
|
||||
def get_first_contact_instance_from_jid(account, jid):
|
||||
contact = None # if not found skip TB
|
||||
contact = None
|
||||
if jid in contacts[account]:
|
||||
contact = contacts[account][jid][0]
|
||||
else: # it's fake jid
|
||||
|
|
|
@ -269,12 +269,14 @@ class PreferencesWindow:
|
|||
set_active(gajim.config.get('ignore_unknown_contacts'))
|
||||
|
||||
# send chat state notifications
|
||||
st = gajim.config.get('send_receive_chat_state_notifications')
|
||||
btn = self.xml.get_widget('send_receive_chat_state_checkbutton')
|
||||
if st:
|
||||
btn.set_active(True)
|
||||
else:
|
||||
btn.set_active(False)
|
||||
st = gajim.config.get('chat_state_notifications')
|
||||
combo = self.xml.get_widget('chat_states_combobox')
|
||||
if st == 'composing_only':
|
||||
combo.set_active(0)
|
||||
elif st == 'all':
|
||||
combo.set_active(1)
|
||||
else: # disabled
|
||||
btn.set_active(2)
|
||||
|
||||
#sounds
|
||||
if os.name == 'nt': # if windows, player must not become visible on show_all
|
||||
|
@ -765,9 +767,15 @@ class PreferencesWindow:
|
|||
def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget):
|
||||
self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts')
|
||||
|
||||
def on_send_receive_chat_state_checkbutton_toggled(self, widget):
|
||||
self.on_checkbutton_toggled(widget,
|
||||
'send_receive_chat_state_notifications')
|
||||
def on_chat_states_combobox_changed(self, widget):
|
||||
active = widget.get_active()
|
||||
if active == 0: # only composing
|
||||
gajim.config.set('chat_state_notifications', 'composing_only')
|
||||
elif active == 1: # all
|
||||
gajim.config.set('chat_state_notifications', 'all')
|
||||
else: # disabled
|
||||
gajim.config.set('chat_state_notifications', 'disabled')
|
||||
|
||||
|
||||
def on_play_sounds_checkbutton_toggled(self, widget):
|
||||
self.on_checkbutton_toggled(widget, 'sounds_on',
|
||||
|
|
|
@ -4386,18 +4386,56 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="send_receive_chat_state_checkbutton">
|
||||
<widget class="GtkHBox" id="hbox2991">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEventBox" id="eventbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">If checked, Gajim will broadcast capability to send and receive meta-information related to a conversation you may have with a contact such as composing a message</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Send & receive chat state noti_fications</property>
|
||||
<property name="visible_window">True</property>
|
||||
<property name="above_child">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label354">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Chat state noti_fications:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_send_receive_chat_state_checkbutton_toggled" last_modification_time="Wed, 20 Jul 2005 19:11:23 GMT"/>
|
||||
<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="mnemonic_widget">chat_states_combobox</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="chat_states_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Composing only
|
||||
All
|
||||
Disabled</property>
|
||||
<signal name="changed" handler="on_chat_states_combobox_changed" last_modification_time="Sun, 07 Aug 2005 19:15:49 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
@ -5303,7 +5341,7 @@
|
|||
<child>
|
||||
<widget class="GtkComboBox" id="links_open_with_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Autodetect
|
||||
<property name="items" translatable="yes">Autodetect at every application startup
|
||||
Always use GNOME default applications
|
||||
Always use KDE default applications
|
||||
Custom</property>
|
||||
|
@ -11133,7 +11171,7 @@ Status message</property>
|
|||
<child>
|
||||
<widget class="GtkLabel" id="event_type_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="label">Event Type</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
|
@ -11187,7 +11225,7 @@ Status message</property>
|
|||
<child>
|
||||
<widget class="GtkLabel" id="event_description_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="label">Event desc</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
|
|
|
@ -133,7 +133,7 @@ class TabbedChatWindow(chat.Chat):
|
|||
#FIXME: when gtk2.4 is OOOOLD do it via glade2.10+
|
||||
if gtk.pygtk_version >= (2, 6, 0) and gtk.gtk_version >= (2, 6, 0):
|
||||
banner_name_label.set_ellipsize(pango.ELLIPSIZE_END)
|
||||
#FIXME: do me with pango ellipseEND when gtk24 is OLD
|
||||
#FIXME: remove me when gtk24 is OLD
|
||||
elif status is not None and len(status) > 50:
|
||||
status = status[:47] + '...'
|
||||
status = gtkgui_helpers.escape_for_pango_markup(status)
|
||||
|
@ -146,8 +146,18 @@ class TabbedChatWindow(chat.Chat):
|
|||
#label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
|
||||
# % (name, fulljid)
|
||||
|
||||
if chatstate:
|
||||
|
||||
st = gajim.config.get('chat_state_notifications')
|
||||
if chatstate and st in ('composing_only', 'all'):
|
||||
if st == 'all':
|
||||
chatstate = helpers.get_uf_chatstate(chatstate)
|
||||
else: # 'composing_only'
|
||||
if chatstate in ('composing', 'paused'):
|
||||
# only print composing, paused
|
||||
chatstate = helpers.get_uf_chatstate(chatstate)
|
||||
else:
|
||||
chatstate = ''
|
||||
print chatstate
|
||||
label_text = \
|
||||
'<span weight="heavy" size="x-large">%s</span> %s' % (name, chatstate)
|
||||
else:
|
||||
|
@ -200,10 +210,12 @@ class TabbedChatWindow(chat.Chat):
|
|||
contacts_list = gajim.contacts[self.account][jid]
|
||||
else:
|
||||
contacts_list = [self.contacts[jid]]
|
||||
|
||||
user = contacts_list[0]
|
||||
show = user.show
|
||||
jid = user.jid
|
||||
keyID = user.keyID
|
||||
|
||||
for u in contacts_list:
|
||||
if u.priority > prio:
|
||||
prio = u.priority
|
||||
|
@ -215,10 +227,12 @@ class TabbedChatWindow(chat.Chat):
|
|||
state_images = self.plugin.roster.get_appropriate_state_images(jid)
|
||||
image = state_images[show]
|
||||
banner_status_image = self.xmls[jid].get_widget('banner_status_image')
|
||||
|
||||
if keyID:
|
||||
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True)
|
||||
else:
|
||||
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False)
|
||||
|
||||
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||
banner_status_image.set_from_animation(image.get_animation())
|
||||
status_image.set_from_animation(image.get_animation())
|
||||
|
@ -475,10 +489,10 @@ class TabbedChatWindow(chat.Chat):
|
|||
# in an workaround way (we could also get somehow the listed shortcuts
|
||||
# but I don't know if it's possible)
|
||||
chars_no = len(message)
|
||||
gobject.timeout_add(1000, self.on_timeout_for_check_composing,
|
||||
gobject.timeout_add(1000, self.check_for_possible_composing,
|
||||
message_buffer, jid, chars_no)
|
||||
|
||||
def on_timeout_for_check_composing(self, message_buffer, jid, chars_no):
|
||||
def check_for_possible_composing(self, message_buffer, jid, chars_no):
|
||||
start_iter, end_iter = message_buffer.get_bounds()
|
||||
message = message_buffer.get_text(start_iter, end_iter, False)
|
||||
chars_no_after_one_sec = len(message)
|
||||
|
@ -486,7 +500,7 @@ class TabbedChatWindow(chat.Chat):
|
|||
# so GTK+ decided key_press was for writing..
|
||||
self.kbd_activity_in_last_5_secs = True
|
||||
self.kbd_activity_in_last_30_secs = True
|
||||
self.send_chatstate('composing')
|
||||
self.send_chatstate('composing', jid)
|
||||
|
||||
def send_chatstate(self, state, jid = None):
|
||||
''' sends our chatstate as STANDLONE chat state message (eg. no body)
|
||||
|
@ -503,7 +517,7 @@ class TabbedChatWindow(chat.Chat):
|
|||
# do not send nothing if we have chat state notifications disabled
|
||||
# that means we won't reply to the <active/> from other peer
|
||||
# so we do not broadcast jep85 capabalities
|
||||
if not gajim.config.get('send_receive_chat_state_notifications'):
|
||||
if gajim.config.get('chat_state_notifications') == 'disabled':
|
||||
return
|
||||
|
||||
if jid is None:
|
||||
|
@ -585,7 +599,7 @@ class TabbedChatWindow(chat.Chat):
|
|||
encrypted = True
|
||||
|
||||
chatstates_on = gajim.config.get(
|
||||
'send_receive_chat_state_notifications')
|
||||
'chat_state_notifications') != 'disabled'
|
||||
|
||||
chatstate_to_send = None
|
||||
|
||||
|
@ -607,6 +621,8 @@ class TabbedChatWindow(chat.Chat):
|
|||
gajim.connections[self.account].send_message(jid, message, keyID,
|
||||
chatstate = chatstate_to_send)
|
||||
|
||||
contact.chatstate = chatstate_to_send
|
||||
|
||||
message_buffer.set_text('')
|
||||
self.print_conversation(message, jid, jid, encrypted = encrypted)
|
||||
|
||||
|
|
Loading…
Reference in New Issue