Note that there are some explanatory texts on larger screens.

plurals
  1. POValidate format of the string typed in gtk_entry
    primarykey
    data
    text
    <p>I need to write a function that will validate device name typed by user in gtk entry field.</p> <p>Device must be in the following form:</p> <pre><code>"/dev/video + one digits" ( e.g. /dev/video1 ) </code></pre> <p>For this I made function but I don't now how to write condition</p> <pre><code>void validate_device_cb (GtkEntry* entry, const gchar* text, gint length, gint* position, gpointer data) { GtkEditable *editable = GTK_EDITABLE (entry); int i, count = 0; gchar *result = g_new (gchar, length); for (i = 0; i &lt; length; i++) { /* insert condition here */ continue; result[count++] = text[i]; } if (count &gt; 0) { g_signal_handlers_block_by_func (G_OBJECT (editable), G_CALLBACK (validate_device_cb), data); gtk_editable_insert_text (editable, result, count, position); g_signal_handlers_unblock_by_func (G_OBJECT (editable), G_CALLBACK (validate_device_cb), data); } g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text"); g_free (result); } </code></pre> <p>Any help are welcome Best regards</p> <p>UPDATE ( more explication)</p> <p>gtk entry must should accept only this chars typed:</p> <pre><code>first typed: '/' second 'd' third 'e' fourth 'v' fifth '/' sixth 'v' seventh 'i' eight 'd' ......... eleven digit twelve digit </code></pre> <p>setting device entry:</p> <pre><code>video_device = gtk_entry_new_with_max_length(12); gtk_editable_set_editable(GTK_EDITABLE(video_device),TRUE); g_signal_connect(G_OBJECT(video_device), "insert_text" , G_CALLBACK(validate_device_cb), NULL); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload