Gui for the '/me' command plugin
This commit is contained in:
1
gui_for_me/__init__.py
Normal file
1
gui_for_me/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from gui_for_me import GuiForMe
|
||||||
BIN
gui_for_me/gui_for_me.png
Normal file
BIN
gui_for_me/gui_for_me.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 818 B |
83
gui_for_me/gui_for_me.py
Normal file
83
gui_for_me/gui_for_me.py
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import gtk
|
||||||
|
|
||||||
|
from common import gajim
|
||||||
|
from plugins import GajimPlugin
|
||||||
|
from plugins.helpers import log_calls
|
||||||
|
|
||||||
|
|
||||||
|
class GuiForMe(GajimPlugin):
|
||||||
|
|
||||||
|
@log_calls('GuiForMePlugin')
|
||||||
|
def init(self):
|
||||||
|
self.description = _('Gui for the \'/me\' command.')
|
||||||
|
self.config_dialog = None # GuiForMePluginConfigDialog(self)
|
||||||
|
self.gui_extension_points = {
|
||||||
|
'chat_control_base': (self.connect_with_chat_control,
|
||||||
|
self.disconnect_from_chat_control)}
|
||||||
|
self.controls = []
|
||||||
|
|
||||||
|
@log_calls('GuiForMePlugin')
|
||||||
|
def connect_with_chat_control(self, chat_control):
|
||||||
|
if chat_control.widget_name != 'groupchat_control':
|
||||||
|
return
|
||||||
|
|
||||||
|
self.chat_control = chat_control
|
||||||
|
control = Base(self, self.chat_control)
|
||||||
|
self.controls.append(control)
|
||||||
|
|
||||||
|
|
||||||
|
@log_calls('GuiForMePlugin')
|
||||||
|
def disconnect_from_chat_control(self, chat_control):
|
||||||
|
for control in self.controls:
|
||||||
|
control.disconnect_from_chat_control()
|
||||||
|
self.controls = []
|
||||||
|
|
||||||
|
|
||||||
|
class Base(object):
|
||||||
|
def __init__(self, plugin, chat_control):
|
||||||
|
self.chat_control = chat_control
|
||||||
|
self.plugin = plugin
|
||||||
|
self.textview = self.chat_control.conv_textview
|
||||||
|
self.change_cursor = False
|
||||||
|
|
||||||
|
self.create_buttons()
|
||||||
|
|
||||||
|
def create_buttons(self):
|
||||||
|
# create juick button
|
||||||
|
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('gui_for_me.png')
|
||||||
|
pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
|
||||||
|
iconset = gtk.IconSet(pixbuf=pixbuf)
|
||||||
|
factory = gtk.IconFactory()
|
||||||
|
factory.add('gui_for_me', iconset)
|
||||||
|
factory.add_default()
|
||||||
|
img.set_from_stock('gui_for_me', gtk.ICON_SIZE_MENU)
|
||||||
|
self.button.set_image(img)
|
||||||
|
self.button.set_tooltip_text(_('Insert /me to conversation input box,'
|
||||||
|
' at cursor position'))
|
||||||
|
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_me_button_clicked)
|
||||||
|
self.chat_control.handlers[id_] = self.button
|
||||||
|
self.button.show()
|
||||||
|
|
||||||
|
def on_me_button_clicked(self, widget):
|
||||||
|
"""
|
||||||
|
Insert /me to conversation input box, at cursor position
|
||||||
|
"""
|
||||||
|
message_buffer = self.chat_control.msg_textview.get_buffer()
|
||||||
|
message_buffer.insert_at_cursor('/me ')
|
||||||
|
self.chat_control.msg_textview.grab_focus()
|
||||||
|
|
||||||
|
def disconnect_from_chat_control(self):
|
||||||
|
actions_hbox = self.chat_control.xml.get_object('actions_hbox')
|
||||||
|
actions_hbox.remove(self.button)
|
||||||
10
gui_for_me/manifest.ini
Normal file
10
gui_for_me/manifest.ini
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[info]
|
||||||
|
name: GUI For Me
|
||||||
|
short_name: gui_for_me
|
||||||
|
version: 0.1
|
||||||
|
description: Gui for the '/me' command.
|
||||||
|
authors: BomberMan
|
||||||
|
copper
|
||||||
|
Denis Fomin <fominde@gmail.com>
|
||||||
|
homepage: http://trac-plugins.gajim.org/wiki/GUIForMePlugin
|
||||||
|
max_gajim_version: 0.15.9
|
||||||
Reference in New Issue
Block a user