From: NeilBrown Date: Mon, 14 Jan 2013 20:15:06 +0000 (+1100) Subject: dialler: allow easy access to contacts. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=ad3b5c295a7f40bced38b2e79b7e2351f0fcd183;p=plato.git dialler: allow easy access to contacts. If you tap the place where the name of the contact can be displayed, it takes you to the 'contacts' app. --- diff --git a/utils/dialer.py b/utils/dialer.py index 3bb9587..faa29ef 100644 --- a/utils/dialer.py +++ b/utils/dialer.py @@ -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: