title: Gtk signal with multiple arguments
body: <h2>Context</h2>
  <p>After writing a simple application using a <code>GtkEntry</code> widget to process textual commands from user I would like to do some design changes.</p>
  <p>As of now I use signal hook on key-press. If key(s) are a specified value, then show command line and process various actions on <code>entry</code> widget. Like e.g.</p>
  <ul>
  <li><kbd>Ctrl</kbd>+<kbd>a</kbd>: move cursor to start of input.</li>
  <li><kbd>Ctrl</kbd>+<kbd>u</kbd>: delete text before the cursor.</li>
  <li>...</li>
  </ul>
  <p>As well as parsing commands and saving/loading history.</p>
  <p>I am not satisfied with how this is stitched together. The command parsing becomes a subset of:</p>
  <pre><code>main_window -&gt; mode_check -&gt; command_line_act -&gt; parse_cmd+execute
  </code></pre>
  <p>As I see it one good approach would be to write a new widget using GtkEntry as base – and send signals on <em>command enter</em>. All of the internals like Ctrl+... and history handled by the new widget.</p>
  <p>Signals emitted from new widget being e.g.:</p>
  <ul>
  <li>&quot;cmdline-abort&quot;</li>
  <li>&quot;cmdline-cmd&quot;</li>
  <li>...</li>
  </ul>
  <h2>Status</h2>
  <p>Have written the base for this but I am at a hault when it comes to emitting signals with more then one argument.</p>
  <p>I have:</p>
  <pre><code>gtk_signal_emit(obj, sig, 0, command)
                                   |
                                   +---- string.
  </code></pre>
  <p>but would like, (for now at least, most likely more/other down the line.):</p>
  <pre><code>gtk_signal_emit(obj, sig, 0, command, length)
  </code></pre>
  <p><sup><i>gtk_emit_signal</i> Typo fixed. <a href="https://stackoverflow.com/a/19940119/2148245">Thanks to jku.</a>. Also, now using <i>g_signal_</i></sup></p>
  <hr />
  <p>In widget code:</p>
  <pre><code>static void
  cmdline_class_init(CmdlineClass *klass)
  {
  </code></pre>
  <p>With one argument I am using <a href="https://developer.gnome.org/gobject/2.28/gobject-Signals.html#g-signal-new" rel="nofollow noreferrer">g_signal_new()</a> as:</p>
  <pre><code>cmdline_signals[CMDLINE_CMD] = g_signal_new(
                  &quot;cmdline-cmd&quot;,
                  G_TYPE_FROM_CLASS(klass),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET(CmdlineClass, cmdline),
                  NULL,
                  NULL,
                  g_cclosure_marshal_VOID__VOID,
                  G_TYPE_NONE,
                  1,
                  G_TYPE_STRING
  );
  </code></pre>
  <p>And as I see it, for two arguments, should change it to something like:</p>
  <pre><code>cmdline_signals[CMDLINE_CMD] = g_signal_new(
                  &quot;cmdline-cmd&quot;,
                  G_TYPE_FROM_CLASS(klass),
                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                  G_STRUCT_OFFSET(CmdlineClass, cmdline),
                  NULL,
                  NULL,
                  g_cclosure_user_marshal_VOID__STRING_INT,
                  G_TYPE_NONE,
                  2,
                  G_TYPE_STRING,
                  G_TYPE_INT
  );
  </code></pre>
  <hr />
  <h2>Trouble in the garden</h2>
  <p>Using <a href="https://developer.gnome.org/gobject/stable/glib-genmarshal.html" rel="nofollow noreferrer">glib-genmarshal</a> to generate marshals with marshal.list holding:</p>
  <pre><code>VOID:STRING,INT
  </code></pre>
  <p>This works, but gives me a warning upon compile time as:</p>
  <pre><strong>warning: ISO C forbids conversion of object pointer to function pointer type</strong></pre>
  <p>Caused by this code generated by glib-genmarshal:</p>
  <pre><code>  typedef void (*GMarshalFunc_VOID__STRING_INT) (gpointer     data1,
                                                   gpointer     arg_1,
                                                   gint         arg_2,
                                                   gpointer     data2);
  
    register GMarshalFunc_VOID__STRING_INT callback;
  
    /* GCC Warnig: conversion of object pointer to function =&gt; */
    callback = (GMarshalFunc_VOID__STRING_INT) ( 
                      marshal_data ? 
                      marshal_data : 
                      cc-&gt;callback
    );
  </code></pre>
  <hr />
  <h2>Question</h2>
  <p>Is this the wrong approach? Is there some way to fix the conversion error? Etc.</p>
  <p><em>As a note: I am fairly new to Gtk, and Gui programming in general.</em></p>
  <hr />
  <h3>Side point</h3>
  <p>There are some deprecations I also wonder if could affect the code / should be avoided:</p>
  <ul>
  <li><a href="https://developer.gnome.org/gtk2/stable/gtk2-Types.html#GtkSignalMarshaller" rel="nofollow noreferrer">GtkSignalMarshaller</a>, does this indicate anything about the status of <code>GSignalCMarshaller</code>?</li>
  <li><a href="https://developer.gnome.org/gtk2/stable/gtk2-Types.html#GtkCallbackMarshal" rel="nofollow noreferrer">GtkCallbackMarshal</a>, does this indicate anything about the use of marshalers in general?</li>
  </ul>