jverzani / gWidgets2

Rewrite of gWidgets
35 stars 9 forks source link

argument or method to assign icons and tooltips to tabs #53

Closed landroni closed 10 years ago

landroni commented 10 years ago

As per http://stackoverflow.com/questions/24706434/how-to-assign-icons-to-gnotebook-tabs/24741832#24741832 , I was wondering if there should be gnotebook() argument or method to assign icons to tabs.

The following function can do this:

add_stock_icon <- function(nb, nm, page, left=TRUE){
    child <- nb$widget$getNthPage(page-1)
    box <- nb$widget$getTabLabel(child)
    icon <- gimage(stock.id=nm)
    box$packStart(icon$widget$parent)
    if(left) box$reorderChild(icon$widget$parent, 0)
}

Should there be something similar included in gWidgets2?

jverzani commented 10 years ago

I'd like this, but I'm not sure I can make it multiplatform and am pretty sure I can't get it to accept an event, which would make things like a close button possible. I can add it as a private method for gWidgets2RGtk2 though (so that nb$add_tab_icon(page, nm, left) could be called.)

landroni commented 10 years ago

Until this can be made multiplatform, I think a private method for gWidgets2RGtk2 would be nice.

jverzani commented 10 years ago

I just checked something in to gWidgets2RGtk2 (add_tab_icon). Let me know if it doesn't work.

landroni commented 10 years ago

Perfect!

jverzani commented 10 years ago

I also added a tooltip argument here.

On Tue, Jul 15, 2014 at 4:33 AM, landroni notifications@github.com wrote:

Perfect!

— Reply to this email directly or view it on GitHub https://github.com/jverzani/gWidgets2/issues/53#issuecomment-49004370.

John Verzani Chair, Department of Mathematics College of Staten Island, CUNY verzani@math.csi.cuny.edu

landroni commented 10 years ago

Works great. My only concern is: what if you want to add a tooltip, but no icon. Perhaps a separate add_tab_tooltip would be more intuitive?

jverzani commented 10 years ago

Okay, good point. Just added add_tab_tooltip to gWidgets2RGtk2. Thanks.

On Tue, Jul 15, 2014 at 12:28 PM, landroni notifications@github.com wrote:

Works great. My only concern is: what if you want to add a tooltip, but no icon. Perhaps a separate add_tab_tooltip would be more intuitive?

— Reply to this email directly or view it on GitHub https://github.com/jverzani/gWidgets2/issues/53#issuecomment-49057479.

John Verzani Chair, Department of Mathematics College of Staten Island, CUNY verzani@math.csi.cuny.edu

landroni commented 10 years ago

There is an issue: "Error in ntbk$add_tab_tooltip(1, "Filter data frame and display subset") : object 'evb' not found"

I suspect the missing bit is evb <- icon$widget$parent, or similar.

jverzani commented 10 years ago

Sorry, fixed now. If you add the icon after the tooltip, only the label will get the tooltip.

On Tue, Jul 15, 2014 at 2:30 PM, landroni notifications@github.com wrote:

There is an issue: "Error in ntbk$add_tab_tooltip(1, "Filter data frame and display subset") : object 'evb' not found"

I suspect the missing bit is evb <- icon$widget$parent, or similar.

— Reply to this email directly or view it on GitHub https://github.com/jverzani/gWidgets2/issues/53#issuecomment-49073295.

John Verzani Chair, Department of Mathematics College of Staten Island, CUNY verzani@math.csi.cuny.edu

landroni commented 10 years ago

Works great!