static void
add_connection_buttons (NMConnectionList *self)
{
	GtkWidget *button, *box;
	GtkTreeSelection *selection;

	selection = gtk_tree_view_get_selection (self->connection_list);

	/* Add */
	button = GTK_WIDGET (gtk_builder_get_object (self->gui, "connection_add"));
	g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), self);

	box = GTK_WIDGET (gtk_builder_get_object (self->gui, "connection_button_box"));

	/* Edit */
	button = ce_polkit_button_new (_("_Edit"),
	                               _("Edit the selected connection"),
	                               _("_Edit..."),
	                               _("Authenticate to edit the selected connection"),
	                               GTK_STOCK_EDIT,
	                               self->nm_client,
	                               NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
	g_object_set_data (G_OBJECT (button), "NMConnectionList", self);
	gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
	gtk_box_pack_end (GTK_BOX (box), button, TRUE, TRUE, 0);

	g_signal_connect_swapped (button, "clicked", G_CALLBACK (do_edit), self);
	g_signal_connect (self->connection_list, "row-activated", G_CALLBACK (connection_double_clicked_cb), button);
	g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), button);
	pk_button_selection_changed_cb (selection, button);

	/* Delete */
	button = ce_polkit_button_new (_("_Delete"),
	                               _("Delete the selected connection"),
	                               _("_Delete..."),
	                               _("Authenticate to delete the selected connection"),
	                               GTK_STOCK_DELETE,
	                               self->nm_client,
	                               NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
	g_object_set_data (G_OBJECT (button), "NMConnectionList", self);
	gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
	gtk_box_pack_end (GTK_BOX (box), button, TRUE, TRUE, 0);

	g_signal_connect (button, "clicked", G_CALLBACK (delete_clicked), self);
	g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), button);
	pk_button_selection_changed_cb (selection, button);

	gtk_widget_show_all (box);
}
NMConnectionEditor *
nm_connection_editor_new (GtkWindow *parent_window,
                          NMConnection *connection,
                          NMClient *client)
{
	NMConnectionEditor *editor;
	GtkWidget *hbox;
	gboolean is_new;
	GError *error = NULL;

	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);

	is_new = !nm_client_get_connection_by_uuid (client, nm_connection_get_uuid (connection));

	editor = g_object_new (NM_TYPE_CONNECTION_EDITOR, NULL);
	editor->parent_window = parent_window ? g_object_ref (parent_window) : NULL;
	editor->client = g_object_ref (client);
	editor->is_new_connection = is_new;

	editor->can_modify = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
	editor->permission_id = g_signal_connect (editor->client,
	                                          "permission-changed",
	                                          G_CALLBACK (permissions_changed_cb),
	                                          editor);

	editor->ok_button = ce_polkit_button_new (_("_Save"),
	                                          _("Save any changes made to this connection."),
	                                          _("Authenticate to save this connection for all users of this machine."),
	                                          GTK_STOCK_APPLY,
	                                          client,
	                                          NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
	gtk_button_set_use_underline (GTK_BUTTON (editor->ok_button), TRUE);

	g_signal_connect (editor->ok_button, "actionable",
	                  G_CALLBACK (ok_button_actionable_cb), editor);
	g_signal_connect (editor->ok_button, "authorized",
	                  G_CALLBACK (ok_button_actionable_cb), editor);
	hbox = GTK_WIDGET (gtk_builder_get_object (editor->builder, "action_area_hbox"));
	gtk_box_pack_end (GTK_BOX (hbox), editor->ok_button, TRUE, TRUE, 0);
	gtk_widget_show_all (editor->ok_button);

	if (!nm_connection_editor_set_connection (editor, connection, &error)) {
		nm_connection_editor_error (parent_window,
		                            is_new ? _("Could not create connection") : _("Could not edit connection"),
		                            "%s",
		                            error ? error->message : _("Unknown error creating connection editor dialog."));
		g_clear_error (&error);
		g_object_unref (editor);
		return NULL;
	}

	if (!active_editors)
		active_editors = g_hash_table_new_full (NULL, NULL, g_object_unref, NULL);
	g_hash_table_insert (active_editors, g_object_ref (connection), editor);

	return editor;
}