3 class IdCardWidget : Box
5 public IdCard id_card { get; set; default = null; }
7 private VBox main_vbox;
9 public Button delete_button { get; private set; default = null; }
10 public Button details_button { get; private set; default = null; }
11 public Button send_button { get; private set; default = null; }
12 private HButtonBox hbutton_box;
13 private EventBox event_box;
15 public signal void expanded ();
16 public signal void remove_id ();
17 public signal void details_id ();
18 public signal void send_id ();
20 public void collapse ()
22 this.hbutton_box.set_visible (false);
27 private bool button_press_cb ()
29 this.hbutton_box.set_visible (!hbutton_box.get_visible ());
33 if (hbutton_box.get_visible () == true)
39 private void delete_button_cb ()
44 private void details_button_cb ()
49 private void send_button_cb ()
54 private void set_idcard_color ()
56 var color = Gdk.Color ();
58 if (hbutton_box.get_visible () == false)
70 var state = this.get_state ();
71 this.event_box.modify_bg (state, color);
74 public IdCardWidget (IdCard id_card)
76 string services_text = "";
77 this.id_card = id_card;
79 var image = new Image.from_pixbuf (id_card.pixbuf);
81 var issuer = Markup.printf_escaped ("<b>%s</b>", this.id_card.issuer);
82 foreach (string service in id_card.services)
84 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
86 var text = issuer + "\n" + services_text;
88 var id_data_label = new Label (null);
89 id_data_label.set_markup (text);
90 id_data_label.set_alignment ((float) 0, (float) 0.5);
92 this.table = new Table (1, 2, false);
93 table.attach_defaults (image, 0, 1, 0, 1);
94 table.attach_defaults (id_data_label, 1, 2, 0, 1);
96 this.delete_button = new Button.with_label (_("Delete"));
97 this.details_button = new Button.with_label (_("View details"));
98 this.send_button = new Button.with_label (_("Send"));
99 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
100 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
101 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
102 this.hbutton_box = new HButtonBox ();
103 hbutton_box.pack_end (delete_button);
104 hbutton_box.pack_end (details_button);
105 hbutton_box.pack_end (send_button);
107 delete_button.clicked.connect (delete_button_cb);
108 details_button.clicked.connect (details_button_cb);
109 send_button.clicked.connect (send_button_cb);
111 this.main_vbox = new VBox (false, 12);
112 main_vbox.pack_start (table, true, true, 0);
113 main_vbox.pack_start (hbutton_box, false, false, 0);
114 main_vbox.set_border_width (12);
116 event_box = new EventBox ();
117 event_box.add (main_vbox);
118 event_box.button_press_event.connect (button_press_cb);
119 this.pack_start (event_box, true, true);
122 this.hbutton_box.hide ();
127 private void set_atk_name_description (Widget widget, string name, string description)
129 var atk_widget = widget.get_accessible ();
131 atk_widget.set_name (name);
132 atk_widget.set_description (description);