Gtk Pop up menus are coming disabled



I have created  GTK Popup menu, which is getting created and getting popped
up on button press, but it is coming disabled

I am unable to activate it, i have read the gtkmm documentation as well, i
am following the  required process

I am sharing the code which is used to create this pop up menu

testpopup.h

#ifndef SEEN_TESTPOPUP_H
#define SEEN_TESTPOPUP_H

#include <gtkmm.h>

class Testpopup : public Gtk::ApplicationWindow {

public:
    Testpopup();
    void custom_popupmenu();

    void on_menu_file_popup_generic();

};

#endif

testpopup.cpp

#include "testpopup.h"
#include <iostream>


#include <gtkmm.h>
#include <gtkmm/application.h>

Testpopup::Testpopup() {

    std::cout << "Testpopup constructor call" << std::endl;
}

void Testpopup::on_menu_file_popup_generic() {

    std::cout << "A popup menu item was selected." << std::endl;

}



void Testpopup::custom_popupmenu() {

    std::cout << "We are just testing if this process can be separated out
from verbs " << std::endl;

    auto m_refActionGroup = Gio::SimpleActionGroup::create();

    m_refActionGroup->add_action("clone",
            sigc::mem_fun(*this, &Testpopup::on_menu_file_popup_generic));

    m_refActionGroup->add_action("create",
            sigc::mem_fun(*this, &Testpopup::on_menu_file_popup_generic));

    m_refActionGroup->add_action("unlink",
            sigc::mem_fun(*this, &Testpopup::on_menu_file_popup_generic));

    m_refActionGroup->add_action("relink",
            sigc::mem_fun(*this, &Testpopup::on_menu_file_popup_generic));

    
    insert_action_group("dicclonetiler",m_refActionGroup);

    
    Glib::ustring dicclonetilerui_info =
            "<interface>"
            " <menu id='menu-dicclonetiler'>"
            "  <section>"
            "    <item>"
            "      <attribute name='label' translatable='yes'>DIC
Clonetiler</attribute>"
            "      <attribute name='action'>dicclonetiler.clone</attribute>"
            "      <attribute
name='icon'>/home/vishal/Downloads/source_preferences_update_complete/share/col_half_drop.svg</attribute>"
            "    </item>"
            "    <item>"
            "      <attribute name='label' translatable='yes'>Create
clones</attribute>"
            "      <attribute
name='action'>dicclonetiler.create</attribute>"
            "      <attribute
name='icon'>/home/vishal/Downloads/source_preferences_update_complete/share/row_half_drop.svg</attribute>"
            "    </item>"
            "    <item>"
            "      <attribute name='label' translatable='yes'>Unlink
clones</attribute>"
            "      <attribute
name='action'>dicclonetiler.unlink</attribute>"
            "      <attribute
name='icon'>/home/vishal/Downloads/source_preferences_update_complete/share/full_drop.svg</attribute>"
            "    </item>"
            "    <item>"
            "      <attribute name='label' translatable='yes'>Relink
clones</attribute>"
            "      <attribute
name='action'>dicclonetiler.relink</attribute>"
            "      <attribute
name='icon'>/home/vishal/Downloads/source_preferences_update_complete/share/regular_tiling.svg</attribute>"
            "    </item>"
            "  </section>"
            " </menu>"
            "</interface>";



              Glib::RefPtr<Gtk::Builder> m_refBuilder =
Gtk::Builder::create();
              m_refBuilder->add_from_string(dicclonetilerui_info);

              Glib::RefPtr<Glib::Object> object =
m_refBuilder->get_object("menu-dicclonetiler");
              Glib::RefPtr<Gio::Menu> gmenu =
Glib::RefPtr<Gio::Menu>::cast_dynamic(object);

              Gtk::Menu* m_pMenuPopup = new Gtk::Menu(gmenu);

              m_pMenuPopup->popup(1,gtk_get_current_event_time());

}

Subsequently there is a main.cpp where i am creating Testpopup class object
and invoking custom_popupmenu() function using this code 

Testpopup* m_pTestpopup = new Testpopup();
m_pTestpopup->custom_popupmenu();




--
Sent from: http://gtk.10911.n7.nabble.com/Gtk-General-f47634.html


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