Adding tab-holding causes refresh and mixing misc bugs
authorepage <eopage@byu.net>
Mon, 10 Aug 2009 23:38:18 +0000 (23:38 +0000)
committerepage <eopage@byu.net>
Mon, 10 Aug 2009 23:38:18 +0000 (23:38 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@374 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

src/dc_glade.py
src/file_backend.py
src/gc_views.py
src/gtk_toolbox.py
support/builddeb.py

index 997897c..2370076 100755 (executable)
@@ -39,6 +39,7 @@ import ConfigParser
 import itertools
 import warnings
 
+import gobject
 import gtk
 import gtk.glade
 
@@ -105,6 +106,7 @@ class Dialcentral(object):
                self._messagesViews = None
                self._recentViews = None
                self._contactsViews = None
+               self._tabHoldTimeoutId = None
 
                for path in self._glade_files:
                        if os.path.isfile(path):
@@ -304,12 +306,14 @@ class Dialcentral(object):
 
                        callbackMapping = {
                                "on_paste": self._on_paste,
-                               "on_refresh": self._on_refresh,
+                               "on_refresh": self._on_menu_refresh,
                                "on_clearcookies_clicked": self._on_clearcookies_clicked,
                                "on_notebook_switch_page": self._on_notebook_switch_page,
                                "on_about_activate": self._on_about_activate,
                        }
                        self._widgetTree.signal_autoconnect(callbackMapping)
+                       self._notebook.connect("button-press-event", self._on_tab_press)
+                       self._notebook.connect("button-release-event", self._on_tab_release)
 
                        self._initDone = True
 
@@ -413,10 +417,10 @@ class Dialcentral(object):
                for attemptCount in xrange(numOfAttempts):
                        if loggedIn:
                                break
-                       availableServices = {
-                               self.GV_BACKEND: "Google Voice",
-                               self.GC_BACKEND: "Grand Central",
-                       }
+                       availableServices = (
+                               (self.GV_BACKEND, "Google Voice"),
+                               (self.GC_BACKEND, "Grand Central"),
+                       )
                        with gtk_toolbox.gtk_lock():
                                credentials = self._credentialsDialog.request_credentials_from(
                                        availableServices, defaultCredentials = self._credentials
@@ -551,6 +555,15 @@ class Dialcentral(object):
                with open(self._user_settings, "wb") as configFile:
                        config.write(configFile)
 
+       def _refresh_active_tab(self):
+               page_num = self._notebook.get_current_page()
+               if page_num == self.CONTACTS_TAB:
+                       self._contactsViews[self._selectedBackendId].update(force=True)
+               elif page_num == self.RECENT_TAB:
+                       self._recentViews[self._selectedBackendId].update(force=True)
+               elif page_num == self.MESSAGES_TAB:
+                       self._messagesViews[self._selectedBackendId].update(force=True)
+
        def _on_close(self, *args, **kwds):
                try:
                        if self._osso is not None:
@@ -637,6 +650,19 @@ class Dialcentral(object):
                elif page_num == self.ACCOUNT_TAB:
                        self._accountViews[self._selectedBackendId].update()
 
+       def _on_tab_press(self, *args):
+               self._tabHoldTimeoutId = gobject.timeout_add(1000, self._on_tab_refresh)
+
+       def _on_tab_release(self, *args):
+               if self._tabHoldTimeoutId is not None:
+                       gobject.source_remove(self._tabHoldTimeoutId)
+               self._tabHoldTimeoutId = None
+
+       def _on_tab_refresh(self, *args):
+               self._tabHoldTimeoutId = None
+               self._refresh_active_tab()
+               return False
+
        def _on_sms_clicked(self, number, message):
                assert number
                assert message
@@ -663,7 +689,7 @@ class Dialcentral(object):
                        self._errorDisplay.push_exception(e)
 
        def _on_dial_clicked(self, number):
-               assert number
+               assert number, "No number to call"
                try:
                        loggedIn = self._phoneBackends[self._selectedBackendId].is_authed()
                except StandardError, e:
@@ -679,7 +705,7 @@ class Dialcentral(object):
 
                dialed = False
                try:
-                       assert self._phoneBackends[self._selectedBackendId].get_callback_number() != ""
+                       assert self._phoneBackends[self._selectedBackendId].get_callback_number() != "", "No callback number specified"
                        self._phoneBackends[self._selectedBackendId].dial(number)
                        dialed = True
                except StandardError, e:
@@ -690,14 +716,8 @@ class Dialcentral(object):
                if dialed:
                        self._dialpads[self._selectedBackendId].clear()
 
-       def _on_refresh(self, *args):
-               page_num = self._notebook.get_current_page()
-               if page_num == self.CONTACTS_TAB:
-                       self._contactsViews[self._selectedBackendId].update(force=True)
-               elif page_num == self.RECENT_TAB:
-                       self._recentViews[self._selectedBackendId].update(force=True)
-               elif page_num == self.MESSAGES_TAB:
-                       self._messagesViews[self._selectedBackendId].update(force=True)
+       def _on_menu_refresh(self, *args):
+               self._refresh_active_tab()
 
        def _on_paste(self, *args):
                contents = self._clipboard.wait_for_text()
index 31fc52a..b373561 100644 (file)
@@ -144,7 +144,7 @@ class FilesystemAddressBookFactory(object):
 
        def open_addressbook(self, bookId):
                name, ext = bookId.rsplit(".", 1)
-               assert ext in self.FILETYPE_SUPPORT
+               assert ext in self.FILETYPE_SUPPORT, "Unsupported file extension %s" % ext
                return self.FILETYPE_SUPPORT[ext](bookId)
 
        @staticmethod
index f84e06a..4d7c2e8 100644 (file)
@@ -469,7 +469,7 @@ class Dialpad(object):
                """
                @note Actual dial function is patched in later
                """
-               raise NotImplementedError
+               raise NotImplementedError("Horrible unknown error has occurred")
 
        def get_number(self):
                return self._phonenumber
@@ -557,7 +557,7 @@ class AccountInfo(object):
                self._defaultCallback = ""
 
        def enable(self):
-               assert self._backend.is_authed()
+               assert self._backend.is_authed(), "Attempting to enable backend while not logged in"
                self._accountViewNumberDisplay.set_use_markup(True)
                self.set_account_number("")
                self._callbackList.clear()
@@ -708,7 +708,7 @@ class RecentCallsView(object):
                )
 
        def enable(self):
-               assert self._backend.is_authed()
+               assert self._backend.is_authed(), "Attempting to enable backend while not logged in"
                self._recentview.set_model(self._recentmodel)
 
                self._recentview.append_column(self._dateColumn)
@@ -733,7 +733,7 @@ class RecentCallsView(object):
                """
                @note Actual dial function is patched in later
                """
-               raise NotImplementedError
+               raise NotImplementedError("Horrible unknown error has occurred")
 
        def update(self, force = False):
                if not force and self._isPopulated:
@@ -758,8 +758,8 @@ class RecentCallsView(object):
                pass
 
        def _idly_populate_recentview(self):
-               self._isPopulated = True
                self._recentmodel.clear()
+               self._isPopulated = True
 
                try:
                        recentItems = self._backend.get_recent()
@@ -797,7 +797,7 @@ class RecentCallsView(object):
                )
                if action == PhoneTypeSelector.ACTION_CANCEL:
                        return
