Ivan Perez | 9 Apr 2012 10:30
Picon
Gravatar

Size problem when adding buttons to notebook tab labels

Hi,
 I'm trying to add close buttons to notebook tab labels (similar to the ones you
get in firefox). The strategy I followed is the simplest I could think of:
 I created an hbox with a label and a button with a "close" icon in
it, and added it as the
tab's label widget (for a given tab).

I seem to be unable to produce the desired result: the size of the
hbox is too small.
This is the smallest example that I've been able to produce with
similar symptoms
(it uses a button instead of an hbox):

import Graphics.UI.Gtk

main = do
  initGUI

  win <- windowNew

  nb <- notebookNew

  lblL1 <- labelNew (Just "Some long label")
  lblL2 <- labelNew (Just "Some other long label")
  vbox <- vBoxNew False 10
  boxPackStartDefaults vbox lblL1
  boxPackStartDefaults vbox lblL2
  notebookAppendPage nb vbox "Hiellloooo"

  -- Set a button as the new tab label
(Continue reading)

Ivan Perez | 4 May 2012 15:09
Picon
Gravatar

Re: Size problem when adding buttons to notebook tab labels

Hi again,
 I'm going to answer myself in case anyone ever asks the same question:

For some reason, adding the following hbox instead of a button works fine:

[...]

 -- Init.
 box     <- hBoxNew False 0
 label   <- labelNew $ Just "Label"
 image <- imageNewFromFile "close.png"
 closeButton <- toolButtonNew (Just image) Nothing

 -- Show.
 boxPackStart box label PackRepel 0
 boxPackStart box closeButton PackRepel 0
 widgetShowAll box

 -- Add to tab box
notebookSetTabLabel nb vbox

[...]

I took it from Andy Stewart's manatee-core.

Cheers,
Ivan.

On 9 April 2012 10:30, Ivan Perez <ivanperezdominguez <at> gmail.com> wrote:
> Hi,
(Continue reading)


Gmane