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 ();
19 public void collapse ()
21 this.hbutton_box.set_visible (false);
26 private bool button_press_cb ()
28 this.hbutton_box.set_visible (!hbutton_box.get_visible ());
32 if (hbutton_box.get_visible () == true)
38 private void delete_button_cb ()
43 private void details_button_cb ()
48 private void set_idcard_color ()
50 var color = Gdk.Color ();
52 if (hbutton_box.get_visible () == false)
64 var state = this.get_state ();
65 this.event_box.modify_bg (state, color);
68 public IdCardWidget (IdCard id_card)
70 string services_text = "";
71 this.id_card = id_card;
73 var image = new Image.from_pixbuf (id_card.pixbuf);
75 var issuer = Markup.printf_escaped ("<b>%s</b>", this.id_card.issuer);
76 foreach (string service in id_card.services)
78 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
80 var text = issuer + "\n" + services_text;
82 var id_data_label = new Label (null);
83 id_data_label.set_markup (text);
84 id_data_label.set_alignment ((float) 0, (float) 0.5);
86 this.table = new Table (1, 2, false);
87 table.attach_defaults (image, 0, 1, 0, 1);
88 table.attach_defaults (id_data_label, 1, 2, 0, 1);
90 this.delete_button = new Button.with_label (_("Delete"));
91 this.details_button = new Button.with_label (_("View details"));
92 this.send_button = new Button.with_label (_("Send"));
93 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
94 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
95 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
96 this.hbutton_box = new HButtonBox ();
97 hbutton_box.pack_end (delete_button);
98 hbutton_box.pack_end (details_button);
99 hbutton_box.pack_end (send_button);
101 delete_button.clicked.connect (delete_button_cb);
102 details_button.clicked.connect (details_button_cb);
104 this.main_vbox = new VBox (false, 12);
105 main_vbox.pack_start (table, true, true, 0);
106 main_vbox.pack_start (hbutton_box, false, false, 0);
107 main_vbox.set_border_width (12);
109 event_box = new EventBox ();
110 event_box.add (main_vbox);
111 event_box.button_press_event.connect (button_press_cb);
112 this.pack_start (event_box, true, true);
115 this.hbutton_box.hide ();
120 private void set_atk_name_description (Widget widget, string name, string description)
122 var atk_widget = widget.get_accessible ();
124 atk_widget.set_name (name);
125 atk_widget.set_description (description);