2 * Copyright (c) 2011-2014, 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 private const int WINDOW_WIDTH = 700;
39 private const int WINDOW_HEIGHT = 500;
40 protected IdentityManagerApp parent_app;
42 public OSXApplication osxApp;
44 private UIManager ui_manager = new UIManager();
45 private Entry search_entry;
46 private VBox vbox_right;
47 // private VBox login_vbox;
48 // private VBox services_vbox;
49 private CustomVBox custom_vbox;
50 // private VBox services_internal_vbox;
51 // private ScrolledWindow services_vscroll;
52 // private Entry issuer_entry;
53 // private Entry username_entry;
54 // private Entry password_entry;
55 private Label prompting_service;
56 private Label no_identity_title;
57 // private CheckButton remember_checkbutton;
58 // private Button update_password_button;
59 private Button edit_button;
60 private Button remove_button;
62 private Gtk.ListStore* listmodel;
63 private TreeModelFilter filter;
65 internal IdentityManagerModel identities_manager;
66 private unowned SList<IdCard> candidates;
68 public GLib.Queue<IdentityRequest> request_queue;
70 // private HashTable<Gtk.Button, string> service_button_map;
82 private const string menu_layout =
83 "<menubar name='MenuBar'>" +
84 " <menu name='HelpMenu' action='HelpMenuAction'>" +
85 " <menuitem name='About' action='AboutAction' />" +
89 public IdentityManagerView(IdentityManagerApp app) {
92 osxApp = OSXApplication.get_instance();
94 identities_manager = parent_app.model;
95 request_queue = new GLib.Queue<IdentityRequest>();
96 // service_button_map = new HashTable<Gtk.Button, string>(direct_hash, direct_equal);
97 this.title = "Moonshot Identity Selector";
98 this.set_position(WindowPosition.CENTER);
99 set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT);
106 public void on_card_list_changed() {
110 private bool visible_func(TreeModel model, TreeIter iter)
115 Columns.IDCARD_COL, out id_card);
120 if (candidates != null)
122 bool is_candidate = false;
123 foreach (IdCard candidate in candidates)
125 if (candidate == id_card)
132 string entry_text = search_entry.get_text();
133 if (entry_text == null || entry_text == "")
138 foreach (string search_text in entry_text.split(" "))
140 if (search_text == "")
144 string search_text_casefold = search_text.casefold();
146 if (id_card.issuer != null)
148 string issuer_casefold = id_card.issuer;
150 if (issuer_casefold.contains(search_text_casefold))
154 if (id_card.display_name != null)
156 string display_name_casefold = id_card.display_name.casefold();
158 if (display_name_casefold.contains(search_text_casefold))
162 if (id_card.services.length > 0)
164 foreach (string service in id_card.services)
166 string service_casefold = service.casefold();
168 if (service_casefold.contains(search_text_casefold))
176 private void setup_list_model()
178 this.listmodel = new Gtk.ListStore(Columns.N_COLUMNS, typeof(IdCard),
183 this.filter = new TreeModelFilter(listmodel, null);
185 filter.set_visible_func(visible_func);
188 private void search_entry_icon_press_cb(EntryIconPosition pos, Gdk.Event event)
190 if (pos == EntryIconPosition.PRIMARY)
192 print("Search entry icon pressed\n");
196 this.search_entry.set_text("");
200 private void search_entry_text_changed_cb()
202 this.filter.refilter();
203 redraw_id_card_widgets();
205 var has_text = this.search_entry.get_text_length() > 0;
206 this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, has_text);
207 this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, has_text);
209 // this.vbox_right.set_visible(false);
212 private bool search_entry_key_press_event_cb(Gdk.EventKey e)
214 if(Gdk.keyval_name(e.keyval) == "Escape")
215 this.search_entry.set_text("");
217 // Continue processing this event, since the
218 // text entry functionality needs to see it too.
222 // private void update_password_cb()
224 // if (this.custom_vbox.current_idcard != null) {
225 // var identity = this.custom_vbox.current_idcard.id_card;
226 // var dialog = new AddPasswordDialog(identity, null);
227 // var result = dialog.run();
230 // case ResponseType.OK:
231 // identity.password = dialog.password;
232 // identity.store_password = dialog.remember;
233 // if (dialog.remember)
234 // identity.temporary = false;
235 // identity = identities_manager.update_card(identity);
244 private void load_id_cards() {
245 logger.trace("load_id_cards");
247 string current_idcard_nai = null;
248 if (this.custom_vbox.current_idcard != null) {
249 current_idcard_nai = custom_vbox.current_idcard.id_card.nai;
250 custom_vbox.current_idcard = null;
252 var children = this.custom_vbox.get_children();
255 this.listmodel->clear();
256 LinkedList<IdCard> card_list = identities_manager.get_card_list() ;
257 if (card_list == null) {
261 foreach (IdCard id_card in card_list) {
262 add_id_card_data(id_card);
263 IdCardWidget id_card_widget = add_id_card_widget(id_card);
264 if (id_card_widget.id_card.nai == current_idcard_nai) {
265 // fill_details(id_card_widget.id_card);
266 id_card_widget.expand();
271 // private void fill_details(IdCard id_card)
273 // logger.trace("fill_details: id_card=%s".printf(id_card == null ? "null" : "non-null"));
275 // if (id_card != null) {
276 // if (id_card.display_name == IdCard.NO_IDENTITY) {
277 // logger.trace("fill_details: Displaying title for NO_IDENTITY");
278 // login_vbox.hide();
279 // no_identity_title.show_all();
281 // logger.trace("fill_details: Displaying details for selected card");
282 // // this.issuer_entry.set_text(id_card.issuer);
283 // // this.username_entry.set_text(id_card.username);
284 // // this.password_entry.set_text(id_card.password ?? "");
285 // this.remember_checkbutton.active = id_card.store_password;
286 // no_identity_title.hide();
287 // login_vbox.show_all();
290 // fill_services_vbox(id_card);
294 // private void show_details(IdCard id_card)
296 // this.vbox_right.set_visible(!vbox_right.get_visible());
298 // if (this.vbox_right.get_visible() == false)
300 // this.resize(WINDOW_WIDTH, WINDOW_HEIGHT);
304 // private void details_identity_cb(IdCardWidget id_card_widget)
306 // fill_details(id_card_widget.id_card);
307 // show_details(id_card_widget.id_card);
310 private IdCard update_id_card_data(IdentityDialog dialog, IdCard id_card)
312 id_card.display_name = dialog.display_name;
313 id_card.issuer = dialog.issuer;
314 id_card.username = dialog.username;
315 id_card.password = dialog.password;
316 id_card.store_password = dialog.store_password;
317 id_card.services = dialog.get_services();
322 private void add_id_card_data(IdCard id_card)
326 this.listmodel->append(out iter);
327 pixbuf = get_pixbuf(id_card);
329 Columns.IDCARD_COL, id_card,
330 Columns.LOGO_COL, pixbuf,
331 Columns.ISSUER_COL, id_card.issuer,
332 Columns.USERNAME_COL, id_card.username,
333 Columns.PASSWORD_COL, id_card.password);
336 private void remove_id_card_data(IdCard id_card)
341 if (listmodel->get_iter_first(out iter))
346 Columns.ISSUER_COL, out issuer);
348 if (id_card.issuer == issuer)
350 listmodel->remove(iter);
354 while (listmodel->iter_next(ref iter));
358 private IdCardWidget add_id_card_widget(IdCard id_card)
360 var id_card_widget = new IdCardWidget(id_card);
361 this.custom_vbox.add_id_card_widget(id_card_widget);
362 // id_card_widget.details_id.connect(details_identity_cb);
363 // id_card_widget.remove_id.connect(remove_identity_cb);
364 // id_card_widget.send_id.connect((w) => send_identity_cb(w.id_card));
365 id_card_widget.expanded.connect(this.widget_selected_cb);
366 // id_card_widget.expanded.connect((w) => fill_details(w.id_card));
367 return id_card_widget;
370 private void widget_selected_cb(IdCardWidget id_card_widget)
372 remove_button.set_sensitive(true);
373 this.edit_button.set_sensitive(true);
374 this.custom_vbox.receive_expanded_event(id_card_widget);
377 public bool add_identity(IdCard id_card, bool force_flat_file_store)
381 * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
382 * so for now we will install silently
384 var ret = Gtk.ResponseType.YES;
386 Gtk.MessageDialog dialog;
387 IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
389 int flags = prev_id.Compare(id_card);
391 return false; // no changes, no need to update
392 } else if ((flags & (1 << IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
393 dialog = new Gtk.MessageDialog(this,
394 Gtk.DialogFlags.DESTROY_WITH_PARENT,
395 Gtk.MessageType.QUESTION,
396 Gtk.ButtonsType.YES_NO,
397 _("Would you like to replace ID Card '%s' using nai '%s' with the new ID Card '%s'?"),
398 prev_id.display_name,
400 id_card.display_name);
402 dialog = new Gtk.MessageDialog(this,
403 Gtk.DialogFlags.DESTROY_WITH_PARENT,
404 Gtk.MessageType.QUESTION,
405 Gtk.ButtonsType.YES_NO,
406 _("Would you like to update ID Card '%s' using nai '%s'?"),
407 id_card.display_name,
411 dialog = new Gtk.MessageDialog(this,
412 Gtk.DialogFlags.DESTROY_WITH_PARENT,
413 Gtk.MessageType.QUESTION,
414 Gtk.ButtonsType.YES_NO,
415 _("Would you like to add '%s' ID Card to the ID Card Organizer?"),
416 id_card.display_name);
418 var ret = dialog.run();
422 if (ret == Gtk.ResponseType.YES) {
423 this.identities_manager.add_card(id_card, force_flat_file_store);
429 private void add_identity_cb()
431 var dialog = new IdentityDialog(this);
432 int result = ResponseType.CANCEL;
433 while (!dialog.complete)
434 result = dialog.run();
437 case ResponseType.OK:
438 this.identities_manager.add_card(update_id_card_data(dialog, new IdCard()), false);
446 private void edit_identity_cb(IdCard card)
448 var dialog = new IdentityDialog.with_idcard(card, _("Edit Identity"), this);
449 int result = ResponseType.CANCEL;
450 while (!dialog.complete)
451 result = dialog.run();
454 case ResponseType.OK:
455 this.identities_manager.update_card(update_id_card_data(dialog, card));
463 private void remove_identity(IdCardWidget id_card_widget)
465 var id_card = id_card_widget.id_card;
466 this.custom_vbox.remove_id_card_widget(id_card_widget);
468 this.identities_manager.remove_card(id_card);
470 // Nothing is selected, so disable edit and remove buttons
471 this.edit_button.set_sensitive(false);
472 this.remove_button.set_sensitive(false);
475 private void redraw_id_card_widgets()
477 logger.trace("redraw_id_card_widgets");
482 var children = this.custom_vbox.get_children();
483 this.custom_vbox.clear();
485 if (filter.get_iter_first(out iter))
490 Columns.IDCARD_COL, out id_card);
492 add_id_card_widget(id_card);
494 while (filter.iter_next(ref iter));
498 private void remove_identity_cb(IdCardWidget id_card_widget)
500 var id_card = id_card_widget.id_card;
502 var dialog = new MessageDialog(this,
503 DialogFlags.DESTROY_WITH_PARENT,
504 MessageType.QUESTION,
505 Gtk.ButtonsType.YES_NO,
506 _("Are you sure you want to delete %s ID Card?"), id_card.issuer);
507 var result = dialog.run();
509 case ResponseType.YES:
510 remove_identity(id_card_widget);
518 public void set_prompting_service(string service)
520 prompting_service.set_label( _("Identity requested for service: %s").printf(service) );
523 public void queue_identity_request(IdentityRequest request)
525 if (this.request_queue.is_empty())
526 { /* setup widgets */
527 candidates = request.candidates;
529 redraw_id_card_widgets();
530 set_prompting_service(request.service);
533 this.request_queue.push_tail(request);
537 /** Makes the window visible, or at least, notifies the user that the window
538 * wants to be visible.
540 * This differs from show() in that show() does not guarantee that the
541 * window will be moved to the foreground. Actually, neither does this
542 * method, because the user's settings and window manager may affect the
543 * behavior significantly.
545 public void make_visible()
547 set_urgency_hint(true);
551 public IdCard check_add_password(IdCard identity, IdentityRequest request, IdentityManagerModel model)
553 IdCard retval = identity;
554 bool idcard_has_pw = (identity.password != null) && (identity.password != "");
555 bool request_has_pw = (request.password != null) && (request.password != "");
556 if ((!idcard_has_pw) && (!identity.IsNoIdentity())) {
557 if (request_has_pw) {
558 identity.password = request.password;
559 retval = model.update_card(identity);
561 var dialog = new AddPasswordDialog(identity, request);
562 var result = dialog.run();
565 case ResponseType.OK:
566 identity.password = dialog.password;
567 identity.store_password = dialog.remember;
569 identity.temporary = false;
570 retval = model.update_card(identity);
582 private void send_identity_cb(IdCard id)
584 IdCard identity = id;
585 return_if_fail(request_queue.length > 0);
588 var request = this.request_queue.pop_head();
589 identity = check_add_password(identity, request, identities_manager);
590 if (this.request_queue.is_empty())
593 prompting_service.set_label(_(""));
594 if (!parent_app.explicitly_launched) {
595 // The following occasionally causes the app to exit without sending the dbus
596 // reply, so for now we just don't exit
602 IdentityRequest next = this.request_queue.peek_head();
603 candidates = next.candidates;
604 set_prompting_service(next.service);
607 redraw_id_card_widgets();
609 if ((identity != null) && (!identity.IsNoIdentity()))
610 parent_app.default_id_card = identity;
612 request.return_identity(identity);
615 // private void label_make_bold(Label label)
617 // var font_desc = new Pango.FontDescription();
619 // font_desc.set_weight(Pango.Weight.BOLD);
621 // /* This will only affect the weight of the font, the rest is
622 // * from the current state of the widget, which comes from the
623 // * theme or user prefs, since the font desc only has the
624 // * weight flag turned on.
626 // label.modify_font(font_desc);
629 // private void fill_services_vbox(IdCard id_card)
631 // logger.trace("fill_services_vbox");
633 // var children = this.services_internal_vbox.get_children();
634 // foreach (var widget in children) {
635 // services_internal_vbox.remove(widget);
639 // var n_rows = id_card.services.length;
641 // var services_table = new Table(n_rows, 2, false);
642 // services_table.set_col_spacings(10);
643 // services_table.set_row_spacings(10);
644 // this.services_internal_vbox.pack_start(services_table, true, false, 0);
646 // service_button_map.remove_all();
648 // foreach (string service in id_card.services)
650 // var label = new Label(service);
651 // label.set_alignment(0, (float) 0.5);
653 // var remove_button = new Button.from_stock(Stock.REMOVE);
655 // var remove_button = new Button.from_stock(STOCK_REMOVE);
659 // service_button_map.insert(remove_button, service);
661 // remove_button.clicked.connect((remove_button) =>
663 // var candidate = service_button_map.lookup(remove_button);
664 // if (candidate == null)
666 // var dialog = new Gtk.MessageDialog(this,
667 // Gtk.DialogFlags.DESTROY_WITH_PARENT,
668 // Gtk.MessageType.QUESTION,
669 // Gtk.ButtonsType.YES_NO,
670 // _("Are you sure you want to stop '%s' ID Card from being used with %s?"),
671 // custom_vbox.current_idcard.id_card.display_name,
673 // var ret = dialog.run();
676 // if (ret == Gtk.ResponseType.YES)
678 // IdCard idcard = custom_vbox.current_idcard.id_card;
679 // if (idcard != null) {
680 // SList<string> services = new SList<string>();
682 // foreach (string srv in idcard.services)
684 // if (srv == candidate)
686 // services.append(srv);
689 // idcard.services = new string[services.length()];
690 // for (int j = 0; j < idcard.services.length; j++)
692 // idcard.services[j] = services.nth_data(j);
695 // identities_manager.update_card(idcard);
700 // services_table.attach_defaults(label, 0, 1, i, i+1);
701 // services_table.attach_defaults(remove_button, 1, 2, i, i+1);
705 // services_vbox.show_all();
708 private void on_about_action()
710 string copyright = "Copyright 2011, 2016 JANET";
714 Copyright (c) 2011, 2016 JANET(UK)
717 Redistribution and use in source and binary forms, with or without
718 modification, are permitted provided that the following conditions
721 1. Redistributions of source code must retain the above copyright
722 notice, this list of conditions and the following disclaimer.
724 2. Redistributions in binary form must reproduce the above copyright
725 notice, this list of conditions and the following disclaimer in the
726 documentation and/or other materials provided with the distribution.
728 3. Neither the name of JANET(UK) nor the names of its contributors
729 may be used to endorse or promote products derived from this software
730 without specific prior written permission.
732 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"
733 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
734 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
735 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
736 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
737 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
738 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
739 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
740 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
741 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
745 Gtk.show_about_dialog(this,
746 "comments", _("Moonshot project UI"),
747 "copyright", copyright,
748 "website", Config.PACKAGE_URL,
749 "version", Config.PACKAGE_VERSION,
751 "website-label", _("Visit the Moonshot project web site"),
752 // "authors", authors,
753 "translator-credits", _("translator-credits"),
758 private Gtk.ActionEntry[] create_actions() {
759 Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
761 // Gtk.ActionEntry add = { "AddIdCardAction",
767 // N_("Add ID Card"),
769 // N_("Add a new ID Card"),
770 // add_identity_manual_cb };
773 Gtk.ActionEntry helpmenu = { "HelpMenuAction",
778 Gtk.ActionEntry about = { "AboutAction",
786 N_("About this application"),
794 private void create_ui_manager()
796 Gtk.ActionGroup action_group = new Gtk.ActionGroup("GeneralActionGroup");
797 action_group.add_actions(create_actions(), this);
798 ui_manager.insert_action_group(action_group, 0);
801 ui_manager.add_ui_from_string(menu_layout, -1);
805 stderr.printf("%s\n", e.message);
806 logger.error("create_ui_manager: Caught error: " + e.message);
808 ui_manager.ensure_update();
811 private void build_ui()
815 this.search_entry = new Entry();
817 set_atk_name_description(search_entry, _("Search entry"), _("Search for a specific ID Card"));
818 this.search_entry.set_icon_from_pixbuf(EntryIconPosition.PRIMARY,
819 find_icon_sized("edit-find", Gtk.IconSize.MENU));
820 // find_icon_sized("edit-find-symbolic", Gtk.IconSize.MENU));
821 this.search_entry.set_icon_tooltip_text(EntryIconPosition.PRIMARY,
822 _("Search for an identity or service"));
823 this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, false);
825 this.search_entry.set_icon_from_pixbuf(EntryIconPosition.SECONDARY,
826 find_icon_sized("process-stop", Gtk.IconSize.MENU));
827 // find_icon_sized("edit-clear-symbolic", Gtk.IconSize.MENU));
828 this.search_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY,
829 _("Clear the current search"));
830 this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, false);
833 this.search_entry.icon_press.connect(search_entry_icon_press_cb);
834 this.search_entry.notify["text"].connect(search_entry_text_changed_cb);
835 this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
836 this.search_entry.set_width_chars(30);
839 this.custom_vbox = new CustomVBox(this, false, 2);
841 var viewport = new Viewport(null, null);
842 viewport.set_border_width(2);
843 viewport.set_shadow_type(ShadowType.NONE);
844 viewport.add(custom_vbox);
845 var id_scrollwin = new ScrolledWindow(null, null);
846 id_scrollwin.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
847 id_scrollwin.set_shadow_type(ShadowType.IN);
848 id_scrollwin.add_with_viewport(viewport);
849 this.prompting_service = new Label(_(""));
851 prompting_service.set_alignment(0, (float )0.5);
853 var vbox_left = new VBox(false, 0);
854 // vbox_left.pack_start(search_entry, false, false, 6);
855 // vbox_left.pack_start(id_scrollwin, true, true, 6);
857 var search_hbox = new HBox(false, 6);
858 var search_label = new Label(_("Search:"));
859 search_label.set_alignment(1, (float) 0.5);
860 set_atk_relation(search_label, search_entry, Atk.RelationType.LABEL_FOR);
861 search_hbox.pack_end(search_entry, false, false, 0);
862 search_hbox.pack_end(search_label, false, false, 6);
864 var full_search_label = new Label(_("Search for an identity or service"));
865 full_search_label.set_alignment(1, 1);
866 var search_vbox = new VBox(false, 4);
867 search_vbox.pack_start(search_hbox, false, false, 0);
868 search_vbox.pack_start(full_search_label, false, false, 0);
870 var inner_left_vbox = new VBox(false, 6);
871 inner_left_vbox.pack_start(search_vbox, false, false, 6);
872 inner_left_vbox.pack_start(id_scrollwin, true, true, 0);
874 var id_and_button_box = new HBox(false, 6);
875 id_and_button_box.pack_start(inner_left_vbox, true, true, 6);
876 vbox_left.pack_start(id_and_button_box, true, true, 0);
877 vbox_left.pack_start(prompting_service, false, false, 6);
878 vbox_left.set_size_request(WINDOW_WIDTH, 0);
880 this.no_identity_title = new Label(_("No Identity: Send this identity to services which should not use Moonshot"));
881 no_identity_title.set_alignment(0, (float ) 0.5);
882 no_identity_title.set_line_wrap(true);
883 no_identity_title.show();
885 // var login_vbox_title = new Label(_("Login: "));
886 // label_make_bold(login_vbox_title);
887 // login_vbox_title.set_alignment(0, (float) 0.5);
888 // var issuer_label = new Label(_("Issuer:"));
889 // issuer_label.set_alignment(1, (float) 0.5);
890 // this.issuer_entry = new Entry();
891 // issuer_entry.set_can_focus(false);
892 // var username_label = new Label(_("Username:"));
893 // username_label.set_alignment(1, (float) 0.5);
894 // this.username_entry = new Entry();
895 // username_entry.set_can_focus(false);
896 // var password_label = new Label(_("Password:"));
897 // password_label.set_alignment(1, (float) 0.5);
898 // this.password_entry = new Entry();
899 // password_entry.set_invisible_char('*');
900 // password_entry.set_visibility(false);
901 // password_entry.set_sensitive(false);
902 // this.remember_checkbutton = new CheckButton.with_label(_("Remember password"));
903 // remember_checkbutton.set_sensitive(false);
905 // set_atk_relation(issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
906 // set_atk_relation(username_label, username_entry, Atk.RelationType.LABEL_FOR);
907 // set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR);
909 // // Create the login_vbox. This starts off hidden, because the first card we
910 // // display, by default, is NO_IDENTITY.
911 // var login_table = new Table(5, 2, false);
912 // login_table.set_col_spacings(10);
913 // login_table.set_row_spacings(10);
914 // login_table.attach_defaults(issuer_label, 0, 1, 0, 1);
915 // login_table.attach_defaults(issuer_entry, 1, 2, 0, 1);
916 // login_table.attach_defaults(username_label, 0, 1, 1, 2);
917 // login_table.attach_defaults(username_entry, 1, 2, 1, 2);
918 // login_table.attach_defaults(password_label, 0, 1, 2, 3);
919 // login_table.attach_defaults(password_entry, 1, 2, 2, 3);
920 // login_table.attach_defaults(remember_checkbutton, 1, 2, 3, 4);
921 // login_table.attach_defaults(update_password_button, 0, 1, 4, 5);
922 // var login_vbox_alignment = new Alignment(0, 0, 0, 0);
923 // login_vbox_alignment.set_padding(0, 0, 12, 0);
924 // login_vbox_alignment.add(login_table);
925 // this.login_vbox = new VBox(false, 6);
926 // login_vbox.pack_start(login_vbox_title, false, true, 0);
927 // login_vbox.pack_start(login_vbox_alignment, false, true, 0);
928 // login_vbox.hide();
930 // var services_vbox_title = new Label(_("Services:"));
931 // label_make_bold(services_vbox_title);
932 // services_vbox_title.set_alignment(0, (float) 0.5);
934 // this.services_internal_vbox = new VBox(true, 6);
936 // var services_vbox_alignment = new Alignment(0, 0, 0, 1);
937 // services_vbox_alignment.set_padding(6, 6, 6, 6);
938 // services_vbox_alignment.add(services_internal_vbox);
939 // services_vscroll = new ScrolledWindow(null, null);
940 // services_vscroll.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
941 // services_vscroll.set_shadow_type(ShadowType.IN);
942 // services_vscroll.add_with_viewport(services_vbox_alignment);
944 // services_vbox = new VBox(false, 6);
945 this.vbox_right = new VBox(false, 6);
946 // services_vbox.pack_start(services_vbox_title, false, false, 0);
947 // services_vbox.pack_start(services_vscroll, true, true, 0);
949 // vbox_right.pack_start(no_identity_title, true, false, 0);
950 // vbox_right.pack_start(login_vbox, false, false, 0);
951 // vbox_right.pack_start(services_vbox, true, true, 0);
953 var add_button = new Button.with_label(_("Add"));
954 add_button.clicked.connect((w) => {add_identity_cb();});
956 this.edit_button = new Button.with_label(_("Edit"));
957 edit_button.clicked.connect((w) => {edit_identity_cb(custom_vbox.current_idcard.id_card);});
958 edit_button.set_sensitive(false);
960 this.remove_button = new Button.with_label(_("Remove"));
961 remove_button.clicked.connect((w) => {remove_identity_cb(custom_vbox.current_idcard);});
962 remove_button.set_sensitive(false);
964 var send_button = new Button.with_label(_("Send"));
965 send_button.clicked.connect((w) => {send_identity_cb(custom_vbox.current_idcard.id_card);});
966 send_button.set_visible(false);
968 var empty_box = new VBox(false, 0);
969 empty_box.set_size_request(0, 0);
970 vbox_right.pack_start(empty_box, false, false, 14);
971 vbox_right.pack_start(add_button, false, false, 6);
972 vbox_right.pack_start(edit_button, false, false, 6);
973 vbox_right.pack_start(remove_button, false, false, 6);
974 vbox_right.pack_start(send_button, false, false, 24);
976 //var hbox = new HBox(false, 12);
977 // hbox.pack_start(vbox_left, true, true, 0);
978 // hbox.pack_start(vbox_right, false, false, 0);
979 id_and_button_box.pack_start(vbox_right, false, false, 0);
980 var main_vbox = new VBox(false, 0);
981 main_vbox.set_border_width(12);
984 // hide the File | Quit menu item which is now on the Mac Menu
985 Gtk.Widget quit_item = this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
988 Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
989 osxApp.set_menu_bar(menushell);
990 osxApp.set_use_quartz_accelerators(true);
991 osxApp.sync_menu_bar();
994 var menubar = this.ui_manager.get_widget("/MenuBar");
995 main_vbox.pack_start(menubar, false, false, 0);
997 main_vbox.pack_start(vbox_left, true, true, 0);
999 main_vbox.show_all();
1002 private void set_atk_name_description(Widget widget, string name, string description)
1004 var atk_widget = widget.get_accessible();
1006 atk_widget.set_name(name);
1007 atk_widget.set_description(description);
1010 private void connect_signals()
1012 this.destroy.connect(Gtk.main_quit);
1013 this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
1016 private static void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
1018 var atk_widget = widget.get_accessible();
1019 var atk_target_widget = target_widget.get_accessible();
1021 atk_widget.add_relationship(relationship, atk_target_widget);