Eu tentei o seu código iconify()/deiconify()
e ele funciona. Eu adicionei o código mínimo para fazê-lo funcionar. Você pode confirmar que esta versão funciona?
#include <gtkmm.h>
#include <libappindicator/app-indicator.h>
#include <gtkmm/stylecontext.h>
class CMainWindow: public Gtk::Window {
Glib::RefPtr<Gtk::StyleContext> m_rStyle;
Glib::RefPtr<Gtk::UIManager> m_rUIManager;
Glib::RefPtr<Gtk::ActionGroup> m_rActionGroup;
AppIndicator* m_pAppIcon;
public:
void TrayInit();
void TrayWinShow();
void TrayWinHide();
void TrayWinExit();
};
void CMainWindow::TrayInit() {
m_rActionGroup = Gtk::ActionGroup::create();
m_rActionGroup->add(Gtk::Action::create("Show", "Show"),
sigc::mem_fun(*this, &CMainWindow::TrayWinShow));
m_rActionGroup->add(Gtk::Action::create("Hide", "Hide"),
sigc::mem_fun(*this, &CMainWindow::TrayWinHide));
m_rUIManager = Gtk::UIManager::create();
m_rUIManager->insert_action_group(m_rActionGroup);
add_accel_group(m_rUIManager->get_accel_group());
Glib::ustring strUI =
"<ui>"
" <popup name='IndicatorPopup'>"
" <menuitem action='Show' />"
" <menuitem action='Hide' />"
" </popup>"
"</ui>";
m_rUIManager->add_ui_from_string(strUI);
Gtk::Widget *pWidget;
pWidget = m_rUIManager->get_widget("/ui/IndicatorPopup");
m_pAppIcon = app_indicator_new("sample", "weather-clear-night",
APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
app_indicator_set_status(m_pAppIcon, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_menu(m_pAppIcon, GTK_MENU(pWidget->gobj()));
}
void CMainWindow::TrayWinShow() {
deiconify();
}
void CMainWindow::TrayWinHide() {
iconify();
}
int main(int argc, char** argv) {
Glib::RefPtr<Gtk::Application> app =
Gtk::Application::create(argc, argv,"org.gtkmm.examples.base");
CMainWindow c;
c.set_default_size(200, 200);
c.TrayInit();
return app->run(c);
}
Eu salvei como test.cpp
e o compilei da seguinte forma:
g++ test.cpp 'pkg-config --cflags --libs gtkmm-3.0 appindicator3-0.1'