X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fmoonshot-identity-management-view.vala;h=94e628e4fc04d2178b629bb72c428c3fb6711757;hb=c13c41f51f8e5550d1f23d89f971bd3ba71c4c6f;hp=4c343a96d20235bd01210cd15d0530ea984ae2f6;hpb=c64066e0fd6838caafba7cac51b00ea2980a717e;p=moonshot-ui.git diff --git a/src/moonshot-identity-management-view.vala b/src/moonshot-identity-management-view.vala index 4c343a9..94e628e 100644 --- a/src/moonshot-identity-management-view.vala +++ b/src/moonshot-identity-management-view.vala @@ -33,6 +33,8 @@ using Gee; using Gtk; public class IdentityManagerView : Window { + static MoonshotLogger logger = get_logger("IdentityManagerView"); + private const int WINDOW_WIDTH = 400; private const int WINDOW_HEIGHT = 500; protected IdentityManagerApp parent_app; @@ -46,7 +48,7 @@ public class IdentityManagerView : Window { private VBox services_vbox; private CustomVBox custom_vbox; private VBox services_internal_vbox; - + private ScrolledWindow services_vscroll; private Entry issuer_entry; private Entry username_entry; private Entry password_entry; @@ -177,11 +179,11 @@ public class IdentityManagerView : Window { private void setup_list_model() { - this.listmodel = new Gtk.ListStore (Columns.N_COLUMNS, typeof(IdCard), - typeof(Gdk.Pixbuf), - typeof(string), - typeof(string), - typeof(string)); + this.listmodel = new Gtk.ListStore(Columns.N_COLUMNS, typeof(IdCard), + typeof(Gdk.Pixbuf), + typeof(string), + typeof(string), + typeof(string)); this.filter = new TreeModelFilter(listmodel, null); filter.set_visible_func(visible_func); @@ -263,38 +265,32 @@ public class IdentityManagerView : Window { add_id_card_data(id_card); IdCardWidget id_card_widget = add_id_card_widget(id_card); if (id_card_widget.id_card.nai == current_idcard_nai) { - fill_details(id_card_widget); + fill_details(id_card_widget.id_card); id_card_widget.expand(); } } - if (custom_vbox.current_idcard == null) - fill_details(null); } - private void fill_details(IdCardWidget? id_card_widget) + private void fill_details(IdCard id_card) { - var vr_children = this.vbox_right.get_children(); - foreach (var vr_child in vr_children) { - this.vbox_right.remove(vr_child); - } - if (id_card_widget != null) { - var id_card = id_card_widget.id_card; + logger.trace("fill_details: id_card=%s".printf(id_card == null ? "null" : "non-null")); + + if (id_card != null) { if (id_card.display_name == IdCard.NO_IDENTITY) { - this.vbox_right.pack_start(no_identity_title, false, true, 0); + logger.trace("fill_details: Displaying title for NO_IDENTITY"); + login_vbox.hide(); + no_identity_title.show_all(); } else { + logger.trace("fill_details: Displaying details for selected card"); this.issuer_entry.set_text(id_card.issuer); this.username_entry.set_text(id_card.username); this.password_entry.set_text(id_card.password ?? ""); - this.vbox_right.pack_start(login_vbox, false, true, 0); this.remember_checkbutton.active = id_card.store_password; + no_identity_title.hide(); + login_vbox.show_all(); } - this.vbox_right.pack_start(services_vbox, false, true, 0); - var children = this.services_internal_vbox.get_children(); - foreach (var hbox in children) { - services_internal_vbox.remove(hbox); - } - fill_services_vbox(id_card_widget.id_card); + fill_services_vbox(id_card); } } @@ -310,7 +306,7 @@ public class IdentityManagerView : Window { private void details_identity_cb(IdCardWidget id_card_widget) { - fill_details(id_card_widget); + fill_details(id_card_widget.id_card); show_details(id_card_widget.id_card); } @@ -372,7 +368,7 @@ public class IdentityManagerView : Window { id_card_widget.remove_id.connect(remove_identity_cb); id_card_widget.send_id.connect((w) => send_identity_cb(w.id_card)); id_card_widget.expanded.connect(this.custom_vbox.receive_expanded_event); - id_card_widget.expanded.connect(fill_details); + id_card_widget.expanded.connect((w) => fill_details(w.id_card)); return id_card_widget; } @@ -567,7 +563,7 @@ public class IdentityManagerView : Window { public void send_identity_cb(IdCard id) { IdCard identity = id; - return_if_fail (request_queue.length > 0); + return_if_fail(request_queue.length > 0); candidates = null; var request = this.request_queue.pop_head(); @@ -613,13 +609,20 @@ public class IdentityManagerView : Window { private void fill_services_vbox(IdCard id_card) { + logger.trace("fill_services_vbox"); + + var children = this.services_internal_vbox.get_children(); + foreach (var widget in children) { + services_internal_vbox.remove(widget); + } + int i = 0; - var n_columns = id_card.services.length; + var n_rows = id_card.services.length; - var services_table = new Table(n_columns, 2, false); + var services_table = new Table(n_rows, 2, false); services_table.set_col_spacings(10); services_table.set_row_spacings(10); - this.services_internal_vbox.add(services_table); + this.services_internal_vbox.pack_start(services_table, true, false, 0); service_button_map.remove_all(); @@ -627,11 +630,11 @@ public class IdentityManagerView : Window { { var label = new Label(service); label.set_alignment(0, (float) 0.5); - #if VALA_0_12 - var remove_button = new Button.from_stock(Stock.REMOVE); - #else - var remove_button = new Button.from_stock(STOCK_REMOVE); - #endif +#if VALA_0_12 + var remove_button = new Button.from_stock(Stock.REMOVE); +#else + var remove_button = new Button.from_stock(STOCK_REMOVE); +#endif service_button_map.insert(remove_button, service); @@ -679,7 +682,8 @@ public class IdentityManagerView : Window { services_table.attach_defaults(remove_button, 1, 2, i, i+1); i++; } - this.services_internal_vbox.show_all(); + + services_vbox.show_all(); } private void on_about_action() @@ -803,6 +807,7 @@ SUCH DAMAGE. catch (Error e) { stderr.printf("%s\n", e.message); + logger.error("create_ui_manager: Caught error: " + e.message); } ui_manager.ensure_update(); } @@ -839,17 +844,17 @@ SUCH DAMAGE. viewport.set_border_width(6); viewport.set_shadow_type(ShadowType.NONE); viewport.add(custom_vbox); - var scroll = new ScrolledWindow(null, null); - scroll.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC); - scroll.set_shadow_type(ShadowType.IN); - scroll.add_with_viewport(viewport); + var id_scrollwin = new ScrolledWindow(null, null); + 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); var vbox_left = new VBox(false, 0); vbox_left.pack_start(search_entry, false, false, 6); - vbox_left.pack_start(scroll, true, true, 0); + vbox_left.pack_start(id_scrollwin, true, true, 0); vbox_left.pack_start(prompting_service, false, false, 6); vbox_left.set_size_request(WINDOW_WIDTH, 0); @@ -884,6 +889,8 @@ SUCH DAMAGE. set_atk_relation(username_label, username_entry, Atk.RelationType.LABEL_FOR); set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR); + // Create the login_vbox. This starts off hidden, because the first card we + // display, by default, is NO_IDENTITY. var login_table = new Table(5, 2, false); login_table.set_col_spacings(10); login_table.set_row_spacings(10); @@ -901,21 +908,30 @@ SUCH DAMAGE. this.login_vbox = new VBox(false, 6); login_vbox.pack_start(login_vbox_title, false, true, 0); login_vbox.pack_start(login_vbox_alignment, false, true, 0); + login_vbox.hide(); var services_vbox_title = new Label(_("Services:")); label_make_bold(services_vbox_title); services_vbox_title.set_alignment(0, (float) 0.5); - var services_vbox_alignment = new Alignment(0, 0, 0, 0); - services_vbox_alignment.set_padding(0, 0, 12, 0); + this.services_internal_vbox = new VBox(true, 6); + + var services_vbox_alignment = new Alignment(0, 0, 0, 1); + services_vbox_alignment.set_padding(6, 6, 6, 6); services_vbox_alignment.add(services_internal_vbox); - this.services_vbox = new VBox(false, 6); - services_vbox.pack_start(services_vbox_title, false, true, 0); - services_vbox.pack_start(services_vbox_alignment, false, true, 0); + services_vscroll = new ScrolledWindow(null, null); + services_vscroll.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC); + services_vscroll.set_shadow_type(ShadowType.IN); + services_vscroll.add_with_viewport(services_vbox_alignment); + services_vbox = new VBox(false, 6); this.vbox_right = new VBox(false, 18); - vbox_right.pack_start(login_vbox, false, true, 0); - vbox_right.pack_start(services_vbox, false, true, 0); + services_vbox.pack_start(services_vbox_title, false, false, 0); + services_vbox.pack_start(services_vscroll, true, true, 0); + + vbox_right.pack_start(no_identity_title, true, false, 0); + vbox_right.pack_start(login_vbox, false, false, 0); + vbox_right.pack_start(services_vbox, true, true, 0); var hbox = new HBox(false, 12); hbox.pack_start(vbox_left, false, false, 0); @@ -923,7 +939,7 @@ SUCH DAMAGE. var main_vbox = new VBox(false, 0); 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"); @@ -934,10 +950,10 @@ SUCH DAMAGE. osxApp.set_use_quartz_accelerators(true); osxApp.sync_menu_bar(); osxApp.ready(); - #else +#else var menubar = this.ui_manager.get_widget("/MenuBar"); main_vbox.pack_start(menubar, false, false, 0); - #endif +#endif main_vbox.pack_start(hbox, true, true, 0); add(main_vbox); main_vbox.show_all(); @@ -966,5 +982,3 @@ SUCH DAMAGE. atk_widget.add_relationship(relationship, atk_target_widget); } } - -