-typedef std::stack<GtkWidget*> WidgetStack;
-
-void PlugInMenu_Add(GtkMenu* plugin_menu, IPlugIn* pPlugIn)
-{
- GtkWidget *menu, *item, *parent, *subMenu;
- const char *menuText, *menuCommand;
- WidgetStack menuStack;
-
- parent = gtk_menu_item_new_with_label (pPlugIn->getMenuName());
- gtk_widget_show (parent);
- gtk_container_add (GTK_CONTAINER (plugin_menu), parent);
-
- std::size_t nCount = pPlugIn->getCommandCount();
- if (nCount > 0)
- {
- menu = gtk_menu_new();
- if (g_Layout_enableDetachableMenus.m_value)
- menu_tearoff (GTK_MENU(menu));
- while (nCount > 0)
- {
- menuText = pPlugIn->getCommandTitle(--nCount);
- menuCommand = pPlugIn->getCommand(nCount);
-
- if (menuText != 0 && strlen(menuText) > 0)
- {
- if (!strcmp(menuText, "-"))
- {
- item = gtk_menu_item_new();
- gtk_widget_set_sensitive (item, FALSE);
- }
- else if (!strcmp(menuText, ">"))
- {
- menuText = pPlugIn->getCommandTitle(--nCount);
- menuCommand = pPlugIn->getCommand(nCount);
- if (!strcmp(menuText, "-") || !strcmp(menuText, ">") || !strcmp(menuText, "<"))
- {
- globalErrorStream() << pPlugIn->getMenuName() << " Invalid title (" << menuText << ") for submenu.\n";
- continue;
- }
-
- item = gtk_menu_item_new_with_label(menuText);
- gtk_widget_show (item);
- gtk_container_add (GTK_CONTAINER (menu), item);
-
- subMenu = gtk_menu_new();
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), subMenu);
- menuStack.push(menu);
- menu = subMenu;
- continue;
- }
- else if (!strcmp(menuText, "<"))
- {
- if (!menuStack.empty())
- {
- menu = menuStack.top();
- menuStack.pop();
- }
- else
- {
- globalErrorStream() << pPlugIn->getMenuName() << ": Attempt to end non-existent submenu ignored.\n";
- }
- continue;
- }
- else
- {
- item = gtk_menu_item_new_with_label (menuText);
- g_object_set_data(G_OBJECT(item),"command", const_cast<gpointer>(static_cast<const void*>(menuCommand)));
- g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(plugin_activated), gint_to_pointer(m_nNextPlugInID));
- }
- gtk_widget_show (item);
- gtk_container_add (GTK_CONTAINER (menu), item);
- pPlugIn->addMenuID(m_nNextPlugInID++);
- }
- }
- if (!menuStack.empty())
- {
- std::size_t size = menuStack.size();
- if (size != 0)
- {
- globalErrorStream() << pPlugIn->getMenuName() << " mismatched > <. " << Unsigned(size) << " submenu(s) not closed.\n";
- }
- for (std::size_t i = 0; i < (size -1); i++)
- {
- menuStack.pop();
- }
- menu = menuStack.top();
- menuStack.pop();
- }
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), menu);
- }
+
+void PlugInMenu_Add( ui::Menu plugin_menu, IPlugIn* pPlugIn ){
+ ui::Widget item, parent;
+ ui::Menu menu{ui::null}, subMenu{ui::null};
+ const char *menuText, *menuCommand;
+ std::stack<ui::Menu> menuStack;
+
+ parent = ui::MenuItem( pPlugIn->getMenuName() );
+ parent.show();
+ plugin_menu.add(parent);
+
+ std::size_t nCount = pPlugIn->getCommandCount();
+ if ( nCount > 0 ) {
+ menu = ui::Menu();
+ if ( g_Layout_enableDetachableMenus.m_value ) {
+ menu_tearoff( menu );
+ }
+ while ( nCount > 0 )
+ {
+ menuText = pPlugIn->getCommandTitle( --nCount );
+ menuCommand = pPlugIn->getCommand( nCount );
+
+ if ( menuText != 0 && strlen( menuText ) > 0 ) {
+ if ( !strcmp( menuText, "-" ) ) {
+ item = ui::Widget(gtk_menu_item_new());
+ gtk_widget_set_sensitive( item, FALSE );
+ }
+ else if ( !strcmp( menuText, ">" ) ) {
+ menuText = pPlugIn->getCommandTitle( --nCount );
+ menuCommand = pPlugIn->getCommand( nCount );
+ if ( !strcmp( menuText, "-" ) || !strcmp( menuText, ">" ) || !strcmp( menuText, "<" ) ) {
+ globalErrorStream() << pPlugIn->getMenuName() << " Invalid title (" << menuText << ") for submenu.\n";
+ continue;
+ }
+
+ item = ui::MenuItem( menuText );
+ item.show();
+ menu.add(item);
+
+ subMenu = ui::Menu();
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu );
+ menuStack.push( menu );
+ menu = subMenu;
+ continue;
+ }
+ else if ( !strcmp( menuText, "<" ) ) {
+ if ( !menuStack.empty() ) {
+ menu = menuStack.top();
+ menuStack.pop();
+ }
+ else
+ {
+ globalErrorStream() << pPlugIn->getMenuName() << ": Attempt to end non-existent submenu ignored.\n";
+ }
+ continue;
+ }
+ else
+ {
+ item = ui::MenuItem( menuText );
+ g_object_set_data( G_OBJECT( item ),"command", const_cast<gpointer>( static_cast<const void*>( menuCommand ) ) );
+ item.connect( "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) );
+ }
+ item.show();
+ menu.add(item);
+ pPlugIn->addMenuID( m_nNextPlugInID++ );
+ }
+ }
+ if ( !menuStack.empty() ) {
+ std::size_t size = menuStack.size();
+ if ( size != 0 ) {
+ globalErrorStream() << pPlugIn->getMenuName() << " mismatched > <. " << Unsigned( size ) << " submenu(s) not closed.\n";
+ }
+ for ( std::size_t i = 0; i < ( size - 1 ); i++ )
+ {
+ menuStack.pop();
+ }
+ menu = menuStack.top();
+ menuStack.pop();
+ }
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM( parent ), menu );
+ }