Thank you Moh, I will try this.
2012/10/6 Moh B. <[email protected]>
> On Tue, 2012-10-02 at 10:36 +0200, Juan Angel Moreno wrote:
> > Hi!
> >
> > I want to show the tooltips that each of my menuitems has, in the
> > statusbar of a window.
> > How can I do this??
> >
> > Greetings
> > jamf
> >
> > _______________________________________________
>
>
> Hi, these are the crazy tips to get tooltips working
>
> //In the mainwin.cpp add:
> //start example code
> ====================================================
> mpActionGroup = Gtk::ActionGroup::create();
> mpActionGroup->add(Gtk::Action::create("fileMenu", "_File"));
>
> mpActionGroup->add(Gtk::Action::create("fileOpen",
> "Open ISO file", "Open ISO file to examine
> content"),
> sigc::mem_fun(*this,
> &mainwin::on_selectIsoFileButton_click));
>
> mpActionGroup->add(Gtk::Action::create("fileQuit", "_Exit", "Exit /
> terminate the application"),
> sigc::mem_fun(*this,
> &mainwin::on_exitButton_click));
>
> mpActionGroup->add(Gtk::Action::create("helpMenu", "_Help"));
>
> mpActionGroup->add(Gtk::Action::create("helpHowTo", "_How to",
> "Search
> for help"),
> sigc::mem_fun(*this, &mainwin::on_howTo_click));
>
> mpActionGroup->add(Gtk::Action::create("helpAbout", "_About", "This
> shows the about dialog: Ver. 1.0.0"),
> sigc::mem_fun(*this, &mainwin::on_about_click));
>
> mpUiManager = Gtk::UIManager::create();
> mpUiManager->insert_action_group(mpActionGroup);
>
> mpUiManager->add_ui_from_file("ui.xml");
> mpUiManager->signal_connect_proxy().connect(sigc::mem_fun(this,
> &mainwin::install_menu_hints));
>
> //add accelerators to the main window:
> add_accel_group(mpUiManager->get_accel_group()) ;
>
> mpptrmenuBar = mpUiManager->get_widget("/menuBar");
>
> HBoxMenuBar.pack_start(*mpptrmenuBar, true, true, 15);
>
> //3- The related functions are as follows:
>
> void mainwin::install_menu_hints(const Glib::RefPtr<Gtk::Action>&
> action, Gtk::Widget* widget)
> {
> if(dynamic_cast<Gtk::MenuItem*>(widget))
> {
>
> (static_cast<Gtk::MenuItem*>(widget))->signal_select().connect(sigc::bind(sigc::mem_fun(*this,
> &mainwin::on_show_menu_tip), action));
>
> (static_cast<Gtk::MenuItem*>(widget))->signal_deselect().connect(sigc::mem_fun(*this,
> &mainwin::on_clear_menu_tip));
> }
> }
>
> void mainwin::on_show_menu_tip(const Glib::RefPtr<Gtk::Action>& action)
> {
> Glib::ustring tip = action->property_tooltip();
> if (tip == "") tip = " ";
> m_statusBar.push(" " + tip);
> }
>
> void mainwin::on_clear_menu_tip()
> {
> m_statusBar.pop();
> }
>
> // end of example code to add in the mainwin.cpp
> ==============================
>
> //The ui.xml file is as follows:
>
> <ui>
> <menubar name='menuBar'>
> <menu action='fileMenu'>
> <menuitem action='fileOpen'/>
> <separator/>
> <menuitem action='fileQuit'/>
> </menu>
> <menu action='helpMenu'>
> <menuitem action='helpHowTo'/>
> <menuitem action='helpAbout'/>
> </menu>
> </menubar>
> </ui>
>
> //++++++++++And my mainwin.h is as follows: ++++++++++++++
> #include <gtkmm.h>
> #include <gtkmm/menu.h>
> #include <gtkmm/menubar.h>
> #include <gtkmm/menuitem.h>
>
> class mainwin : public Gtk::Window
> {
> private:
>
> protected:
>
> Gtk::Box HBoxMenuBar;
>
> Gtk::Box VBox1;
> Gtk::Box HBoxSelectFile;
> Gtk::Box HBoxDestination;
> Gtk::Box HBoxActionButtons;
>
> /****
> /*** other widgets here...
>
> ====> Glib::RefPtr<Gtk::ActionGroup> mpActionGroup;
> ====> Glib::RefPtr<Gtk::UIManager> mpUiManager;
> ====> Gtk::Widget *mpptrmenuBar;
>
> ====> Gtk::Statusbar m_statusBar;
>
>
> //SIGNAL HANDLERS:
> /****
> /*** my handling functions here...
>
> public:
> mainwin(); // Connstructor
> virtual ~mainwin(); // Destructor
>
>
> ====> void install_menu_hints(const Glib::RefPtr<Gtk::Action>& action,
> Gtk::Widget* widget);
> ====> void on_show_menu_tip(const Glib::RefPtr<Gtk::Action>& action) ;
> ====> void on_clear_menu_tip();
>
> };
>
>
>
--
Atentamente:
Juan Ángel Moreno Fernández
[email protected]
------------------------------
Proyecto Gelide
http://gelide.sf.net
------------------------------
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list