From bd853376fc789cd6aa037fb63bc6ff3adc338465 Mon Sep 17 00:00:00 2001 From: Evgeniy Popov Date: Fri, 31 May 2013 21:43:23 +0600 Subject: [PATCH] QuickRepliesPlugin. init commit --- quick_replies/README.md | 1 + quick_replies/__init__.py | 1 + quick_replies/config_dialog.ui | 303 +++++++++++++++++++++++++++++++++ quick_replies/manifest.ini | 7 + quick_replies/plugin.py | 135 +++++++++++++++ quick_replies/qicon.png | Bin 0 -> 1590 bytes 6 files changed, 447 insertions(+) create mode 100644 quick_replies/README.md create mode 100644 quick_replies/__init__.py create mode 100644 quick_replies/config_dialog.ui create mode 100644 quick_replies/manifest.ini create mode 100644 quick_replies/plugin.py create mode 100644 quick_replies/qicon.png diff --git a/quick_replies/README.md b/quick_replies/README.md new file mode 100644 index 0000000..f32ca55 --- /dev/null +++ b/quick_replies/README.md @@ -0,0 +1 @@ +# Gajim plugin QuickReplies diff --git a/quick_replies/__init__.py b/quick_replies/__init__.py new file mode 100644 index 0000000..8c4cd0b --- /dev/null +++ b/quick_replies/__init__.py @@ -0,0 +1 @@ +from plugin import QuickRepliesPlugin diff --git a/quick_replies/config_dialog.ui b/quick_replies/config_dialog.ui new file mode 100644 index 0000000..71d2826 --- /dev/null +++ b/quick_replies/config_dialog.ui @@ -0,0 +1,303 @@ + + + + + + False + 140 + 100 + + + True + False + 10 + 2 + + + True + False + 1 + + + + + True + False + 2 + + + 1 + 2 + + + + + True + False + 3 + + + 2 + 3 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 1 + 2 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 2 + 3 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 3 + 4 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 4 + 5 + + + + + True + True + + True + False + False + True + True + + + + 1 + 2 + 5 + 6 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 6 + 7 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 7 + 8 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 8 + 9 + + + + + True + True + + False + False + True + True + + + + 1 + 2 + 9 + 10 + + + + + True + False + 4 + + + 3 + 4 + + + + + True + False + 5 + + + 4 + 5 + + + + + True + False + 6 + + + 5 + 6 + + + + + True + False + 7 + + + 6 + 7 + + + + + True + False + 8 + + + 7 + 8 + + + + + True + False + 9 + + + 8 + 9 + + + + + True + False + 10 + + + 9 + 10 + + + + + + diff --git a/quick_replies/manifest.ini b/quick_replies/manifest.ini new file mode 100644 index 0000000..111d4cc --- /dev/null +++ b/quick_replies/manifest.ini @@ -0,0 +1,7 @@ +[info] +name: Quick replies +short_name: quick_replies +version: 0.0.1 +description: Plugin for quick insert template message and add your own template messages +authors = Evgeniy Popov +homepage = https://bitbucket.org/axce1/quickreplies diff --git a/quick_replies/plugin.py b/quick_replies/plugin.py new file mode 100644 index 0000000..dd8f658 --- /dev/null +++ b/quick_replies/plugin.py @@ -0,0 +1,135 @@ +import gtk +import gtkgui_helpers + +from plugins import GajimPlugin +from plugins.gui import GajimPluginConfigDialog +from plugins.helpers import log_calls + + +class QuickRepliesPlugin(GajimPlugin): + + @log_calls('QuickRepliesPlugin') + def init(self): + + self.description = _('Plugin for quick replies') + self.config_dialog = QuickRepliesPluginConfigDialog(self) + self.chat_control = None + self.gui_extension_points = { + 'chat_control_base': (self.connect_with_chat_control, + self.disconnect_from_chat_control),} + self.config_default_values = { + 'entry1': ('Hello!', ''), + 'entry2': ('How are you?', ''), + 'entry3': ('Good bye.', ''), + 'entry4': ('', ''), + 'entry5': ('', ''), + 'entry6': ('', ''), + 'entry7': ('', ''), + 'entry8': ('', ''), + 'entry9': ('', ''), + 'entry10': ('', ''), + } + self.controls = [] + + @log_calls('QuickRepliesPlugin') + def connect_with_chat_control(self, chat_control): + + self.chat_control = chat_control + control = Base(self, self.chat_control) + self.controls.append(control) + + @log_calls('QuickRepliesPlugin') + def disconnect_from_chat_control(self, chat_control): + + for control in self.controls: + control.disconnect_from_chat_contro() + self.controls = [] + +class Base(object): + + def __init__(self, plugin, chat_control): + + self.plugin = plugin + self.chat_control = chat_control + self.create_menu() + self.create_button() + + + def create_button(self): + + actions_hbox = self.chat_control.xml.get_object('actions_hbox') + self.button = gtk.Button(label=None, stock=None, use_underline=True) + self.button.set_property('relief', gtk.RELIEF_NONE) + self.button.set_property('can-focus', False) + img = gtk.Image() + img_path = self.plugin.local_file_path('qicon.png') + pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) + iconset = gtk.IconSet(pixbuf=pixbuf) + factory = gtk.IconFactory() + factory.add('quickreplies', iconset) + factory.add_default() + img.set_from_stock('quickreplies', gtk.ICON_SIZE_MENU) + self.button.set_image(img) + self.button.set_tooltip_text(_('Quick replies')) + send_button = self.chat_control.xml.get_object('send_button') + send_button_pos = actions_hbox.child_get_property(send_button, + 'position') + actions_hbox.add_with_properties(self.button, 'position', + send_button_pos - 1, 'expand', False) + id_ = self.button.connect('clicked', self.on_button_cliecked) + self.chat_control.handlers[id_] = self.button + self.button.show() + + + def on_button_cliecked(self, widget): + + gtkgui_helpers.popup_emoticons_under_button(self.menu, widget, + self.chat_control.parent_win) + + + def on_insert(self, widget, text): + + text = text.rstrip() + ' ' + message_buffer = self.chat_control.msg_textview.get_buffer() + message_buffer.insert_at_cursor(text) + self.chat_control.msg_textview.grab_focus() + + def create_menu(self): + + self.menu = gtk.Menu() + + for count in xrange(1, 11): + text = self.plugin.config['entry' + str(count)] + if not text: + continue + item = gtk.MenuItem(text) + item.connect('activate', self.on_insert, text) + self.menu.append(item) + self.menu.show_all() + +class QuickRepliesPluginConfigDialog(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, ['table1']) + hbox = self.xml.get_object('table1') + self.child.pack_start(hbox) + self.xml.connect_signals(self) + + def on_run(self): + + for count in xrange(1, 11): + self.xml.get_object('entry' + str(count)).set_text( + self.plugin.config['entry' + str(count)]) + + def entry_changed(self, widget): + + name = gtk.Buildable.get_name(widget) + self.plugin.config[name] = widget.get_text() + for control in self.plugin.controls: + control.create_menu() + diff --git a/quick_replies/qicon.png b/quick_replies/qicon.png new file mode 100644 index 0000000000000000000000000000000000000000..bc9da4bed44d12549522ab01b040645a468206cc GIT binary patch literal 1590 zcmV-62Fdw}P){MRq*}6~A%WLwSJGbguB@%ZAIq%3?(~kwgGD^?J2oN(8 zBKSatAR|Fwqy(+eAPDEwlryxT$@FB*|Mi$a^!Hb)er~DJ0y@%%MQj8BW&^b`2?4)M z0dP-)>F*!3RbDQak;rACxck#B#78-uvu8b{L_zhzGQg%_Mhh8+;IMce;K!@w zS~6-8Qf1(3^9@K&-3m{i_JCYw4`EA!z;lWRbkgf9jm^;8HvkHS98P_80HPwocx0L~ zBT)!&7K*5cMd67WoITrH)zVm^vy2fg&D-twKozxyi#j1T0uJumN!(mrY#9veN62UU zaxgcqh}hfPp|+|J<_7q23P45-B8iMrO({YHgs4`jIe_NNXDEP$A~2YcycsTCX(n-R zEyZt6>;r~j2(J@9O1_GS8M_aW+`M88S~wSKD)I>kDiTTMv^=aJjj&jqq{dmZl&WhD zMOw4T40k&oz?bR1;YZu{z@nf)a;D&bb!Lzk zQ21*q$2IR~VB^)FVE^aaXa-S&4Iv_t6vcK@Shixl8fVT_sxDRM>x}v#($(FE!RocN z)JPiZ3vrUWEA1Hzv2tT|%^thDdPr#GIvk<3s6C%ce7vXG=8{MxL8-kxM8t030klXQ)B@i(^^9WQ{UnYx#=V5O4E|5yZEZu0;I_qG}Y{s;V!{lOp6D|mx4Mq9;362Lr zL=qN24pH$N)#&T1RMk~}tsNQa=X`W`_d(n{Y0%l#18>Zq1G{#t2jvV;p&Sf6eAEe9 z*#)3&xDE~q8I%-c!D}FI~t?SIm7Jc?ApBzu1v2Kf7MqM}S9wFRSbl-S!zQRd(b zu}NFh96)v13EgmiH{UG6R38~JV)3~esGxLFAX|~$T%Ad5R4Aq-MUx4R3hq92PVx%R zW6**CsIG4!3+MUciWSQtE_tgOy}gyHs&mJ+!+o94i$!>|vCUInbqS80EMX@rI5@~5 zJY+tE1OxQkj&7j$FWXz``PZQU#!H_a5v1kDExg-tpSR&`_G oJNyr;zrVlJXf*ylFfcIoH``{ge=*}4FaQ7m07*qoM6N<$g3XNN`Tzg` literal 0 HcmV?d00001