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;
17 public signal void expanded ();
18 public signal void remove_id ();
19 public signal void details_id ();
20 public signal void send_id ();
22 public void collapse ()
24 this.hbutton_box.set_visible (false);
29 private bool button_press_cb ()
31 this.hbutton_box.set_visible (!hbutton_box.get_visible ());
35 if (hbutton_box.get_visible () == true)
41 private void delete_button_cb ()
46 private void details_button_cb ()
51 private void send_button_cb ()
56 private void set_idcard_color ()
58 var color = Gdk.Color ();
60 if (hbutton_box.get_visible () == false)
72 var state = this.get_state ();
73 this.event_box.modify_bg (state, color);
77 update_id_card_label ()
79 string services_text = "";
81 var display_name = Markup.printf_escaped ("<big><b>%s</b></big>", this.id_card.display_name);
82 var issued_by = Markup.printf_escaped ("<i>%s</i>", _("Issued by: "));
83 var issuer_name = Markup.printf_escaped ("<i><b>%s</b></i>", this.id_card.issuer);
84 for (int i=0; i<id_card.services.length; i++)
86 var service = id_card.services[i];
88 if (i == (id_card.services.length - 1))
89 services_text = services_text + Markup.printf_escaped ("<i>%s</i>", service);
91 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
93 label.set_markup (display_name + "\n" + issued_by + issuer_name + "\n" + services_text);
96 public IdCardWidget (IdCard id_card)
98 this.id_card = id_card;
100 var image = new Image.from_pixbuf (id_card.get_data ("pixbuf"));
102 label = new Label (null);
103 label.set_alignment ((float) 0.5, (float) 0.5);
104 label.set_justify(Gtk.Justification.CENTER);
105 label.set_ellipsize (Pango.EllipsizeMode.END);
106 update_id_card_label();
108 table = new Gtk.HBox (false, 6);
109 table.pack_start (image, false, false, 0);
110 table.pack_start (label, true, true, 0);
112 this.delete_button = new Button.with_label (_("Delete"));
113 this.details_button = new Button.with_label (_("View details"));
114 this.send_button = new Button.with_label (_("Send"));
115 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
116 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
117 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
118 this.hbutton_box = new HButtonBox ();
119 hbutton_box.pack_end (delete_button);
120 hbutton_box.pack_end (details_button);
121 hbutton_box.pack_end (send_button);
122 send_button.set_sensitive (false);
124 delete_button.clicked.connect (delete_button_cb);
125 details_button.clicked.connect (details_button_cb);
126 send_button.clicked.connect (send_button_cb);
128 this.main_vbox = new VBox (false, 12);
129 main_vbox.pack_start (table, true, true, 0);
130 main_vbox.pack_start (hbutton_box, false, false, 0);
131 main_vbox.set_border_width (12);
133 event_box = new EventBox ();
134 event_box.add (main_vbox);
135 event_box.button_press_event.connect (button_press_cb);
136 this.pack_start (event_box, true, true);
139 this.hbutton_box.hide ();
144 private void set_atk_name_description (Widget widget, string name, string description)
146 var atk_widget = widget.get_accessible ();
148 atk_widget.set_name (name);
149 atk_widget.set_description (description);