chatstate by default only are about composing. chatstates ready for 0.8

This commit is contained in:
Nikos Kouremenos 2005-08-07 20:58:44 +00:00
parent 94c2922909
commit 5a054fd790
5 changed files with 95 additions and 33 deletions

View File

@ -120,7 +120,7 @@ class Config:
'always_english_wikipedia': [opt_bool, False], 'always_english_wikipedia': [opt_bool, False],
'always_english_wiktionary': [opt_bool, False], 'always_english_wiktionary': [opt_bool, False],
'use_dbus': [opt_bool, True], # allow control via dbus service '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], 'autodetect_browser_mailer': [opt_bool, True],
'print_ichat_every_foo_minutes': [opt_int, 5], 'print_ichat_every_foo_minutes': [opt_int, 5],
'confirm_close_muc': [opt_bool, True], # confirm closing MUC window 'confirm_close_muc': [opt_bool, True], # confirm closing MUC window

View File

@ -88,7 +88,7 @@ def get_contact_instances_from_jid(account, jid):
return contacts_instances return contacts_instances
def get_first_contact_instance_from_jid(account, jid): def get_first_contact_instance_from_jid(account, jid):
contact = None # if not found skip TB contact = None
if jid in contacts[account]: if jid in contacts[account]:
contact = contacts[account][jid][0] contact = contacts[account][jid][0]
else: # it's fake jid else: # it's fake jid

View File

