Commit 735e0165 authored by Dicson's avatar Dicson

message_box_size. minimum size in lines not in pixels

parent acc940a4
......@@ -18,7 +18,7 @@
<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="label" translatable="yes">Minimum lines</property>
<property name="ellipsize">start</property>
<property name="track_visited_links">False</property>
</object>
......@@ -27,14 +27,14 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="message_box_size">
<object class="GtkSpinButton" id="minimum_lines">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</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"/>
<signal name="value_changed" handler="on_minimum_lines_value_changed"/>
</object>
<packing>
<property name="expand">False</property>
......@@ -58,7 +58,7 @@
</child>
<child>
<object class="GtkCheckButton" id="checkbutton">
<property name="label" translatable="yes">Do not resize message box</property>
<property name="label" translatable="yes">Do not resize input message field</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
......
[info]
name: Message Box Size
short_name: message_box_size
version: 0.1
version: 0.2
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
......@@ -18,7 +18,7 @@ class MsgBoxSizePlugin(GajimPlugin):
'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, ''),}
'Minimum_lines': (2, ''),}
self.chat_control = None
self.controls = []
......@@ -37,8 +37,12 @@ class MsgBoxSizePlugin(GajimPlugin):
class Base(object):
def __init__(self, plugin, chat_control):
chat_control.msg_textview.set_property('height-request',
plugin.config['Message_box_size'])
tbuffer = chat_control.msg_textview.get_buffer()
min_size = chat_control.msg_textview.get_line_yrange(
tbuffer.get_start_iter())[1] * plugin.config['Minimum_lines'] + 2
chat_control.msg_textview.set_property('height-request', min_size)
# plugin.config['Minimum_lines'])
self.id_ = chat_control.msg_textview.connect('size-request',
self.size_request)
......@@ -47,14 +51,17 @@ class Base(object):
self.plugin = plugin
def size_request(self, msg_textview, requisition):
tbuffer = msg_textview.get_buffer()
min_size = msg_textview.get_line_yrange(tbuffer.get_start_iter())[1] * \
self.plugin.config['Minimum_lines'] + 2
if self.plugin.config['Do_not_resize']:
self.chat_control.msg_scrolledwindow.set_property(
'vscrollbar-policy', gtk.POLICY_AUTOMATIC)
elif requisition.height > self.plugin.config['Message_box_size']:
elif requisition.height > min_size:
msg_textview.set_property('height-request', requisition.height)
else:
msg_textview.set_property('height-request',
self.plugin.config['Message_box_size'])
msg_textview.set_property('height-request', min_size)
def disconnect_from_chat_control(self):
if self.id_ not in self.chat_control.handlers:
......@@ -74,8 +81,8 @@ class MsgBoxSizePluginConfigDialog(GajimPluginConfigDialog):
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, 16, 200, 1, 10, 0)
self.spinbutton = self.xml.get_object('minimum_lines')
self.spinbutton.get_adjustment().set_all(20, 1, 10, 1, 10, 0)
vbox = self.xml.get_object('vbox1')
self.child.pack_start(vbox)
......@@ -83,10 +90,10 @@ class MsgBoxSizePluginConfigDialog(GajimPluginConfigDialog):
def on_run(self):
self.checkbutton.set_active(self.plugin.config['Do_not_resize'])
self.spinbutton.set_value(self.plugin.config['Message_box_size'])
self.spinbutton.set_value(self.plugin.config['Minimum_lines'])
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()
def on_minimum_lines_value_changed(self, spinbutton):
self.plugin.config['Minimum_lines'] = spinbutton.get_value()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment