]> git.neil.brown.name Git - plato.git/commitdiff
Make sms search function work.
authorNeilBrown <neilb@suse.de>
Thu, 12 Dec 2013 22:15:13 +0000 (09:15 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 12 Dec 2013 22:15:13 +0000 (09:15 +1100)
sms/sendsms.py

index bdacecdfee99d87d69fcbe973c74b6cb03640fda..1aaaed3e01db7e673a8af044b17a834f5d3589f2 100755 (executable)
@@ -1251,15 +1251,22 @@ class SendSMS(gtk.Window):
         self.view_button = self.add_button(h, 'View', self.view)
         self.reply = self.add_button(h, 'New', self.open)
 
+
+        fd = pango.FontDescription("sans 8")
+        fd.set_absolute_size(25*pango.SCALE)
         h = gtk.HBox() ; h.show()
         v.pack_start(h, expand=False)
-        b = gtk.Button("clr") ; b.show()
+        b = gtk.Button("  clear  ")
+        b.child.modify_font(fd)
+        b.show()
         b.connect('clicked', self.clear_search)
         h.pack_end(b, expand=False)
-        l = gtk.Label('search:') ; l.show()
+        l = gtk.Label('Search:') ; l.show()
+        l.modify_font(fd)
         h.pack_start(l, expand=False)
 
         e = gtk.Entry() ; e.show()
+        e.modify_font(fd)
         self.search_entry = e
         h.pack_start(e)
 
@@ -1555,14 +1562,19 @@ class SendSMS(gtk.Window):
             while now and len(l) < lines:
                 (now, l2) = self.store.lookup(now)
                 for e in l2:
-                    if patn and patn not in e.correspondent:
+                    if target == 'Sent' and e.source != 'LOCAL':
                         continue
-                    if target == 'All':
-                        l.append(e)
-                    elif target == 'Sent' and e.source == 'LOCAL':
-                        l.append(e)
-                    elif target == 'Recv' and e.source != 'LOCAL':
-                        l.append(e)
+                    if target == 'Recv' and e.source == 'LOCAL':
+                        continue
+                    if patn and patn not in e.correspondent:
+                        if not self.book:
+                            continue
+                        n = book_name(self.book, e.correspondent)
+                        if not n or not n[0]:
+                            continue
+                        if patn.lower() not in n[0].lower():
+                            continue
+                    l.append(e)
         return l
 
     def rotate_list(self, w=None, ev=None, which = None, target=None):
@@ -1596,7 +1608,7 @@ class SendSMS(gtk.Window):
         self.listview.reset_list()
 
     def clear_search(self, *a):
-        pass
+        self.search_entry.set_text('')
 
     def got_new(self):
         self.rotate_list(self, target = 'New')