+ var services_vbox = new VBox(false, 6);
+ services_vbox.pack_start(services_vbox_title, false, false, 6);
+ services_vbox.pack_start(table_button_hbox, true, true, 6);
+
+ int i = 0;
+ foreach (string service in card.services)
+ {
+ var label = new Label(service);
+ label.set_alignment((float) 0, (float) 0);
+
+ EventBox event_box = new EventBox();
+ event_box.modify_bg(StateType.NORMAL, white);
+ event_box.add(label);
+ event_box.button_press_event.connect(() =>
+ {
+ var state = label.get_state();
+ logger.trace("button_press_callback: Label state=" + state.to_string() + " setting bg to " + white.to_string());
+
+ if (selected_item == label)
+ {
+ // Deselect
+ selected_item.parent.modify_bg(state, white);
+ selected_item = null;
+ remove_button.set_sensitive(false);
+ }
+ else
+ {
+ if (selected_item != null)
+ {
+ // Deselect
+ selected_item.parent.modify_bg(state, white);
+ selected_item = null;
+ }
+
+ // Select
+ selected_item = label;
+ selected_item.parent.modify_bg(state, selected_color);
+ remove_button.set_sensitive(true);
+ }
+ return false;
+ });
+
+ AttachOptions opts = AttachOptions.EXPAND | AttachOptions.FILL;
+ services_table.attach(event_box, 0, 1, i, i+1, opts, opts, 3, 0);
+ i++;
+ }
+
+ remove_button.clicked.connect((remove_button) =>
+ {
+ var result = WarningDialog.confirm(this,
+ "<span font-weight='heavy'>You are about to remove the service '%s'.</span>"
+ .printf(selected_item.label)
+ + "\n\nAre you sure you want to do this?",
+ "delete_service");
+
+ if (result)
+ {
+ if (card != null) {
+ SList<string> services = new SList<string>();
+
+ foreach (string srv in card.services)
+ {
+ if (srv != selected_item.label)
+ services.append(srv);
+ }
+
+ card.services = new string[services.length()];
+ for (int j = 0; j < card.services.length; j++)
+ {
+ card.services[j] = services.nth_data(j);
+ }
+
+ services_table.remove(selected_item.parent);
+ selected_item = null;
+ remove_button.set_sensitive(false);
+ }
+ }
+
+ });
+
+ return services_vbox;