[Glade-users] IP input checking

Hariyanto xhonghar at gmail.com
Tue Jun 6 10:25:50 EDT 2006


I newbie on glade and try this code maybe can help you.
hariyanto

#include "stdlib.h"

gboolean
on_entry1_key_press_event              (GtkWidget       *widget,
                                        GdkEventKey     *event,
                                        gpointer         user_data)
{
gchar *str;
gdouble num;

  if (event->hardware_keycode == 60)
   {  
    str = gtk_entry_get_text(GTK_ENTRY(lookup_widget(frm_main,"entry1")));
    num = atof(str);

    if (num >= 0 && num <=255)
     {
      gtk_widget_grab_focus(GTK_ENTRY(lookup_widget(frm_main,"entry2")));
      return TRUE;    
     }
    else
     {    
      gtk_widget_grab_focus(GTK_ENTRY(lookup_widget(frm_main,"entry1")));    
      return TRUE;          
     }
   }  
  else if (event->hardware_keycode < 10 || event->hardware_keycode > 19)
   {
    g_print("Input not Numeric");
    return TRUE;
   }  
   
  return FALSE;
}

On Mon, 5 Jun 2006 08:27:51 -0700 (PDT)
Denes Matetelki <cs0rbagomba at yahoo.com> wrote:

> 
> Hi!
> 
> I've made 4 text entrys to accept IP addresses. 
> 
> How can I check that the input is numeric and in the range 0-255?
> It would be nice too if I can move to the next field by pressing the '.' key.
> 
> How should it be done?
> 
> Best Regards:
> Denes
> 
> 
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 


More information about the Glade-users mailing list