Philipp Hörist pushed to branch master at gajim / gajim


Commits:
7819a8e8 by lovetox at 2020-11-22T18:26:46+01:00
Test: Add more values to dataform test

So we can see a scrollbar

- - - - -
4da4aa82 by lovetox at 2020-11-22T19:11:01+01:00
Test: Add long multi-list entry

So we can test ellipsizing and the tooltip

- - - - -
8645a286 by lovetox at 2020-11-22T19:13:21+01:00
DataForm: Improve ListMutliTreeView

- Disable horizontal scrollbar so the treeview expands
- Ellipsize values after 40 chars
- Add row tooltip if entries were ellipsized

- - - - -


2 changed files:

- gajim/gtk/dataform.py
- test/gtk/dataform.py


Changes:

=====================================
gajim/gtk/dataform.py
=====================================
@@ -375,6 +375,7 @@ def __init__(self, field, form_grid, options):
         self._widget.set_propagate_natural_height(True)
         self._widget.set_min_content_height(100)
         self._widget.set_max_content_height(300)
+        self._widget.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
         self._widget.add(self._treeview)
 
     def validate(self):
@@ -388,10 +389,13 @@ def __init__(self, field, multi_field):
         self._field = field
         self._multi_field = multi_field
 
-        self._store = Gtk.ListStore(str, str, bool)
+        # label, value, tooltip, toggled
+        self._store = Gtk.ListStore(str, str, str, bool)
 
         col = Gtk.TreeViewColumn()
         cell = Gtk.CellRendererText()
+        cell.set_property('ellipsize', Pango.EllipsizeMode.END)
+        cell.set_property('width-chars', 40)
         col.pack_start(cell, True)
         col.set_attributes(cell, text=0)
         self.append_column(col)
@@ -403,15 +407,20 @@ def __init__(self, field, multi_field):
         cell.set_property('xpad', 10)
         cell.connect('toggled', self._toggled)
         col.pack_start(cell, True)
-        col.set_attributes(cell, active=2)
+        col.set_attributes(cell, active=3)
         self.append_column(col)
 
         self.set_headers_visible(False)
 
         for option in field.options:
-            # option = (label, value)
+            label, value = option
             self._store.append(
-                [*option, option[1] in field.values])
+                [label, value, label, value in field.values])
+
+        labels_over_max_width = map(lambda x: len(x) > 40,
+                                    [option[0] for option in field.options])
+        if any(labels_over_max_width):
+            self.set_tooltip_column(2)
 
         self.set_model(self._store)
 


=====================================
test/gtk/dataform.py
=====================================
@@ -76,6 +76,9 @@
     <option label='Polls'><value>polls</value></option>
     <option label='Reminders'><value>reminders</value></option>
     <option label='Search'><value>search</value></option>
+    <option label='Search1'><value>search1</value></option>
+    <option label='Really long long long long long long long long 
entry'><value>longentry</value></option>
+    <option label='Search3'><value>search3</value></option>
     <value>news</value>
     <value>search</value>
   </field>



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/0f5ef09a6100b64cd8aadf557da71ae704b051e2...8645a2861ab9dbc892f5116b0a4e8ac323e859d2

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/0f5ef09a6100b64cd8aadf557da71ae704b051e2...8645a2861ab9dbc892f5116b0a4e8ac323e859d2
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to