Search code examples
layoutgtkgtk3scrollable

Gtk3 - Prevent TextView to make Window grow


I am currently trying to create a small note app with GTK3. It's basically a Window that sticks on your desktop and is undecorated. Currently it contains a Button and a TextView which reside in a ListBox. However as soon as the TextView has more rows of text than space for rows of text, the TextView and the Window will grow. The Window will actually grow bigger than the screen is.

What I have tried:

  • window.SetResizable(false)
  • using SetVExpand(false) on the Window and the ListBox
  • Wrapping the TextView in a Layout, which the documentation claims is a scrollable container (I probably misunderstood)

Solution

  • I simply used Gtk.ScrolledWindow.

    var hAdjustment, vAdjustment *gtk.Adjustment
    textViewScrollPane, _ := gtk.ScrolledWindowNew(hAdjustment, vAdjustment)
    
    textView, _ := gtk.TextViewNew()
    
    textViewScrollPane.Add(textView)
    

    The example is Go, but it doesn't really matter.