See attached.

On 07/07/2014 12:27 AM, Kjell Ahlstedt wrote:

2014-07-05 23:08, Phil Wolff skrev:
I'm using GTKMM 3.10.1 on 64-bit Ubuntu 14.04. I've got three Gtk::MenuToolButtons in my UI, and I want the same icon to appear on all three of them. This seems not to work -- my icon appears only on the last button to be instantiated, and the first two have no icon, only the activate arrow. To get my icon to appear on all three buttons, I've had to fetch the icon as a Gdk::Pixmap and create from it three unique Gtk::Image instances, one for each button. Should I presume there's some arcane Gtk requirement that makes this necessary?

If you can give me a (preferably short) test case to experiment with, I can look into this. I don't know if it's a bug or by design.
And, in a closely related but extremely minor issue, I've noticed that run-time error messages related to Gtk::Image problems in Gtk::Builder mis-identify the source, e.g.

     gtkmm-CRITICAL **: gtkmm: Gtk::Buidler: widget `FolderIcon' was not found in the GtkBuilder file, or the specified part of it.

I've fixed the typo in Gtk::Builder.

Kjell

--
If sunbeams were weapons of war, we would have had solar energy centuries ago.
    -- George Porter

Attachment: paned.ui
Description: application/designer

#include <gtkmm.h>
#include <glibmm.h>
#include <iostream>

#define  FIRST
#define SECOND
//#define USE_INDIVIDUAL_IMAGES

class Test : public Gtk::Window
{
public:
    Test ();
    virtual ~Test () {}
};

Test::Test ()
{
    try {
        Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create_from_file ( "paned.ui" );
        Gtk::Widget* p;
        refBuilder->get_widget ( "Boss", p );
        add ( *p );
        Gtk::Notebook* pn;
        Glib::RefPtr<Gdk::Pixbuf > refMenuTool =
                Gdk::Pixbuf::create_from_file ( "MenuButtonImage.png" );
        Gtk::Image* pi = Gtk::manage ( new Gtk::Image ( refMenuTool ));
        Gtk::MenuToolButton *pmtb;
    #ifdef FIRST
        refBuilder->get_widget ( "FilesBook", pn );
        pmtb = new Gtk::MenuToolButton ( *pi );
        pn->set_action_widget( (Gtk::Widget*)pmtb, Gtk::PACK_END );
        pmtb->show ();
    #endif
    #ifdef USE_INDIVIDUAL_IMAGES
        pi = Gtk::manage ( new Gtk::Image ( refMenuTool ));
    #endif
    #ifdef SECOND
        refBuilder->get_widget ( "FiltersBook", pn );
        pmtb = new Gtk::MenuToolButton ( *pi );
        pn->set_action_widget( (Gtk::Widget*)pmtb, Gtk::PACK_END );
        pmtb->show ();
    #endif
    }
    catch ( const Glib::FileError& ex ) {
        std::cout << "FileError: " << ex.what () << std::endl;
        return;
    }
    catch ( const Glib::MarkupError& ex ) {
        std::cout << "MarkupError: " << ex.what () << std::endl;
        return;
    }
    catch ( const Gtk::BuilderError& ex ) {
        std::cout << "BuilderError: " << ex.what () << std::endl;
        return;
    }
    set_position ( Gtk::WIN_POS_CENTER );
    show_all_children ();
}

int main ( int argc, char *argv[] )
{
    Glib::RefPtr<Gtk::Application > pApp =
            Gtk::Application::create ( argc, argv, "org.pwolff.stuff" );
    Test window;
    return pApp->run ( window );
}
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to