092543fa6cbeac8416346dc6b65c1d17c53c6eff
[moonshot-ui.git] / src / moonshot-idcard-widget.vala
1 using Gtk;
2
3 class IdCardWidget : Box
4 {
5     private VBox main_vbox;
6     private Table table;
7     private HButtonBox hbutton_box;
8
9     private bool button_press_cb ()
10     {
11         this.hbutton_box.set_visible (!hbutton_box.get_visible ());
12
13         return false;
14     }
15
16     public IdCardWidget ()
17     {
18         Gdk.Pixbuf pixbuf;
19
20         var icon_theme = IconTheme.get_default ();
21         try
22         {
23             pixbuf = icon_theme.load_icon ("avatar-default",
24                                            48,
25                                            IconLookupFlags.FORCE_SIZE);
26         }
27         catch (Error e)
28         {
29             pixbuf = null;
30             stdout.printf("Error: %s\n", e.message);
31         }
32         var image = new Image.from_pixbuf (pixbuf);
33
34         var issuer = Markup.printf_escaped ("<b>%s</b>", "University");
35         var services = Markup.printf_escaped ("<i>%s</i>", "Send Email, Connect to jabber");
36         var text = issuer + "\n" + services;
37
38         var id_data_label = new Label (null);
39         id_data_label.set_markup (text);
40
41         this.table = new Table (1, 2, false);
42         table.attach_defaults (image, 0, 1, 0, 1);
43         table.attach_defaults (id_data_label, 1, 2, 0, 1);
44
45         var delete_button = new Button.with_label ("Delete");
46         var details_button = new Button.with_label ("View details");
47         var send_button = new Button.with_label ("Send");
48         this.hbutton_box = new HButtonBox ();
49         hbutton_box.pack_end (delete_button);
50         hbutton_box.pack_end (details_button);
51         hbutton_box.pack_end (send_button);
52
53         this.main_vbox = new VBox (false, 12);
54         main_vbox.pack_start (table, true, true, 0);
55         main_vbox.pack_start (hbutton_box, false, false, 0);
56         main_vbox.set_border_width (12);
57
58         var event_box = new EventBox ();
59         event_box.add (main_vbox);
60         event_box.button_press_event.connect (button_press_cb);
61         add (event_box);
62
63         event_box.show_all ();
64         this.hbutton_box.hide ();
65     }
66 }