<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hi Gaël,<br>
      <br>
      Thanks.<br>
      <br>
      But not sufficient for me to understand.<br>
      <br>
      I did a test with "show" and "hide", I didn't found where I could
      connect on GtkMenuShell's "selection-done" signal. Especially I'm
      not sure "selection-done" will occur, scenario:<br>
      <br>
      open the menu to track unwanted item:<br>
      <ol>
        <li>click to open</li>
        <li>navigate up down key of with mouse over</li>
        <li>hit delete key, the item is removed and menu updated</li>
        <li>you can do it for some more item too.</li>
        <li>click else where to continue or close the menu, no selection
          have been done.<br>
        </li>
      </ol>
      <p>My commit looks like:</p>
      <p><a moz-do-not-send="true"
href="https://gitlab.xfce.org/Sylvain/xfce4-clipman-plugin/-/commit/8e8e3c69ec9d70cf1fc138826e8a778f895ff0bb#9ccec1d9c5b9b6500f958458cfe0b9d1a4ad557e">https://gitlab.xfce.org/Sylvain/xfce4-clipman-plugin/-/commit/8e8e3c69ec9d70cf1fc138826e8a778f895ff0bb#9ccec1d9c5b9b6500f958458cfe0b9d1a4ad557e</a><br>
      </p>
      There's already a callback on "show":  _clipman_menu_update_list()<br>
      I suppose I can connect multiple handler on the same signal,
      right?<br>
      <br>
      If I remove the hide handler which crashes, and change for DEL
      key, it seems never reached,<br>
      <br>
      <font face="monospace">+++ b/panel-plugin/menu.c<br>
        @@ -637,20 +637,20 @@ clipman_menu_class_init (ClipmanMenuClass
        *klass)<br>
         static gboolean<br>
         _clipman_menu_keyboard_event (GtkWidget *widget, GdkEventKey
        *event, gpointer data)<br>
         {<br>
        -  if (event->keyval == GDK_KEY_space)<br>
        +  if (event->keyval == GDK_KEY_Delete)<br>
           {<br>
        -    printf("SPACE KEY PRESSED!");<br>
        +    printf("DEL KEY PRESSED!");<br>
             return TRUE;<br>
           }<br>
           return FALSE;<br>
         }<br>
         <br>
      </font>but it is connected, and putting a gdb break point in a
      keyboard handler, has interesting result, the keyboard nor the
      mouse works anymore....  <font face="monospace"><br>
      </font><br>
      Do gtk knows that my handler is expecting <font face="monospace">GdkEventKey
        *event</font> data, automatically?<br>
      I mean, the prototype of _clipman_menu_update_list() is:<br>
      <br>
      static void _clipman_menu_update_list (ClipmanMenu *menu) <br>
      <font face="monospace"></font><br>
      I read that keyboard handler must return bool, so signaling if
      they decided to grab the keystroke or not...<br>
      <br>
      To be continued,<br>
      Regards,<br>
      Sylvain.<br>
       <br>
      On 03/09/2021 10:49, Gaël Bonithon wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:LNsZ1-Rm3WjNz3xqacrwJiEQMSg7GWDtlRctpknXe7Wo_vH0ITW1ea4rcs-vIgGnr8y--6IwVJrskw3yrDk7zSyxMbnYWjjHn0BwYbhzSq0=@protonmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <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><br>
      </div>
      <div class="protonmail_quote"> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br>
        On Thursday, September 2nd, 2021 at 6:20 AM, Sylvain Viart
        <a class="moz-txt-link-rfc2396E" href="mailto:sylvain@opensource-expert.com"><sylvain@opensource-expert.com></a> 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>
          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"
            moz-do-not-send="true">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"
            moz-do-not-send="true">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"
            moz-do-not-send="true">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>_____________________________________________
        </blockquote>
      </div>
      <pre class="moz-quote-pre" wrap="">Xfce4-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Xfce4-dev@xfce.org">Xfce4-dev@xfce.org</a>
<a class="moz-txt-link-freetext" href="https://mail.xfce.org/mailman/listinfo/xfce4-dev">https://mail.xfce.org/mailman/listinfo/xfce4-dev</a></pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Sylvain Viart - GNU/Linux Sysadmin/Developer/DevOps - France</pre>
  </body>
</html>