clean up code [we do not need to touch horizontal on checking on height] add verbose comments
This commit is contained in:
parent
47d1c0ac58
commit
4f46b4e7c1
1 changed files with 16 additions and 8 deletions
22
src/chat.py
22
src/chat.py
|
@ -647,7 +647,9 @@ class Chat:
|
||||||
|
|
||||||
def size_request(self, msg_textview , requisition, xml_top):
|
def size_request(self, msg_textview , requisition, xml_top):
|
||||||
''' When message_textview changes its size. If the new height
|
''' When message_textview changes its size. If the new height
|
||||||
will enlarge the window, enable the scrollbar automatic policy'''
|
will enlarge the window, enable the scrollbar automatic policy
|
||||||
|
Also enable scrollbar automatic policy for horizontal scrollbar
|
||||||
|
if message we have in message_textview is too big'''
|
||||||
if msg_textview.window is None:
|
if msg_textview.window is None:
|
||||||
return
|
return
|
||||||
message_scrolledwindow = xml_top.get_widget('message_scrolledwindow')
|
message_scrolledwindow = xml_top.get_widget('message_scrolledwindow')
|
||||||
|
@ -667,27 +669,33 @@ class Chat:
|
||||||
if conversation_height < min_height:
|
if conversation_height < min_height:
|
||||||
min_height = conversation_height
|
min_height = conversation_height
|
||||||
|
|
||||||
|
# we don't want to always resize in height the message_textview
|
||||||
|
# so we have minimum on conversation_textview's scrolled window
|
||||||
|
# but we also want to avoid window resizing so if we reach that
|
||||||
|
# minimum for conversation_textview and maximum for message_textview
|
||||||
|
# we set to automatic the scrollbar policy
|
||||||
diff_y = message_height - requisition.height
|
diff_y = message_height - requisition.height
|
||||||
if diff_y is not 0:
|
if diff_y != 0:
|
||||||
if conversation_height + diff_y < min_height:
|
if conversation_height + diff_y < min_height:
|
||||||
if message_height + conversation_height - min_height > min_height:
|
if message_height + conversation_height - min_height > min_height:
|
||||||
message_scrolledwindow.set_property('vscrollbar-policy',
|
message_scrolledwindow.set_property('vscrollbar-policy',
|
||||||
gtk.POLICY_AUTOMATIC)
|
gtk.POLICY_AUTOMATIC)
|
||||||
message_scrolledwindow.set_property('hscrollbar-policy',
|
|
||||||
gtk.POLICY_AUTOMATIC)
|
|
||||||
message_scrolledwindow.set_property('height-request',
|
message_scrolledwindow.set_property('height-request',
|
||||||
message_height + conversation_height - min_height)
|
message_height + conversation_height - min_height)
|
||||||
self.bring_scroll_to_end(msg_textview)
|
self.bring_scroll_to_end(msg_textview)
|
||||||
else:
|
else:
|
||||||
message_scrolledwindow.set_property('vscrollbar-policy',
|
message_scrolledwindow.set_property('vscrollbar-policy',
|
||||||
gtk.POLICY_NEVER)
|
gtk.POLICY_NEVER)
|
||||||
message_scrolledwindow.set_property('hscrollbar-policy',
|
|
||||||
gtk.POLICY_NEVER)
|
|
||||||
message_scrolledwindow.set_property('height-request', -1)
|
message_scrolledwindow.set_property('height-request', -1)
|
||||||
|
|
||||||
|
conv_textview.bring_scroll_to_end(diff_y - 18)
|
||||||
|
|
||||||
|
# enable scrollbar automatic policy for horizontal scrollbar
|
||||||
|
# if message we have in message_textview is too big
|
||||||
if requisition.width > message_width:
|
if requisition.width > message_width:
|
||||||
message_scrolledwindow.set_property('hscrollbar-policy',
|
message_scrolledwindow.set_property('hscrollbar-policy',
|
||||||
gtk.POLICY_AUTOMATIC)
|
gtk.POLICY_AUTOMATIC)
|
||||||
conv_textview.bring_scroll_to_end(diff_y - 18)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_tab_eventbox_button_press_event(self, widget, event, child):
|
def on_tab_eventbox_button_press_event(self, widget, event, child):
|
||||||
|
|
Loading…
Add table
Reference in a new issue