I have function to set DEVICE in gtk entry field:
gboolean device_entry_activate_cb (GtkWidget *widget, gpointer data)
{
const gchar *text;
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (!strcmp( DEVICE, text )
return FALSE;
if ( DEVICE )
g_free( DEVICE );
DEVICE = g_strdup( text );
if (0 == strcmp(DEVICE, "auto"))
/* do something: start printer for example */
return FALSE;
}
void device_entry_auto_activate_cb(GtkEntry* entry, const gchar* text, gpointer data)
{
GtkEditable *editable = GTK_EDITABLE (entry);
text = gtk_entry_get_text (GTK_ENTRY ( entry));
if (0 == strcmp(text, ""))
g_signal_emit_by_name(G_OBJECT (editable), "activate");
}
and connected with "hide" and "activate" signals
I'd like to automatically activate without press enter key after I typed "auto" text in entry field. Activate after last char "o" is typed in entry. What I'm doing now is : make the Gtk signal "editing_done" active on the widget. But it doesn't seem to work, I never get my callback function called.
g_signal_connect(G_OBJECT(entry), "hide", G_CALLBACK(device_entry_activate_cb), app);
g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(device_entry_activate_cb), NULL);
g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(device_entry_auto_activate_cb), NULL);
I don't wan't to require an "enter" to "activate" if gtk_entry containe text: auto
UPDATE code that I use.
You need to connect to the GtkEditable:changed signal and when the text in the entry is auto, use g_signal_emit_by_name to fake-send the GtkEntry:activate signal.