diff --git a/chatstate/__init__.py b/chatstate/__init__.py new file mode 100644 index 0000000..2e0e6b6 --- /dev/null +++ b/chatstate/__init__.py @@ -0,0 +1 @@ +from chatstate import ChatstatePlugin diff --git a/chatstate/chatstate.py b/chatstate/chatstate.py new file mode 100644 index 0000000..2fd4c8b --- /dev/null +++ b/chatstate/chatstate.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +## + +import gtk +import gobject +import pango + +from plugins.gui import GajimPluginConfigDialog +from plugins import GajimPlugin +from plugins.helpers import log_calls, log +from common import ged +from common import gajim +from common import helpers +import gtkgui_helpers + + +class ChatstatePlugin(GajimPlugin): + + @log_calls('ChatstatePlugin') + def init(self): + self.config_dialog = ChatstatePluginConfigDialog(self) + self.events_handlers = {'raw-message-received' : + (ged.POSTCORE, self.raw_pres_received),} + self.config_default_values = { + 'active': ('darkblue',''), + 'composing': ('darkred', ''), + 'inactive': ('#675B5B',''), + 'paused': ('darkgreen', ''),} + self.compose = ('active', 'composing', 'gone', 'inactive', 'paused') + + + def raw_pres_received(self, event_object): + jid = str(event_object.xmpp_msg.getFrom()) + account = event_object.account + contact = gajim.contacts.get_contact_from_full_jid(account, jid) + if not contact: + return + + for compose in self.compose: + state = event_object.xmpp_msg.getTag(compose) + if state: + break + if not state: + return + + self.model = gajim.interface.roster.model + child_iters = gajim.interface.roster._get_contact_iter( + jid.split('/')[0], account, contact, self.model) + + for child_iter in child_iters: + name = gobject.markup_escape_text(contact.get_shown_name()) + if compose != 'gone': + name = '%s' % ( + self.config[compose], name) + if contact.status and gajim.config.get('show_status_msgs_in_roster'): + status = contact.status.strip() + if status != '': + status = helpers.reduce_chars_newlines(status, + max_lines = 1) + color = gtkgui_helpers.get_fade_color( + gajim.interface.roster.tree, False, False) + colorstring = '#%04x%04x%04x' % (color.red, color.green, + color.blue) + name += '\n%s' % (colorstring, + gobject.markup_escape_text(status)) + self.model[child_iter][1] = name + + @log_calls('ChatstatePlugin') + def activate(self): + pass + + @log_calls('ChatstatePlugin') + def deactivate(self): + pass + + +class ChatstatePluginConfigDialog(GajimPluginConfigDialog): + def init(self): + self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( + 'config_dialog.ui') + self.xml = gtk.Builder() + self.xml.set_translation_domain('gajim') + self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, + ['vbox1']) + vbox1 = self.xml.get_object('vbox1') + self.child.pack_start(vbox1) + self.xml.connect_signals(self) + self.connect('hide', self.on_hide) + + def on_run(self): + for name in self.plugin.config_default_values: + widget = self.xml.get_object(name) + widget.set_color(gtk.gdk.color_parse(self.plugin.config[name])) + + def changed(self, entry): + name = gtk.Buildable.get_name(entry) + self.plugin.config[name] = entry.get_text() + + def on_hide(self, widget): + for name in self.plugin.config_default_values: + widget = self.xml.get_object(name) + self.plugin.config[name] = widget.get_color().to_string() diff --git a/chatstate/config_dialog.ui b/chatstate/config_dialog.ui new file mode 100644 index 0000000..57efc75 --- /dev/null +++ b/chatstate/config_dialog.ui @@ -0,0 +1,159 @@ + + + + + + + + True + vertical + 2 + + + True + 3 + + + True + 0 + is doing something else + + + False + False + 0 + + + + + True + True + True + #000000000000 + + + False + end + 1 + + + + + False + False + 0 + + + + + True + 3 + + + True + 0 + is composing a message... + + + False + False + 0 + + + + + True + True + True + #000000000000 + + + False + end + 1 + + + + + False + False + 1 + + + + + True + 3 + + + True + 0 + paused composing a message + + + False + False + 0 + + + + + True + True + True + False + 0 + #000000000000 + + + False + end + 1 + + + + + False + False + 2 + + + + + True + 3 + + + True + 0 + is paying attention to the conversation + + + False + 0 + + + + + True + True + True + #000000000000 + + + False + end + 1 + + + + + False + False + 3 + + + + + + diff --git a/chatstate/manifest.ini b/chatstate/manifest.ini new file mode 100644 index 0000000..9def70d --- /dev/null +++ b/chatstate/manifest.ini @@ -0,0 +1,12 @@ +[info] +name: Chatstate in roster +short_name: chatstate +version: 0.1 +description: Chat State Notifications in roster. + Font color of the contact varies depending on the chat state. + The plugin does not work if you use custom font color for contacts in roster. + http://trac.gajim.org/ticket/3628. + http://xmpp.org/extensions/xep-0085.html +authors = Denis Fomin +homepage = http://trac-plugins.gajim.org/wiki + diff --git a/juick/manifest.ini b/juick/manifest.ini index 1c19bd6..5f67459 100644 --- a/juick/manifest.ini +++ b/juick/manifest.ini @@ -4,6 +4,6 @@ short_name: Juick version: 0.2 description: Clickable juick links , juick nics, preview juick picturs. The key combination alt + up in the textbox allow insert the number of last message (comment or topic). -authors: Denis Fomin >, evgen +authors: Denis Fomin , evgen homepage: http://trac-plugins.gajim.org/wiki/JuickPlugin