]> git.neil.brown.name Git - plato.git/commitdiff
dialler: allow easy access to contacts.
authorNeilBrown <neilb@suse.de>
Mon, 14 Jan 2013 20:15:06 +0000 (07:15 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 14 Jan 2013 20:15:06 +0000 (07:15 +1100)
If you tap the place where  the name of the contact can
be displayed, it takes you to the  'contacts' app.

utils/dialer.py

index 3bb9587f9df7ef697fb73d187b0e10dac8b6381e..faa29ef9563e4ed31487b643fc507064ddfe739d 100644 (file)
@@ -55,6 +55,28 @@ def recall(key):
     return l.strip()
 
 
+sel_number = None
+clips = {}
+def clip_get_data(clip, sel, info, data):
+    global sel_number
+    if sel_number:
+        sel.set_text(sel_number)
+def clip_clear_data(clip, data):
+    global sel_number
+    sel_number = None
+
+def send_number(sel, num):
+    global sel_number, clips
+    if not num:
+        return
+    sel_number = num
+    if sel not in clips:
+        clips[sel] = gtk.Clipboard(selection = sel)
+    c = clips[sel]
+    c.set_with_data([(gtk.gdk.SELECTION_TYPE_STRING, 0, 0)],
+                    clip_get_data, clip_clear_data, None)
+
+
 class Dialer(gtk.Window):
     def __init__(self):
         gtk.Window.__init__(self)
@@ -105,12 +127,13 @@ class Dialer(gtk.Window):
         self.num = n
 
         # name (or number) of other end.
-        n = gtk.Label(); n.show()
-        n.modify_font(self.nfont)
+        n = gtk.Button(''); n.show()
+        n.child.modify_font(self.nfont)
         n.set_size_request(-1, 90)
         v.pack_start(n, expand=False)
-        self.callee = n
+        self.callee = n.child
         self.check_callee_font()
+        n.connect('button_press_event', self.contact)
 
         k = self.create_keypad()
         v.pack_start(k, expand=True)
@@ -140,6 +163,12 @@ class Dialer(gtk.Window):
             v.pack_start(bt)
         return v
 
+    def contact(self, *b):
+        n = self.num.get_text()
+        if not n:
+            n = '-'
+        send_number('contact-find', n)
+
     def press(self, b, ev, key):
         if len(key) == 1:
             if self.oncall == 2: