aboutsummaryrefslogtreecommitdiffstats
path: root/packages/gpe-contacts/gpe-contacts-0.32/filtered-paste.patch
blob: 4b1e70dadb287860f0eeccffb382601846bb499f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Index: editing.c
===================================================================
RCS file: /cvs/gpe/base/gpe-contacts/editing.c,v
retrieving revision 1.59
diff -u -r1.59 editing.c
--- editing.c	20 Oct 2004 14:00:36 -0000	1.59
+++ editing.c	24 Oct 2004 22:32:43 -0000
@@ -46,17 +46,23 @@
 void on_name_clicked (GtkButton *button, gpointer user_data);
 
 
-
 /* this is the filter for phone number edits */
-static gboolean
-phone_key_press_event (GtkWidget *widget, GdkEventKey *k, gpointer p)
+void
+on_phone_insert_text(GtkEditable *editable, gchar *new_text,
+                     gint new_text_length, gint *position,
+                     gpointer user_data)
 {
-  if (!strstr(" +0123456789-/()", k->string) 
-      && !(k->state & GDK_CONTROL_MASK))
-    {
-      return TRUE;
-    }
-  return FALSE;
+  int i;
+  gboolean isok = TRUE;
+  
+  for (i = 0; i < new_text_length; i++)
+    if (!strchr(" +0123456789-/()", new_text[i]))
+      {
+        isok = FALSE;
+        break;
+      }
+  if (!isok)
+    gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert-text");
 }
 
 static void
@@ -91,8 +97,8 @@
               || strstr(e->tag,".MOBILE") 
               || strstr(e->tag,".FAX"))
             {
-               g_signal_connect (G_OBJECT (w), "key_press_event", 
-		         G_CALLBACK (phone_key_press_event), NULL);
+              g_signal_connect (G_OBJECT (w), "insert-text", 
+		         G_CALLBACK (on_phone_insert_text), NULL);
             }
           if (strcasecmp(e->tag, "NAME")) /* the name field on a button */
             {