Updated the appearance of two warning dialogs.
[moonshot-ui.git] / src / moonshot-identity-management-view.vala
index a20a396..8033d75 100644 (file)
@@ -45,7 +45,7 @@ public class IdentityManagerView : Window {
     private Entry search_entry;
     private VBox vbox_right;
     private CustomVBox custom_vbox;
-    private Label prompting_service;
+    private VBox service_prompt_vbox;
     private Label no_identity_title;
     private Button edit_button;
     private Button remove_button;
@@ -311,8 +311,10 @@ public class IdentityManagerView : Window {
         #else
         Gtk.MessageDialog dialog;
         IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
+        logger.trace("add_identity: find_id_card returned " + (prev_id != null ? "non-null" : "null"));
         if (prev_id!=null) {
             int flags = prev_id.Compare(id_card);
+            logger.trace("add_identity: compare returned " + flags.to_string());
             if (flags == 0) {
                 return false; // no changes, no need to update
             } else if ((flags & (1 << IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
@@ -426,27 +428,43 @@ public class IdentityManagerView : Window {
     {
         var id_card = id_card_widget.id_card;
 
-        var dialog = new MessageDialog(this,
-                                       DialogFlags.DESTROY_WITH_PARENT,
-                                       MessageType.QUESTION,
-                                       Gtk.ButtonsType.YES_NO,
-                                       _("Are you sure you want to delete %s ID Card?"), id_card.issuer);
-        var result = dialog.run();
-        switch (result) {
-        case ResponseType.YES:
+        bool remove = WarningDialog.confirm(this, 
+                                            "<span font-weight='heavy'>You are about to remove the identity '%s'.</span>"
+                                            .printf(id_card.display_name)
+                                            + "\n\nAre you sure you want to do this?",
+                                            "delete_idcard");
+        if (remove) 
             remove_identity(id_card_widget);
-            break;
-        default:
-            break;
-        }
-        dialog.destroy();
     }
 
-    public void set_prompting_service(string service)
+    private void set_prompting_service(string service)
+    {
+        clear_selection_prompts();
+
+        var prompting_service = new Label(_("Identity requested for service:\n%s").printf(service));
+        prompting_service.set_line_wrap(true);
+
+        // left-align
+        prompting_service.set_alignment(0, (float )0.5);
+
+        var selection_prompt = new Label(_("Select your identity:"));
+        selection_prompt.set_alignment(0, 1);
+
+        this.service_prompt_vbox.pack_start(prompting_service, false, false, 12);
+        this.service_prompt_vbox.pack_start(selection_prompt, false, false, 2);
+        this.service_prompt_vbox.show_all();
+    }
+
+    private void clear_selection_prompts()
     {
-        prompting_service.set_label( _("Identity requested for service: %s").printf(service) );
+        var list = service_prompt_vbox.get_children();
+        foreach (Widget w in list)
+        {
+            service_prompt_vbox.remove(w);
+        }
     }
 
+
     public void queue_identity_request(IdentityRequest request)
     {
         if (this.request_queue.is_empty())
@@ -517,7 +535,7 @@ public class IdentityManagerView : Window {
         if (this.request_queue.is_empty())
         {
             candidates = null;
-            prompting_service.set_label(_(""));
+            clear_selection_prompts();
             if (!parent_app.explicitly_launched) {
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
@@ -684,33 +702,34 @@ SUCH DAMAGE.
         id_scrollwin.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
         id_scrollwin.set_shadow_type(ShadowType.IN);
         id_scrollwin.add_with_viewport(viewport);
-        this.prompting_service = new Label(_(""));
-        // left-align
-        prompting_service.set_alignment(0, (float )0.5);
+
+        service_prompt_vbox = new VBox(false, 0);
 
         var vbox_left = new VBox(false, 0);
+        vbox_left.pack_start(service_prompt_vbox, false, false, 12);
 
         var search_hbox = new HBox(false, 6);
-        var search_label = new Label(_("Search:"));
-        search_label.set_alignment(1, (float) 0.5);
-        set_atk_relation(search_label, search_entry, Atk.RelationType.LABEL_FOR);
         search_hbox.pack_end(search_entry, false, false, 0);
-        search_hbox.pack_end(search_label, false, false, 6);
+        //// var search_label = new Label(_("Search:"));
+        //// search_label.set_alignment(1, (float) 0.5);
+        //// set_atk_relation(search_label, search_entry, Atk.RelationType.LABEL_FOR);
+        //// search_hbox.pack_end(search_label, false, false, 6);
 
         var full_search_label = new Label(_("Search for an identity or service"));
-        full_search_label.set_alignment(1, 1);
+        full_search_label.set_alignment(1, 0);
         var search_vbox = new VBox(false, 4);
-        search_vbox.pack_start(search_hbox, false, false, 0);
         search_vbox.pack_start(full_search_label, false, false, 0);
+        search_vbox.pack_start(search_hbox, false, false, 0);
 
         var inner_left_vbox = new VBox(false, 6);
         inner_left_vbox.pack_start(search_vbox, false, false, 6);
+//        inner_left_vbox.pack_start(selection_prompt, false, false, 6);
         inner_left_vbox.pack_start(id_scrollwin, true, true, 0);
 
         var id_and_button_box = new HBox(false, 6);
         id_and_button_box.pack_start(inner_left_vbox, true, true, 6);
         vbox_left.pack_start(id_and_button_box, true, true, 0);
-        vbox_left.pack_start(prompting_service, false, false, 6);
+        // vbox_left.pack_start(prompting_service, false, false, 6);
         vbox_left.set_size_request(WINDOW_WIDTH, 0);
 
         this.no_identity_title = new Label(_("No Identity: Send this identity to services which should not use Moonshot"));
@@ -745,15 +764,20 @@ SUCH DAMAGE.
         vbox_right.pack_start(send_button, false, false, 24);
 
         id_and_button_box.pack_start(vbox_right, false, false, 0);
+
         var main_vbox = new VBox(false, 0);
+
+        // Note: This places a border above the menubar. Is that what we want?
         main_vbox.set_border_width(12);
 
 #if OS_MACOS
         // hide the  File | Quit menu item which is now on the Mac Menu
-        Gtk.Widget quit_item =  this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
-        quit_item.hide();
+//        Gtk.Widget quit_item =  this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
+//        quit_item.hide();
         
         Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
+        menushell.modify_bg(StateType.NORMAL, white);
+
         osxApp.set_menu_bar(menushell);
         osxApp.set_use_quartz_accelerators(true);
         osxApp.sync_menu_bar();
@@ -761,6 +785,7 @@ SUCH DAMAGE.
 #else
         var menubar = this.ui_manager.get_widget("/MenuBar");
         main_vbox.pack_start(menubar, false, false, 0);
+        menubar.modify_bg(StateType.NORMAL, white);
 #endif
         main_vbox.pack_start(vbox_left, true, true, 0);
         add(main_vbox);