r6856 - in bigboard/trunk/bigboard: . libbig stocks/google_calendar
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r6856 - in bigboard/trunk/bigboard: . libbig stocks/google_calendar
- Date: Wed, 31 Oct 2007 17:35:36 -0500 (CDT)
Author: hp
Date: 2007-10-31 17:35:32 -0500 (Wed, 31 Oct 2007)
New Revision: 6856
Modified:
bigboard/trunk/bigboard/accounts_dialog.py
bigboard/trunk/bigboard/google.py
bigboard/trunk/bigboard/google_stock.py
bigboard/trunk/bigboard/libbig/gutil.py
bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py
Log:
fix accounts dialog to handle multiple accounts appearing, though no UI to create them; handle calendar callbacks coming in post-delisting
Modified: bigboard/trunk/bigboard/accounts_dialog.py
===================================================================
--- bigboard/trunk/bigboard/accounts_dialog.py 2007-10-31 21:42:06 UTC (rev 6855)
+++ bigboard/trunk/bigboard/accounts_dialog.py 2007-10-31 22:35:32 UTC (rev 6856)
@@ -6,6 +6,7 @@
import bigboard.globals as globals
import libbig.logutil
from libbig.logutil import log_except
+import bigboard.libbig.gutil as gutil
_logger = logging.getLogger("bigboard.AccountsDialog")
@@ -45,10 +46,15 @@
self.show_all()
self.__on_account_changed(self.__account)
- self.__account.connect('changed', self.__on_account_changed)
+ self.__changed_id = self.__account.connect('changed', self.__on_account_changed)
self.__password_entry.set_activates_default(True)
+ self.connect('destroy', self.__on_destroy)
+
+ def __on_destroy(self, self2):
+ self.__account.disconnect(self.__changed_id)
+
def __on_account_changed(self, account):
self.__username_entry.set_text(account.get_username())
self.__password_entry.set_text(account.get_password())
@@ -78,14 +84,34 @@
self.__editors_by_account = {}
- accts = accounts.get_accounts().get_accounts_with_kind(accounts.KIND_GOOGLE)
- if len(accts) == 0:
+ self.__connections = gutil.DisconnectSet()
+
+ accts = accounts.get_accounts()
+ id = accts.connect('account-added', self.__on_account_added)
+ self.__connections.add(accts, id)
+ id = accts.connect('account-removed', self.__on_account_removed)
+ self.__connections.add(accts, id)
+
+ google_accounts = accts.get_accounts_with_kind(accounts.KIND_GOOGLE)
+ if len(google_accounts) == 0:
accounts.get_accounts().create_account(accounts.KIND_GOOGLE)
else:
- for a in accts:
- self.__editors_by_account[a] = AccountEditor(account=a)
- self.vbox.pack_start(self.__editors_by_account[a])
+ for a in google_accounts:
+ self.__on_account_added(a)
+ ## should be a destroy() that disconnects connections, but we never destroy anyway
+
+ def __on_account_added(self, a):
+ if a.get_kind() == accounts.KIND_GOOGLE and a not in self.__editors_by_account:
+ self.__editors_by_account[a] = AccountEditor(account=a)
+ self.vbox.pack_end(self.__editors_by_account[a])
+
+ def __on_account_removed(self, a):
+ if a in self.__editors_by_account:
+ editor = self.__editors_by_account[a]
+ del self.__editors_by_account[a]
+ editor.destroy() ## should remove it from vbox
+
def __on_delete_event(self, dialog, event):
self.hide()
return True
Modified: bigboard/trunk/bigboard/google.py
===================================================================
--- bigboard/trunk/bigboard/google.py 2007-10-31 21:42:06 UTC (rev 6855)
+++ bigboard/trunk/bigboard/google.py 2007-10-31 22:35:32 UTC (rev 6856)
@@ -349,12 +349,15 @@
else:
self.__actions[id][0] = self.__actions[id][0] + 1
+ _logger.debug("check count bumped to %d for google check action %s" % (self.__actions[id][0], id))
+
def remove_action(self, id):
if id not in self.__actions:
raise Exception("removing action id that wasn't added")
self.__actions[id][0] = self.__actions[id][0] - 1
+ _logger.debug("check count reduced to %d for google check action %s" % (self.__actions[id][0], id))
if self.__actions[id][0] == 0:
- del self.__actions[id]
+ del self.__actions[id]
def do_periodic_task(self):
for (id, a) in self.__actions.values():
Modified: bigboard/trunk/bigboard/google_stock.py
===================================================================
--- bigboard/trunk/bigboard/google_stock.py 2007-10-31 21:42:06 UTC (rev 6855)
+++ bigboard/trunk/bigboard/google_stock.py 2007-10-31 22:35:32 UTC (rev 6856)
@@ -31,10 +31,8 @@
id = accts.connect('account-added', self.__on_account_added)
self.__connections.add(accts, id)
id = accts.connect('account-removed', self.__on_account_removed)
- self.__connections.add(accts, id)
+ self.__connections.add(accts, id)
-
-
## we can't just override _on_delisted() because of multiple inheritance,
## so our subclasses have to override it then call this
def _delist_google(self):
Modified: bigboard/trunk/bigboard/libbig/gutil.py
===================================================================
--- bigboard/trunk/bigboard/libbig/gutil.py 2007-10-31 21:42:06 UTC (rev 6855)
+++ bigboard/trunk/bigboard/libbig/gutil.py 2007-10-31 22:35:32 UTC (rev 6856)
@@ -18,6 +18,16 @@
def add(self, object, id):
self.__connections.add((object, id))
+ def disconnect_object(self, object_to_disconnect):
+ to_remove = []
+ for (object, id) in self.__connections:
+ if object == object_to_disconnect:
+ object.disconnect(id)
+ to_remove.append((object, id))
+
+ for (object, id) in to_remove:
+ self.__connections.remove((object, id))
+
def disconnect_all(self):
for (object, id) in self.__connections:
object.disconnect(id)
Modified: bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py 2007-10-31 21:42:06 UTC (rev 6855)
+++ bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py 2007-10-31 22:35:32 UTC (rev 6856)
@@ -598,7 +598,11 @@
google_key = gobj
if google_key is None:
_logger.warn("didn't find google_key for %s", gobj)
- return
+ return
+ if gobj not in self.googles:
+ _logger.debug("loaded a calendar from already-removed google account")
+ return
+
# parse calendar list feed into a list of Calendar objects
calendar_list = gcalendar.CalendarListFeedFromString(data)
updated_calendar_dictionary = {}
@@ -645,7 +649,12 @@
google_key = gobj
if google_key is None:
_logger.warn("didn't find google_key for %s", gobj)
- return
+ return
+
+ if gobj not in self.googles:
+ _logger.debug("loaded a calendar from already-removed google account")
+ return
+
try:
p = EventsParser(data)
color = self.__calendars[calendar_feed_url][google_key].color.value
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]