RadioToolButton

View: New views
5 Messages — Rating Filter:   Alert me  

RadioToolButton

by Louis-Francis Ratté-Boulianne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just want to point out an error in the code examples. In the file :

http://www.gtkmm.org/docs/gtkmm-2.4/examples/book/toolbar/examplewindow.cc

At line 68, the code should be

  Gtk::RadioButtonGroup group;
  Gtk::RadioToolButton* btn;

  btn = new Gtk::RadioToolButton(group, "Radio1");
  group = btn->get_group();
  m_Toolbar.append( *Gtk::manage(btn) )

  btn = new Gtk::RadioToolButton(group, "Radio2");
  group = btn->get_group();
  m_Toolbar.append( *Gtk::manage(btn) );

  btn = new Gtk::RadioToolButton(group, "Radio3");
  group = btn->get_group();
  m_Toolbar.append( *Gtk::manage(btn) );


Thanks to correct the example, that would certainly save time to a lot
of people,

--
Louis-Francis

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: RadioToolButton

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, 2008-10-25 at 18:02 -0400, Louis-Francis Ratté-Boulianne wrote:

> I just want to point out an error in the code examples. In the file :
>
> http://www.gtkmm.org/docs/gtkmm-2.4/examples/book/toolbar/examplewindow.cc
>
> At line 68, the code should be
>
>   Gtk::RadioButtonGroup group;
>   Gtk::RadioToolButton* btn;
>
>   btn = new Gtk::RadioToolButton(group, "Radio1");
>   group = btn->get_group();
>   m_Toolbar.append( *Gtk::manage(btn) )
>
>   btn = new Gtk::RadioToolButton(group, "Radio2");
>   group = btn->get_group();
>   m_Toolbar.append( *Gtk::manage(btn) );
>
>   btn = new Gtk::RadioToolButton(group, "Radio3");
>   group = btn->get_group();
>   m_Toolbar.append( *Gtk::manage(btn) );
>
>
> Thanks to correct the example, that would certainly save time to a lot
> of people,

For context: That code was commented as not working in the example.

Thanks. So, it's the "group = btn->get_group()" that makes it work. I
wonder if that is a bug or how it is meant to be done.


--
murrayc@...
www.murrayc.com
www.openismus.com

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: RadioToolButton

by Louis-Francis Ratté-Boulianne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The class RadioButtonGroup is basically a wrapper around a GSList* that
is initialized to NULL. A comment in radiotoolbutton.hg makes me believe
that is normal behavior :

* The RadioToolButton will have an empty label and will reside in an
newly created Group.
* Use get_group() to retrieve this group and pass it to other radio buttons to assign
* them to this group.

--
Louis-Francis

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: RadioToolButton

by apoapsis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Use get_group() to retrieve this group and pass it to other radio buttons to assign
* them to this group.
I've given the suggested work-around a try, and have run into a slightly different problem.  Instead of having all buttons in the group permently pressed, its starts out as one pressed, however, when I press another button, the first does not become 'un-pressed'.  It does eventually become unpressed as i press more buttons though.

Here's the code I'm working from.  If anyone can see what I'm doing wrong that'd be great.  ty

#include <gtkmm.h>


class MyToolbar : public Gtk::Toolbar
{

public:

  MyToolbar()
  {
    set_toolbar_style( Gtk::TOOLBAR_ICONS );

    m_center = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_CENTER );

    m_group = m_center->get_group();

    m_left = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_LEFT );
    m_right = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_RIGHT );


    append( *m_center );
    append( *m_left );
    append( *m_right );
  }
     
private:

  Gtk::RadioButtonGroup m_group;

  Gtk::RadioToolButton* m_center;
  Gtk::RadioToolButton* m_left;
  Gtk::RadioToolButton* m_right;

};


class ToolWindow : public Gtk::Window
{

public:

  ToolWindow()
  {
    set_border_width(10);
    set_default_size( 300, 200 );
   
    m_vbox.pack_start( m_toolbar, Gtk::PACK_SHRINK );

    add( m_vbox );

    show_all_children();
  }

protected:

  Gtk::VBox m_vbox;
  MyToolbar m_toolbar;

};


int main( int argc, char* argv[] )
{
  Gtk::Main kit(argc, argv);
  ToolWindow window;

  Gtk::Main::run( window );

  return 0;
}

Re: RadioToolButton

by Daniel Elstner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Freitag, den 19.06.2009, 17:07 -0700 schrieb apoapsis:

> > * Use get_group() to retrieve this group and pass it to other radio
> > buttons to assign
> > * them to this group.
>
> I've given the suggested work-around a try, and have run into a slightly
> different problem.

The code suggested in this thread is wrong because it called get_group()
more than once.  I also had a look at the example, and it still seems to
be broken as well.

> Here's the code I'm working from.  If anyone can see what I'm doing wrong
> that'd be great.  ty
[...]
>     m_center = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_CENTER);

Try removing the m_group argument to the constructor.

>     m_group = m_center->get_group();

This gets the group from the first radio button...

>     m_left = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_LEFT );
>     m_right = new Gtk::RadioToolButton( m_group, Gtk::Stock::JUSTIFY_RIGHT);

...and assigns the other radio buttons to the same group.

--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list