#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <liberdm/display.h>
#include <liberdm/erdm.h>
#include <libergtk/ergtk.h>
#include <liberipc/eripctoolbar.h>
#include "setupLog.h"
#include "displayStatus.h"
#include "gtkPincodeEntry.h"
Go to the source code of this file.
Functions | |
| static void | gtk_pincode_entry_class_init (GtkPincodeEntryClass *klass) |
| static void | gtk_pincode_entry_init (GtkPincodeEntry *input_entry) |
| static void | on_gtk_pincode_entry_insert_text (GtkWidget *widget, const gchar *text, gint length, gint *position, gpointer user_data) |
| GtkWidget * | gtk_pincode_entry_new () |
| GType | gtk_pincode_entry_get_type (void) |
| gboolean | gtk_pincode_entry_check_text (GtkPincodeEntry *pincode_entry) |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
override the standard GtkEntry
input pincode entry, limited between 4-8 digital numbers characters are shown as '********' call displayMgr to show the user's input to user on eink screen
Definition in file gtkPincodeEntry.c.
| gboolean gtk_pincode_entry_check_text | ( | GtkPincodeEntry * | pincode_entry | ) |
check user input is valid or not, should be 4-8 digital numbers
| pincode_entry | the GtkPincodeEntry widget |
Definition at line 120 of file gtkPincodeEntry.c.
00121 { 00122 const gchar *text = NULL; 00123 int i, len; 00124 gboolean entry_ok = FALSE; 00125 00126 g_return_val_if_fail((pincode_entry!= NULL), FALSE); 00127 g_return_val_if_fail(IS_GTK_PINCODE_ENTRY(pincode_entry), FALSE); 00128 00129 GtkEntry* entry = (GtkEntry*)pincode_entry; 00130 00131 text = gtk_entry_get_text(entry); 00132 if (text == NULL) 00133 { 00134 text = ""; 00135 } 00136 00137 len = strlen(text); 00138 if ( len >= PINCODE_UI_MIN_LENGTH 00139 && len <= PINCODE_UI_MAX_LENGTH ) 00140 { 00141 entry_ok = TRUE; 00142 for (i = 0; i < len; i++) 00143 { 00144 if ( !isdigit(text[i]) ) 00145 { 00146 entry_ok = FALSE; 00147 } 00148 } 00149 } 00150 00151 return entry_ok; 00152 }
| static void gtk_pincode_entry_class_init | ( | GtkPincodeEntryClass * | klass | ) | [static] |
| GType gtk_pincode_entry_get_type | ( | void | ) |
returns type of GtkPincodeEntry widget
Definition at line 73 of file gtkPincodeEntry.c.
00074 { 00075 static GType pincode_entry_type = 0; 00076 00077 if (!pincode_entry_type) 00078 { 00079 static const GTypeInfo pincode_entry_info = { 00080 sizeof(GtkPincodeEntryClass), 00081 NULL, /* base_init */ 00082 NULL, /* base_finalize */ 00083 (GClassInitFunc) gtk_pincode_entry_class_init, 00084 NULL, /* class_finalize */ 00085 NULL, /* class_data */ 00086 sizeof(GtkPincodeEntry), 00087 0, /* n_preallocs */ 00088 (GInstanceInitFunc) gtk_pincode_entry_init, 00089 }; 00090 00091 pincode_entry_type = g_type_register_static(ERGTK_ENTRY_TYPE, "PincodeEntry", &pincode_entry_info, 0); 00092 } 00093 return pincode_entry_type; 00094 }

| static void gtk_pincode_entry_init | ( | GtkPincodeEntry * | input_entry | ) | [static] |
Definition at line 103 of file gtkPincodeEntry.c.
00104 { 00105 g_return_if_fail(pincode_entry != NULL); 00106 00107 GtkWidget* widget = (GtkWidget*)pincode_entry; 00108 GtkEntry* entry = (GtkEntry* )pincode_entry; 00109 00110 gtk_widget_set_size_request(widget, PINCODE_INPUT_ENTRY_WIDTH, PINCODE_INPUT_ENTRY_HEIGHT); 00111 gtk_entry_set_max_length(entry, PINCODE_UI_MAX_LENGTH); 00112 gtk_entry_set_visibility(entry, FALSE); 00113 00114 gtk_signal_connect(GTK_OBJECT(entry), "insert_text", GTK_SIGNAL_FUNC(on_gtk_pincode_entry_insert_text), NULL); 00115 }

| GtkWidget* gtk_pincode_entry_new | ( | ) |
creates a new GtkPincodeEntry widget
| - |
Definition at line 66 of file gtkPincodeEntry.c.
00067 { 00068 GtkPincodeEntry* pincode_entry = (GtkPincodeEntry*) g_object_new(GTK_PINCODE_ENTRY_TYPE, NULL); 00069 00070 return GTK_WIDGET(pincode_entry); 00071 }
| static void on_gtk_pincode_entry_insert_text | ( | GtkWidget * | widget, | |
| const gchar * | text, | |||
| gint | length, | |||
| gint * | position, | |||
| gpointer | user_data | |||
| ) | [static] |
Definition at line 156 of file gtkPincodeEntry.c.
00158 { 00159 GtkEditable *editable = GTK_EDITABLE(widget); 00160 int i, count = 0; 00161 gchar *result = g_new(gchar, length); 00162 00163 for (i = 0; i < length; i++) 00164 { 00165 if (!isdigit(text[i])) 00166 continue; 00167 result[count++] = text[i]; 00168 } 00169 if (count > 0) 00170 { 00171 gtk_signal_handler_block_by_func(GTK_OBJECT(editable), 00172 GTK_SIGNAL_FUNC(on_gtk_pincode_entry_insert_text), user_data); 00173 gtk_editable_insert_text(editable, result, count, position); 00174 gtk_signal_handler_unblock_by_func(GTK_OBJECT(editable), 00175 GTK_SIGNAL_FUNC(on_gtk_pincode_entry_insert_text), user_data); 00176 } 00177 gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text"); 00178 00179 g_free(result); 00180 }
1.5.6