Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2011-11-17 00:26:16 +0400
committerYann Leboulanger <asterix@lagaule.org>2011-11-17 00:26:16 +0400
commit8b612b98478fe908c9ad7c2697bcf030a9c19912 (patch)
tree828d5c040ee4f4bd9adfa3a4bae203f917d04579 /length_notifier
parent330d242734abae9fcd68be9646cf12eda2d4e9c3 (diff)
add plugins from trunk: banner_tweaks, google_translation, length_notifier, plugin_installer, triggers, whiteboard
Diffstat (limited to 'length_notifier')
-rw-r--r--length_notifier/__init__.py2
-rw-r--r--length_notifier/config_dialog.ui152
-rw-r--r--length_notifier/length_notifier.py157
-rw-r--r--length_notifier/manifest.ini9
4 files changed, 320 insertions, 0 deletions
diff --git a/length_notifier/__init__.py b/length_notifier/__init__.py
new file mode 100644
index 0000000..67c8c61
--- /dev/null
+++ b/length_notifier/__init__.py
@@ -0,0 +1,2 @@
+
+from length_notifier import LengthNotifierPlugin
diff --git a/length_notifier/config_dialog.ui b/length_notifier/config_dialog.ui
new file mode 100644
index 0000000..f06bfe1
--- /dev/null
+++ b/length_notifier/config_dialog.ui
@@ -0,0 +1,152 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkWindow" id="window1">
+ <child>
+ <object class="GtkTable" id="length_notifier_config_table">
+ <property name="visible">True</property>
+ <property name="border_width">9</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">7</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">Message length at which notification is invoked.</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Message length:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">Background color of text entry field in chat window when notification is invoked.</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Notification color:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">JabberIDs that plugin should be used with (eg. restrict only to one microblogging bot). Use comma (without space) as separator. If empty plugin is used with every JID. </property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">JabberIDs to include:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="jids_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">JabberIDs that plugin should be used with (eg. restrict only to one microblogging bot). Use comma (without space) as separator. If empty plugin is used with every JID. </property>
+ <signal name="editing_done" handler="on_jids_entry_editing_done"/>
+ <signal name="changed" handler="on_jids_entry_changed"/>
+ </object>
+ <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="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkColorButton" id="notification_colorbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Background color of text entry field in chat window when notification is invoked.</property>
+ <property name="xalign">0</property>
+ <property name="title" translatable="yes">Pick a color for notification</property>
+ <property name="color">#000000000000</property>
+ <signal name="color_set" handler="on_notification_colorbutton_color_set"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSpinButton" id="message_length_spinbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Message length at which notification is invoked.</property>
+ <property name="width_chars">6</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ <signal name="value_changed" handler="on_message_length_spinbutton_value_changed"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/length_notifier/length_notifier.py b/length_notifier/length_notifier.py
new file mode 100644
index 0000000..3c9e9bc
--- /dev/null
+++ b/length_notifier/length_notifier.py
@@ -0,0 +1,157 @@
+# -*- coding: utf-8 -*-
+
+## This file is part of Gajim.
+##
+## Gajim is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation; version 3 only.
+##
+## Gajim is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+##
+
+'''
+Message length notifier plugin.
+
+:author: Mateusz Biliński <mateusz@bilinski.it>
+:since: 1st June 2008
+:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
+:license: GPL
+'''
+
+import sys
+
+import gtk
+
+from plugins import GajimPlugin
+from plugins.helpers import log, log_calls
+from plugins.gui import GajimPluginConfigDialog
+
+class LengthNotifierPlugin(GajimPlugin):
+
+ @log_calls('LengthNotifierPlugin')
+ def init(self):
+ self.description = _('Highlights message entry field in chat window '
+ 'when given length of message is exceeded.')
+ self.config_dialog = LengthNotifierPluginConfigDialog(self)
+
+ self.gui_extension_points = {
+ 'chat_control' : (self.connect_with_chat_control,
+ self.disconnect_from_chat_control)
+ }
+
+ self.config_default_values = {
+ 'MESSAGE_WARNING_LENGTH' : (140, 'Message length at which notification is invoked.'),
+ 'WARNING_COLOR' : ('#F0DB3E', 'Background color of text entry field in chat window when notification is invoked.'),
+ 'JIDS' : ([], 'JabberIDs that plugin should be used with (eg. restrict only to one microblogging bot). If empty plugin is used with every JID. [not implemented]')
+ }
+
+ @log_calls('LengthNotifierPlugin')
+ def textview_length_warning(self, tb, chat_control):
+ tv = chat_control.msg_textview
+ d = chat_control.length_notifier_plugin_data
+ t = tb.get_text(tb.get_start_iter(), tb.get_end_iter())
+ if t:
+ len_t = len(t)
+ #print("len_t: %d"%(len_t))
+ if len_t>self.config['MESSAGE_WARNING_LENGTH']:
+ if not d['prev_color']:
+ d['prev_color'] = tv.style.copy().base[gtk.STATE_NORMAL]
+ tv.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.config['WARNING_COLOR']))
+ elif d['prev_color']:
+ tv.modify_base(gtk.STATE_NORMAL, d['prev_color'])
+ d['prev_color'] = None
+
+ @log_calls('LengthNotifierPlugin')
+ def connect_with_chat_control(self, chat_control):
+ jid = chat_control.contact.jid
+ if self.jid_is_ok(jid):
+ d = {'prev_color' : None}
+ tv = chat_control.msg_textview
+ tb = tv.get_buffer()
+ h_id = tb.connect('changed', self.textview_length_warning, chat_control)
+ d['h_id'] = h_id
+
+ t = tb.get_text(tb.get_start_iter(), tb.get_end_iter())
+ if t:
+ len_t = len(t)
+ if len_t>self.config['MESSAGE_WARNING_LENGTH']:
+ d['prev_color'] = tv.style.copy().base[gtk.STATE_NORMAL]
+ tv.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.config['WARNING_COLOR']))
+
+ chat_control.length_notifier_plugin_data = d
+
+ return True
+
+ return False
+
+ @log_calls('LengthNotifierPlugin')
+ def disconnect_from_chat_control(self, chat_control):
+ try:
+ d = chat_control.length_notifier_plugin_data
+ tv = chat_control.msg_textview
+ tv.get_buffer().disconnect(d['h_id'])
+ if d['prev_color']:
+ tv.modify_base(gtk.STATE_NORMAL, d['prev_color'])
+ except AttributeError, error:
+ pass
+ #log.debug('Length Notifier Plugin was (probably) never connected with this chat window.\n Error: %s' % (error))
+
+ @log_calls('LengthNotifierPlugin')
+ def jid_is_ok(self, jid):
+ if jid in self.config['JIDS'] or not self.config['JIDS']:
+ return True
+
+ return False
+
+class LengthNotifierPluginConfigDialog(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_plugins')
+ self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
+ ['length_notifier_config_table'])
+ self.config_table = self.xml.get_object('length_notifier_config_table')
+ self.child.pack_start(self.config_table)
+
+ self.message_length_spinbutton = self.xml.get_object(
+ 'message_length_spinbutton')
+ self.message_length_spinbutton.get_adjustment().set_all(140, 0, 500, 1,
+ 10, 0)
+ self.notification_colorbutton = self.xml.get_object(
+ 'notification_colorbutton')
+ self.jids_entry = self.xml.get_object('jids_entry')
+
+ self.xml.connect_signals(self)
+
+ def on_run(self):
+ self.message_length_spinbutton.set_value(self.plugin.config['MESSAGE_WARNING_LENGTH'])
+ self.notification_colorbutton.set_color(gtk.gdk.color_parse(self.plugin.config['WARNING_COLOR']))
+ #self.jids_entry.set_text(self.plugin.config['JIDS'])
+ self.jids_entry.set_text(','.join(self.plugin.config['JIDS']))
+
+ @log_calls('LengthNotifierPluginConfigDialog')
+ def on_message_length_spinbutton_value_changed(self, spinbutton):
+ self.plugin.config['MESSAGE_WARNING_LENGTH'] = spinbutton.get_value()
+
+ @log_calls('LengthNotifierPluginConfigDialog')
+ def on_notification_colorbutton_color_set(self, colorbutton):
+ self.plugin.config['WARNING_COLOR'] = colorbutton.get_color().to_string()
+
+ @log_calls('LengthNotifierPluginConfigDialog')
+ def on_jids_entry_changed(self, entry):
+ text = entry.get_text()
+ if len(text)>0:
+ self.plugin.config['JIDS'] = entry.get_text().split(',')
+ else:
+ self.plugin.config['JIDS'] = []
+
+ @log_calls('LengthNotifierPluginConfigDialog')
+ def on_jids_entry_editing_done(self, entry):
+ pass
diff --git a/length_notifier/manifest.ini b/length_notifier/manifest.ini
new file mode 100644
index 0000000..d50feaa
--- /dev/null
+++ b/length_notifier/manifest.ini
@@ -0,0 +1,9 @@
+[info]
+name: Message Length Notifier
+short_name: length_notifier
+version: 0.1
+description: Highlights message entry field in chat window when given length of message is exceeded.
+authors = Mateusz Biliński <mateusz@bilinski.it>
+homepage = http://blog.bilinski.it
+
+