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);
31 this.hbutton_box.set_visible (true);
37 private bool button_press_cb ()
39 if (hbutton_box.get_visible ())
47 private void delete_button_cb ()
52 private void details_button_cb ()
57 private void send_button_cb ()
62 private void set_idcard_color ()
64 var color = Gdk.Color ();
66 if (hbutton_box.get_visible () == false)
78 var state = this.get_state ();
79 this.event_box.modify_bg (state, color);
83 update_id_card_label ()
85 string services_text = "";
87 var display_name = Markup.printf_escaped ("<big>%s</big>", this.id_card.display_name);
88 for (int i=0; i<id_card.services.length; i++)
90 var service = id_card.services[i];
92 if (i == (id_card.services.length - 1))
93 services_text = services_text + Markup.printf_escaped ("<i>%s</i>", service);
95 services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
97 label.set_markup (display_name + "\n" + services_text);
100 public IdCardWidget (IdCard id_card)
102 this.id_card = id_card;
104 var image = new Image.from_pixbuf (get_pixbuf(id_card));
106 label = new Label (null);
107 label.set_alignment ((float) 0, (float) 0.5);
108 label.set_ellipsize (Pango.EllipsizeMode.END);
109 update_id_card_label();
111 table = new Gtk.HBox (false, 6);
112 table.pack_start (image, false, false, 0);
113 table.pack_start (label, true, true, 0);
115 this.delete_button = new Button.with_label (_("Delete"));
116 this.details_button = new Button.with_label (_("View details"));
117 this.send_button = new Button.with_label (_("Send"));
118 set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
119 set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
120 set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
121 this.hbutton_box = new HButtonBox ();
122 hbutton_box.pack_end (delete_button);
123 hbutton_box.pack_end (details_button);
124 hbutton_box.pack_end (send_button);
125 send_button.set_sensitive (false);
127 delete_button.clicked.connect (delete_button_cb);
128 details_button.clicked.connect (details_button_cb);
129 send_button.clicked.connect (send_button_cb);
131 this.main_vbox = new VBox (false, 12);
132 main_vbox.pack_start (table, true, true, 0);
133 main_vbox.pack_start (hbutton_box, false, false, 0);
134 main_vbox.set_border_width (12);
136 event_box = new EventBox ();
137 event_box.add (main_vbox);
138 event_box.button_press_event.connect (button_press_cb);
139 this.pack_start (event_box, true, true);
142 this.hbutton_box.hide ();
147 private void set_atk_name_description (Widget widget, string name, string description)
149 var atk_widget = widget.get_accessible ();
151 atk_widget.set_name (name);
152 atk_widget.set_description (description);