Re: Putting a image on the Gtk::Button..?



On Sat, 2010-01-30 at 17:54 +0530, sankar bose wrote:
> Hi,
> 
> i have created a very small program to put a simple image on the button .
>  the method show_all does not work i mean a cant see the image but the
> explicitly calling the show method works. My program is given below..

I think the "problem" is that on your system the default is to not show
images in buttons (this is GNOME's default since 2.28). I guess the
image shows up normally if you turn
on /desktop/gnome/interface/buttons_have_icons in gconf.

I am not sure what the correct way is to force an image to be shown,
even if that option is off. But I am not sure either whether that is a
good idea anyway.

> #ifndef UNITTEST_H_INCLUDED
> #define UNITTEST_H_INCLUDED
> #include <gtkmm.h>
> class Mywindow : public Gtk::Window
> {
>     public:
>     Mywindow();
>     virtual ~Mywindow();
>     private:
>     Gtk::VBox m_main_vbox;
>     Gtk::Button m_close_button;
>     Gtk::Image m_button_image;
> 
> };
> 
> #endif // UNITTEST_H_INCLUDED
> 
> #include "Unittest.h"
> #include <iostream>
> 
> Mywindow::Mywindow():m_main_vbox(false,10),m_close_button("close
> me"),m_button_image("gtk-paste.png")
> {
>     m_close_button.set_image(m_button_image);
>     m_main_vbox.pack_start(m_close_button);
>     add(m_main_vbox);
> 
>     m_close_button.show_all();  // Does not work i cant see the image
>     show_all_children();
>    // without explicitly calling the show method i cant see the image
>      m_button_image.show();  // works..
> }
> Mywindow::~Mywindow()
> {
> }
> 
> #include "Unittest.h"
> #include <iostream>
> int main(int argc, char *argv[])
> {
>     Gtk::Main kit(argc,argv);
>     Mywindow mwindow;
>     kit.run(mwindow);
> }
> 
>      i am very new to programming so i dont know how to write a test
> case using tools such as  Boost.test ( i am looking into it). please
> check this and if i made any mistake please tell me.
> 
> 
> 
> with regards........

Armin



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