From babd1ee042e82a72aeac582ca93bfdbe7e3a6f2e Mon Sep 17 00:00:00 2001
From: Stephan Erb <steve-e@h3c.de>
Date: Mon, 11 Jun 2007 08:37:46 +0000
Subject: [PATCH] Enable ellipsization in roster and chatwindow. Fixes #2079,
 #2739 Reorder occupantlist in groupchat to match roster. Fixes #2102

---
 data/glade/message_window.glade |  2 +-
 src/config.py                   |  9 ++++++++-
 src/groupchat_control.py        | 18 +++++++++++-------
 src/roster_window.py            |  4 ++++
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/data/glade/message_window.glade b/data/glade/message_window.glade
index ad23fad7bb..77d9028b11 100644
--- a/data/glade/message_window.glade
+++ b/data/glade/message_window.glade
@@ -591,7 +591,7 @@ Status message</property>
 		      <property name="yalign">0.5</property>
 		      <property name="xpad">0</property>
 		      <property name="ypad">0</property>
-		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		      <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
diff --git a/src/config.py b/src/config.py
index 294885e926..9acba1a855 100644
--- a/src/config.py
+++ b/src/config.py
@@ -580,7 +580,14 @@ class PreferencesWindow:
 	def on_show_avatars_in_roster_checkbutton_toggled(self, widget):
 		self.on_checkbutton_toggled(widget, 'show_avatars_in_roster')
 		gajim.interface.roster.draw_roster()
-
+		# Redraw connected groupchats (in an ugly way)
+		for account in gajim.connections:
+			if gajim.connections[account].connected:
+				for gc_control in gajim.interface.msg_win_mgr.get_controls(
+					message_control.TYPE_GC) + \
+					gajim.interface.minimized_controls[account].values():
+						gc_control.draw_roster()
+	
 	def on_emoticons_combobox_changed(self, widget):
 		active = widget.get_active()
 		model = widget.get_model()
diff --git a/src/groupchat_control.py b/src/groupchat_control.py
index fc4c55cedd..d698706f4e 100644
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -288,14 +288,8 @@ class GroupchatControl(ChatControlBase):
 		# first one img, second one text, third is sec pixbuf
 		column = gtk.TreeViewColumn()
 
-		renderer_pixbuf = gtk.CellRendererPixbuf() # avatar image
-		column.pack_start(renderer_pixbuf, expand = False)
-		column.add_attribute(renderer_pixbuf, 'pixbuf', C_AVATAR)
-		column.set_cell_data_func(renderer_pixbuf, tree_cell_data_func,
-			self.list_treeview)
-		renderer_pixbuf.set_property('xalign', 1) # align pixbuf to the right
-
 		renderer_image = cell_renderer_image.CellRendererImage(0, 0) # status img
+		renderer_image.set_property('width', 26)
 		column.pack_start(renderer_image, expand = False)
 		column.add_attribute(renderer_image, 'image', C_IMG)
 		column.set_cell_data_func(renderer_image, tree_cell_data_func, 
@@ -304,9 +298,17 @@ class GroupchatControl(ChatControlBase):
 		renderer_text = gtk.CellRendererText() # nickname
 		column.pack_start(renderer_text, expand = True)
 		column.add_attribute(renderer_text, 'markup', C_TEXT)
+		renderer_text.set_property("ellipsize", pango.ELLIPSIZE_END)
 		column.set_cell_data_func(renderer_text, tree_cell_data_func,
 			self.list_treeview)
 
+		renderer_pixbuf = gtk.CellRendererPixbuf() # avatar image
+		column.pack_start(renderer_pixbuf, expand = False)
+		column.add_attribute(renderer_pixbuf, 'pixbuf', C_AVATAR)
+		column.set_cell_data_func(renderer_pixbuf, tree_cell_data_func,
+			self.list_treeview)
+		renderer_pixbuf.set_property('xalign', 1) # align pixbuf to the right
+
 		self.list_treeview.append_column(column)
 
 		# workaround to avoid gtk arrows to be shown
@@ -801,6 +803,8 @@ class GroupchatControl(ChatControlBase):
 			self.add_contact_to_roster(nick, gc_contact.show, gc_contact.role,
 						gc_contact.affiliation, gc_contact.status,
 						gc_contact.jid)
+		# Recalculate column width for ellipsizin
+		self.list_treeview.columns_autosize()
 
 	def on_send_pm(self, widget = None, model = None, iter = None, nick = None,
 	msg = None):
diff --git a/src/roster_window.py b/src/roster_window.py
index 283513e983..374fb425e1 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -16,6 +16,7 @@
 ##
 
 import gtk
+import pango
 import gobject
 import os
 import time
@@ -1188,6 +1189,8 @@ class RosterWindow:
 		for acct in gajim.connections:
 			self.add_account_to_roster(acct)
 			self.add_account_contacts(acct)
+		# Recalculate column width for ellipsizing 
+		self.tree.columns_autosize()
 
 	def add_account_contacts(self, account):
 		'''adds contacts of group to roster treeview'''
@@ -5045,6 +5048,7 @@ class RosterWindow:
 		col.set_cell_data_func(render_image, self.iconCellDataFunc, None)
 
 		render_text = gtk.CellRendererText() # contact or group or account name
+		render_text.set_property("ellipsize", pango.ELLIPSIZE_END)
 		col.pack_start(render_text, expand = True)
 		col.add_attribute(render_text, 'markup', C_NAME) # where we hold the name
 		col.set_cell_data_func(render_text, self.nameCellDataFunc, None)
-- 
GitLab