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 = "";
80 var display_name = Markup.printf_escaped ("<b>%s</b>", this.id_card.display_name);
81 for (int i=0; i<id_card.services.length; i++)
83 var service = id_card.services[i];
85 if (i == (id_card.services.length - 1))
86 services_text = services_text + Markup.printf_escaped ("<i>%s</i>", service);
88 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
90 label.set_markup (display_name + "\n" + services_text);
93 public IdCardWidget (IdCard id_card)
95 this.id_card = id_card;
97 var image = new Image.from_pixbuf (id_card.pixbuf);
99 label = new Label (null);
100 label.set_alignment ((float) 0, (float) 0.5);
101 label.set_ellipsize (Pango.EllipsizeMode.END);
102 update_id_card_label();
104 table = new Gtk.HBox (false, 6);
105 table.pack_start (image, false, false, 0);
106 table.pack_start (label, true, true, 0);
108 this.delete_button = new Button.with_label (_("Delete"));
109 this.details_button = new Button.with_label (_("View details"));
110 this.send_button = new Button.with_label (_("Send"));
111 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
112 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
113 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
114 this.hbutton_box = new HButtonBox ();
115 hbutton_box.pack_end (delete_button);
116 hbutton_box.pack_end (details_button);
117 hbutton_box.pack_end (send_button);
118 send_button.set_sensitive (false);
120 delete_button.clicked.connect (delete_button_cb);
121 details_button.clicked.connect (details_button_cb);
122 send_button.clicked.connect (send_button_cb);
124 this.main_vbox = new VBox (false, 12);
125 main_vbox.pack_start (table, true, true, 0);
126 main_vbox.pack_start (hbutton_box, false, false, 0);
127 main_vbox.set_border_width (12);
129 event_box = new EventBox ();
130 event_box.add (main_vbox);
131 event_box.button_press_event.connect (button_press_cb);
132 this.pack_start (event_box, true, true);
135 this.hbutton_box.hide ();
140 private void set_atk_name_description (Widget widget, string name, string description)
142 var atk_widget = widget.get_accessible ();
144 atk_widget.set_name (name);
145 atk_widget.set_description (description);