Fix 'Send' button sensitivity
authorAlberto Ruiz <aruiz@gnome.org>
Wed, 13 Jul 2011 14:05:45 +0000 (15:05 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Mon, 18 Jul 2011 16:12:54 +0000 (17:12 +0100)
src/moonshot-custom-vbox.vala
src/moonshot-idcard-widget.vala
src/moonshot-window.vala

index 2740292..31b2a20 100644 (file)
@@ -3,31 +3,36 @@ using Gtk;
 class CustomVBox : VBox
 {
     public IdCardWidget current_idcard { get; set; default = null; }
+    private MainWindow main_window; 
 
-    public CustomVBox (bool homogeneous, int spacing)
+    public CustomVBox (MainWindow window, bool homogeneous, int spacing)
     {
-        this.set_homogeneous (homogeneous);
-        this.set_spacing (spacing);
+        main_window = window;
+        set_homogeneous (homogeneous);
+        set_spacing (spacing);
     }
 
     public void receive_expanded_event (IdCardWidget id_card_widget)
     {
-        var list = this.get_children ();
+        var list = get_children ();
         foreach (Widget id_card in list)
         {
             if (id_card != id_card_widget)
                 ((IdCardWidget) id_card).collapse ();
         }
         current_idcard = id_card_widget;
+        
+        if (current_idcard != null && main_window.request_queue.length > 0)
+            current_idcard.send_button.set_sensitive (true);
     }
 
     public void add_id_card_widget (IdCardWidget id_card_widget)
     {
-        this.pack_start (id_card_widget, false, false);
+        pack_start (id_card_widget, false, false);
     }
 
     public void remove_id_card_widget (IdCardWidget id_card_widget)
     {
-        this.remove (id_card_widget);
+        remove (id_card_widget);
     }
 }
index fcfd45b..7a81f4d 100644 (file)
@@ -115,6 +115,7 @@ class IdCardWidget : Box
         hbutton_box.pack_end (delete_button);
         hbutton_box.pack_end (details_button);
         hbutton_box.pack_end (send_button);
+        send_button.set_sensitive (false);
 
         delete_button.clicked.connect (delete_button_cb);
         details_button.clicked.connect (details_button_cb);
index bf7ae19..d349a84 100644 (file)
@@ -22,7 +22,7 @@ class MainWindow : Window
     private MoonshotServer ipc_server;
 
     private IdCard default_id_card;
-    private Queue<IdentityRequest> request_queue;
+    public Queue<IdentityRequest> request_queue;
 
     private HashTable<Gtk.Button, string> service_button_map;
 
@@ -374,6 +374,10 @@ class MainWindow : Window
         IdCard identity = null;
 
         this.request_queue.push_tail (request);
+        
+        if (custom_vbox.current_idcard != null &&
+            custom_vbox.current_idcard.send_button != null)
+          custom_vbox.current_idcard.send_button.set_sensitive (true);
 
         if (request.select_default)
         {
@@ -667,7 +671,7 @@ SUCH DAMAGE.
         this.search_entry.notify["text"].connect (search_entry_text_changed_cb);
         this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
 
-        this.custom_vbox = new CustomVBox (false, 6);
+        this.custom_vbox = new CustomVBox (this, false, 6);
 
         var viewport = new Viewport (null, null);
         viewport.set_border_width (6);