[gnome-sharing-service] rewrite email plugin
- From: Daniel G. Siegel <dgsiegel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sharing-service] rewrite email plugin
- Date: Sun, 4 Jul 2010 00:11:27 +0000 (UTC)
commit c92ffab55c8bcb81ca854e4658a1fe8e618cf6b6
Author: daniel g. siegel <dgsiegel gnome org>
Date: Sun Jul 4 02:10:16 2010 +0200
rewrite email plugin
src/gss/plugins/email.py | 94 ++++++++++++++++++++++++++++++----------------
1 files changed, 62 insertions(+), 32 deletions(-)
---
diff --git a/src/gss/plugins/email.py b/src/gss/plugins/email.py
index 9028dcf..3e552ad 100644
--- a/src/gss/plugins/email.py
+++ b/src/gss/plugins/email.py
@@ -7,6 +7,10 @@ import evolution
from gss.plugin import Plugin
+
+COLUMN_PIXBUF, COLUMN_NAME, COLUMN_SEARCH, COLUMN_VISIBLE = range(4)
+
+
class EmailSharing(Plugin):
name = "Email"
description = "Email Sharing"
@@ -18,42 +22,53 @@ class EmailSharing(Plugin):
credentials_required = False
widget = None
- address = None
text = None
+ treeview = None
+ liststore = None
+ filter = None
def __init__(self, mime):
# We support every mime
self.activated = True
- label = gtk.Entry (0)
- self.widget = gtk.VBox(False, 5)
- self.widget.pack_start (label, True)
def get_widget(self):
self.widget = gtk.VBox(False, 5)
- label = gtk.Label()
- label.set_markup("Sending a mail to:")
- self.widget.pack_start(label, False, False, 0)
+ entry = gtk.Entry()
+ self.widget.pack_start(entry, False)
+ entry.grab_focus()
+ entry.get_toplevel().child_focus(gtk.DIR_TAB_FORWARD)
+
+ scroll = gtk.ScrolledWindow()
+ scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ scroll.set_shadow_type(gtk.SHADOW_IN)
+ self.widget.pack_start(scroll, True)
- # Create our entry
- self.address = gtk.Entry()
- self.widget.pack_start(self.address, False, False, 0)
+ self.treeview = gtk.TreeView()
+ self.treeview.set_headers_visible(False)
+ self.treeview.expand_all()
+ scroll.add(self.treeview)
- sw = gtk.ScrolledWindow()
- sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.text = gtk.TextView()
- sw.add(self.text)
- self.widget.pack_start(sw, True, True, 0)
+ self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, bool)
+ self.liststore.set_sort_column_id(COLUMN_NAME, gtk.SORT_ASCENDING)
- completion = gtk.EntryCompletion()
- self.address.set_completion(completion)
+ self.filter = self.liststore.filter_new()
+ self.filter.set_visible_column(COLUMN_VISIBLE)
+ self.treeview.set_model(self.filter)
- pixbufcell = gtk.CellRendererPixbuf()
- completion.pack_start(pixbufcell)
- completion.add_attribute(pixbufcell, 'pixbuf', 0)
+ selection = self.treeview.get_selection()
+ selection.set_mode(gtk.SELECTION_MULTIPLE)
- store = gtk.ListStore(gtk.gdk.Pixbuf, str)
+ img_cell = gtk.CellRendererPixbuf()
+ img_column = gtk.TreeViewColumn("Photo", img_cell, pixbuf=COLUMN_PIXBUF)
+ self.treeview.append_column(img_column)
+
+ text_cell = gtk.CellRendererText()
+ text_column = gtk.TreeViewColumn("Name", text_cell, markup=COLUMN_NAME)
+ self.treeview.append_column(text_column)
+
+ theme = gtk.icon_theme_get_default()
+ icon = theme.load_icon("face-monkey", 48, 0)
for addrDesc, addrName in evolution.ebook.list_addressbooks():
addresses = evolution.ebook.open_addressbook(addrName)
@@ -62,26 +77,41 @@ class EmailSharing(Plugin):
for i in range(1, 5):
name = contact.get_property("full-name")
mail = contact.get_property("email-" + str(i))
- # photo = contact.get_photo(32)
- photo = None
+ photo = contact.get_photo(48)
if not photo:
- photo = self.widget.render_icon(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_MENU)
+ photo = icon
if mail:
- store.append([photo, name + " <" + mail + ">"])
+ self.liststore.append([photo, "<b>" + name + "</b>\n<small><i>" +
+ mail + "</i></small>", name + " <" + mail + ">", True])
- completion.set_model(store)
-
- completion.set_text_column(1)
+ entry.connect("changed", self._update_treeview)
return self.widget
def share (self, files):
- buffer = self.text.get_buffer()
- command = "xdg-email --utf8 --subject 'Shared Files' --body '" + (buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter())) + "'"
+ recipients = ""
+ (model, selection) = self.treeview.get_selection().get_selected_rows()
+ for s in selection:
+ iter = self.filter.get_iter_from_string(str(s[0]))
+ store_iter = self.filter.convert_iter_to_child_iter(iter)
+ val = self.liststore.get_value(store_iter, COLUMN_SEARCH)
+ recipients = recipients + " '" + val + "'"
+ command = "xdg-email --utf8 --subject 'Shared Files'"
for file in files:
command = command + " --attach " + file
- command = command + " '" + self.address.get_text() + "'"
+ command = command + recipients
print command
os.system(command)
+
+ def _update_treeview (self, data):
+ keywords = data.get_text().lower().split(" ")
+ iter = self.liststore.get_iter_first()
+ while (iter != None):
+ val = self.liststore.get_value(iter, COLUMN_SEARCH).lower()
+ self.liststore.set_value(iter, COLUMN_VISIBLE, True)
+ for k in keywords:
+ if k not in val:
+ self.liststore.set_value(iter, COLUMN_VISIBLE, False)
+ iter = self.liststore.iter_next(iter)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]