fixes for message view - reset size
on new tab && not always scroll to the end
This commit is contained in:
parent
a43aae3a26
commit
30517fa3e1
39
src/chat.py
39
src/chat.py
|
@ -363,12 +363,12 @@ class Chat:
|
||||||
textview.scroll_to_iter(end_iter, 0, False, 1, 1)
|
textview.scroll_to_iter(end_iter, 0, False, 1, 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def size_request(self, message_textview , requisition, xml_top,
|
def size_request(self, message_textview , requisition, xml_top):
|
||||||
message_scrolledwindow):
|
|
||||||
''' 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'''
|
||||||
if message_textview.window is None:
|
if message_textview.window is None:
|
||||||
return
|
return
|
||||||
|
message_scrolledwindow = xml_top.get_widget('message_scrolledwindow')
|
||||||
conversation_scrolledwindow = \
|
conversation_scrolledwindow = \
|
||||||
xml_top.get_widget('conversation_scrolledwindow')
|
xml_top.get_widget('conversation_scrolledwindow')
|
||||||
conversation_textview = \
|
conversation_textview = \
|
||||||
|
@ -377,19 +377,30 @@ class Chat:
|
||||||
min_height = conversation_scrolledwindow.get_property('height-request')
|
min_height = conversation_scrolledwindow.get_property('height-request')
|
||||||
conversation_height = conversation_textview.window.get_size()[1]
|
conversation_height = conversation_textview.window.get_size()[1]
|
||||||
message_height = message_textview.window.get_size()[1]
|
message_height = message_textview.window.get_size()[1]
|
||||||
|
# new tab is not exposed yet
|
||||||
|
if conversation_height < 2:
|
||||||
|
return
|
||||||
|
|
||||||
|
if conversation_height < min_height:
|
||||||
|
min_height = conversation_height
|
||||||
|
|
||||||
diff_y = message_height - requisition.height
|
diff_y = message_height - requisition.height
|
||||||
if diff_y is not 0:
|
if diff_y is not 0:
|
||||||
if conversation_height + diff_y < min_height:
|
if conversation_height + diff_y < min_height:
|
||||||
message_scrolledwindow.set_property('vscrollbar-policy', gtk.POLICY_AUTOMATIC)
|
message_scrolledwindow.set_property('vscrollbar-policy',
|
||||||
message_scrolledwindow.set_property('hscrollbar-policy', gtk.POLICY_AUTOMATIC)
|
gtk.POLICY_AUTOMATIC)
|
||||||
|
message_scrolledwindow.set_property('hscrollbar-policy',
|
||||||
|
gtk.POLICY_AUTOMATIC)
|
||||||
message_scrolledwindow.set_property('height-request', message_height + \
|
message_scrolledwindow.set_property('height-request', message_height + \
|
||||||
conversation_height - min_height)
|
conversation_height - min_height)
|
||||||
self.bring_scroll_to_end(message_textview)
|
self.bring_scroll_to_end(message_textview)
|
||||||
else:
|
else:
|
||||||
message_scrolledwindow.set_property('vscrollbar-policy', gtk.POLICY_NEVER)
|
message_scrolledwindow.set_property('vscrollbar-policy',
|
||||||
message_scrolledwindow.set_property('hscrollbar-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)
|
||||||
self.bring_scroll_to_end(conversation_textview, diff_y)
|
self.bring_scroll_to_end(conversation_textview, diff_y - 18)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def new_tab(self, jid):
|
def new_tab(self, jid):
|
||||||
|
@ -475,26 +486,18 @@ class Chat:
|
||||||
if self.widget_name == 'tabbed_chat_window':
|
if self.widget_name == 'tabbed_chat_window':
|
||||||
xm = gtk.glade.XML(GTKGUI_GLADE, 'chat_tab_hbox', APP)
|
xm = gtk.glade.XML(GTKGUI_GLADE, 'chat_tab_hbox', APP)
|
||||||
tab_hbox = xm.get_widget('chat_tab_hbox')
|
tab_hbox = xm.get_widget('chat_tab_hbox')
|
||||||
message_textview = self.xmls[jid].get_widget('message_textview')
|
|
||||||
message_scrolledwindow = self.xmls[jid].get_widget('message_scrolledwindow')
|
|
||||||
elif self.widget_name == 'groupchat_window':
|
elif self.widget_name == 'groupchat_window':
|
||||||
xm = gtk.glade.XML(GTKGUI_GLADE, 'groupchat_tab_hbox', APP)
|
xm = gtk.glade.XML(GTKGUI_GLADE, 'groupchat_tab_hbox', APP)
|
||||||
tab_hbox = xm.get_widget('groupchat_tab_hbox')
|
tab_hbox = xm.get_widget('groupchat_tab_hbox')
|
||||||
message_textview = self.xmls[jid].get_widget('message_textview')
|
|
||||||
message_scrolledwindow = self.xmls[jid].get_widget('message_scrolledwindow')
|
|
||||||
|
|
||||||
xm.signal_connect('on_close_button_clicked',
|
xm.signal_connect('on_close_button_clicked',
|
||||||
self.on_close_button_clicked, jid)
|
self.on_close_button_clicked, jid)
|
||||||
|
|
||||||
child = self.childs[jid]
|
child = self.childs[jid]
|
||||||
self.notebook.append_page(child, tab_hbox)
|
self.notebook.append_page(child, tab_hbox)
|
||||||
|
message_textview = self.xmls[jid].get_widget('message_textview')
|
||||||
message_textview.connect('size-request', self.size_request,
|
message_textview.connect('size-request', self.size_request,
|
||||||
self.xmls[jid], message_scrolledwindow)
|
self.xmls[jid])
|
||||||
|
|
||||||
message_scrolledwindow.set_property('height-request', -1)
|
|
||||||
message_scrolledwindow.set_property('hscrollbar-policy', gtk.POLICY_NEVER)
|
|
||||||
message_scrolledwindow.set_property('vscrollbar-policy', gtk.POLICY_NEVER)
|
|
||||||
#init new sent history for this conversation
|
#init new sent history for this conversation
|
||||||
self.sent_history[jid] = []
|
self.sent_history[jid] = []
|
||||||
self.sent_history_pos[jid] = 0
|
self.sent_history_pos[jid] = 0
|
||||||
|
|
Loading…
Reference in New Issue