Message Box Size plugin added
This commit is contained in:
1
message_box_size/__init__.py
Normal file
1
message_box_size/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from msg_box_size import MsgBoxSizePlugin
|
||||
77
message_box_size/config_dialog.ui
Normal file
77
message_box_size/config_dialog.ui
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="message_box_size_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.029999999329447746</property>
|
||||
<property name="label" translatable="yes">Message box size</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="track_visited_links">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="message_box_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</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_box_size_value_changed"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</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="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton">
|
||||
<property name="label" translatable="yes">Do not resize message box</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_checkbutton_toggled"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
7
message_box_size/manifest.ini
Normal file
7
message_box_size/manifest.ini
Normal file
@@ -0,0 +1,7 @@
|
||||
[info]
|
||||
name: Message Box Size
|
||||
short_name: message_box_size
|
||||
version: 0.1
|
||||
description: Allows you to adjust the height of the new message input field.
|
||||
authors: Denis Fomin <fominde@gmail.com>
|
||||
homepage: http://trac-plugins.gajim.org/wiki/JuickPlugin
|
||||
99
message_box_size/msg_box_size.py
Normal file
99
message_box_size/msg_box_size.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import gtk
|
||||
|
||||
from common import gajim
|
||||
from plugins import GajimPlugin
|
||||
from plugins.helpers import log_calls, log
|
||||
from plugins.gui import GajimPluginConfigDialog
|
||||
|
||||
|
||||
class MsgBoxSizePlugin(GajimPlugin):
|
||||
@log_calls('MsgBoxSizePlugin')
|
||||
def init(self):
|
||||
self.description = _('Allows you to adjust the height'
|
||||
' of the new message input field.')
|
||||
self.config_dialog = MsgBoxSizePluginConfigDialog(self)
|
||||
self.gui_extension_points = {
|
||||
'chat_control_base': (self.connect_with_chat_control,
|
||||
self.disconnect_from_chat_control)}
|
||||
self.config_default_values = {'Do_not_resize': (False, ''),
|
||||
'Message_box_size': (40, ''),}
|
||||
self.chat_control = None
|
||||
self.controls = []
|
||||
|
||||
@log_calls('MsgBoxSizePlugin')
|
||||
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('MsgBoxSizePlugin')
|
||||
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):
|
||||
if plugin.config['Do_not_resize']:
|
||||
chat_control.msg_textview.set_property('height-request',
|
||||
plugin.config['Message_box_size'])
|
||||
|
||||
id_ = chat_control.msg_textview.connect('size-request',
|
||||
self.size_request)
|
||||
chat_control.handlers[id_] = chat_control.msg_textview
|
||||
self.chat_control = chat_control
|
||||
self.plugin = plugin
|
||||
self.scrolledwindow = chat_control.conv_scrolledwindow
|
||||
|
||||
def size_request(self, msg_textview, requisition):
|
||||
if msg_textview.window is None:
|
||||
return
|
||||
|
||||
if self.plugin.config['Do_not_resize']:
|
||||
self.chat_control.conv_scrolledwindow.set_property('height-request',
|
||||
self.chat_control.conv_scrolledwindow.allocation.height)
|
||||
self.chat_control.msg_scrolledwindow.set_property(
|
||||
'vscrollbar-policy', gtk.POLICY_AUTOMATIC)
|
||||
else:
|
||||
if requisition.height < self.plugin.config['Message_box_size']:
|
||||
allc = self.chat_control.msg_textview.allocation
|
||||
allc.height = self.plugin.config['Message_box_size']
|
||||
msg_textview.set_size_request(allc.width, allc.height)
|
||||
else:
|
||||
new_req = self.scrolledwindow.allocation.height - (
|
||||
requisition.height - self.plugin.config['Message_box_size'])
|
||||
if new_req > 1:
|
||||
self.scrolledwindow.set_property('height-request', new_req)
|
||||
self.chat_control.msg_textview.set_property('height-request', -1)
|
||||
|
||||
def disconnect_from_chat_control(self):
|
||||
pass
|
||||
|
||||
|
||||
class MsgBoxSizePluginConfigDialog(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, ['vbox1'])
|
||||
self.checkbutton = self.xml.get_object('checkbutton')
|
||||
self.spinbutton = self.xml.get_object('message_box_size')
|
||||
self.spinbutton.get_adjustment().set_all(20, 15, 320, 1, 10, 0)
|
||||
vbox = self.xml.get_object('vbox1')
|
||||
self.child.pack_start(vbox)
|
||||
|
||||
self.xml.connect_signals(self)
|
||||
|
||||
def on_run(self):
|
||||
self.checkbutton.set_active(self.plugin.config['Do_not_resize'])
|
||||
self.spinbutton.set_value(self.plugin.config['Message_box_size'])
|
||||
|
||||
def on_checkbutton_toggled(self, checkbutton):
|
||||
self.plugin.config['Do_not_resize'] = checkbutton.get_active()
|
||||
|
||||
def on_message_box_size_value_changed(self, spinbutton):
|
||||
self.plugin.config['Message_box_size'] = spinbutton.get_value()
|
||||
Reference in New Issue
Block a user