Changed IdCard.IsNoIdentity to IdCard.is_no_identity
[moonshot-ui.git] / src / moonshot-identity-management-view.vala
index 8033d75..35dcd5f 100644 (file)
@@ -60,6 +60,8 @@ public class IdentityManagerView : Window {
 
     public GLib.Queue<IdentityRequest> request_queue;
 
+    internal CheckButton remember_identity_binding = null;
+
     private enum Columns
     {
         IDCARD_COL,
@@ -215,7 +217,6 @@ public class IdentityManagerView : Window {
             current_idcard_nai = custom_vbox.current_idcard.id_card.nai;
             custom_vbox.current_idcard = null;
         }
-        var children = this.custom_vbox.get_children();
 
         custom_vbox.clear();
         this.listmodel->clear();
@@ -287,6 +288,7 @@ public class IdentityManagerView : Window {
         var id_card_widget = new IdCardWidget(id_card);
         this.custom_vbox.add_id_card_widget(id_card_widget);
         id_card_widget.expanded.connect(this.widget_selected_cb);
+        id_card_widget.collapsed.connect(this.widget_unselected_cb);
         return id_card_widget;
     }
 
@@ -300,6 +302,15 @@ public class IdentityManagerView : Window {
              this.send_button.set_sensitive(true);
     }
 
+    private void widget_unselected_cb(IdCardWidget id_card_widget)
+    {
+        this.remove_button.set_sensitive(false);
+        this.edit_button.set_sensitive(false);
+        this.custom_vbox.receive_collapsed_event(id_card_widget);
+
+        this.send_button.set_sensitive(false);
+    }
+
     public bool add_identity(IdCard id_card, bool force_flat_file_store)
     {
         #if OS_MACOS
@@ -408,7 +419,6 @@ public class IdentityManagerView : Window {
         TreeIter iter;
         IdCard id_card;
 
-        var children = this.custom_vbox.get_children();
         this.custom_vbox.clear();
 
         if (filter.get_iter_first(out iter))
@@ -429,8 +439,9 @@ public class IdentityManagerView : Window {
         var id_card = id_card_widget.id_card;
 
         bool remove = WarningDialog.confirm(this, 
-                                            "<span font-weight='heavy'>You are about to remove the identity '%s'.</span>"
-                                            .printf(id_card.display_name)
+                                            Markup.printf_escaped(
+                                                "<span font-weight='heavy'>You are about to remove the identity '%s'.</span>",
+                                                id_card.display_name)
                                             + "\n\nAre you sure you want to do this?",
                                             "delete_idcard");
         if (remove) 
@@ -473,6 +484,7 @@ public class IdentityManagerView : Window {
             filter.refilter();
             redraw_id_card_widgets();
             set_prompting_service(request.service);
+            remember_identity_binding.show();
             make_visible();
         }
         this.request_queue.push_tail(request);
@@ -495,10 +507,11 @@ public class IdentityManagerView : Window {
 
     public IdCard check_add_password(IdCard identity, IdentityRequest request, IdentityManagerModel model)
     {
+        logger.trace(@"check_add_password");
         IdCard retval = identity;
         bool idcard_has_pw = (identity.password != null) && (identity.password != "");
         bool request_has_pw = (request.password != null) && (request.password != "");
-        if ((!idcard_has_pw) && (!identity.IsNoIdentity())) {
+        if ((!idcard_has_pw) && (!identity.is_no_identity())) {
             if (request_has_pw) {
                 identity.password = request.password;
                 retval = model.update_card(identity);
@@ -526,6 +539,8 @@ public class IdentityManagerView : Window {
 
     private void send_identity_cb(IdCard id)
     {
+        send_button.set_sensitive(false);
+
         IdCard identity = id;
         return_if_fail(request_queue.length > 0);
 
@@ -551,10 +566,13 @@ public class IdentityManagerView : Window {
         filter.refilter();
         redraw_id_card_widgets();
 
-        if ((identity != null) && (!identity.IsNoIdentity()))
+        if ((identity != null) && (!identity.is_no_identity()))
             parent_app.default_id_card = identity;
 
-        request.return_identity(identity);
+        request.return_identity(identity, remember_identity_binding.active);
+
+        remember_identity_binding.active = false;
+        remember_identity_binding.hide();
     }
 
     // private void label_make_bold(Label label)
@@ -750,7 +768,7 @@ SUCH DAMAGE.
         remove_button.clicked.connect((w) => {remove_identity_cb(custom_vbox.current_idcard);});
         remove_button.set_sensitive(false);
 
-        send_button = new Button.with_label(_("Send"));
+        this.send_button = new Button.with_label(_("Send"));
         send_button.clicked.connect((w) => {send_identity_cb(custom_vbox.current_idcard.id_card);});
         // send_button.set_visible(false);
         send_button.set_sensitive(false);
@@ -788,8 +806,16 @@ SUCH DAMAGE.
         menubar.modify_bg(StateType.NORMAL, white);
 #endif
         main_vbox.pack_start(vbox_left, true, true, 0);
+
+        remember_identity_binding = new CheckButton.with_label(_("Remember my identity choice for this service"));
+        remember_identity_binding.active = false;
+        main_vbox.pack_start(remember_identity_binding, false, false, 6);
+
         add(main_vbox);
         main_vbox.show_all();
+
+        if (this.request_queue.length == 0)
+            remember_identity_binding.hide();
     } 
 
     private void set_atk_name_description(Widget widget, string name, string description)
@@ -805,12 +831,4 @@ SUCH DAMAGE.
         this.destroy.connect(Gtk.main_quit);
         this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
     }
-
-    private static void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
-    {
-        var atk_widget = widget.get_accessible();
-        var atk_target_widget = target_widget.get_accessible();
-
-        atk_widget.add_relationship(relationship, atk_target_widget);
-    }
 }