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 display_name = Markup.printf_escaped ("<b>%s</b>", this.id_card.display_name);
83 for (int i=0; i<id_card.services.length; i++)
85 var service = id_card.services[i];
87 if (i == (id_card.services.length - 1))
88 services_text = services_text + Markup.printf_escaped ("<i>%s</i>", service);
90 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
92 var text = display_name + "\n" + services_text;
94 var id_data_label = new Label (null);
95 id_data_label.set_markup (text);
96 id_data_label.set_alignment ((float) 0, (float) 0.5);
98 this.table = new Table (1, 2, false);
99 table.attach_defaults (image, 0, 1, 0, 1);
100 table.attach_defaults (id_data_label, 1, 2, 0, 1);
102 this.delete_button = new Button.with_label (_("Delete"));
103 this.details_button = new Button.with_label (_("View details"));
104 this.send_button = new Button.with_label (_("Send"));
105 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
106 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
107 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
108 this.hbutton_box = new HButtonBox ();
109 hbutton_box.pack_end (delete_button);
110 hbutton_box.pack_end (details_button);
111 hbutton_box.pack_end (send_button);
113 delete_button.clicked.connect (delete_button_cb);
114 details_button.clicked.connect (details_button_cb);
115 send_button.clicked.connect (send_button_cb);
117 this.main_vbox = new VBox (false, 12);
118 main_vbox.pack_start (table, true, true, 0);
119 main_vbox.pack_start (hbutton_box, false, false, 0);
120 main_vbox.set_border_width (12);
122 event_box = new EventBox ();
123 event_box.add (main_vbox);
124 event_box.button_press_event.connect (button_press_cb);
125 this.pack_start (event_box, true, true);
128 this.hbutton_box.hide ();
133 private void set_atk_name_description (Widget widget, string name, string description)
135 var atk_widget = widget.get_accessible ();
137 atk_widget.set_name (name);
138 atk_widget.set_description (description);