Re: [gtkmm] adding a widget to a container
- From: cedric <cedric probesys com>
- To: Ainsley Pereira <gtkmm pebble org uk>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] adding a widget to a container
- Date: Mon, 03 May 2004 18:00:26 +0200
Thanks for answering me, but it seems i ve simplified to much my problem
not to have you read too much code :-[
So your answer was perfectly pertinent to my question, but i have
reformulate it:
i develop a modular application, with plugins (test1, test2..., with
both .hh and .cc files) each one of them is a different class and they
all herit from a Plugin class (just a .hh). i have loadplugins files
(both .hh and .cc files) which herit form Plugin.hh and load the plugins
and incorporate them into the interface by adding buttons in the
menubar, adding lines in a functionnalities liststore, and creating one
toolbar for each module. the toolbar of a given module is displayed only
when this module is selected in the menubar! in this case, i thought i
would hide the "current" toolbar, and display the "new" toolbar instead.
so to do this, i ve 2 ptr declared in my Plugin.hh file
static Gtk::HBox *toolBarModContainer_ptr;
static Gtk::Toolbar *toolBarModDisplayed_ptr;
i use toolBarModContainer_ptr to add the toolbar of each module to the
container of my interface where i want to put it (in a HBox so...). this
ptr is initialised in the loadplugins.cc file, before i add the modules
elements to my interface. without this ptr, i don t see how to "attach"
each toolbar to the container. i think it s not a problem to have many
toolbars added to the HBox (but does it a difference to use "pack_start"
or "add", considering the fact i display only one toolbar at a time?)
i use toolBarModDisplayed_ptr to know what the "current" toolbar. so
this ptr points on one of the modules' toolbar.
when i want to change the displayed toolbar, i do this:
(*toolBarModDisplayed_ptr).hide(); //hide the current toolbar
toolBarModDisplayed_ptr = &toolbarmod; //the current toolbar
is now the toolbar of this module
(*toolBarModDisplayed_ptr).show(); //display the the current
toolbar
these instructions are done in a module, after it have been selected in
the menubar. without this ptr, i don t see how to hide the previous
displayed toolbar.
so in the class constructor of each of my modules, i put some buttons in
my toolbar, and then i choose ONE of my modules' toolbar to be the
current one. my toolbar is declared as "Gtk::Toolbar toolbarmod;" in my
test1.hh (the testX files are my modules).
toolBarModContainer_ptr->add(toolbarmod);
when i put this, it provoques a segfault: "in test : undefined symbol
toolbarmod"...
and this time (not like in my previous question),
toolBarModContainer_ptr points on existing HBox! i ve tried using
pack_start, but same result... :-(
i ve tried to manipulate a bit toolBarModContainer_ptr to see if it s
wrongly initialised, by doing
(*toolBarModContainer_ptr).hide();
when i select a module in the menubar: it hides correctly the HBox (and
so the toolbar which is inside). so this pointer is ok, or at least it
seems to be ok! that s why i don t see the problem!
the toolBarModDisplayed_ptr works also, it can hide the non-module
default toolbar but since i can t add a module toolbar to the HBox, i
can t see if the "toolBarModDisplayed_ptr = &toolbarmod;" assigment is
effective (but it compiles).
i hope this time i ve explained clearlier my problem ;-)
so if you have any idea...
thanks again!
cedric
Ainsley Pereira a écrit :
On Mon, May 03, 2004 at 04:19:47PM +0200, cedric wrote:
Gtk::HBox a; a.add(toolbarmod);
//it works, normal
Yes, you've got an HBox and are using it.
Gtk::HBox *b; b->add(toolbarmod);
// provoques a seg fault !?!?!
You have a POINTER to an HBox, but no HBox to actually point to, so when
you try to use it, BANG!
Gtk::HBox *c; (*c).add(toolbarmod);
// provoques a seg fault !?!?!
As before.
Try Gtk::HBox *b = new Gtk::HBox; if you really want to allocate the
HBox on the heap (but wouldn't you rather use a class member?).
(But remember to use manage() or delete it yourself.)
~Ainsley
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]