[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk
Subject:    GMenu items with detailed action names not working
From:       Tom Schoonjans via gtk-list <gtk-list () gnome ! org>
Date:       2018-07-13 12:54:54
Message-ID: 058DDC90-883B-4834-B3B3-E320314D5164 () me ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi all,


I am trying to add three items to a toolbar submenu, that when clicked should open \
the default browser with a particular url.

Based on https://wiki.gnome.org/HowDoI/GAction \
<https://wiki.gnome.org/HowDoI/GAction> and \
https://developer.gnome.org/gio/stable/GActionMap.html \
<https://developer.gnome.org/gio/stable/GActionMap.html>

I came up with something like:


<?xml version="1.0"?>
<interface>
	<menu id="menubar">
		<section>
			<submenu>
				<attribute name="label">_Help</attribute>
				<section>
					<attribute name="id">help-section</attribute>
					<item>
						<attribute name="label">Visit site a</attribute>
						<attribute name="action">app.help-url('https://a.com')</attribute>
					</item>
					<item>
						<attribute name="label">Visit site b</attribute>
						<attribute name="action">app.help-url('https://b.com')</attribute>
					</item>
					<item>
						<attribute name="label">Visit site c</attribute>
						<attribute name="action">app.help-url('https://c.com')</attribute>
					</item>
				</section>
			</submenu>
		</section>
	</menu>
</interface>


In my GtkApplication derived class:

static GActionEntry app_entries[] = {
	{"help-url", help_url_activated, "s", NULL, NULL},
};


This causes the items to be shown in the menu, but they are not sensitive (cannot be \
activated).

The real example is considerably more complicated and also contains menu items with \
actions that do not require a parameter: these all work fine.

I am using the latest versions of Gtk+3 and Glib, in case it matters...

No errors or warnings are being shown in the terminal.

Many thanks for your comments in advance,

Tom


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; line-break: after-white-space;" class="">Hi all,<div class=""><br \
class=""></div><div class=""><br class=""></div><div class="">I am trying to add \
three items to a toolbar submenu, that when clicked should open the default browser \
with a particular url.</div><div class=""><br class=""></div><div class="">Based \
on&nbsp;<a href="https://wiki.gnome.org/HowDoI/GAction" \
class="">https://wiki.gnome.org/HowDoI/GAction</a>&nbsp;and&nbsp;<a \
href="https://developer.gnome.org/gio/stable/GActionMap.html" \
class="">https://developer.gnome.org/gio/stable/GActionMap.html</a></div><div \
class=""><br class=""></div><div class="">I came up with something like:</div><div \
class=""><br class=""></div><div class=""><br class=""></div><div class="">&lt;?xml \
version="1.0"?&gt;</div><div class=""><div class="">&lt;interface&gt;</div></div><div \
class=""><div class=""><span class="Apple-tab-span" \
style="white-space:pre">	</span>&lt;menu id="menubar"&gt;</div><div class=""><span \
class="Apple-tab-span" \
style="white-space:pre">		</span>&lt;section&gt;</div></div><div class=""><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">			</span>&lt;submenu&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">				</span>&lt;attribute \
name="label"&gt;_Help&lt;/attribute&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">				</span>&lt;section&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">					</span>&lt;attribute \
name="id"&gt;help-section&lt;/attribute&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">					</span>&lt;item&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="label"&gt;Visit site \
a&lt;/attribute&gt;</div><div class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="action"&gt;app.help-url('<a \
href="https://a.com" class="">https://a.com</a>')&lt;/attribute&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">					</span>&lt;/item&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">					</span>&lt;item&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="label"&gt;Visit site \
b&lt;/attribute&gt;</div><div class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="action"&gt;app.help-url('<a \
href="https://b.com" class="">https://b.com</a>')&lt;/attribute&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">					</span>&lt;/item&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">					</span>&lt;item&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="label"&gt;Visit site \
c&lt;/attribute&gt;</div><div class=""><span class="Apple-tab-span" \
style="white-space:pre">						</span>&lt;attribute name="action"&gt;app.help-url('<a \
href="https://c.com" class="">https://c.com</a>')&lt;/attribute&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">					</span>&lt;/item&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">				</span>&lt;/section&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">			</span>&lt;/submenu&gt;</div><div class=""><span \
class="Apple-tab-span" style="white-space:pre">		</span>&lt;/section&gt;</div><div \
class=""><span class="Apple-tab-span" \
style="white-space:pre">	</span>&lt;/menu&gt;</div><div \
class="">&lt;/interface&gt;</div></div><div class=""><br class=""></div><div \
class=""><br class=""></div><div class="">In my GtkApplication derived \
class:</div><div class=""><br class=""></div><div class=""><div class="">static \
GActionEntry app_entries[] = {</div><div class=""><span class="Apple-tab-span" \
style="white-space:pre">	</span>{"help-url", help_url_activated, "s", NULL, \
NULL},</div><div class="">};</div></div><div class=""><br class=""></div><div \
class=""><br class=""></div><div class="">This causes the items to be shown in the \
menu, but they are not sensitive (cannot be activated).</div><div class=""><br \
class=""></div><div class="">The real example is considerably more complicated and \
also contains menu items with actions that do not require a parameter: these all work \
fine.</div><div class=""><br class=""></div><div class="">I am using the latest \
versions of Gtk+3 and Glib, in case it matters...</div><div class=""><br \
class=""></div><div class="">No errors or warnings are being shown in the \
terminal.</div><div class=""><br class=""></div><div class="">Many thanks for your \
comments in advance,</div><div class=""><br class=""></div><div \
class="">Tom</div></body></html>



_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic