[kupfer: 13/51] grouping: Move contacts API wholly to obj.contacts



commit b5eb157267ddbe831644d9264f50daadcb6e3ef0
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Jan 7 02:44:40 2010 +0100

    grouping: Move contacts API wholly to obj.contacts
    
    Now with the "bottoms-up" approach, we can separate the grouping and
    contacts API to some extent.
    
    Plugins updated with the move.

 kupfer/obj/contacts.py       |   21 ++++++++++++++++++++-
 kupfer/obj/grouping.py       |   12 ------------
 kupfer/plugin/clawsmail.py   |    4 ++--
 kupfer/plugin/gajim.py       |    4 ++--
 kupfer/plugin/pidgin.py      |    4 ++--
 kupfer/plugin/thunderbird.py |    3 ++-
 6 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/kupfer/obj/contacts.py b/kupfer/obj/contacts.py
index f82a15b..448fa5d 100644
--- a/kupfer/obj/contacts.py
+++ b/kupfer/obj/contacts.py
@@ -1,4 +1,22 @@
-from kupfer.obj.grouping import ContactLeaf, EMAIL_KEY, NAME_KEY, JID_KEY
+# -*- encoding: utf-8 -*-
+"""
+Kupfer's Contacts API
+"""
+from kupfer.obj.grouping import GroupingLeaf
+
+__author__ = ("Ulrik Sverdrup <ulrik sverdrup gmail com>, "
+              "Karol BÄ?dkowski <karol bedkowsk+gh gmail com>" )
+
+EMAIL_KEY = "EMAIL"
+NAME_KEY = "NAME"
+JID_KEY = "JID"
+
+CONTACTS_CATEGORY = "Contacts"
+
+class ContactLeaf(GroupingLeaf):
+	grouping_slots = (EMAIL_KEY, NAME_KEY)
+	def get_icon_name(self):
+		return "stock_person"
 
 class EmailContact (ContactLeaf):
 	def __init__(self, email, name):
@@ -13,6 +31,7 @@ class EmailContact (ContactLeaf):
 
 
 class JabberContact (ContactLeaf):
+	grouping_slots = ContactLeaf.grouping_slots + (JID_KEY, )
 	def __init__(self, jid, name, accout, status, resource):
 		slots = {JID_KEY: jid, NAME_KEY: name}
 		ContactLeaf.__init__(self, slots, name)
diff --git a/kupfer/obj/grouping.py b/kupfer/obj/grouping.py
index f00b384..3341208 100644
--- a/kupfer/obj/grouping.py
+++ b/kupfer/obj/grouping.py
@@ -12,12 +12,6 @@ from kupfer import utils
 __author__ = ("Karol BÄ?dkowski <karol bedkowsk+gh gmail com>, "
               "Ulrik Sverdrup <ulrik sverdrup gmail com>" )
 
-
-EMAIL_KEY = "EMAIL"
-NAME_KEY = "NAME"
-JID_KEY = "JID"
-
-CONTACTS_CATEGORY = "Contacts"
 HOSTS_CATEGORY = "Hosts"
 
 class GroupingLeaf (Leaf):
@@ -172,12 +166,6 @@ class _GroupedItemsSource(Source):
 		for leaf in self._leaf.links:
 			yield leaf
 
-class ContactLeaf(GroupingLeaf):
-	grouping_slots = (EMAIL_KEY, NAME_KEY)
-	def get_icon_name(self):
-		return "stock_person"
-
-
 class HostLeaf(GroupingLeaf):
 	def get_icon_name(self):
 		return "stock_host"
diff --git a/kupfer/plugin/clawsmail.py b/kupfer/plugin/clawsmail.py
index f5f7762..170cbc5 100644
--- a/kupfer/plugin/clawsmail.py
+++ b/kupfer/plugin/clawsmail.py
@@ -8,8 +8,8 @@ from kupfer.objects import (TextLeaf, UrlLeaf, RunnableLeaf, FileLeaf,
 		AppLeafContentMixin )
 from kupfer import utils
 from kupfer.helplib import FilesystemWatchMixin
-from kupfer.obj.grouping import EMAIL_KEY, ContactLeaf, ToplevelGroupingSource
-from kupfer.obj.contacts import EmailContact
+from kupfer.obj.grouping import ToplevelGroupingSource
+from kupfer.obj.contacts import EMAIL_KEY, ContactLeaf, EmailContact
 
 __kupfer_name__ = _("Claws Mail")
 __kupfer_sources__ = ("ClawsContactsSource", )
diff --git a/kupfer/plugin/gajim.py b/kupfer/plugin/gajim.py
index 4d5ef18..346ef74 100644
--- a/kupfer/plugin/gajim.py
+++ b/kupfer/plugin/gajim.py
@@ -5,8 +5,8 @@ from kupfer.objects import Leaf, Action, Source, AppLeafContentMixin, AppLeaf
 from kupfer import pretty
 from kupfer.helplib import dbus_signal_connect_weakly, PicklingHelperMixin
 from kupfer import plugin_support
-from kupfer.obj.grouping import JID_KEY, ContactLeaf, ToplevelGroupingSource
-from kupfer.obj.contacts import JabberContact
+from kupfer.obj.grouping import ToplevelGroupingSource
+from kupfer.obj.contacts import JID_KEY, ContactLeaf, JabberContact
 
 __kupfer_name__ = _("Gajim")
 __kupfer_sources__ = ("ContactsSource", )
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 7ea4194..9892606 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -8,8 +8,8 @@ from kupfer import pretty, scheduler
 from kupfer import icons
 from kupfer import plugin_support
 from kupfer.helplib import dbus_signal_connect_weakly, PicklingHelperMixin
-from kupfer.obj.grouping import (EMAIL_KEY, NAME_KEY, ContactLeaf,
-		ToplevelGroupingSource)
+from kupfer.obj.grouping import ToplevelGroupingSource
+from kupfer.obj.contacts import NAME_KEY, EMAIL_KEY, ContactLeaf
 
 __kupfer_name__ = _("Pidgin")
 __kupfer_sources__ = ("ContactsSource", )
diff --git a/kupfer/plugin/thunderbird.py b/kupfer/plugin/thunderbird.py
index 69d9290..75fb8bf 100644
--- a/kupfer/plugin/thunderbird.py
+++ b/kupfer/plugin/thunderbird.py
@@ -9,7 +9,8 @@ from kupfer.objects import Leaf, Action, Source
 from kupfer.objects import TextLeaf, UrlLeaf, RunnableLeaf, AppLeafContentMixin
 from kupfer.helplib import FilesystemWatchMixin
 from kupfer import utils, icons
-from kupfer.obj.contacts import EmailContact, ContactLeaf, EMAIL_KEY
+from kupfer.obj.grouping import ToplevelGroupingSource
+from kupfer.obj.contacts import EMAIL_KEY, ContactLeaf, EmailContact
 
 from kupfer.plugin import thunderbird_support as support
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]