AW: Change a Button Pixlabel out of a Dialog



Hi Bob,

the path to the picture is fine, and you are right ICONPATH is a little
macro. And as I sad generally the hole thing to change the button works
fine, as long as I change the pixlabel out of the signal_clicked handler in 
my mainwindow. But if try to change it out of my Optionsdialog the hole
thing screws up. 

Sometimes the program crashes immediately with the Xlib message, without any
change of the pixlabel, and sometimes the picture is removed but no new
picture is added, and in this case there is even no "no picture label"
instead the button is very thin and just grey.

So I guess it has something to do with communication between 2 windows, the
Optionsdialog is a popup dialog it is not transient and also not modal to
the mainwindow, but I also tried to change that...it didn't help. 
So the two windows run in the same mainloop-right!?

The user setups some options in the dialog, and then clicks ok, and in the
handler I figure out if I have to change the label in the mainwindow. And
after setting everything up I hide the dialog.

What's the right way to do it? Can I directly call my function to change the
label, out of the dialog, or should I use a dispatcher or a signal or
whatelse? Is it possible that first the mainwindow needs to become active
before I can change the buttonlabel, if yes how can I force that? 

Thanks!

Alex


Hello Alex:

I created a test case that does precisely what your code is doing. It
fails to display an image on my button. Instead it displays a "missing
image" icon.  It does not seg-fault and I get no Xlib messages.  That
your application is not displaying the "missing icon" image on the
button probably indicates some other problem that is the root cause of
the Xlib messages and the seg-fault you're experiencing.

When I actually specify the full path name of the image in the call to
Gtk::Bin::add_pixlabel, it works fine.  I do not know what "ICONPATH"
is, but I'm assuming that it is a macro defined to a string literal; so
you should probably modify your code thusly:

void MyToolbar::ChangeButton()
{
    Glib::ustring str = ICONPATH;
    str += (m_enabled?"Pic2.bmp":"Pic1.bmp");
    m_button.remove();
    m_button.add_pixlabel(str,"");
}

I hope this helps.

Bob



mail gehli com wrote:

>Hi,
>
>I've got the following problem:
>
>I have a MainWindow with a Toolbar, on special Button clicks I change the
pixlabel of the 
>Buttons (to indicate the Option is enable or disabled). The buttons are
connected to signalhandlers, that hole thing works fine. 
>
>But also the user can start an Optionwindow, it's like a popup dialog (from
typ Gtk::Window). And there the user also can change some Options so that I
have to update the pixlabels of the buttons too. I tried several things to
do this, like call the change Pixlabel function direct or via a dispatcher,
but nothing works. I get a Xlib message "Xlib: unexpected async reply" and
the button has no pixlabel anymore, and my program crash... How should or
how can I do that???
>
>thats my function to change the pixlabel:
>
>void MyToolbar::ChangeButton(){
>	m_Button.remove();
>	
>	if(m_enabled){
>
>		m_Button.add_pixlabel(ICONPATH + "Pic2.bmp","");
>				
>	}
>	else{
>		m_Button.add_pixlabel(ICONPATH + "Pic1.bmp","");
>	}
>
>}
>
>Thanks In Advance!!!
>
>Alex
>
>
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>gtkmm-list mailing list
>gtkmm-list gnome org
>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>  
>




-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/200 - Release Date: 14.12.2005




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]