Skip to content
Snippets Groups Projects
Commit 6ad3d01f authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

remove plugins that have been move to gajim-plugins reprository

parent 87504e39
No related branches found
No related tags found
No related merge requests found
Showing
with 1 addition and 2659 deletions
SUBDIRS = src data plugins po icons
SUBDIRS = src data po icons
ACLOCAL_AMFLAGS = -I m4
......
......@@ -79,7 +79,6 @@ AC_CONFIG_FILES([
scripts/gajim-remote:scripts/gajim.in
scripts/gajim-history-manager:scripts/gajim.in
po/Makefile.in
plugins/Makefile
])
AC_OUTPUT
echo "
......
INCLUDES = \
$(PYTHON_INCLUDES)
gajimpluginsdir = $(gajim_pluginsdir)
installedplugins = acronyms_expander banner_tweaks length_notifier plugin_installer triggers whiteboard
installedpluginsfiles = $(wildcard ${srcdir}/${p}/*.py ${srcdir}/${p}/manifest.ini ${srcdir}/${p}/*.ui ${srcdir}/${p}/*.png)
nobase_dist_gajimplugins_PYTHON = $(foreach p, ${installedplugins}, $(installedpluginsfiles))
EXTRA_DIST = \
$(srcdir)/*/*.py \
$(srcdir)/*/manifest.ini \
$(srcdir)/*/*.ui
MAINTAINERCLEANFILES = Makefile.in
from plugin import BannerTweaksPlugin
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkVBox" id="banner_tweaks_config_vbox">
<property name="visible">True</property>
<property name="border_width">9</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkCheckButton" id="show_banner_image_checkbutton">
<property name="label" translatable="yes">Display status icon</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If checked, status icon will be displayed in chat window banner.</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_banner_image_checkbutton_toggled"/>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_banner_online_msg_checkbutton">
<property name="label" translatable="yes">Display status message of contact</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If checked, status message of contact will be displayed in chat window banner.</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_banner_online_msg_checkbutton_toggled"/>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_banner_resource_checkbutton">
<property name="label" translatable="yes">Display resource name of contact</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If checked, resource name of contact will be displayed in chat window banner.</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_show_banner_resource_checkbutton_toggled"/>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="banner_small_fonts_checkbutton">
<property name="label" translatable="yes">Use small fonts for contact name and resource name</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If checked, smaller font will be used to display resource name and contact name in chat window banner.</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_banner_small_fonts_checkbutton_toggled"/>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
[info]
name: Banner Tweaks
short_name: banner_tweaks
version: 0.1
description: Allows user to tweak chat window banner appearance (eg. make it compact).
Based on patch by pb in ticket #4133:
http://trac.gajim.org/attachment/ticket/4133.
authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://blog.bilinski.it
# -*- 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/>.
##
'''
Adjustable chat window banner.
Includes tweaks to make it compact.
Based on patch by pb in ticket #4133:
http://trac.gajim.org/attachment/ticket/4133/gajim-chatbanneroptions-svn10008.patch
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 30 July 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
import sys
import gtk
import gobject
import message_control
from common import gajim
from common import helpers
from plugins import GajimPlugin
from plugins.helpers import log, log_calls
from plugins.gui import GajimPluginConfigDialog
class BannerTweaksPlugin(GajimPlugin):
@log_calls('BannerTweaksPlugin')
def init(self):
self.description = _('Allows user to tweak chat window banner '
'appearance (eg. make it compact).\n'
'Based on patch by pb in ticket #4133:\n'
'http://trac.gajim.org/attachment/ticket/4133.')
self.config_dialog = BannerTweaksPluginConfigDialog(self)
self.gui_extension_points = {
'chat_control_base_draw_banner': (self.chat_control_base_draw_banner_called,
self.chat_control_base_draw_banner_deactivation)
}
self.config_default_values = {
'show_banner_image': (True, 'If True, Gajim will display a status icon in the banner of chat windows.'),
'show_banner_online_msg': (True, 'If True, Gajim will display the status message of the contact in the banner of chat windows.'),
'show_banner_resource': (False, 'If True, Gajim will display the resource name of the contact in the banner of chat windows.'),
'banner_small_fonts': (False, 'If True, Gajim will use small fonts for contact name and resource name in the banner of chat windows.'),
'old_chat_avatar_height': (52, 'chat_avatar_height value before plugin was activated'),
}
@log_calls('BannerTweaksPlugin')
def activate(self):
self.config['old_chat_avatar_height'] = gajim.config.get('chat_avatar_height')
#gajim.config.set('chat_avatar_height', 28)
@log_calls('BannerTweaksPlugin')
def deactivate(self):
gajim.config.set('chat_avatar_height', self.config['old_chat_avatar_height'])
@log_calls('BannerTweaksPlugin')
def chat_control_base_draw_banner_called(self, chat_control):
if not self.config['show_banner_online_msg']:
chat_control.banner_status_label.hide()
chat_control.banner_status_label.set_no_show_all(True)
status_text = ''
chat_control.banner_status_label.set_markup(status_text)
if not self.config['show_banner_image']:
if chat_control.TYPE_ID == message_control.TYPE_GC:
banner_status_img = chat_control.xml.get_object(
'gc_banner_status_image')
else:
banner_status_img = chat_control.xml.get_object(
'banner_status_image')
banner_status_img.clear()
# TODO: part below repeats a lot of code from ChatControl.draw_banner_text()
# This could be rewritten using re module: getting markup text from
# banner_name_label and replacing some elements based on plugin config.
# Would it be faster?
if self.config['show_banner_resource'] or self.config['banner_small_fonts']:
banner_name_label = chat_control.xml.get_object('banner_name_label')
label_text = banner_name_label.get_label()
contact = chat_control.contact
jid = contact.jid
name = contact.get_shown_name()
if chat_control.resource:
name += '/' + chat_control.resource
elif contact.resource and self.config['show_banner_resource']:
name += '/' + contact.resource
if chat_control.TYPE_ID == message_control.TYPE_PM:
name = _('%(nickname)s from group chat %(room_name)s') %\
{'nickname': name, 'room_name': chat_control.room_name}
name = gobject.markup_escape_text(name)
# We know our contacts nick, but if another contact has the same nick
# in another account we need to also display the account.
# except if we are talking to two different resources of the same contact
acct_info = ''
for account in gajim.contacts.get_accounts():
if account == chat_control.account:
continue
if acct_info: # We already found a contact with same nick
break
for jid in gajim.contacts.get_jid_list(account):
other_contact_ = \
gajim.contacts.get_first_contact_from_jid(account, jid)
if other_contact_.get_shown_name() == chat_control.contact.get_shown_name():
acct_info = ' (%s)' % \
gobject.markup_escape_text(chat_control.account)
break
font_attrs, font_attrs_small = chat_control.get_font_attrs()
if self.config['banner_small_fonts']:
font_attrs = font_attrs_small
st = gajim.config.get('displayed_chat_state_notifications')
cs = contact.chatstate
if cs and st in ('composing_only', 'all'):
if contact.show == 'offline':
chatstate = ''
elif st == 'all' or cs == 'composing':
chatstate = helpers.get_uf_chatstate(cs)
else:
chatstate = ''
label_text = '<span %s>%s</span><span %s>%s %s</span>' % \
(font_attrs, name, font_attrs_small, acct_info, chatstate)
else:
# weight="heavy" size="x-large"
label_text = '<span %s>%s</span><span %s>%s</span>' % \
(font_attrs, name, font_attrs_small, acct_info)
banner_name_label.set_markup(label_text)
@log_calls('BannerTweaksPlugin')
def chat_control_base_draw_banner_deactivation(self, chat_control):
pass
#chat_control.draw_banner()
class BannerTweaksPluginConfigDialog(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,
['banner_tweaks_config_vbox'])
self.config_vbox = self.xml.get_object('banner_tweaks_config_vbox')
self.child.pack_start(self.config_vbox)
self.show_banner_image_checkbutton = self.xml.get_object('show_banner_image_checkbutton')
self.show_banner_online_msg_checkbutton = self.xml.get_object('show_banner_online_msg_checkbutton')
self.show_banner_resource_checkbutton = self.xml.get_object('show_banner_resource_checkbutton')
self.banner_small_fonts_checkbutton = self.xml.get_object('banner_small_fonts_checkbutton')
self.xml.connect_signals(self)
def on_run(self):
self.show_banner_image_checkbutton.set_active(self.plugin.config['show_banner_image'])
self.show_banner_online_msg_checkbutton.set_active(self.plugin.config['show_banner_online_msg'])
self.show_banner_resource_checkbutton.set_active(self.plugin.config['show_banner_resource'])
self.banner_small_fonts_checkbutton.set_active(self.plugin.config['banner_small_fonts'])
def on_show_banner_image_checkbutton_toggled(self, button):
self.plugin.config['show_banner_image'] = button.get_active()
def on_show_banner_online_msg_checkbutton_toggled(self, button):
self.plugin.config['show_banner_online_msg'] = button.get_active()
def on_show_banner_resource_checkbutton_toggled(self, button):
self.plugin.config['show_banner_resource'] = button.get_active()
def on_banner_small_fonts_checkbutton_toggled(self, button):
self.plugin.config['banner_small_fonts'] = button.get_active()
from plugin import GoogleTranslationPlugin
[info]
name: Google Translation
short_name: google_translation
version: 0.2
description: Translates (currently only incoming) messages using Google Translate.
authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://blog.bilinski.it
# -*- 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/>.
##
'''
Google Translation plugin.
Translates (currently only incoming) messages using Google Translate.
:note: consider this as proof-of-concept
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 25th August 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
import json
import urllib2
import HTMLParser
import gtk
from sys import getfilesystemencoding
import chat_control
import groupchat_control
from common import helpers
from common import gajim
from plugins import GajimPlugin
from plugins.helpers import log_calls, log
from common import ged
languages = {
_('Afrikaans'): 'af',
_('Albanian'): 'sq',
_('Armenian'): 'hy',
_('Azerbaijani'): 'az',
_('Arabic'): 'ar',
_('Basque'): 'eu',
_('Belarusian'): 'be',
_('Bulgarian'): 'bg',
_('Catalan'): 'ca',
_('Chinese (Simplified)'): 'zh-cn',
_('Chinese (Traditional)'): 'zh-tw',
_('Croatian'): 'hr',
_('Czech'): 'cs',
_('Danish'): 'da',
_('Dutch'): 'nl',
_('English'): 'en',
_('Estonian'): 'et',
_('Filipino'): 'tl',
_('Finnish'): 'fi',
_('French'): 'fr',
_('Galician'): 'gl',
_('Georgian'): 'ka',
_('German'): 'de',
_('Greek'): 'el',
_('Haitian Creole'): 'ht',
_('Hebrew'): 'iw',
_('Hindi'): 'hi',
_('Hungarian'): 'hu',
_('Icelandic'): 'is',
_('Indonesian'): 'id',
_('Italian'): 'it',
_('Irish'): 'da',
_('Japanese'): 'ja',
_('Korean'): 'ko',
_('Latvian'): 'lv',
_('Lithuanian'): 'lt',
_('Macedonian'): 'mk',
_('Malay'): 'ml',
_('Maltese'): 'mt',
_('Norwegian'): 'no',
_('Persian'): 'fa',
_('Polish'): 'pl',
_('Portuguese'): 'pt-BR',
_('Romanian'): 'ro',
_('Russian'): 'ru',
_('Serbian'): 'sr',
_('Slovak'): 'sk',
_('Slovenian'): 'sl',
_('Spanish'): 'es',
_('Swahili'): 'sw',
_('Swedish'): 'sv',
_('Thai'): 'th',
_('Turkish'): 'tr',
_('Ukrainian'): 'uk',
_('Urdu'): 'ur',
_('Vietnamese'): 'vi',
_('Welsh'): 'cy',
_('Yiddish'): 'yi',
}
class GoogleTranslationPlugin(GajimPlugin):
@log_calls('GoogleTranslationPlugin')
def init(self):
self.description = _('Translates (currently only incoming)'
'messages using Google Translate.')
self.config_dialog = None
self.config_default_values = {
'per_jid_config': ({}, ''),
}
self.events_handlers = {'decrypted-message-received': (ged.PREGUI,
self._nec_decrypted_message_received)}
self.gui_extension_points = {
'chat_control_base' : (self.connect_with_control,
self.disconnect_from_control),
}
self.controls = []
@log_calls('GoogleTranslationPlugin')
def translate_text(self, account, text, from_lang, to_lang):
# Converts text so it can be used within URL as query to Google
# Translate.
quoted_text = urllib2.quote(text.encode(getfilesystemencoding()))
# prepare url
translation_url = u'https://ajax.googleapis.com/ajax/services/' \
'language/translate?q=%(quoted_text)s&' \
'langpair=%(from_lang)s%%7C%(to_lang)s&key=notsupplied&v=1.0' % \
locals()
results = helpers.download_image(account, {'src': translation_url})[0]
if not results:
return text
result = json.loads(results)
if result.get('responseStatus', '') != 200:
return text
translated_text = result['responseData'].get('translatedText', '')
if translated_text:
try:
htmlparser = HTMLParser.HTMLParser()
translated_text = htmlparser.unescape(translated_text)
except Exception:
pass
return translated_text
return text
@log_calls('GoogleTranslationPlugin')
def _nec_decrypted_message_received(self, obj):
if not obj.msgtxt:
return
if obj.jid not in self.config['per_jid_config']:
return
if not self.config['per_jid_config'][obj.jid]['enabled']:
return
from_lang = self.config['per_jid_config'][obj.jid]['from']
to_lang = self.config['per_jid_config'][obj.jid]['to']
translated_text = self.translate_text(obj.conn.name, obj.msgtxt,
from_lang, to_lang)
if translated_text:
obj.msgtxt = translated_text + '\n/' + _('Original text:') + '/ ' +\
obj.msgtxt
@log_calls('GoogleTranslationPlugin')
def activate(self):
pass
@log_calls('GoogleTranslationPlugin')
def deactivate(self):
pass
@log_calls('GoogleTranslationPlugin')
def connect_with_control(self, control):
base = Base(self, control)
self.controls.append(base)
@log_calls('GoogleTranslationPlugin')
def disconnect_from_control(self, chat_control):
for base in self.controls:
base.disconnect_from_control()
self.controls = []
class Base(object):
def __init__(self, plugin, control):
self.plugin = plugin
self.control = control
self.contact = control.contact
self.account = control.account
self.jid = self.contact.jid
if self.jid in self.plugin.config['per_jid_config']:
self.config = self.plugin.config['per_jid_config'][self.jid]
else:
self.config = {'from': '', 'to': 'en', 'enabled': False}
self.create_buttons()
def create_buttons(self):
if isinstance(self.control, chat_control.ChatControl):
vbox = self.control.xml.get_object('vbox106')
elif isinstance(self.control, groupchat_control.GroupchatControl):
vbox = self.control.xml.get_object('gc_textviews_vbox')
else:
return
self.expander = gtk.Expander(_('Google translation'))
hbox = gtk.HBox(spacing=6)
self.expander.add(hbox)
label = gtk.Label(_('Translate from'))
hbox.pack_start(label, False, False)
liststore1 = gtk.ListStore(str, str)
liststore2 = gtk.ListStore(str, str)
cb1 = gtk.ComboBox(liststore1)
cb2 = gtk.ComboBox(liststore2)
cell = gtk.CellRendererText()
cb1.pack_start(cell, True)
cb1.add_attribute(cell, 'text', 0)
cell = gtk.CellRendererText()
cb2.pack_start(cell, True)
cb2.add_attribute(cell, 'text', 0)
#Language to translate from
liststore1.append([_('Auto'), ''])
if self.config['from'] == '':
cb1.set_active(0)
if self.config['from'] == '':
cb1.set_active(0)
i = 0
ls = languages.items()
ls.sort()
for l in ls:
liststore1.append(l)
if l[1] == self.config['from']:
cb1.set_active(i+1)
liststore2.append(l)
if l[1] == self.config['to']:
cb2.set_active(i)
i += 1
hbox.pack_start(cb1, False, False)
label = gtk.Label(_('to'))
hbox.pack_start(label, False, False)
hbox.pack_start(cb2, False, False)
cb = gtk.CheckButton(_('enable'))
if self.config['enabled']:
cb.set_active(True)
hbox.pack_start(cb, False, False)
vbox.pack_start(self.expander, False, False)
vbox.reorder_child(self.expander, 1)
cb1.connect('changed', self.on_cb_changed, 'from')
cb2.connect('changed', self.on_cb_changed, 'to')
cb.connect('toggled', self.on_cb_toggled)
self.expander.show_all()
def on_cb_changed(self, widget, option):
model = widget.get_model()
it = widget.get_active_iter()
self.config[option] = model[it][1]
self.plugin.config['per_jid_config'][self.jid] = self.config
self.plugin.config.save()
def on_cb_toggled(self, widget):
self.config['enabled'] = widget.get_active()
self.plugin.config['per_jid_config'][self.jid] = self.config
self.plugin.config.save()
def disconnect_from_control(self):
if isinstance(self.control, chat_control.ChatControl):
vbox = self.control.xml.get_object('vbox106')
elif isinstance(self.control, groupchat_control.GroupchatControl):
vbox = self.control.xml.get_object('gc_textviews_vbox')
else:
return
vbox.remove(self.expander)
from length_notifier import LengthNotifierPlugin
<?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>
# -*- 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
[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
from plugin_installer import PluginInstaller
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkTextBuffer" id="textbuffer1">
<property name="text">Plug-in decription should be displayed here. This text will be erased during PluginsWindow initialization.</property>
</object>
<object class="GtkWindow" id="window1">
<child>
<object class="GtkHPaned" id="hpaned2">
<property name="width_request">600</property>
<property name="height_request">350</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">340</property>
<property name="position_set">True</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">6</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkTreeView" id="available_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="search_column">1</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="plugin_name_label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">&lt;empty&gt;</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">Authors:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="plugin_authors_label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label">&lt;empty&gt;</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox9">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">Homepage:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="plugin_homepage_linkbutton1">
<property name="label">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">Description:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="plugin_description_textview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="pixels_above_lines">6</property>
<property name="wrap_mode">word</property>
<property name="left_margin">6</property>
<property name="right_margin">6</property>
<property name="indent">1</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox15">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="inslall_upgrade_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_inslall_upgrade_clicked"/>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install/Upgrade</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="window2">
<child>
<object class="GtkHBox" id="hbox111">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Ftp server:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ftp_server">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
[info]
name: Plugin Installer
short_name: plugin_installer
version: 0.5
description: Install and upgrade plugins from ftp
authors: Denis Fomin <fominde@gmail.com>
Yann Leboulanger <asterix@lagaule.org>
homepage: http://www.gajim.org/
This diff is collapsed.
from triggers import Triggers
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment