X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fmoonshot-custom-vbox.vala;h=bc86729a4a8b8281f432f84d9a2e3ff212266f1d;hb=4001b9f4bf07db45f642c3ceab65bcd3c6279961;hp=55208f97c418003f0266bd831f35ee8ef1f6e6f7;hpb=fe758926d68ee515d12f6e87e644514e3c4ab921;p=moonshot-ui.git diff --git a/src/moonshot-custom-vbox.vala b/src/moonshot-custom-vbox.vala index 55208f9..bc86729 100644 --- a/src/moonshot-custom-vbox.vala +++ b/src/moonshot-custom-vbox.vala @@ -34,7 +34,6 @@ using Gtk; class CustomVBox : VBox { static MoonshotLogger logger = get_logger("CustomVBox"); - public IdCardWidget current_idcard { get; set; default = null; } private IdentityManagerView main_window; int next_pos = 0; @@ -45,7 +44,7 @@ class CustomVBox : VBox set_spacing(spacing); } - public void receive_expanded_event(IdCardWidget id_card_widget) + internal void receive_expanded_event(IdCardWidget id_card_widget) { var list = get_children(); foreach (Widget id_card in list) @@ -53,10 +52,12 @@ class CustomVBox : VBox if (id_card != id_card_widget) ((IdCardWidget) id_card).collapse(); } - current_idcard = id_card_widget; - // if (current_idcard != null && main_window.request_queue.length > 0) - // current_idcard.send_button.set_sensitive(true); + check_resize(); + } + + internal void receive_collapsed_event(IdCardWidget id_card_widget) + { check_resize(); } @@ -64,23 +65,29 @@ class CustomVBox : VBox { pack_start(id_card_widget, false, false); id_card_widget.position = next_pos++; - logger.trace("add_id_card_widget: Added idcard at position " + id_card_widget.position.to_string()); } - public void remove_id_card_widget(IdCardWidget id_card_widget) - { - logger.trace("remove_id_card_widget"); - - remove(id_card_widget); - - // Caller will eventually clear the list, re-setting all positions. I hope. + public IdCardWidget find_idcard_widget(IdCard id_card) { + foreach (var w in get_children()) { + IdCardWidget widget = (IdCardWidget) w; + if (widget.id_card.nai == id_card.nai) { + return widget; + } + } + return null; + } - // var list = get_children(); - // next_pos = 0; - // foreach (Widget id_card in list) - // { - // id_card_widget.position = next_pos++; - // } + public void remove_id_card(IdCard id_card) + { + logger.trace("remove_id_card: Have %u children".printf(get_children().length())); + var widget = find_idcard_widget(id_card); + if (widget != null) { + logger.trace(@"remove_id_card: Removing '$(id_card.display_name)'"); + remove(widget); + } + else { + logger.trace(@"remove_id_card: Couldn't find widget for '$(id_card.display_name)'"); + } } internal void clear() @@ -89,7 +96,7 @@ class CustomVBox : VBox var children = get_children(); foreach (var id_card_widget in children) { - remove_id_card_widget((IdCardWidget) id_card_widget); + remove(id_card_widget); } next_pos = 0;