bigboard r7277 - trunk/bigboard



Author: marinaz
Date: Thu Apr  3 01:47:29 2008
New Revision: 7277
URL: http://svn.gnome.org/viewvc/bigboard?rev=7277&view=rev

Log:
Handle the situation when there are no existing accounts or no account types that can be added locally.

Remove accounts that are not supported from the list of accounts.


Modified:
   trunk/bigboard/accounts.py
   trunk/bigboard/accounts_dialog.py

Modified: trunk/bigboard/accounts.py
==============================================================================
--- trunk/bigboard/accounts.py	(original)
+++ trunk/bigboard/accounts.py	Thu Apr  3 01:47:29 2008
@@ -41,11 +41,11 @@
         return "<AccountKind:%s, provided_by_server:%s>" % (self.get_id(), self.get_provided_by_server())
 
 KIND_GOOGLE = AccountKind("google", "Google", True)
-KIND_TWITTER = AccountKind("twitter", "Twitter", True)
-KIND_RTM = AccountKind("rtm", "Remember The Milk", False)
-KIND_LIBRARY = AccountKind("library", "LibraryThing", False)
+# KIND_TWITTER = AccountKind("twitter", "Twitter", True)
+# KIND_RTM = AccountKind("rtm", "Remember The Milk", False)
+# KIND_LIBRARY = AccountKind("library", "LibraryThing", False)
 
-ALL_ACCOUNT_KINDS = [KIND_GOOGLE, KIND_TWITTER, KIND_RTM, KIND_LIBRARY]
+ALL_ACCOUNT_KINDS = [KIND_GOOGLE]
 
 def kind_from_string(s):
     for kind in ALL_ACCOUNT_KINDS:

Modified: trunk/bigboard/accounts_dialog.py
==============================================================================
--- trunk/bigboard/accounts_dialog.py	(original)
+++ trunk/bigboard/accounts_dialog.py	Thu Apr  3 01:47:29 2008
@@ -100,10 +100,15 @@
         self.__outer_new_account_vbox.pack_start(self.__new_account_vbox, False, False) 
 
         self.add(self.__notebook)
+
         self.connect('delete-event', self.__on_delete_event)
 
         # stuff below gets added to the "Existing Accounts" tab
 
+        # self.__no_accounts_label = gtk.Label("No existing accounts")
+        # self.__no_accounts_label.size_allocate(gtk.gdk.Rectangle(width=0, height=0)) 
+        # self.__existing_accounts_vbox.pack_start(self.__no_accounts_label)
+
         self.__model = gtk.ListStore(gobject.TYPE_STRING)
         self.__accounts_combo = gtk.ComboBox(self.__model)
         self.__existing_accounts_vbox.pack_start(self.__accounts_combo, True, False)
@@ -121,9 +126,8 @@
                                       self.__on_account_settings_applied)
 
         password_vbox = gtk.VBox(spacing=2)
-        label = gtk.Label("Password:")
-        label.set_alignment(0.0, 0.5)
-        password_vbox.pack_start(label, True, False)    
+        self.__existing_accounts_label = gtk.Label()
+        password_vbox.pack_start(self.__existing_accounts_label, True, False)    
         password_vbox.pack_end(self.__password_entry, False, False)
         self.__existing_accounts_vbox.pack_start(password_vbox, padding=5)
 
@@ -169,7 +173,7 @@
         self.__remove_link_box.pack_end(self.__remove_link, expand=False, fill=False)
 
         self.__existing_accounts_vbox.pack_start(remove_button_box, False, False, padding=5)
-        self.__existing_accounts_vbox.pack_start(self.__remove_link_box, False, False)
+        self.__existing_accounts_vbox.pack_start(self.__remove_link_box, False, False)   
 
         # stuff below gets added to the "Add Account" tab
 
@@ -183,8 +187,13 @@
             if not kind.get_provided_by_server():
                 self.__account_kinds_model.append([kind.get_name()])
             
+        # Setting padding to 1 here is a hack to get the content of both tabs to be aligned,
+        # we'll need to change this when it will become possible to add new account types to
+        # the existing dialog, for example, by adding stocks that require these account types
+        padding = 1  
         if len(self.__account_kinds_model) > 0:
             self.__account_kinds_combo.set_active(0) 
+            padding = 5
 
         self.__username_entry = gtk.Entry()
         self.__username_entry.connect('changed',
@@ -193,11 +202,11 @@
                                       self.__on_new_username_added)
 
         username_vbox = gtk.VBox(spacing=2)
