After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770374 - Gtk Treeview Editable overshoots column width when column width is small
Gtk Treeview Editable overshoots column width when column width is small
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2016-08-25 10:22 UTC by Manu Varkey
Modified: 2016-08-29 07:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Editable overshooting (39.26 KB, image/png)
2016-08-25 10:22 UTC, Manu Varkey
  Details
cell renderer text: Allow entries to shrink (984 bytes, patch)
2016-08-25 11:50 UTC, Matthias Clasen
committed Details | Review

Description Manu Varkey 2016-08-25 10:22:42 UTC
Created attachment 334119 [details]
Editable overshooting

See attached screen-shot.

Steps to reproduce:
1. Run the below program
2. Change column width of any column below 150px
3. Start editing

Expected:
The editable spans the column width.

What happens:
The editable exceeds column width.



PyGi program
------------

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

#list of tuples for each software, containing the software name, initial release, and main programming languages used
software_list = [("Firefox", 2002,  "C++"),
                 ("Eclipse", 2004, "Java" ),
                 ("Pitivi", 2004, "Python"),
                 ("Netbeans", 1996, "Java")]

class TreeViewWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Treeview Filter Demo")
        self.set_border_width(10)

        #Setting up the self.grid in which the elements are to be positionned
        self.box = Gtk.Box()
        self.add(self.box)

        #Creating the ListStore model
        self.software_liststore = Gtk.ListStore(str, int, str)
        for software_ref in software_list:
            self.software_liststore.append(list(software_ref))

        #Creating the treeview
        self.treeview = Gtk.TreeView.new_with_model(self.software_liststore)
        for i, column_title in enumerate(["Software", "Release Year", "Programming Language"]):
            renderer = Gtk.CellRendererText()
            renderer.set_property("editable", True)
            column = Gtk.TreeViewColumn(column_title, renderer, text=i)
            column.props.resizable = True
            self.treeview.append_column(column)
        self.box.add(self.treeview)

        self.show_all()


win = TreeViewWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()

Gtk.main()
Comment 1 Matthias Clasen 2016-08-25 11:50:03 UTC
Created attachment 334128 [details] [review]
cell renderer text: Allow entries to shrink

Set a small max-width on entries used for editing cells, so they
adapt to small columns and don't overlap the next column.
Comment 2 Matthias Clasen 2016-08-25 11:56:32 UTC
Attachment 334128 [details] pushed as f53706b - cell renderer text: Allow entries to shrink
Comment 3 Manu Varkey 2016-08-29 07:48:45 UTC
(In reply to Matthias Clasen from comment #2)
> Attachment 334128 [details] pushed as f53706b - cell renderer text: Allow
> entries to shrink

Thank you for the prompt fix. Is there any specific reason why the width_chars property is set to 5. Why not set it to 1 so that the editable will span the column width for the smallest of columns?