GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 23, 2014 8:59 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GtkEntry and “editing_done” signal
PostPosted: Wed Sep 11, 2013 9:46 am 
Offline
Familiar Face

Joined: Thu Nov 22, 2012 3:46 pm
Posts: 19
Code:
I have function to set DEVICE in gtk entry field:

gboolean device_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 */

    return FALSE;
}

and connected with "hide" and "activate" signals

I'd like to automatically activate when I typed "auto" text in entry field without press enter key.

Thanks


Top
 Profile  
 
 Post subject: Re: GtkEntry and “editing_done” signal
PostPosted: Sat Sep 14, 2013 6:14 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hello,

You will need to look at the GtkEntryBuffer for your GtkEntry. The two signals that you need to connect to are "deleted-text" and "inserted-text", these signals are called for every insertion or deletion of text from the GtkEntryBuffer. You will also need to make sure that your connection is last so that the text is already modified and then compare the text strings.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GtkEntry and “editing_done” signal
PostPosted: Tue Sep 24, 2013 8:21 pm 
Offline
Familiar Face

Joined: Thu Nov 22, 2012 3:46 pm
Posts: 19
Thank you for your answer. I solve problem with GtkEditable:

Code:
void device_entry_auto_activate_cb(GtkEntry* entry, const gchar* text, gpointer data)
{
   GtkEditable *editable;

   editable = GTK_EDITABLE (entry);

   text = gtk_entry_get_text(GTK_ENTRY(entry));

   if (0 == strcmp(text, "auto"))
      g_signal_emit_by_name(G_OBJECT (editable), "activate");
}


and connect to "changed" signal:

Code:
g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(device_entry_auto_activate_cb), NULL);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group