Re: Enable / disable a Gio::SimpleAction.
- From: Carlo Wood <carlo alinoe com>
- To: Kjell Ahlstedt <kjellahlstedt gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Enable / disable a Gio::SimpleAction.
- Date: Wed, 7 Oct 2020 22:04:23 +0200
On Wed, 7 Oct 2020 11:15:26 +0200
Kjell Ahlstedt <kjellahlstedt gmail com> wrote:
Have you seen the gtkmm tutorial?
https://developer.gnome.org/gtkmm-tutorial/3.24/gtkmm-tutorial.html
One of the examples in the /Menus and Toolbars/ chapter has a menu
with radio items.
There is also a menu demo among the gtkmm demo programs.
https://gitlab.gnome.org/GNOME/gtkmm/-/blob/gtkmm-3-24/demos/gtk-demo/example_menus.cc
The demo program uses Gtk::RadioMenuItem.
If you want to simplify the future upgrade of your program from
gtkmm3 to gtkmm4, I recommend that you look at the tutorial example
in the first place. It does not use Gtk::RadioMenuItem. There are no
specialized radio button classes or radio menu item classes in
gtkmm4. (It's still possible to make GUIs with radio buttons and
radio menu items.)
Thanks again,
I cloned https://gitlab.gnome.org/GNOME/gtkmm-documentation.git
and checked out tag "3.24.0".
I found an example that has radio items in the menu and
a toggle item. However, this information was read using
Gtk::Builder::add_from_string from a string (ui_info) with the format:
"<interface>"
" <!-- menubar -->"
" <menu id='menu-example'>"
" <submenu>"
" <attribute name='label' translatable='yes'>_File</attribute>"
" <section>"
" <item>"
and so on.
When I put that string in an XML file "example.glade" and try
to read it, glade gives the error:
example.glade targets Gtk+ 2.12
But this version of Glade is for GTK+ 3 only.
Make sure you can run this project with Glade 3.8 with no
deprecated widgets first.
In other words, it seems that the usage of "<menu>", "<submenu>" and "<section>" etc.
is old-style, pre- GTK+ 3.
I constructed MY menu with Glade 3.36 and that produces something like:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkMenu" id="PlacePiece">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="PlacePieceWhitePawn">
<property name="visible">True</property>
etc.
Most notably, when I add a radio menu item it results in
the following in the .glade file (two radio menu items shown):
<child>
<object class="GtkMenuItem" id="PlacepieceBlackPawn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="action_name">PlacepieceMenu.PlacepieceBlackPawn</property>
<property name="label" translatable="yes">Black pawn</property>
<property name="use_underline">True</property> </object>
</child>
<child>
<object class="GtkMenuItem" id="PlacepieceBlackRook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="action_name">PlacepieceMenu.PlacepieceBlackRook</property>
<property name="label" translatable="yes">Black rook</property>
<property name="use_underline">True</property> </object>
</child>
where-as the tutorial example has:
" <section>"
" <item>"
" <attribute name='label' translatable='yes'>Choice_A</attribute>"
" <attribute name='action'>win.choice</attribute>"
" <attribute name='target'>a</attribute>"
" </item>"
" <item>"
" <attribute name='label' translatable='yes'>Choice_B</attribute>"
" <attribute name='action'>win.choice</attribute>"
" <attribute name='target'>b</attribute>"
" </item>"
" </section>"
Since the 'action' and 'target' attributes are important in order to get
the whole to work as a radio button, I need to know how one can do this
with glade.
Or am I missing something?
Carlo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]