Re: GtkEditable and utf8 question
- From: Olexiy Avramchenko <olexiy ctech cn ua>
- To: Vincent Torri <Vincent Torri iecn u-nancy fr>
- Cc: gtk-list gnome org
- Subject: Re: GtkEditable and utf8 question
- Date: Mon, 21 Nov 2005 10:23:53 +0200
Vincent Torri wrote:
Hello,
Hi,
I would like to force an entry to insert only digit characters. I have
tried to modify the insert_text_handler example that is in the GtkEditable
API. The result is:
static void
_insert_numeric (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer data)
{
gint i;
gint j;
gchar *result;
result = (gchar *)g_malloc (sizeof (gchar) * (length + 1));
if (!result)
return;
for (i = 0, j = 0; i < length; i++)
{
if (g_ascii_isdigit (text[i]))
{
result[j] = text[i];
j++;
}
}
result[j] = '\0';
g_signal_handlers_block_by_func (editable,
(gpointer) _insert_numeric, data);
gtk_editable_insert_text (editable, result, length, position);
gtk_editable_insert_text (editable, result, j, position);
/* You've passed the incorrect string's length */
g_signal_handlers_unblock_by_func (editable,
(gpointer) _insert_numeric, data);
g_signal_stop_emission_by_name (editable, "insert-text");
g_free (result);
}
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]