add_connection_buttons (NMConnectionList *self,
                        const char *prefix,
                        GtkTreeView *treeview,
                        GType ctype,
                        PageNewConnectionFunc new_func)
{
	char *name;
	GtkWidget *button, *hbox;
	ActionInfo *info;
	GtkTreeSelection *selection;
	PolKitGnomeAction *action = NULL;

	selection = gtk_tree_view_get_selection (treeview);

	/* Add */
	name = g_strdup_printf ("%s_add", prefix);
	button = glade_xml_get_widget (self->gui, name);
	g_free (name);
	info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
	g_signal_connect (button, "clicked", G_CALLBACK (add_connection_clicked), info);
	if (ctype == NM_TYPE_SETTING_VPN) {
		GHashTable *plugins;

		/* disable the "Add..." button if there aren't any VPN plugins */
		plugins = vpn_get_plugins (NULL);
		gtk_widget_set_sensitive (button, (plugins && g_hash_table_size (plugins)));
	}
	if (new_func)
		action_info_set_new_func (info, new_func);

	name = g_strdup_printf ("%s_button_box", prefix);
	hbox = glade_xml_get_widget (self->gui, name);
	g_free (name);

	/* Edit */
	info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
	action = NULL;
	button = create_system_action_button ("system-edit",
	                                      _("Edit..."),
	                                      _("Authenticate to edit the selected connection."),
	                                      _("Edit"),
	                                      _("Edit the selected connection."),
	                                      GTK_STOCK_EDIT,
	                                      GTK_STOCK_DIALOG_AUTHENTICATION,
	                                      G_CALLBACK (system_pk_result_changed_cb),
	                                      hbox,
	                                      &action,
	                                      info);
	action_info_set_button (info, button, action);
	g_signal_connect (button, "clicked", G_CALLBACK (edit_connection_cb), info);
	g_signal_connect (treeview, "row-activated", G_CALLBACK (connection_double_clicked_cb), info);
	g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), info);
	pk_button_selection_changed_cb (selection, info);

	/* Delete */
	info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
	action = NULL;
	button = create_system_action_button ("system-delete",
	                                      _("Delete..."),
	                                      _("Authenticate to delete the selected connection."),
	                                      _("Delete"),
	                                      _("Delete the selected connection."),
	                                      GTK_STOCK_DELETE,
	                                      GTK_STOCK_DIALOG_AUTHENTICATION,
	                                      G_CALLBACK (system_pk_result_changed_cb),
	                                      hbox,
	                                      &action,
	                                      info);
	action_info_set_button (info, button, action);
	g_signal_connect (button, "clicked", G_CALLBACK (delete_connection_cb), info);
	g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), info);
	pk_button_selection_changed_cb (selection, info);

	/* Import */
	name = g_strdup_printf ("%s_import", prefix);
	button = glade_xml_get_widget (self->gui, name);
	g_free (name);
	if (button) {
		gboolean import_supported = FALSE;

		info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button, self->system_action);
		g_signal_connect (button, "clicked", G_CALLBACK (import_vpn_cb), info);

		g_hash_table_foreach (vpn_get_plugins (NULL), check_vpn_import_supported, &import_supported);
		gtk_widget_set_sensitive (button, import_supported);
	}

	/* Export */
	name = g_strdup_printf ("%s_export", prefix);
	button = glade_xml_get_widget (self->gui, name);
	g_free (name);
	if (button) {
		info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button, self->system_action);
		g_signal_connect (button, "clicked", G_CALLBACK (export_vpn_cb), info);
		g_signal_connect (selection, "changed", G_CALLBACK (vpn_list_selection_changed_cb), info);
		gtk_widget_set_sensitive (button, FALSE);
	}
}