class IdCardWidget : Box
{
+ static MoonshotLogger logger = get_logger("IdCardWidget");
+
public IdCard id_card { get; set; default = null; }
private VBox main_vbox;
public Button delete_button { get; private set; default = null; }
public Button details_button { get; private set; default = null; }
public Button send_button { get; private set; default = null; }
- private HButtonBox hbutton_box;
+// private HButtonBox hbutton_box;
private EventBox event_box;
+ private bool is_selected = false;
private Label label;
public void collapse()
{
- this.hbutton_box.set_visible(false);
+// this.hbutton_box.set_visible(false);
+ is_selected = false;
+ update_id_card_label();
set_idcard_color();
}
public void expand()
{
- this.hbutton_box.set_visible(true);
+// this.hbutton_box.set_visible(true);
+ is_selected = true;
+ update_id_card_label();
set_idcard_color();
this.expanded();
private bool button_press_cb()
{
- if (hbutton_box.get_visible())
+ if (is_selected)
collapse();
else
expand();
{
var color = Gdk.Color();
- if (hbutton_box.get_visible() == false)
+ if (!is_selected)
{
color.red = 65535;
color.green = 65535;
}
else
{
- color.red = 33333;
- color.green = 33333;
- color.blue = 60000;
+
+ color.red = 0xd9 << 8;
+ color.green = 0xf7 << 8;
+ color.blue = 65535;
}
var state = this.get_state();
this.event_box.modify_bg(state, color);
}
- public void
+ private void
update_id_card_label()
{
- string services_text = "";
+ // !!TODO: Use a table to format the labels and values
+ string services_text = "Services: ";
+ string service_spacer = " ";
+
+ var label_text = Markup.printf_escaped("<big>%s</big>", this.id_card.display_name);
- var display_name = Markup.printf_escaped("<big>%s</big>", this.id_card.display_name);
- for (int i = 0; i < id_card.services.length; i++)
+ if (is_selected)
{
- var service = id_card.services[i];
-
- if (i == (id_card.services.length - 1))
- services_text = services_text + Markup.printf_escaped("<i>%s</i>", service);
- else
- services_text = services_text + Markup.printf_escaped("<i>%s, </i>", service);
+ label_text += "\nUsername: " + id_card.username;
+ label_text += "\nRealm: " + id_card.issuer;
+
+ var sep = "";
+ for (int i = 0; i < id_card.services.length; i++)
+ {
+ services_text += sep;
+ services_text += id_card.services[i];
+
+ sep = "\n" + service_spacer;
+ }
+ label_text += "\n" + services_text;
}
- label.set_markup(display_name + "\n" + services_text);
+
+ label.set_markup(label_text);
}
public IdCardWidget(IdCard id_card)
set_atk_name_description(delete_button, _("Delete"), _("Delete this ID Card"));
set_atk_name_description(details_button, _("Details"), _("View the details of this ID Card"));
set_atk_name_description(send_button, _("Send"), _("Send this ID Card"));
- this.hbutton_box = new HButtonBox();
- hbutton_box.pack_end(delete_button);
- hbutton_box.pack_end(details_button);
- hbutton_box.pack_end(send_button);
+ // this.hbutton_box = new HButtonBox();
+ // hbutton_box.pack_end(delete_button);
+ // hbutton_box.pack_end(details_button);
+ // hbutton_box.pack_end(send_button);
send_button.set_sensitive(false);
delete_button.clicked.connect(delete_button_cb);
this.main_vbox = new VBox(false, 12);
main_vbox.pack_start(table, true, true, 0);
- main_vbox.pack_start(hbutton_box, false, false, 0);
+// main_vbox.pack_start(hbutton_box, false, false, 0);
main_vbox.set_border_width(12);
event_box = new EventBox();
this.pack_start(event_box, true, true);
this.show_all();
- this.hbutton_box.hide();
+// this.hbutton_box.hide();
set_idcard_color();
}
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)
{
- logger.trace("fill_details: id_card_widget=%s".printf(id_card_widget == null ? "null" : "non-null"));
+ logger.trace("fill_details: id_card=%s".printf(id_card == null ? "null" : "non-null"));
- if (id_card_widget != null) {
- var id_card = id_card_widget.id_card;
+ if (id_card != null) {
if (id_card.display_name == IdCard.NO_IDENTITY) {
logger.trace("fill_details: Displaying title for NO_IDENTITY");
login_vbox.hide();
login_vbox.show_all();
}
- fill_services_vbox(id_card_widget.id_card);
+ fill_services_vbox(id_card);
}
}
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);
}
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;
}