2 * Copyright (c) 2011-2016, JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 public class IdentityManagerView : Window {
36 static MoonshotLogger logger = get_logger("IdentityManagerView");
38 // The latest year in which Moonshot sources were modified.
39 private static int LATEST_EDIT_YEAR = 2016;
41 public static Gdk.Color white = make_color(65535, 65535, 65535);
43 private const int WINDOW_WIDTH = 700;
44 private const int WINDOW_HEIGHT = 500;
45 protected IdentityManagerApp parent_app;
47 public OSXApplication osxApp;
49 private UIManager ui_manager = new UIManager();
50 private Entry search_entry;
51 private CustomVBox custom_vbox;
52 private VBox service_prompt_vbox;
53 private Button edit_button;
54 private Button remove_button;
56 private Button send_button;
58 private Gtk.ListStore* listmodel;
59 private TreeModelFilter filter;
61 internal IdentityManagerModel identities_manager;
62 private unowned SList<IdCard> candidates;
64 private GLib.Queue<IdentityRequest> request_queue;
66 internal CheckButton remember_identity_binding = null;
68 private IdCard selected_idcard = null;
80 private const string menu_layout =
81 "<menubar name='MenuBar'>" +
82 " <menu name='HelpMenu' action='HelpMenuAction'>" +
83 " <menuitem name='About' action='AboutAction' />" +
87 public IdentityManagerView(IdentityManagerApp app) {
90 osxApp = OSXApplication.get_instance();
92 identities_manager = parent_app.model;
93 request_queue = new GLib.Queue<IdentityRequest>();
94 this.title = "Moonshot Identity Selector";
95 this.set_position(WindowPosition.CENTER);
96 set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT);
103 private void on_card_list_changed() {
104 logger.trace("on_card_list_changed");
108 private bool visible_func(TreeModel model, TreeIter iter)
113 Columns.IDCARD_COL, out id_card);
118 if (candidates != null)
120 bool is_candidate = false;
121 foreach (IdCard candidate in candidates)
123 if (candidate == id_card)
130 string entry_text = search_entry.get_text();
131 if (entry_text == null || entry_text == "")
136 foreach (string search_text in entry_text.split(" "))
138 if (search_text == "")
142 string search_text_casefold = search_text.casefold();
144 if (id_card.issuer != null)
146 string issuer_casefold = id_card.issuer;
148 if (issuer_casefold.contains(search_text_casefold))
152 if (id_card.display_name != null)
154 string display_name_casefold = id_card.display_name.casefold();
156 if (display_name_casefold.contains(search_text_casefold))
160 if (id_card.services.size > 0)
162 foreach (string service in id_card.services)
164 string service_casefold = service.casefold();
166 if (service_casefold.contains(search_text_casefold))
174 private void setup_list_model()
176 this.listmodel = new Gtk.ListStore(Columns.N_COLUMNS, typeof(IdCard),
181 this.filter = new TreeModelFilter(listmodel, null);
183 filter.set_visible_func(visible_func);
186 private void search_entry_text_changed_cb()
188 this.filter.refilter();
189 redraw_id_card_widgets();
192 private bool search_entry_key_press_event_cb(Gdk.EventKey e)
194 if(Gdk.keyval_name(e.keyval) == "Escape")
195 this.search_entry.set_text("");
197 // Continue processing this event, since the
198 // text entry functionality needs to see it too.
202 private void load_id_cards() {
203 logger.trace("load_id_cards");
206 this.listmodel->clear();
207 LinkedList<IdCard> card_list = identities_manager.get_card_list() ;
208 if (card_list == null) {
212 foreach (IdCard id_card in card_list) {
213 logger.trace(@"load_id_cards: Loading card with display name '$(id_card.display_name)'");
214 add_id_card_data(id_card);
215 add_id_card_widget(id_card);
219 private IdCard update_id_card_data(IdentityDialog dialog, IdCard id_card)
221 id_card.display_name = dialog.display_name;
222 id_card.issuer = dialog.issuer;
223 id_card.username = dialog.username;
224 id_card.password = dialog.password;
225 id_card.store_password = dialog.store_password;
227 id_card.update_services_from_list(dialog.get_services());
229 if (dialog.clear_trust_anchor) {
230 id_card.clear_trust_anchor();
236 private void add_id_card_data(IdCard id_card)
240 this.listmodel->append(out iter);
241 pixbuf = get_pixbuf(id_card);
243 Columns.IDCARD_COL, id_card,
244 Columns.LOGO_COL, pixbuf,
245 Columns.ISSUER_COL, id_card.issuer,
246 Columns.USERNAME_COL, id_card.username,
247 Columns.PASSWORD_COL, id_card.password);
250 // private void remove_id_card_data(IdCard id_card)
255 // if (listmodel->get_iter_first(out iter))
259 // listmodel->get(iter,
260 // Columns.ISSUER_COL, out issuer);
262 // if (id_card.issuer == issuer)
264 // listmodel->remove(iter);
268 // while (listmodel->iter_next(ref iter));
272 private IdCardWidget add_id_card_widget(IdCard id_card)
274 logger.trace("add_id_card_widget: id_card.nai='%s'; selected nai='%s'"
276 this.selected_idcard == null ? "[null selection]" : this.selected_idcard.nai));
279 var id_card_widget = new IdCardWidget(id_card, this);
280 this.custom_vbox.add_id_card_widget(id_card_widget);
281 id_card_widget.expanded.connect(this.widget_selected_cb);
282 id_card_widget.collapsed.connect(this.widget_unselected_cb);
284 if (this.selected_idcard != null && this.selected_idcard.nai == id_card.nai) {
285 logger.trace(@"add_id_card_widget: Expanding selected idcard widget");
286 id_card_widget.expand();
288 return id_card_widget;
291 private void widget_selected_cb(IdCardWidget id_card_widget)
293 logger.trace(@"widget_selected_cb: id_card_widget.id_card.display_name='$(id_card_widget.id_card.display_name)'");
295 this.selected_idcard = id_card_widget.id_card;
296 bool allow_removes = !id_card_widget.id_card.is_no_identity();
297 this.remove_button.set_sensitive(allow_removes);
298 this.edit_button.set_sensitive(true);
299 this.custom_vbox.receive_expanded_event(id_card_widget);
301 if (this.selection_in_progress())
302 this.send_button.set_sensitive(true);
305 private void widget_unselected_cb(IdCardWidget id_card_widget)
307 logger.trace(@"widget_unselected_cb: id_card_widget.id_card.display_name='$(id_card_widget.id_card.display_name)'");
309 this.selected_idcard = null;
310 this.remove_button.set_sensitive(false);
311 this.edit_button.set_sensitive(false);
312 this.custom_vbox.receive_collapsed_event(id_card_widget);
314 this.send_button.set_sensitive(false);
317 public bool add_identity(IdCard id_card, bool force_flat_file_store)
321 * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
322 * so for now we will install silently
324 var ret = Gtk.ResponseType.YES;
326 Gtk.MessageDialog dialog;
327 IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
328 logger.trace("add_identity(flat=%s, card='%s'): find_id_card returned %s"
329 .printf(force_flat_file_store.to_string(), id_card.display_name, (prev_id != null ? prev_id.display_name : "null")));
331 int flags = prev_id.Compare(id_card);
332 logger.trace("add_identity: compare returned " + flags.to_string());
334 return false; // no changes, no need to update
335 } else if ((flags & (1 << IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
336 dialog = new Gtk.MessageDialog(this,
337 Gtk.DialogFlags.DESTROY_WITH_PARENT,
338 Gtk.MessageType.QUESTION,
339 Gtk.ButtonsType.YES_NO,
340 _("Would you like to replace ID Card '%s' using nai '%s' with the new ID Card '%s'?"),
341 prev_id.display_name,
343 id_card.display_name);
345 dialog = new Gtk.MessageDialog(this,
346 Gtk.DialogFlags.DESTROY_WITH_PARENT,
347 Gtk.MessageType.QUESTION,
348 Gtk.ButtonsType.YES_NO,
349 _("Would you like to update ID Card '%s' using nai '%s'?"),
350 id_card.display_name,
354 dialog = new Gtk.MessageDialog(this,
355 Gtk.DialogFlags.DESTROY_WITH_PARENT,
356 Gtk.MessageType.QUESTION,
357 Gtk.ButtonsType.YES_NO,
358 _("Would you like to add '%s' ID Card to the ID Card Organizer?"),
359 id_card.display_name);
361 var ret = dialog.run();
365 if (ret == Gtk.ResponseType.YES) {
366 this.identities_manager.add_card(id_card, force_flat_file_store);
372 private void add_identity_cb()
374 var dialog = new IdentityDialog(this);
375 int result = ResponseType.CANCEL;
376 while (!dialog.complete)
377 result = dialog.run();
380 case ResponseType.OK:
381 this.identities_manager.add_card(update_id_card_data(dialog, new IdCard()), false);
389 private void edit_identity_cb(IdCard card)
391 var dialog = new IdentityDialog.with_idcard(card, _("Edit Identity"), this);
392 int result = ResponseType.CANCEL;
393 while (!dialog.complete)
394 result = dialog.run();
397 case ResponseType.OK:
398 this.identities_manager.update_card(update_id_card_data(dialog, card));
406 private void remove_identity(IdCard id_card)
408 logger.trace(@"remove_identity: id_card.display_name='$(id_card.display_name)'");
409 if (id_card != this.selected_idcard) {
410 logger.error("remove_identity: id_card != this.selected_idcard!");
413 this.selected_idcard = null;
414 this.identities_manager.remove_card(id_card);
416 // Nothing is selected, so disable buttons
417 this.edit_button.set_sensitive(false);
418 this.remove_button.set_sensitive(false);
419 this.send_button.set_sensitive(false);
422 private void redraw_id_card_widgets()
427 this.custom_vbox.clear();
429 if (filter.get_iter_first(out iter))
434 Columns.IDCARD_COL, out id_card);
436 add_id_card_widget(id_card);
438 while (filter.iter_next(ref iter));
442 private void remove_identity_cb(IdCard id_card)
444 bool remove = WarningDialog.confirm(this,
445 Markup.printf_escaped(
446 "<span font-weight='heavy'>You are about to remove the identity '%s'.</span>",
447 id_card.display_name)
448 + "\n\nAre you sure you want to do this?",
451 remove_identity(id_card);
454 private void set_prompting_service(string service)
456 clear_selection_prompts();
458 var prompting_service = new Label(_("Identity requested for service:\n%s").printf(service));
459 prompting_service.set_line_wrap(true);
462 prompting_service.set_alignment(0, (float )0.5);
464 var selection_prompt = new Label(_("Select your identity:"));
465 selection_prompt.set_alignment(0, 1);
467 this.service_prompt_vbox.pack_start(prompting_service, false, false, 12);
468 this.service_prompt_vbox.pack_start(selection_prompt, false, false, 2);
469 this.service_prompt_vbox.show_all();
472 private void clear_selection_prompts()
474 var list = service_prompt_vbox.get_children();
475 foreach (Widget w in list)
477 service_prompt_vbox.remove(w);
482 public void queue_identity_request(IdentityRequest request)
484 bool queue_was_empty = !this.selection_in_progress();
485 this.request_queue.push_tail(request);
488 { /* setup widgets */
489 candidates = request.candidates;
491 redraw_id_card_widgets();
492 set_prompting_service(request.service);
493 remember_identity_binding.show();
495 if (this.selected_idcard != null
496 && this.custom_vbox.find_idcard_widget(this.selected_idcard) != null) {
497 // A widget is already selected, and has not been filtered out of the display via search
498 send_button.set_sensitive(true);
506 /** Makes the window visible, or at least, notifies the user that the window
507 * wants to be visible.
509 * This differs from show() in that show() does not guarantee that the
510 * window will be moved to the foreground. Actually, neither does this
511 * method, because the user's settings and window manager may affect the
512 * behavior significantly.
514 public void make_visible()
516 set_urgency_hint(true);
520 public IdCard check_add_password(IdCard identity, IdentityRequest request, IdentityManagerModel model)
522 logger.trace(@"check_add_password");
523 IdCard retval = identity;
524 bool idcard_has_pw = (identity.password != null) && (identity.password != "");
525 bool request_has_pw = (request.password != null) && (request.password != "");
526 if ((!idcard_has_pw) && (!identity.is_no_identity())) {
527 if (request_has_pw) {
528 identity.password = request.password;
529 retval = model.update_card(identity);
531 var dialog = new AddPasswordDialog(identity, request);
532 var result = dialog.run();
535 case ResponseType.OK:
536 identity.password = dialog.password;
537 identity.store_password = dialog.remember;
539 identity.temporary = false;
540 retval = model.update_card(identity);
552 private void send_identity_cb(IdCard id)
554 return_if_fail(this.selection_in_progress());
556 if (!check_and_confirm_trust_anchor(id)) {
557 // Allow user to pick again
561 var request = this.request_queue.pop_head();
562 var identity = check_add_password(id, request, identities_manager);
563 send_button.set_sensitive(false);
567 if (!this.selection_in_progress())
570 clear_selection_prompts();
571 if (!parent_app.explicitly_launched) {
572 // The following occasionally causes the app to exit without sending the dbus
573 // reply, so for now we just don't exit
579 IdentityRequest next = this.request_queue.peek_head();
580 candidates = next.candidates;
581 set_prompting_service(next.service);
584 redraw_id_card_widgets();
586 if ((identity != null) && (!identity.is_no_identity()))
587 parent_app.default_id_card = identity;
589 request.return_identity(identity, remember_identity_binding.active);
591 remember_identity_binding.active = false;
592 remember_identity_binding.hide();
595 private bool check_and_confirm_trust_anchor(IdCard id)
597 if (!id.trust_anchor.is_empty() && id.trust_anchor.get_anchor_type() == TrustAnchor.TrustAnchorType.SERVER_CERT) {
598 if (!id.trust_anchor.user_verified) {
601 int result = ResponseType.CANCEL;
602 var dialog = new TrustAnchorDialog(id, this);
603 while (!dialog.complete)
604 result = dialog.run();
607 case ResponseType.OK:
608 id.trust_anchor.user_verified = true;
622 private void on_about_action()
624 string copyright = "Copyright (c) 2011, %d JANET".printf(LATEST_EDIT_YEAR);
628 Copyright (c) 2011, %d JANET(UK)
631 Redistribution and use in source and binary forms, with or without
632 modification, are permitted provided that the following conditions
635 1. Redistributions of source code must retain the above copyright
636 notice, this list of conditions and the following disclaimer.
638 2. Redistributions in binary form must reproduce the above copyright
639 notice, this list of conditions and the following disclaimer in the
640 documentation and/or other materials provided with the distribution.
642 3. Neither the name of JANET(UK) nor the names of its contributors
643 may be used to endorse or promote products derived from this software
644 without specific prior written permission.
646 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"
647 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
648 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
650 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
651 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
652 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
653 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
654 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
655 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
657 """.printf(LATEST_EDIT_YEAR);
659 AboutDialog about = new AboutDialog();
661 about.set_comments(_("Moonshot project UI"));
662 about.set_copyright(copyright);
663 about.set_website(Config.PACKAGE_URL);
664 about.set_website_label(_("Visit the Moonshot project web site"));
666 // Note: The package version is configured at the top of moonshot/ui/configure.ac
667 about.set_version(Config.PACKAGE_VERSION);
668 about.set_license(license);
669 about.set_modal(true);
670 about.set_transient_for(this);
671 about.response.connect((a, b) => {about.destroy();});
672 about.modify_bg(StateType.NORMAL, white);
677 private Gtk.ActionEntry[] create_actions() {
678 Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
680 Gtk.ActionEntry helpmenu = { "HelpMenuAction",
685 Gtk.ActionEntry about = { "AboutAction",
693 N_("About this application"),
701 private void create_ui_manager()
703 Gtk.ActionGroup action_group = new Gtk.ActionGroup("GeneralActionGroup");
704 action_group.add_actions(create_actions(), this);
705 ui_manager.insert_action_group(action_group, 0);
708 ui_manager.add_ui_from_string(menu_layout, -1);
712 stderr.printf("%s\n", e.message);
713 logger.error("create_ui_manager: Caught error: " + e.message);
715 ui_manager.ensure_update();
718 private void build_ui()
720 // Note: On Debian7/Gtk+2, the menu bar remains gray. This doesn't happen on Debian8/Gtk+3.
721 this.modify_bg(StateType.NORMAL, white);
727 int button_width = 1;
729 Table top_table = new Table(num_rows, 10, false);
730 top_table.set_border_width(12);
732 AttachOptions fill_and_expand = AttachOptions.EXPAND | AttachOptions.FILL;
733 AttachOptions fill = AttachOptions.FILL;
736 service_prompt_vbox = new VBox(false, 0);
737 top_table.attach(service_prompt_vbox, 0, 1, row, row + 1, fill_and_expand, fill_and_expand, 12, 0);
740 string search_tooltip_text = _("Search for an identity or service");
741 this.search_entry = new Entry();
743 set_atk_name_description(search_entry, _("Search entry"), _("Search for a specific ID Card"));
744 this.search_entry.set_icon_from_pixbuf(EntryIconPosition.SECONDARY,
745 find_icon_sized("edit-find", Gtk.IconSize.MENU));
746 this.search_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY,
747 search_tooltip_text);
749 this.search_entry.set_tooltip_text(search_tooltip_text);
751 this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, false);
753 this.search_entry.notify["text"].connect(search_entry_text_changed_cb);
754 this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
755 this.search_entry.set_width_chars(24);
757 var search_label_markup =_("<small>") + search_tooltip_text + _("</small>");
758 var full_search_label = new Label(null);
759 full_search_label.set_markup(search_label_markup);
760 full_search_label.set_alignment(1, 0);
762 var search_vbox = new VBox(false, 0);
763 search_vbox.pack_start(search_entry, false, false, 0);
764 var search_spacer = new Alignment(0, 0, 0, 0);
765 search_spacer.set_size_request(0, 2);
766 search_vbox.pack_start(search_spacer, false, false, 0);
767 search_vbox.pack_start(full_search_label, false, false, 0);
769 // Overlap with the service_prompt_box
770 top_table.attach(search_vbox, 5, num_cols - button_width, row - 1, row + 1, fill_and_expand, fill, 0, 12);
773 this.custom_vbox = new CustomVBox(this, false, 2);
775 var viewport = new Viewport(null, null);
776 viewport.set_border_width(2);
777 viewport.set_shadow_type(ShadowType.NONE);
778 viewport.add(custom_vbox);
779 var id_scrollwin = new ScrolledWindow(null, null);
780 id_scrollwin.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
781 id_scrollwin.set_shadow_type(ShadowType.IN);
782 id_scrollwin.add_with_viewport(viewport);
783 top_table.attach(id_scrollwin, 0, num_cols - 1, row, num_rows - 1, fill_and_expand, fill_and_expand, 6, 0);
785 // Right below id_scrollwin:
786 remember_identity_binding = new CheckButton.with_label(_("Remember my identity choice for this service"));
787 remember_identity_binding.active = false;
788 top_table.attach(remember_identity_binding, 0, num_cols / 2, num_rows - 1, num_rows, fill_and_expand, fill_and_expand, 3, 0);
790 var add_button = new Button.with_label(_("Add"));
791 add_button.clicked.connect((w) => {add_identity_cb();});
792 top_table.attach(make_rigid(add_button), num_cols - button_width, num_cols, row, row + 1, fill, fill, 0, 0);
793 logger.trace("build_ui: row spacing for row %d is %u".printf(row, top_table.get_row_spacing(row)));
796 this.edit_button = new Button.with_label(_("Edit"));
797 edit_button.clicked.connect((w) => {edit_identity_cb(this.selected_idcard);});
798 edit_button.set_sensitive(false);
799 top_table.attach(make_rigid(edit_button), num_cols - button_width, num_cols, row, row + 1, fill, fill, 0, 0);
802 this.remove_button = new Button.with_label(_("Remove"));
803 remove_button.clicked.connect((w) => {remove_identity_cb(this.selected_idcard);});
804 remove_button.set_sensitive(false);
805 top_table.attach(make_rigid(remove_button), num_cols - button_width, num_cols, row, row + 1, fill, fill, 0, 0);
808 // push the send button down another row.
810 this.send_button = new Button.with_label(_("Send"));
811 send_button.clicked.connect((w) => {send_identity_cb(this.selected_idcard);});
812 // send_button.set_visible(false);
813 send_button.set_sensitive(false);
814 top_table.attach(make_rigid(send_button), num_cols - button_width, num_cols, row, row + 1, fill, fill, 0, 0);
817 var main_vbox = new VBox(false, 0);
820 // hide the File | Quit menu item which is now on the Mac Menu
821 // Gtk.Widget quit_item = this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
824 Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
825 menushell.modify_bg(StateType.NORMAL, white);
827 osxApp.set_menu_bar(menushell);
828 osxApp.set_use_quartz_accelerators(true);
829 osxApp.sync_menu_bar();
832 var menubar = this.ui_manager.get_widget("/MenuBar");
833 main_vbox.pack_start(menubar, false, false, 0);
834 menubar.modify_bg(StateType.NORMAL, white);
836 main_vbox.pack_start(top_table, true, true, 6);
839 main_vbox.show_all();
841 if (!this.selection_in_progress())
842 remember_identity_binding.hide();
845 internal bool selection_in_progress() {
846 return !this.request_queue.is_empty();
849 private void set_atk_name_description(Widget widget, string name, string description)
851 var atk_widget = widget.get_accessible();
853 atk_widget.set_name(name);
854 atk_widget.set_description(description);
857 private void connect_signals()
859 this.destroy.connect(() => {
860 logger.trace("Destroy event; calling Gtk.main_quit()");
863 this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
864 this.delete_event.connect(() => {return confirm_quit();});
867 private bool confirm_quit() {
868 logger.trace("delete_event intercepted; selection_in_progress()=" + selection_in_progress().to_string());
870 if (selection_in_progress()) {
871 var result = WarningDialog.confirm(this,
872 Markup.printf_escaped(
873 _("<span font-weight='heavy'>Do you wish to use the %s service?</span>"),
874 this.request_queue.peek_head().service)
875 + _("\n\nSelect Yes to select an ID for this service, or No to cancel"),
876 "close_moonshot_window");
878 // Prevent other handlers from handling this event; this keeps the window open.
883 // Allow the window deletion to proceed.
887 private static Widget make_rigid(Button button)
889 // Hack to prevent the button from growing vertically
890 VBox fixed_height = new VBox(false, 0);
891 fixed_height.pack_start(button, false, false, 0);