chatstate. use theme color
This commit is contained in:
@@ -5,7 +5,6 @@ import gtk
|
|||||||
import gobject
|
import gobject
|
||||||
import pango
|
import pango
|
||||||
|
|
||||||
from plugins.gui import GajimPluginConfigDialog
|
|
||||||
from plugins import GajimPlugin
|
from plugins import GajimPlugin
|
||||||
from plugins.helpers import log_calls, log
|
from plugins.helpers import log_calls, log
|
||||||
from common import ged
|
from common import ged
|
||||||
@@ -18,15 +17,10 @@ class ChatstatePlugin(GajimPlugin):
|
|||||||
|
|
||||||
@log_calls('ChatstatePlugin')
|
@log_calls('ChatstatePlugin')
|
||||||
def init(self):
|
def init(self):
|
||||||
self.config_dialog = ChatstatePluginConfigDialog(self)
|
self.config_dialog = None#ChatstatePluginConfigDialog(self)
|
||||||
self.events_handlers = {'raw-message-received' :
|
self.events_handlers = {'raw-message-received' :
|
||||||
(ged.POSTCORE, self.raw_pres_received),}
|
(ged.POSTCORE, self.raw_pres_received),}
|
||||||
self.config_default_values = {
|
self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused')
|
||||||
'active': ('darkred',''),
|
|
||||||
'composing': ('darkgreen', ''),
|
|
||||||
'inactive': ('#675B5B',''),
|
|
||||||
'paused': ('darkblue', ''),}
|
|
||||||
self.compose = ('active', 'composing', 'gone', 'inactive', 'paused')
|
|
||||||
self.active = None
|
self.active = None
|
||||||
|
|
||||||
|
|
||||||
@@ -39,8 +33,8 @@ class ChatstatePlugin(GajimPlugin):
|
|||||||
if not contact:
|
if not contact:
|
||||||
return
|
return
|
||||||
|
|
||||||
for compose in self.compose:
|
for chatstate in self.chatstates:
|
||||||
state = event_object.xmpp_msg.getTag(compose)
|
state = event_object.xmpp_msg.getTag(chatstate)
|
||||||
if state:
|
if state:
|
||||||
break
|
break
|
||||||
if not state:
|
if not state:
|
||||||
@@ -52,9 +46,25 @@ class ChatstatePlugin(GajimPlugin):
|
|||||||
|
|
||||||
for child_iter in child_iters:
|
for child_iter in child_iters:
|
||||||
name = gobject.markup_escape_text(contact.get_shown_name())
|
name = gobject.markup_escape_text(contact.get_shown_name())
|
||||||
if compose != 'gone':
|
theme = gajim.config.get('roster_theme')
|
||||||
name = '<span foreground="%s">%s</span>' % (
|
color = None
|
||||||
self.config[compose], name)
|
if chatstate == 'composing':
|
||||||
|
color = gajim.config.get_per('themes', theme,
|
||||||
|
'state_composing_color')
|
||||||
|
elif chatstate == 'inactive':
|
||||||
|
color = gajim.config.get_per('themes', theme,
|
||||||
|
'state_inactive_color')
|
||||||
|
elif chatstate == 'gone':
|
||||||
|
color = gajim.config.get_per('themes', theme,
|
||||||
|
'state_gone_color')
|
||||||
|
elif chatstate == 'paused':
|
||||||
|
color = gajim.config.get_per('themes', theme,
|
||||||
|
'state_paused_color')
|
||||||
|
elif chatstate == 'active':
|
||||||
|
color = gajim.config.get('inmsgcolor')
|
||||||
|
|
||||||
|
name = '<span foreground="%s">%s</span>' % (
|
||||||
|
color, name)
|
||||||
if contact.status and gajim.config.get('show_status_msgs_in_roster'):
|
if contact.status and gajim.config.get('show_status_msgs_in_roster'):
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
if status != '':
|
if status != '':
|
||||||
@@ -78,31 +88,3 @@ class ChatstatePlugin(GajimPlugin):
|
|||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
pass
|
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()
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[info]
|
[info]
|
||||||
name: Chatstate in roster
|
name: Chatstate in roster
|
||||||
short_name: chatstate
|
short_name: chatstate
|
||||||
version: 0.1
|
version: 0.2
|
||||||
description: Chat State Notifications in roster.
|
description: Chat State Notifications in roster.
|
||||||
Font color of the contact varies depending on the chat state.
|
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.
|
The plugin does not work if you use custom font color for contacts in roster.
|
||||||
|
|||||||
Reference in New Issue
Block a user