@ -269,12 +269,14 @@ class PreferencesWindow:
set_active(gajim.config.get('ignore_unknown_contacts')) set_active(gajim.config.get('ignore_unknown_contacts'))
# send chat state notifications # send chat state notifications
st = gajim.config.get('send_receive_chat_state_notifications') st = gajim.config.get('chat_state_notifications')
btn = self.xml.get_widget('send_receive_chat_state_checkbutton') combo = self.xml.get_widget('chat_states_combobox')
if st: if st == 'composing_only':
btn.set_active(True) combo.set_active(0)
else: elif st == 'all':
btn.set_active(False) combo.set_active(1)
else: # disabled
btn.set_active(2)
#sounds #sounds
if os.name == 'nt': # if windows, player must not become visible on show_all 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): def on_ignore_events_from_unknown_contacts_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts') self.on_checkbutton_toggled(widget, 'ignore_unknown_contacts')
def on_send_receive_chat_state_checkbutton_toggled(self, widget): def on_chat_states_combobox_changed(self, widget):
self.on_checkbutton_toggled(widget, active = widget.get_active()
'send_receive_chat_state_notifications') 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): def on_play_sounds_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'sounds_on', self.on_checkbutton_toggled(widget, 'sounds_on',

View File

@ -4386,18 +4386,56 @@
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="send_receive_chat_state_checkbutton"> <widget class="GtkHBox" id="hbox2991">
<property name="visible">True</property> <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="homogeneous">False</property>
<property name="can_focus">True</property> <property name="spacing">12</property>
<property name="label" translatable="yes">Send &amp; receive chat state noti_fications</property>
<property name="use_underline">True</property> <child>
<property name="relief">GTK_RELIEF_NORMAL</property> <widget class="GtkEventBox" id="eventbox4">
<property name="focus_on_click">True</property> <property name="visible">True</property>
<property name="active">False</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="inconsistent">False</property> <property name="visible_window">True</property>
<property name="draw_indicator">True</property> <property name="above_child">False</property>
<signal name="toggled" handler="on_send_receive_chat_state_checkbutton_toggled" last_modification_time="Wed, 20 Jul 2005 19:11:23 GMT"/>
<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="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> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -5303,7 +5341,7 @@
<child> <child>
<widget class="GtkComboBox" id="links_open_with_combobox"> <widget class="GtkComboBox" id="links_open_with_combobox">
<property name="visible">True</property> <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 GNOME default applications
Always use KDE default applications Always use KDE default applications
Custom</property> Custom</property>
@ -11133,7 +11171,7 @@ Status message</property>
<child> <child>
<widget class="GtkLabel" id="event_type_label"> <widget class="GtkLabel" id="event_type_label">
<property name="visible">True</property> <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_underline">False</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -11187,7 +11225,7 @@ Status message</property>
<child> <child>
<widget class="GtkLabel" id="event_description_label"> <widget class="GtkLabel" id="event_description_label">
<property name="visible">True</property> <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_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>

View File

@ -133,7 +133,7 @@ class TabbedChatWindow(chat.Chat):
#FIXME: when gtk2.4 is OOOOLD do it via glade2.10+ #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): if gtk.pygtk_version >= (2, 6, 0) and gtk.gtk_version >= (2, 6, 0):
banner_name_label.set_ellipsize(pango.ELLIPSIZE_END) 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: elif status is not None and len(status) > 50:
status = status[:47] + '...' status = status[:47] + '...'
status = gtkgui_helpers.escape_for_pango_markup(status) 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' \ #label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
# % (name, fulljid) # % (name, fulljid)
if chatstate:
chatstate = helpers.get_uf_chatstate(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 = \ label_text = \
'<span weight="heavy" size="x-large">%s</span> %s' % (name, chatstate) '<span weight="heavy" size="x-large">%s</span> %s' % (name, chatstate)
else: else:
@ -200,10 +210,12 @@ class TabbedChatWindow(chat.Chat):
contacts_list = gajim.contacts[self.account][jid] contacts_list = gajim.contacts[self.account][jid]
else: else:
contacts_list = [self.contacts[jid]] contacts_list = [self.contacts[jid]]
user = contacts_list[0] user = contacts_list[0]
show = user.show show = user.show
jid = user.jid jid = user.jid
keyID = user.keyID keyID = user.keyID
for u in contacts_list: for u in contacts_list:
if u.priority > prio: if u.priority > prio:
prio = u.priority prio = u.priority
@ -215,10 +227,12 @@ class TabbedChatWindow(chat.Chat):
state_images = self.plugin.roster.get_appropriate_state_images(jid) state_images = self.plugin.roster.get_appropriate_state_images(jid)
image = state_images[show] image = state_images[show]
banner_status_image = self.xmls[jid].get_widget('banner_status_image') banner_status_image = self.xmls[jid].get_widget('banner_status_image')
if keyID: if keyID:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True) self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True)
else: else:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False) self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False)
if image.get_storage_type() == gtk.IMAGE_ANIMATION: if image.get_storage_type() == gtk.IMAGE_ANIMATION:
banner_status_image.set_from_animation(image.get_animation()) banner_status_image.set_from_animation(image.get_animation())
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 # in an workaround way (we could also get somehow the listed shortcuts
# but I don't know if it's possible) # but I don't know if it's possible)
chars_no = len(message) 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) 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() start_iter, end_iter = message_buffer.get_bounds()
message = message_buffer.get_text(start_iter, end_iter, False) message = message_buffer.get_text(start_iter, end_iter, False)
chars_no_after_one_sec = len(message) chars_no_after_one_sec = len(message)
@ -486,7 +500,7 @@ class TabbedChatWindow(chat.Chat):
# so GTK+ decided key_press was for writing.. # so GTK+ decided key_press was for writing..
self.kbd_activity_in_last_5_secs = True self.kbd_activity_in_last_5_secs = True
self.kbd_activity_in_last_30_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): def send_chatstate(self, state, jid = None):
''' sends our chatstate as STANDLONE chat state message (eg. no body) ''' 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 # do not send nothing if we have chat state notifications disabled
# that means we won't reply to the <active/> from other peer # that means we won't reply to the <active/> from other peer
# so we do not broadcast jep85 capabalities # 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 return
if jid is None: if jid is None:
@ -585,7 +599,7 @@ class TabbedChatWindow(chat.Chat):
encrypted = True encrypted = True
chatstates_on = gajim.config.get( chatstates_on = gajim.config.get(
'send_receive_chat_state_notifications') 'chat_state_notifications') != 'disabled'
chatstate_to_send = None chatstate_to_send = None
@ -606,6 +620,8 @@ class TabbedChatWindow(chat.Chat):
gajim.connections[self.account].send_message(jid, message, keyID, gajim.connections[self.account].send_message(jid, message, keyID,
chatstate = chatstate_to_send) chatstate = chatstate_to_send)
contact.chatstate = chatstate_to_send
message_buffer.set_text('') message_buffer.set_text('')
self.print_conversation(message, jid, jid, encrypted = encrypted) self.print_conversation(message, jid, jid, encrypted = encrypted)