Re: how to connect Gio::SimpleAction signal
- From: Marty Moore <memoore gunnison com>
- To: Kjell Ahlstedt <kjellahlstedt gmail com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: how to connect Gio::SimpleAction signal
- Date: Tue, 02 Jan 2018 10:39:15 -0700
HappyOn Tue, 2017-12-19 at 10:02 +0100, Kjell Ahlstedt wrote:
Have you looked at the menu examples in the gtkmm tutorial? One with
a
Hapy new year all,
I have been working on this, without much accomplished. I have code
that compiles and runs, with the menu showing up, but can't get the
action to be activated when the menu itme is clicked.
AI'v also noticed that if I append a new menu item with only a label,
the menu item is enabled, but if I append a menu item with label and
action the menu item is disabled.
I haven't been able to avoid this situation. Any ideas??
Marty
code:
include "gui.h"
#include <iostream>
namespace geode
{
//CCCCCC GUI CCCCCCCCCCCCCCCC
Gui::Gui()
: m_Box(), //Gtk::ORIENTATION_VERTICAL),
mbut1()
{
set_title("menu test");
set_default_size(200, 200);
mbut1.set_label("button 1");
add(m_Box);
m_Box.pack_start(mbut1);
cout << "gui 0:" << endl;
giomenu = Gio::Menu::create();
menumodel = giomenu;
gtkmenu = new Gtk::Menu( giomenu);
cout << "gui 1:" << endl;
act_group = Gio::SimpleActionGroup::create();
act_group->add_action("FIRST",
sigc::mem_fun(*this, &Gui::on_action));
act_group->add_action("SECOND",
sigc::mem_fun(*this, &Gui::on_action));
act_group->add_action("THIRD",
sigc::mem_fun(*this, &Gui::on_action));
cout << "gui 2:" << endl;
giomenu->append("FIRST");
giomenu->append("SECOND");
giomenu->append( "THIRD", "THIRD");
cout << "gui 3:" << endl;
mbut1.set_menu(*gtkmenu);
show_all();
}
Gui::~Gui()
{ }
} // end namespace geod
popup menu:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/m
enus/popup?h=gtkmm-3-22
In that example the actions are inserted in a Gio::SimpleActionGroup.
I
think that a SimpleActionGroup would simplify your code. In the
usual
types of menu items (plain menu item, toggle menu item, radio menu
item)
you can connect signal handlers without a VariantBase parameter.
Gio::SimpleActionGroup (actually its base class Gio::ActionMap) has
several add_action*() methods for different types of menu items.
There are other examples with menus. They also use a
SimpleActionGroup.
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/m
enus/main_menu?h=gtkmm-3-22
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/m
enus_and_toolbars?h=gtkmm-3-22
Kjell
On 2017-12-16 21:43, Marty Moore wrote:
Hi Daniel, Thanks for your replay.
I found two things while perusing the documentation:
1. I nedd to connect either the signal_activate or
signal_state_changed
of the SimpleAction if I don't want default behavior.
2. There's a 'TODO' note saying that documentation is needed about
how
to connect the signals.
I'm still playing around with things, but what I really need is a
tutorial about how to use Variant/BariantBase. I'm getting stuck
every
time I run into it. There doesn't seem to be much explanation about
it. I assumed it was along the lines of void*, where you can use it
for
any data type. Is there something to explain how to use it? A good
example about this stuff would really be appreciated.
Thanks for your help,
Marty
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]