From c13c41f51f8e5550d1f23d89f971bd3ba71c4c6f Mon Sep 17 00:00:00 2001 From: Dan Breslau Date: Sun, 24 Jul 2016 21:21:41 -0400 Subject: [PATCH] First pass at reskinning the main dialog (still need to update menu & detail views) --- src/moonshot-idcard-widget.vala | 68 +++++++++++++++++++----------- src/moonshot-identity-management-view.vala | 17 +++----- 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/moonshot-idcard-widget.vala b/src/moonshot-idcard-widget.vala index 6a9c8e8..269e38c 100644 --- a/src/moonshot-idcard-widget.vala +++ b/src/moonshot-idcard-widget.vala @@ -33,6 +33,8 @@ using Gtk; class IdCardWidget : Box { + static MoonshotLogger logger = get_logger("IdCardWidget"); + public IdCard id_card { get; set; default = null; } private VBox main_vbox; @@ -40,8 +42,9 @@ class IdCardWidget : Box 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; @@ -52,14 +55,18 @@ class IdCardWidget : Box 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(); @@ -67,7 +74,7 @@ class IdCardWidget : Box private bool button_press_cb() { - if (hbutton_box.get_visible()) + if (is_selected) collapse(); else expand(); @@ -94,7 +101,7 @@ class IdCardWidget : Box { var color = Gdk.Color(); - if (hbutton_box.get_visible() == false) + if (!is_selected) { color.red = 65535; color.green = 65535; @@ -102,30 +109,41 @@ class IdCardWidget : Box } 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("%s", this.id_card.display_name); - var display_name = Markup.printf_escaped("%s", 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("%s", service); - else - services_text = services_text + Markup.printf_escaped("%s, ", 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) @@ -149,10 +167,10 @@ class IdCardWidget : Box 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); @@ -161,7 +179,7 @@ class IdCardWidget : Box 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(); @@ -170,7 +188,7 @@ class IdCardWidget : Box this.pack_start(event_box, true, true); this.show_all(); - this.hbutton_box.hide(); +// this.hbutton_box.hide(); set_idcard_color(); } diff --git a/src/moonshot-identity-management-view.vala b/src/moonshot-identity-management-view.vala index 5ec2eab..94e628e 100644 --- a/src/moonshot-identity-management-view.vala +++ b/src/moonshot-identity-management-view.vala @@ -265,20 +265,17 @@ 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) { - 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(); @@ -293,7 +290,7 @@ public class IdentityManagerView : Window { login_vbox.show_all(); } - fill_services_vbox(id_card_widget.id_card); + fill_services_vbox(id_card); } } @@ -309,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); } @@ -371,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; } -- 2.1.4