Glade, GTKMM, and adding widgets to containers that are created in Glade.

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

Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Steve Scott-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Is there some trick to adding hand coded widgets to containers that were in created in Glade.  In other words I have a ScrolledWindow created in Glade and in code I have created a TreeView (and model).  No matter what I try I am unable to see my TreeView appear in my GUI.  From all the examples I have found this is how it is supposed to work in this case:

 m_refGlade->get_widget("myscrolledwindow", m_myScrolledWindow); // get my glade defined ScrolledWindow Widget
 m_myScrolledWindow->add(*m_myTreeView); // add my TreeView Widget to the scrolledWindow.  (and yes the Treeview has a listmodel)
 m_myTreeView->show(); // update the GUI

Can someone tell me what I am doing wrong?

Thanks,

Steve


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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2009-10-13 at 18:28 -0500, Steve Scott wrote:

> Hi,
>
> Is there some trick to adding hand coded widgets to containers that
> were in created in Glade.  In other words I have a ScrolledWindow
> created in Glade and in code I have created a TreeView (and model).
> No matter what I try I am unable to see my TreeView appear in my GUI.
> From all the examples I have found this is how it is supposed to work
> in this case:
>
>  m_refGlade->get_widget("myscrolledwindow", m_myScrolledWindow); //
> get my glade defined ScrolledWindow Widget
>  m_myScrolledWindow->add(*m_myTreeView); // add my TreeView Widget to
> the scrolledWindow.  (and yes the Treeview has a listmodel)
>  m_myTreeView->show(); // update the GUI
>
> Can someone tell me what I am doing wrong?

get_widget_derived() might be what you area looking for. Here is some
informatin about its use with Gtk::Builder though it was much the same
with libglademm:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-builder-using-derived-widgets.html.en

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

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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Steve Scott-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



get_widget_derived() might be what you area looking for. Here is some
informatin about its use with Gtk::Builder though it was much the same
with libglademm:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-builder-using-derived-widgets.html.en

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


Murray,

Thanks for the suggestion.  I have used the derived widget for my main window, and that works fine, but is this the only way to add widgets to Glade containers? 

Thanks,

Steve

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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Steve Scott-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Wed, Oct 14, 2009 at 6:47 AM, Steve Scott <sjscott007@...> wrote:


get_widget_derived() might be what you area looking for. Here is some
informatin about its use with Gtk::Builder though it was much the same
with libglademm:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-builder-using-derived-widgets.html.en

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


Murray,

Thanks for the suggestion.  I have used the derived widget for my main window, and that works fine, but is this the only way to add widgets to Glade containers? 

Thanks,

Steve

I went back and derived a ScrolledWindow Class ( m_refGlade->get_widget_derived("myscrolledwindow",myscrolledwindow); ).  Then inside that class I created the tree and the model, and added the tree it to itself.  And sure enough it worked....

Now my question is how come I have to derive a container to add to it?  I should be able to manipulate any widget from glade with the standard m_refGlade->get_widget right?  Hopefully someone can shed some light on this.

Thanks,

Steve


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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-10-14 at 06:47 -0500, Steve Scott wrote:
> I have used the derived widget for my main window, and that works
> fine, but is this the only way to add widgets to Glade containers?

You can add widgets to glade-instantiated containers just as you can add
them to containers instantiated in any other way. Just call the relevant
method, such as add(), pack_start(), etc. In practice, you will then
want to have a placeholder container in the Glade file into which you
will place your special widget.

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

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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Steve Scott-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thats what I tried before I used the derived widget option of Glade. As I wrote before:

m_refGlade->get_widget("myscrolledwindow", m_myScrolledWindow); // get my glade defined ScrolledWindow Widget from glade
m_myScrolledWindow->add(*m_myTreeView); // add my TreeView Widget to the scrolledWindow.  (and yes the Treeview has a listmodel)
m_myTreeView->show(); // update the GUI

For whatever reason my tree would never display.   Once I used a derived widget it worked.  So i ended up creating a derived ScrolledWindow in which I placed my tree into. 


I am with you.  I would have though either way would work, but it doesn't. Unless I am missing something.  ScrolledWindow does not have a pack_start.

Steve


On Wed, Oct 14, 2009 at 12:14 PM, Murray Cumming <murrayc@...> wrote:
On Wed, 2009-10-14 at 06:47 -0500, Steve Scott wrote:
> I have used the derived widget for my main window, and that works
> fine, but is this the only way to add widgets to Glade containers?

You can add widgets to glade-instantiated containers just as you can add
them to containers instantiated in any other way. Just call the relevant
method, such as add(), pack_start(), etc. In practice, you will then
want to have a placeholder container in the Glade file into which you
will place your special widget.

--


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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-10-14 at 14:31 -0500, Steve Scott wrote:

> Thats what I tried before I used the derived widget option of Glade.
> As I wrote before:
>
> m_refGlade->get_widget("myscrolledwindow", m_myScrolledWindow); // get
> my glade defined ScrolledWindow Widget from glade
> m_myScrolledWindow->add(*m_myTreeView); // add my TreeView Widget to
> the scrolledWindow.  (and yes the Treeview has a listmodel)
> m_myTreeView->show(); // update the GUI
>
> For whatever reason my tree would never display.   Once I used a
> derived widget it worked.  So i ended up creating a derived
> ScrolledWindow in which I placed my tree into.  
>
>
> I am with you.  I would have though either way would work, but it
> doesn't. Unless I am missing something.  ScrolledWindow does not have
> a pack_start.

It should work, though you would see a warning on stderr if the
scrolledwindow already had a child widget (it may only contain one). A
simple test case might make things clearer.

I wonder if this has something to do with the Viewport that gtkmm's
ScrolledWindow::add() automatically adds to ScrolledWindows when needed
by the particular type of child widget.


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

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

Re: Glade, GTKMM, and adding widgets to containers that are created in Glade.

by Steve Scott-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Oct 15, 2009 at 3:17 AM, Murray Cumming <murrayc@...> wrote:


It should work, though you would see a warning on stderr if the
scrolledwindow already had a child widget (it may only contain one). A
simple test case might make things clearer.

I wonder if this has something to do with the Viewport that gtkmm's
ScrolledWindow::add() automatically adds to ScrolledWindows when needed
by the particular type of child widget.

I got no error messages in stderr and the TreeView is the only widget I put in it.  I even added a Viewport to the ScrolledWindow in glade even though I don't have to with a TreeView widget, and got the same result.  As I get farther in my program, I am going to try different containers( like a vbox ro hbox) to see if i get the same results.  If I don't then there's something wrong with the scrolledwindow.  I will report back if I find something.

Thanks for all your help.

Steve

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