[pychess] push by gbtami - Use uistuff.appendAutowrapColumn() in bookPanel analyzis line column on 2015-01-15 20:38 GMT

1 view
Skip to first unread message

pyc...@googlecode.com

unread,
Jan 15, 2015, 3:39:01 PM1/15/15
to pychess...@googlegroups.com
Revision: 2a09f1ab79ca
Branch: default
Author: gbtami
Date: Thu Jan 15 20:37:45 2015 UTC
Log: Use uistuff.appendAutowrapColumn() in bookPanel analyzis line
column
https://code.google.com/p/pychess/source/detail?r=2a09f1ab79ca

Modified:
/lib/pychess/System/uistuff.py
/lib/pychess/widgets/ChatWindow.py
/lib/pychess/widgets/preferencesDialog.py
/sidepanel/bookPanel.py
/sidepanel/commentPanel.py

=======================================
--- /lib/pychess/System/uistuff.py Tue Dec 30 15:33:20 2014 UTC
+++ /lib/pychess/System/uistuff.py Thu Jan 15 20:37:45 2015 UTC
@@ -92,10 +92,11 @@



-def appendAutowrapColumn (treeview, defwidth, name, **kvargs):
+# wrap analysis text column. thanks to
+#
http://www.islascruz.org/html/index.php?blog/show/Wrap-text-in-a-TreeView-column.html
+def appendAutowrapColumn (treeview, name, **kvargs):
cell = Gtk.CellRendererText()
cell.props.wrap_mode = Pango.WrapMode.WORD
- cell.props.wrap_width = defwidth
column = Gtk.TreeViewColumn(name, cell, **kvargs)
treeview.append_column(column)

@@ -107,7 +108,7 @@
hsep.init(GObject.TYPE_INT)
hsep.set_int(0)
treeview.style_get_property("horizontal-separator", hsep)
- newWidth -= hsep.get_int() * 2
+ newWidth -= hsep.get_int() * 4

if cell.props.wrap_width == newWidth or newWidth <= 0:
return
=======================================
--- /lib/pychess/widgets/ChatWindow.py Fri Jan 2 18:25:54 2015 UTC
+++ /lib/pychess/widgets/ChatWindow.py Thu Jan 15 20:37:45 2015 UTC
@@ -361,7 +361,7 @@
cell.props.cell_background_set = True
cell.props.yalign = 0
tv.append_column(Gtk.TreeViewColumn("", cell, text=0))
- cell = uistuff.appendAutowrapColumn(tv, 50, "Notes", text=1)
+ cell = uistuff.appendAutowrapColumn(tv, "Notes", text=1)
cell.props.background_rgba = bg_color
cell.props.cell_background_set = True
sw = Gtk.ScrolledWindow()
=======================================
--- /lib/pychess/widgets/preferencesDialog.py Thu Jan 1 12:23:06 2015 UTC
+++ /lib/pychess/widgets/preferencesDialog.py Thu Jan 15 20:37:45 2015 UTC
@@ -451,7 +451,7 @@
pixbuf.props.xpad = 3
self.tv.append_column(Gtk.TreeViewColumn("Icon", pixbuf, pixbuf=1,
sensitive=0))

- uistuff.appendAutowrapColumn(self.tv, 200, "Name", markup=2,
sensitive=0)
+ uistuff.appendAutowrapColumn(self.tv, "Name", markup=2,
sensitive=0)

widgets['notebook1'].connect("switch-page", self.__on_switch_page)
widgets["preferences"].connect("show", self.__on_show_window)
=======================================
--- /sidepanel/bookPanel.py Sun Jan 4 15:38:07 2015 UTC
+++ /sidepanel/bookPanel.py Thu Jan 15 20:37:45 2015 UTC
@@ -4,7 +4,7 @@
from threading import Thread

from pychess.compat import Queue, Full
-from pychess.System import conf, fident
+from pychess.System import conf, fident, uistuff
from pychess.Utils import prettyPrintScore
from pychess.Utils.const import *
from pychess.Utils.book import getOpenings
@@ -389,37 +389,6 @@
self.advisors[int(path[0])].multipv_edited(int(text))
multipvRenderer.connect('edited', multipv_edited)

- ### header text, or analysis line
- renderer = Gtk.CellRendererText()
- renderer.set_property("wrap-mode", Pango.WrapMode.WORD)
- c3 = Gtk.TreeViewColumn("Details", renderer, text=4)
- # wrap analysis text column. thanks to
- #
http://www.islascruz.org/html/index.php?blog/show/Wrap-text-in-a-TreeView-column.html
- def resize_wrap(scroll, allocation, treeview, column, cell):
- otherColumns = (c for c in treeview.get_columns() if c !=
column)
- newWidth = allocation.width - sum(c.get_width() for c in
otherColumns)
-
- hsep = GObject.Value()
- hsep.init(GObject.TYPE_INT)
- hsep.set_int(0)
- treeview.style_get_property("horizontal-separator", hsep)
- newWidth -= hsep.get_int() * 4
-
- if cell.props.wrap_width == newWidth or newWidth <= 0:
- return
-# if newWidth < 100:
-# newWidth = 100
- cell.props.wrap_width = newWidth
-# column.set_property('min-width', newWidth + 10)
-# column.set_property('max-width', newWidth + 10)
- store = treeview.get_model()
- iter = store.get_iter_first()
- while iter and store.iter_is_valid(iter):
- store.row_changed(store.get_path(iter), iter)
- iter = store.iter_next(iter)
- treeview.set_size_request(0,-1)
- self.sw.connect_after('size-allocate', resize_wrap, self.tv, c3,
renderer)
-
### start/stop button for analysis engines
toggleRenderer = CellRendererPixbufXt()
toggleRenderer.set_property("stock-id", "gtk-add")
@@ -446,7 +415,8 @@
self.tv.append_column(c0)
self.tv.append_column(c1)
self.tv.append_column(c2)
- self.tv.append_column(c3)
+ ### header text, or analysis line
+ uistuff.appendAutowrapColumn(self.tv, "Details", text=4)

self.boardview.connect("shown_changed", self.shown_changed)
self.tv.connect("cursor_changed", self.selection_changed)
=======================================
--- /sidepanel/commentPanel.py Tue Dec 30 16:34:48 2014 UTC
+++ /sidepanel/commentPanel.py Thu Jan 15 20:37:45 2015 UTC
@@ -47,11 +47,7 @@
self.store = Gtk.ListStore(str)
self.tv.set_model(self.store)
self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
- #r = Gtk.CellRendererText()
- #r.set_property("wrap-width", 177) #FIXME: Fixed width size
- #r.set_property("wrap-mode", Pango.WrapMode.WORD)
- #self.tv.append_column(Gtk.TreeViewColumn("Comment", r, text=0))
- uistuff.appendAutowrapColumn(self.tv, 200, "Comment", text=0)
+ uistuff.appendAutowrapColumn(self.tv, "Comment", text=0)

self.tv.get_selection().connect_after('changed',
self.select_cursor_row)
self.boardview = gmwidg.board.view
Reply all
Reply to author
Forward
0 new messages