<div>You can just connect `my_keypress_function()` when the menu is shown (GtkWidget's "show" signal), then, when a key is pressed, you look at which key it is, which menu item is active, and act (or not) accordingly.<br></div><div><br></div><div>No need to bother with what you say in the first part, it should work by itself in this case.<br></div><div><br></div><div>Don't forget to disconnect `my_keypress_function()` when the menu disappears though (GtkMenuShell's "selection-done" signal should be fine).<br></div><div><br></div><div class="protonmail_signature_block"><div class="protonmail_signature_block-user"><div>Cheers,<br></div><div>Gaël<br></div><div></div></div></div><div><br></div><div class="protonmail_quote">
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br>
On Thursday, September 2nd, 2021 at 6:20 AM, Sylvain Viart <sylvain@opensource-expert.com> wrote:<br>
<blockquote class="protonmail_quote" type="cite">
Hi,<br>
<br>
I would like to add 2 new key binding in clipman menu, in order to
swap Secure Item as Clear Text, and also to delete any them directly
from menu hitting del key.<br>
<br>
<img src="https://gitlab.xfce.org/Sylvain/xfce4-clipman-plugin/-/raw/secure_item_dbus/image.png" alt="image.png"><br>
<br>
I lack gtk knowledge, what I found is that:<br>
<br>
the app seems to do a g_application_register<br>
<br>
<a href="https://docs.gtk.org/gio/method.Application.register.html" target="_blank" rel="noreferrer nofollow noopener">https://docs.gtk.org/gio/method.Application.register.html</a><br>
<br>
but, I think the sole purpose of this is to avoid duplicate running
clipman.<br>
<br>
I also found, that I should add a keyboard mask somewhere
GDK_KEY_PRESS_MASK<br>
<br>
<a href="https://stackoverflow.com/questions/44098084/how-do-i-handle-keyboard-events-in-gtk3" target="_blank" rel="noreferrer nofollow noopener">https://stackoverflow.com/questions/44098084/how-do-i-handle-keyboard-events-in-gtk3</a><br>
<br>
may be their in panel_plugin_register() ?<br>
<br>
<a href="https://gitlab.xfce.org/Sylvain/xfce4-clipman-plugin/-/blob/secure_item_dbus/panel-plugin/main-panel-plugin.c#L71" target="_blank" rel="noreferrer nofollow noopener">https://gitlab.xfce.org/Sylvain/xfce4-clipman-plugin/-/blob/secure_item_dbus/panel-plugin/main-panel-plugin.c#L71</a><br>
<br>
Then I may be able to add a callback<br>
<br>
<pre><code>g_signal_connect (G_OBJECT (window), <span>"key_press_event"</span>,
G_CALLBACK (my_keypress_function), <span>NULL</span>);
</code></pre>
to my own keyboard handler, and then dispatch on which keystroke I
receive, right?<br>
What about "activate" callback on enter key, should I call them
after I introduce a keyboard handler?<br>
<br>
If you have code example, I would love to discover how it works. 😁<br>
<br>
Regards,<br>
Sylvain. <br>
<code></code>
<pre cols="72">--
Sylvain Viart - GNU/Linux Sysadmin/Developer/DevOps - France</pre>
</blockquote><br>
</div>