SF.net SVN: geany:[4892] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun May 9 15:48:29 UTC 2010
Revision: 4892
http://geany.svn.sourceforge.net/geany/?rev=4892&view=rev
Author: eht16
Date: 2010-05-09 15:48:29 +0000 (Sun, 09 May 2010)
Log Message:
-----------
Add public, generic callback ui_editable_insert_text_callback() to restrict GtkEntry text inputs to +/- and numeric values only.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/ui_utils.c
trunk/src/ui_utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-09 15:48:18 UTC (rev 4891)
+++ trunk/ChangeLog 2010-05-09 15:48:29 UTC (rev 4892)
@@ -2,6 +2,9 @@
* THANKS, src/about.c, plugins/classbuilder.c:
Add support for creating PHP classes (patch by Ondrej Donek, thanks).
+ * src/ui_utils.h, src/ui_utils.c:
+ Add public, generic callback ui_editable_insert_text_callback()
+ to restrict GtkEntry text inputs to +/- and numeric values only.
2010-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2010-05-09 15:48:18 UTC (rev 4891)
+++ trunk/src/ui_utils.c 2010-05-09 15:48:29 UTC (rev 4892)
@@ -2267,3 +2267,25 @@
else
return default_value;
}
+
+
+void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text,
+ gint new_text_len, gint *position, gpointer data)
+{
+ gboolean stop_signal = FALSE;
+ const gchar c = *new_text;
+
+ /* allow inserting '+' and '-' as the first character */
+ if (position != NULL && *position == 0)
+ {
+ if (c != '+' && c != '-' && ! isdigit(c))
+ stop_signal = TRUE;
+ }
+ /* don't insert any text when it is not a digit */
+ else if (! isdigit(c))
+ stop_signal = TRUE;
+
+ if (stop_signal)
+ g_signal_stop_emission_by_name(editable, "insert-text");
+}
+
Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h 2010-05-09 15:48:18 UTC (rev 4891)
+++ trunk/src/ui_utils.h 2010-05-09 15:48:29 UTC (rev 4892)
@@ -203,6 +203,8 @@
void ui_entry_add_clear_icon(GtkEntry *entry);
+void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text,
+ gint new_text_len, gint *position, gpointer data);
#define ui_label_new_bold(text)\
ui_label_set_markup(GTK_LABEL(gtk_label_new(NULL)), "<b>%s</b>", text);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list