bigboard r7305 - trunk/bigboard/stocks/google_calendar
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7305 - trunk/bigboard/stocks/google_calendar
- Date: Thu, 17 Apr 2008 22:05:23 +0100 (BST)
Author: marinaz
Date: Thu Apr 17 22:05:23 2008
New Revision: 7305
URL: http://svn.gnome.org/viewvc/bigboard?rev=7305&view=rev
Log:
Handle not being connected to the internet state well in the Calendar Stock.
Modified:
trunk/bigboard/stocks/google_calendar/CalendarStock.py
Modified: trunk/bigboard/stocks/google_calendar/CalendarStock.py
==============================================================================
--- trunk/bigboard/stocks/google_calendar/CalendarStock.py (original)
+++ trunk/bigboard/stocks/google_calendar/CalendarStock.py Thu Apr 17 22:05:23 2008
@@ -428,6 +428,9 @@
self.__move_up = False
self.__move_down = False
+ self.__have_some_response = False
+ self.__have_response_for_last_fetch = None
+
self.__slideout = None
self.__slideout_event = None
self.__last_slideout_event_time = None
@@ -572,6 +575,7 @@
# removes calendar list and events
def remove_google_data(self, gobj):
+ _logger.debug("removing google data")
removed_calendar_dictionary = {}
affected_calendar_ids = []
for calendar_item in self.__calendars.iteritems():
@@ -593,9 +597,12 @@
if event.get_calendar_links()[0] == calendar_link:
self.__events.remove(event)
+ self.__events_for_day_displayed = None
self.__refresh_events()
def __on_calendar_list_load(self, url, data, gobj):
+ # do not set self.__have_some_response and self.__have_response_for_last_fetch to True, since having a calendar list
+ # doesn't mean we have the events yet; might need to reconsider this if we display calendar names in the stock
_logger.debug("loaded calendar list %d chars" % (len(data)))
google_key = gobj
if google_key is None:
@@ -647,6 +654,8 @@
self.__update_events(google_key)
def __on_calendar_load(self, url, data, calendar_feed_url, event_range_start, event_range_end, gobj):
+ self.__have_some_response = True
+ self.__have_response_for_last_fetch = True
_logger.debug("loaded calendar from " + url)
google_key = gobj
if google_key is None:
@@ -751,15 +760,26 @@
def __refresh_events(self):
self.__box.remove_all()
-
if not self.have_one_good_google():
- _logger.debug("Adding login button")
+ self.__have_some_response = False
+ self.__have_response_for_last_fetch = None
+ _logger.debug("Adding login button")
+ self.__box.remove_all()
if self._login_button.get_property("text") == google_stock.CHECKING_LOGIN_STRING:
error = hippo.CanvasText(text=google_stock.FAILED_TO_LOGIN_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
self.__box.append(error)
self._login_button.set_property("text", google_stock.LOGIN_TO_GOOGLE_STRING)
self.__box.append(self._login_button)
return
+ elif self.__have_response_for_last_fetch is None:
+ message = hippo.CanvasText(text="Loading events...", size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
+ self.__box.prepend(message)
+ return
+ elif not self.__have_response_for_last_fetch:
+ error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
+ self.__box.prepend(error)
+ if not self.__have_some_response:
+ return
_logger.debug("have a google login, refreshing events")
title = hippo.CanvasText(xalign=hippo.ALIGNMENT_START, size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
@@ -990,7 +1010,13 @@
def __on_failed_load(self, response):
_logger.debug("load failed: %s", response)
- ## this displays the "need to log in" thing
+ # we only set self.__have_response_for_last_fetch to False if we got no response, since we do
+ # not want to display "Cannot connect to Google" message if there was an authentication problem
+ # for one of the calendars or Google responded with some other kind of an error message
+ if response is None:
+ self.__have_response_for_last_fetch = False
+ # this displays the "need to log in" thing or "Cannot connect to Google" message, depending
+ # on whether or not we consider that we have one valid Google login
self.__refresh_events()
def __update_calendar_list_and_events(self, selected_gobj = None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]