-        username_label = gtk.Label("Username:")
-        username_label.set_alignment(0.0, 0.5)
-        username_vbox.pack_start(username_label, False, False)    
+        self.__username_label = gtk.Label("Username:")
+        self.__username_label.set_alignment(0.0, 0.5)
+        username_vbox.pack_start(self.__username_label, False, False)    
         username_vbox.pack_end(self.__username_entry, False, False)
-        self.__new_account_vbox.pack_start(username_vbox, padding=5)
+        self.__new_account_vbox.pack_start(username_vbox, padding=padding)
 
         self.__add_button_box = gtk.HBox()
         self.__add_button = gtk.Button(label="Add Account")
@@ -208,19 +217,38 @@
         self.__add_button.connect('clicked',
                                    self.__on_new_username_added)
         self.__add_button_box.pack_end(self.__add_button, expand=False, fill=False)
-        self.__new_account_vbox.pack_start(self.__add_button_box, False, False, padding=5)
+        self.__new_account_vbox.pack_start(self.__add_button_box, False, False, padding=padding)
 
         self.__add_link_box = gtk.HBox()
         self.__add_link = Link()
-        self.__add_link.set_text("Add other accounts online")
         self.__add_link.connect("clicked", self.__open_account_page)
-        self.__add_link_box.pack_end(self.__add_link, expand=False, fill=False)
-        self.__outer_new_account_vbox.pack_end(self.__add_link_box, False, False)
-        
+        if len(self.__account_kinds_model) > 0:
+            self.__account_kinds_combo.set_active(0)
+            self.__add_link.set_text("Add other accounts online")
+            self.__add_link_box.pack_end(self.__add_link, expand=False, fill=False)
+            self.__outer_new_account_vbox.pack_end(self.__add_link_box, False, False)
+        else:  
+            if len(accounts.ALL_ACCOUNT_KINDS) == 1 and \
+               accounts.KIND_GOOGLE in accounts.ALL_ACCOUNT_KINDS:           
+                self.__add_link.set_text("Add Google accounts online")
+            else:
+                self.__add_link.set_text("Add accounts online")
+            self.__add_link_box.pack_start(self.__add_link)
+            self.__new_account_vbox.pack_start(self.__add_link_box)
+   
         self.__model_tree_iter_by_account = {}
         self.__current_account = None
 
         self.show_all()
+        self.__set_no_accounts_state(True)
+        
+        if len(self.__account_kinds_model) == 0:
+            self.__account_kinds_combo.hide()
+            self.__username_label.hide()
+            self.__username_entry.hide()
+            self.__add_button.hide()
+ 
+        self.__notebook.set_current_page(1)
 
         self.__connections = gutil.DisconnectSet()
 
@@ -257,9 +285,11 @@
                 
             self.__model_tree_iter_by_account[a] = tree_iter
 
-            if len(self.__model_tree_iter_by_account) == 1:                
+            if len(self.__model_tree_iter_by_account) == 1:
+                self.__set_no_accounts_state(False)
                 self.__current_account = a
-                self.__accounts_combo.set_active(0)      
+                self.__accounts_combo.set_active(0) 
+                self.__notebook.set_current_page(0)     
 
     @log_except(_logger)      
     def __on_account_removed(self, accts, a):
@@ -272,6 +302,25 @@
             if self.__current_account == a and len(self.__model_tree_iter_by_account) > 0:                
                 self.__current_account = self.__model_tree_iter_by_account.keys()[0]
                 self.__accounts_combo.set_active_iter(self.__model_tree_iter_by_account.values()[0]) 
+   
+        if len(self.__model_tree_iter_by_account) == 0:   
+            self.__set_no_accounts_state(True)
+
+    def __set_no_accounts_state(self, no_accounts):
+        if no_accounts:
+            self.__accounts_combo.hide()
+            self.__password_entry.hide()
+            self.__check_box.hide()
+            self.__undo_button.hide()
+            self.__apply_button.hide()
+            self.__remove_button.hide()
+            self.__remove_link_box.hide()
+            self.__existing_accounts_label.set_text("No existing accounts") 
+            self.__existing_accounts_label.set_alignment(0.5, 0.0)
+        else:
+            self.__existing_accounts_vbox.show_all()
+            self.__existing_accounts_label.set_text("Password:")
+            self.__existing_accounts_label.set_alignment(0.0, 0.5)    
 
     def __on_edited_account_changed(self, *args):
         new_iter = self.__accounts_combo.get_active_iter()



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