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;
60 private Gtk.ListStore* listmodel;
61 private TreeModelFilter filter;
63 public IdentityManagerModel identities_manager;
64 private unowned SList<IdCard> candidates;
66 public GLib.Queue<IdentityRequest> request_queue;
68 // private HashTable<Gtk.Button, string> service_button_map;
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 // service_button_map = new HashTable<Gtk.Button, string>(direct_hash, direct_equal);
95 this.title = "Moonshot Identity Selector";
96 this.set_position(WindowPosition.CENTER);
97 set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT);
104 public void 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.length > 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_icon_press_cb(EntryIconPosition pos, Gdk.Event event)
188 if (pos == EntryIconPosition.PRIMARY)
190 print("Search entry icon pressed\n");
194 this.search_entry.set_text("");
198 private void search_entry_text_changed_cb()
200 this.filter.refilter();
201 redraw_id_card_widgets();
203 var has_text = this.search_entry.get_text_length() > 0;
204 this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, has_text);
205 this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, has_text);
207 // this.vbox_right.set_visible(false);
210 private bool search_entry_key_press_event_cb(Gdk.EventKey e)
212 if(Gdk.keyval_name(e.keyval) == "Escape")
213 this.search_entry.set_text("");
215 // Continue processing this event, since the
216 // text entry functionality needs to see it too.
220 // private void update_password_cb()
222 // if (this.custom_vbox.current_idcard != null) {
223 // var identity = this.custom_vbox.current_idcard.id_card;
224 // var dialog = new AddPasswordDialog(identity, null);
225 // var result = dialog.run();
228 // case ResponseType.OK:
229 // identity.password = dialog.password;
230 // identity.store_password = dialog.remember;
231 // if (dialog.remember)
232 // identity.temporary = false;
233 // identity = identities_manager.update_card(identity);
242 private void load_id_cards() {
243 logger.trace("load_id_cards");
245 string current_idcard_nai = null;
246 if (this.custom_vbox.current_idcard != null) {
247 current_idcard_nai = custom_vbox.current_idcard.id_card.nai;
248 custom_vbox.current_idcard = null;
250 var children = this.custom_vbox.get_children();
253 this.listmodel->clear();
254 LinkedList<IdCard> card_list = identities_manager.get_card_list() ;
255 if (card_list == null) {
259 foreach (IdCard id_card in card_list) {
260 add_id_card_data(id_card);
261 IdCardWidget id_card_widget = add_id_card_widget(id_card);
262 if (id_card_widget.id_card.nai == current_idcard_nai) {
263 // fill_details(id_card_widget.id_card);
264 id_card_widget.expand();
269 // private void fill_details(IdCard id_card)
271 // logger.trace("fill_details: id_card=%s".printf(id_card == null ? "null" : "non-null"));
273 // if (id_card != null) {
274 // if (id_card.display_name == IdCard.NO_IDENTITY) {
275 // logger.trace("fill_details: Displaying title for NO_IDENTITY");
276 // login_vbox.hide();
277 // no_identity_title.show_all();
279 // logger.trace("fill_details: Displaying details for selected card");
280 // // this.issuer_entry.set_text(id_card.issuer);
281 // // this.username_entry.set_text(id_card.username);
282 // // this.password_entry.set_text(id_card.password ?? "");
283 // this.remember_checkbutton.active = id_card.store_password;
284 // no_identity_title.hide();
285 // login_vbox.show_all();
288 // fill_services_vbox(id_card);
292 // private void show_details(IdCard id_card)
294 // this.vbox_right.set_visible(!vbox_right.get_visible());
296 // if (this.vbox_right.get_visible() == false)
298 // this.resize(WINDOW_WIDTH, WINDOW_HEIGHT);
302 // private void details_identity_cb(IdCardWidget id_card_widget)
304 // fill_details(id_card_widget.id_card);
305 // show_details(id_card_widget.id_card);
308 private IdCard get_id_card_data(AddIdentityDialog dialog)
310 var id_card = new IdCard();
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 = {};
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.custom_vbox.receive_expanded_event);
366 // id_card_widget.expanded.connect((w) => fill_details(w.id_card));
367 return id_card_widget;
370 public bool add_identity(IdCard id_card, bool force_flat_file_store)
374 * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
375 * so for now we will install silently
377 var ret = Gtk.ResponseType.YES;
379 Gtk.MessageDialog dialog;
380 IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
382 int flags = prev_id.Compare(id_card);
384 return false; // no changes, no need to update
385 } else if ((flags & (1 << IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
386 dialog = new Gtk.MessageDialog(this,
387 Gtk.DialogFlags.DESTROY_WITH_PARENT,
388 Gtk.MessageType.QUESTION,
389 Gtk.ButtonsType.YES_NO,
390 _("Would you like to replace ID Card '%s' using nai '%s' with the new ID Card '%s'?"),
391 prev_id.display_name,
393 id_card.display_name);
395 dialog = new Gtk.MessageDialog(this,
396 Gtk.DialogFlags.DESTROY_WITH_PARENT,
397 Gtk.MessageType.QUESTION,
398 Gtk.ButtonsType.YES_NO,
399 _("Would you like to update ID Card '%s' using nai '%s'?"),
400 id_card.display_name,
404 dialog = new Gtk.MessageDialog(this,
405 Gtk.DialogFlags.DESTROY_WITH_PARENT,
406 Gtk.MessageType.QUESTION,
407 Gtk.ButtonsType.YES_NO,
408 _("Would you like to add '%s' ID Card to the ID Card Organizer?"),
409 id_card.display_name);
411 var ret = dialog.run();
415 if (ret == Gtk.ResponseType.YES) {
416 this.identities_manager.add_card(id_card, force_flat_file_store);
422 private void add_identity_cb()
424 var dialog = new AddIdentityDialog();
425 int result = ResponseType.CANCEL;
426 while (!dialog.complete)
427 result = dialog.run();
430 case ResponseType.OK:
431 this.identities_manager.add_card(get_id_card_data(dialog), false);
439 private void edit_identity_cb()
444 private void remove_identity(IdCardWidget id_card_widget)
446 var id_card = id_card_widget.id_card;
447 this.custom_vbox.remove_id_card_widget(id_card_widget);
449 this.identities_manager.remove_card(id_card);
452 private void redraw_id_card_widgets()
454 logger.trace("redraw_id_card_widgets");
459 var children = this.custom_vbox.get_children();
460 this.custom_vbox.clear();
462 if (filter.get_iter_first(out iter))
467 Columns.IDCARD_COL, out id_card);
469 add_id_card_widget(id_card);
471 while (filter.iter_next(ref iter));
475 private void remove_identity_cb(IdCardWidget id_card_widget)
477 var id_card = id_card_widget.id_card;
479 var dialog = new MessageDialog(this,
480 DialogFlags.DESTROY_WITH_PARENT,
481 MessageType.QUESTION,
482 Gtk.ButtonsType.YES_NO,
483 _("Are you sure you want to delete %s ID Card?"), id_card.issuer);
484 var result = dialog.run();
486 case ResponseType.YES:
487 remove_identity(id_card_widget);
495 public void set_prompting_service(string service)
497 prompting_service.set_label( _("Identity requested for service: %s").printf(service) );
500 public void queue_identity_request(IdentityRequest request)
502 if (this.request_queue.is_empty())
503 { /* setup widgets */
504 candidates = request.candidates;
506 redraw_id_card_widgets();
507 set_prompting_service(request.service);
510 this.request_queue.push_tail(request);
514 /** Makes the window visible, or at least, notifies the user that the window
515 * wants to be visible.
517 * This differs from show() in that show() does not guarantee that the
518 * window will be moved to the foreground. Actually, neither does this
519 * method, because the user's settings and window manager may affect the
520 * behavior significantly.
522 public void make_visible()
524 set_urgency_hint(true);
528 public IdCard check_add_password(IdCard identity, IdentityRequest request, IdentityManagerModel model)
530 IdCard retval = identity;
531 bool idcard_has_pw = (identity.password != null) && (identity.password != "");
532 bool request_has_pw = (request.password != null) && (request.password != "");
533 if ((!idcard_has_pw) && (!identity.IsNoIdentity())) {
534 if (request_has_pw) {
535 identity.password = request.password;
536 retval = model.update_card(identity);
538 var dialog = new AddPasswordDialog(identity, request);
539 var result = dialog.run();
542 case ResponseType.OK:
543 identity.password = dialog.password;
544 identity.store_password = dialog.remember;
546 identity.temporary = false;
547 retval = model.update_card(identity);
559 private void send_identity_cb(IdCard id)
561 IdCard identity = id;
562 return_if_fail(request_queue.length > 0);
565 var request = this.request_queue.pop_head();
566 identity = check_add_password(identity, request, identities_manager);
567 if (this.request_queue.is_empty())
570 prompting_service.set_label(_(""));
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.IsNoIdentity()))
587 parent_app.default_id_card = identity;
589 request.return_identity(identity);
592 private void label_make_bold(Label label)
594 var font_desc = new Pango.FontDescription();
596 font_desc.set_weight(Pango.Weight.BOLD);
598 /* This will only affect the weight of the font, the rest is
599 * from the current state of the widget, which comes from the
600 * theme or user prefs, since the font desc only has the
601 * weight flag turned on.
603 label.modify_font(font_desc);
606 // private void fill_services_vbox(IdCard id_card)
608 // logger.trace("fill_services_vbox");
610 // var children = this.services_internal_vbox.get_children();
611 // foreach (var widget in children) {
612 // services_internal_vbox.remove(widget);
616 // var n_rows = id_card.services.length;
618 // var services_table = new Table(n_rows, 2, false);
619 // services_table.set_col_spacings(10);
620 // services_table.set_row_spacings(10);
621 // this.services_internal_vbox.pack_start(services_table, true, false, 0);
623 // service_button_map.remove_all();
625 // foreach (string service in id_card.services)
627 // var label = new Label(service);
628 // label.set_alignment(0, (float) 0.5);
630 // var remove_button = new Button.from_stock(Stock.REMOVE);
632 // var remove_button = new Button.from_stock(STOCK_REMOVE);
636 // service_button_map.insert(remove_button, service);
638 // remove_button.clicked.connect((remove_button) =>
640 // var candidate = service_button_map.lookup(remove_button);
641 // if (candidate == null)
643 // var dialog = new Gtk.MessageDialog(this,
644 // Gtk.DialogFlags.DESTROY_WITH_PARENT,
645 // Gtk.MessageType.QUESTION,
646 // Gtk.ButtonsType.YES_NO,
647 // _("Are you sure you want to stop '%s' ID Card from being used with %s?"),
648 // custom_vbox.current_idcard.id_card.display_name,
650 // var ret = dialog.run();
653 // if (ret == Gtk.ResponseType.YES)
655 // IdCard idcard = custom_vbox.current_idcard.id_card;
656 // if (idcard != null) {
657 // SList<string> services = new SList<string>();
659 // foreach (string srv in idcard.services)
661 // if (srv == candidate)
663 // services.append(srv);
666 // idcard.services = new string[services.length()];
667 // for (int j = 0; j < idcard.services.length; j++)
669 // idcard.services[j] = services.nth_data(j);
672 // identities_manager.update_card(idcard);
677 // services_table.attach_defaults(label, 0, 1, i, i+1);
678 // services_table.attach_defaults(remove_button, 1, 2, i, i+1);
682 // services_vbox.show_all();
685 private void on_about_action()
687 string copyright = "Copyright 2011, 2016 JANET";
691 Copyright (c) 2011, 2016 JANET(UK)
694 Redistribution and use in source and binary forms, with or without
695 modification, are permitted provided that the following conditions
698 1. Redistributions of source code must retain the above copyright
699 notice, this list of conditions and the following disclaimer.
701 2. Redistributions in binary form must reproduce the above copyright
702 notice, this list of conditions and the following disclaimer in the
703 documentation and/or other materials provided with the distribution.
705 3. Neither the name of JANET(UK) nor the names of its contributors
706 may be used to endorse or promote products derived from this software
707 without specific prior written permission.
709 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"
710 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
711 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
712 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
713 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
714 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
715 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
716 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
717 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
718 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
722 Gtk.show_about_dialog(this,
723 "comments", _("Moonshot project UI"),
724 "copyright", copyright,
725 "website", Config.PACKAGE_URL,
726 "version", Config.PACKAGE_VERSION,
728 "website-label", _("Visit the Moonshot project web site"),
729 // "authors", authors,
730 "translator-credits", _("translator-credits"),
735 private Gtk.ActionEntry[] create_actions() {
736 Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
738 // Gtk.ActionEntry add = { "AddIdCardAction",
744 // N_("Add ID Card"),
746 // N_("Add a new ID Card"),
747 // add_identity_manual_cb };
750 Gtk.ActionEntry helpmenu = { "HelpMenuAction",
755 Gtk.ActionEntry about = { "AboutAction",
763 N_("About this application"),
771 private void create_ui_manager()
773 Gtk.ActionGroup action_group = new Gtk.ActionGroup("GeneralActionGroup");
774 action_group.add_actions(create_actions(), this);
775 ui_manager.insert_action_group(action_group, 0);
778 ui_manager.add_ui_from_string(menu_layout, -1);
782 stderr.printf("%s\n", e.message);
783 logger.error("create_ui_manager: Caught error: " + e.message);
785 ui_manager.ensure_update();
788 private void build_ui()
792 this.search_entry = new Entry();
794 set_atk_name_description(search_entry, _("Search entry"), _("Search for a specific ID Card"));
795 this.search_entry.set_icon_from_pixbuf(EntryIconPosition.PRIMARY,
796 find_icon_sized("edit-find", Gtk.IconSize.MENU));
797 // find_icon_sized("edit-find-symbolic", Gtk.IconSize.MENU));
798 this.search_entry.set_icon_tooltip_text(EntryIconPosition.PRIMARY,
799 _("Search for an identity or service"));
800 this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, false);
802 this.search_entry.set_icon_from_pixbuf(EntryIconPosition.SECONDARY,
803 find_icon_sized("process-stop", Gtk.IconSize.MENU));
804 // find_icon_sized("edit-clear-symbolic", Gtk.IconSize.MENU));
805 this.search_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY,
806 _("Clear the current search"));
807 this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, false);
810 this.search_entry.icon_press.connect(search_entry_icon_press_cb);
811 this.search_entry.notify["text"].connect(search_entry_text_changed_cb);
812 this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
813 this.search_entry.set_width_chars(30);
816 this.custom_vbox = new CustomVBox(this, false, 2);
818 var viewport = new Viewport(null, null);
819 viewport.set_border_width(2);
820 viewport.set_shadow_type(ShadowType.NONE);
821 viewport.add(custom_vbox);
822 var id_scrollwin = new ScrolledWindow(null, null);
823 id_scrollwin.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
824 id_scrollwin.set_shadow_type(ShadowType.IN);
825 id_scrollwin.add_with_viewport(viewport);
826 this.prompting_service = new Label(_(""));
828 prompting_service.set_alignment(0, (float )0.5);
830 var vbox_left = new VBox(false, 0);
831 // vbox_left.pack_start(search_entry, false, false, 6);
832 // vbox_left.pack_start(id_scrollwin, true, true, 6);
834 var search_hbox = new HBox(false, 6);
835 var search_label = new Label(_("Search:"));
836 search_label.set_alignment(1, (float) 0.5);
837 set_atk_relation(search_label, search_entry, Atk.RelationType.LABEL_FOR);
838 search_hbox.pack_end(search_entry, false, false, 0);
839 search_hbox.pack_end(search_label, false, false, 6);
841 var full_search_label = new Label(_("Search for an identity or service"));
842 full_search_label.set_alignment(1, 1);
843 var search_vbox = new VBox(false, 4);
844 search_vbox.pack_start(search_hbox, false, false, 0);
845 search_vbox.pack_start(full_search_label, false, false, 0);
847 var inner_left_vbox = new VBox(false, 6);
848 inner_left_vbox.pack_start(search_vbox, false, false, 6);
849 inner_left_vbox.pack_start(id_scrollwin, true, true, 0);
851 var id_and_button_box = new HBox(false, 6);
852 id_and_button_box.pack_start(inner_left_vbox, true, true, 6);
853 vbox_left.pack_start(id_and_button_box, true, true, 0);
854 vbox_left.pack_start(prompting_service, false, false, 6);
855 vbox_left.set_size_request(WINDOW_WIDTH, 0);
857 this.no_identity_title = new Label(_("No Identity: Send this identity to services which should not use Moonshot"));
858 no_identity_title.set_alignment(0, (float ) 0.5);
859 no_identity_title.set_line_wrap(true);
860 no_identity_title.show();
862 var login_vbox_title = new Label(_("Login: "));
863 label_make_bold(login_vbox_title);
864 login_vbox_title.set_alignment(0, (float) 0.5);
865 // var issuer_label = new Label(_("Issuer:"));
866 // issuer_label.set_alignment(1, (float) 0.5);
867 // this.issuer_entry = new Entry();
868 // issuer_entry.set_can_focus(false);
869 // var username_label = new Label(_("Username:"));
870 // username_label.set_alignment(1, (float) 0.5);
871 // this.username_entry = new Entry();
872 // username_entry.set_can_focus(false);
873 // var password_label = new Label(_("Password:"));
874 // password_label.set_alignment(1, (float) 0.5);
875 // this.password_entry = new Entry();
876 // password_entry.set_invisible_char('*');
877 // password_entry.set_visibility(false);
878 // password_entry.set_sensitive(false);
879 // this.remember_checkbutton = new CheckButton.with_label(_("Remember password"));
880 // remember_checkbutton.set_sensitive(false);
882 // set_atk_relation(issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
883 // set_atk_relation(username_label, username_entry, Atk.RelationType.LABEL_FOR);
884 // set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR);
886 // // Create the login_vbox. This starts off hidden, because the first card we
887 // // display, by default, is NO_IDENTITY.
888 // var login_table = new Table(5, 2, false);
889 // login_table.set_col_spacings(10);
890 // login_table.set_row_spacings(10);
891 // login_table.attach_defaults(issuer_label, 0, 1, 0, 1);
892 // login_table.attach_defaults(issuer_entry, 1, 2, 0, 1);
893 // login_table.attach_defaults(username_label, 0, 1, 1, 2);
894 // login_table.attach_defaults(username_entry, 1, 2, 1, 2);
895 // login_table.attach_defaults(password_label, 0, 1, 2, 3);
896 // login_table.attach_defaults(password_entry, 1, 2, 2, 3);
897 // login_table.attach_defaults(remember_checkbutton, 1, 2, 3, 4);
898 // login_table.attach_defaults(update_password_button, 0, 1, 4, 5);
899 // var login_vbox_alignment = new Alignment(0, 0, 0, 0);
900 // login_vbox_alignment.set_padding(0, 0, 12, 0);
901 // login_vbox_alignment.add(login_table);
902 // this.login_vbox = new VBox(false, 6);
903 // login_vbox.pack_start(login_vbox_title, false, true, 0);
904 // login_vbox.pack_start(login_vbox_alignment, false, true, 0);
905 // login_vbox.hide();
907 // var services_vbox_title = new Label(_("Services:"));
908 // label_make_bold(services_vbox_title);
909 // services_vbox_title.set_alignment(0, (float) 0.5);
911 // this.services_internal_vbox = new VBox(true, 6);
913 // var services_vbox_alignment = new Alignment(0, 0, 0, 1);
914 // services_vbox_alignment.set_padding(6, 6, 6, 6);
915 // services_vbox_alignment.add(services_internal_vbox);
916 // services_vscroll = new ScrolledWindow(null, null);
917 // services_vscroll.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
918 // services_vscroll.set_shadow_type(ShadowType.IN);
919 // services_vscroll.add_with_viewport(services_vbox_alignment);
921 // services_vbox = new VBox(false, 6);
922 this.vbox_right = new VBox(false, 6);
923 // services_vbox.pack_start(services_vbox_title, false, false, 0);
924 // services_vbox.pack_start(services_vscroll, true, true, 0);
926 // vbox_right.pack_start(no_identity_title, true, false, 0);
927 // vbox_right.pack_start(login_vbox, false, false, 0);
928 // vbox_right.pack_start(services_vbox, true, true, 0);
930 var add_button = new Button.with_label(_("Add"));
931 add_button.clicked.connect((w) => {add_identity_cb();});
933 var edit_button = new Button.with_label(_("Edit"));
934 edit_button.clicked.connect((w) => {edit_identity_cb();});
936 var remove_button = new Button.with_label(_("Remove"));
937 remove_button.clicked.connect((w) => {remove_identity_cb(custom_vbox.current_idcard);});
939 var send_button = new Button.with_label(_("Send"));
940 send_button.clicked.connect((w) => {send_identity_cb(custom_vbox.current_idcard.id_card);});
943 var empty_box = new VBox(false, 0);
944 empty_box.set_size_request(0, 0);
945 vbox_right.pack_start(empty_box, false, false, 14);
946 vbox_right.pack_start(add_button, false, false, 6);
947 vbox_right.pack_start(edit_button, false, false, 6);
948 vbox_right.pack_start(remove_button, false, false, 6);
949 vbox_right.pack_start(send_button, false, false, 24);
951 //var hbox = new HBox(false, 12);
952 // hbox.pack_start(vbox_left, true, true, 0);
953 // hbox.pack_start(vbox_right, false, false, 0);
954 id_and_button_box.pack_start(vbox_right, false, false, 0);
955 var main_vbox = new VBox(false, 0);
956 main_vbox.set_border_width(12);
959 // hide the File | Quit menu item which is now on the Mac Menu
960 Gtk.Widget quit_item = this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
963 Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
964 osxApp.set_menu_bar(menushell);
965 osxApp.set_use_quartz_accelerators(true);
966 osxApp.sync_menu_bar();
969 var menubar = this.ui_manager.get_widget("/MenuBar");
970 main_vbox.pack_start(menubar, false, false, 0);
972 main_vbox.pack_start(vbox_left, true, true, 0);
974 main_vbox.show_all();
977 private void set_atk_name_description(Widget widget, string name, string description)
979 var atk_widget = widget.get_accessible();
981 atk_widget.set_name(name);
982 atk_widget.set_description(description);
985 private void connect_signals()
987 this.destroy.connect(Gtk.main_quit);
988 this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
991 private static void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
993 var atk_widget = widget.get_accessible();
994 var atk_target_widget = target_widget.get_accessible();
996 atk_widget.add_relationship(relationship, atk_target_widget);