-               assert phoneNumber
+               assert phoneNumber, "A lack of phone number exists"
 
                self.number_selected(action, phoneNumber, message)
                self._recentviewselection.unselect_all()
@@ -855,7 +855,7 @@ class MessagesView(object):
                )
 
        def enable(self):
-               assert self._backend.is_authed()
+               assert self._backend.is_authed(), "Attempting to enable backend while not logged in"
                self._messageview.set_model(self._messagemodel)
 
                self._messageview.append_column(self._dateColumn)
@@ -880,7 +880,7 @@ class MessagesView(object):
                """
                @note Actual dial function is patched in later
                """
-               raise NotImplementedError
+               raise NotImplementedError("Horrible unknown error has occurred")
 
        def update(self, force = False):
                if not force and self._isPopulated:
@@ -905,8 +905,8 @@ class MessagesView(object):
                pass
 
        def _idly_populate_messageview(self):
-               self._isPopulated = True
                self._messagemodel.clear()
+               self._isPopulated = True
 
                try:
                        messageItems = self._backend.get_messages()
@@ -938,7 +938,7 @@ class MessagesView(object):
                )
                if action == PhoneTypeSelector.ACTION_CANCEL:
                        return
-               assert phoneNumber
+               assert phoneNumber, "A lock of phone number exists"
 
                self.number_selected(action, phoneNumber, message)
                self._messageviewselection.unselect_all()
@@ -990,7 +990,7 @@ class ContactsView(object):
                )
 
        def enable(self):
-               assert self._backend.is_authed()
+               assert self._backend.is_authed(), "Attempting to enable backend while not logged in"
 
                self._contactsview.set_model(self._contactsmodel)
                self._contactsview.append_column(self._contactColumn)
@@ -1034,7 +1034,7 @@ class ContactsView(object):
                """
                @note Actual dial function is patched in later
                """
-               raise NotImplementedError
+               raise NotImplementedError("Horrible unknown error has occurred")
 
        def get_addressbooks(self):
                """
@@ -1080,8 +1080,8 @@ class ContactsView(object):
                pass
 
        def _idly_populate_contactsview(self):
-               self._isPopulated = True
                self.clear()
+               self._isPopulated = True
 
                # completely disable updating the treeview while we populate the data
                self._contactsview.freeze_child_notify()
@@ -1137,7 +1137,7 @@ class ContactsView(object):
                )
                if action == PhoneTypeSelector.ACTION_CANCEL:
                        return
-               assert phoneNumber
+               assert phoneNumber, "A lack of phone number exists"
 
                self.number_selected(action, phoneNumber, message)
                self._contactsviewselection.unselect_all()
index d6db835..88ceb1f 100644 (file)
@@ -273,7 +273,7 @@ class LoginWindow(object):
                        parentWindow = self._parentWindow
 
                self._serviceList.clear()
-               for serviceIdserviceName in services.iteritems():
+               for serviceIdserviceName in services:
                        self._serviceList.append(serviceIdserviceName)
                self._serviceCombo.set_active(0)
                self._serviceCombo.show()
index 66f8cb8..c9d164f 100755 (executable)
@@ -19,6 +19,10 @@ __version__ = constants.__version__
 __build__ = 0
 __changelog__ = '''
 1.0.3
+* Holding down a tab for a second will now force a refresh
+* Fixed a bug dealing with overzealously refreshing the contacts tab
+* Finding some undescriptive errors and made them more descriptive
+* Swapped the order GrandCentral and GoogleVoice appear in login window
 
 1.0.2
 * Random bug fixes