mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 09:04:55 +00:00
![Thomas Haller](/assets/img/avatar_default.png)
```bash readarray -d '' FILES < <( git ls-files -z \ ':(exclude)po' \ ':(exclude)shared/c-rbtree' \ ':(exclude)shared/c-list' \ ':(exclude)shared/c-siphash' \ ':(exclude)shared/c-stdaux' \ ':(exclude)shared/n-acd' \ ':(exclude)shared/n-dhcp4' \ ':(exclude)src/systemd/src' \ ':(exclude)shared/systemd/src' \ ':(exclude)m4' \ ':(exclude)COPYING*' ) sed \ -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \ -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \ -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \ -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \ -i \ "${FILES[@]}" echo ">>> untouched Copyright lines" git grep Copyright "${FILES[@]}" echo ">>> Copyright lines with unusual extra" git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved sed \ -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \ -i \ "${FILES[@]}" ``` https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
114 lines
2.9 KiB
C
114 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2013 Red Hat, Inc.
|
|
*/
|
|
|
|
/**
|
|
* SECTION:nmtui-hostname
|
|
* @short_description: hostname-setting functionality
|
|
*
|
|
* nmtui-hostname implements the "set hostname" functionality
|
|
*/
|
|
|
|
#include "nm-default.h"
|
|
|
|
#include "nmt-newt.h"
|
|
|
|
#include "nmtui.h"
|
|
#include "nmtui-hostname.h"
|
|
#include "nmt-utils.h"
|
|
|
|
static char *
|
|
nmtui_hostname_run_dialog (void)
|
|
{
|
|
NmtNewtForm *form;
|
|
NmtNewtWidget *widget, *ok, *cancel;
|
|
NmtNewtGrid *grid;
|
|
NmtNewtEntry *entry;
|
|
NmtNewtButtonBox *bbox;
|
|
char *hostname, *ret = NULL;
|
|
|
|
form = g_object_new (NMT_TYPE_NEWT_FORM,
|
|
"title", _("Set Hostname"),
|
|
"escape-exits", TRUE,
|
|
NULL);
|
|
|
|
widget = nmt_newt_grid_new ();
|
|
nmt_newt_form_set_content (form, widget);
|
|
grid = NMT_NEWT_GRID (widget);
|
|
|
|
widget = nmt_newt_label_new (_("Hostname"));
|
|
nmt_newt_grid_add (grid, widget, 0, 0);
|
|
|
|
widget = nmt_newt_entry_new (40, 0);
|
|
nmt_newt_widget_set_exit_on_activate (widget, TRUE);
|
|
nmt_newt_grid_add (grid, widget, 1, 0);
|
|
nmt_newt_widget_set_padding (widget, 1, 0, 0, 0);
|
|
entry = NMT_NEWT_ENTRY (widget);
|
|
|
|
widget = nmt_newt_button_box_new (NMT_NEWT_BUTTON_BOX_HORIZONTAL);
|
|
nmt_newt_grid_add (grid, widget, 1, 1);
|
|
nmt_newt_widget_set_padding (widget, 0, 1, 0, 0);
|
|
bbox = NMT_NEWT_BUTTON_BOX (widget);
|
|
|
|
cancel = nmt_newt_button_box_add_end (bbox, _("Cancel"));
|
|
nmt_newt_widget_set_exit_on_activate (cancel, TRUE);
|
|
ok = nmt_newt_button_box_add_end (bbox, _("OK"));
|
|
nmt_newt_widget_set_exit_on_activate (ok, TRUE);
|
|
|
|
g_object_get (G_OBJECT (nm_client),
|
|
NM_CLIENT_HOSTNAME, &hostname,
|
|
NULL);
|
|
nmt_newt_entry_set_text (entry, hostname);
|
|
g_free (hostname);
|
|
|
|
widget = nmt_newt_form_run_sync (form);
|
|
if (widget == (NmtNewtWidget *)entry || widget == ok)
|
|
ret = g_strdup (nmt_newt_entry_get_text (entry));
|
|
|
|
g_object_unref (form);
|
|
return ret;
|
|
}
|
|
|
|
static void
|
|
hostname_set (GObject *object,
|
|
GAsyncResult *result,
|
|
gpointer op)
|
|
{
|
|
GError *error = NULL;
|
|
|
|
nm_client_save_hostname_finish (NM_CLIENT (object), result, &error);
|
|
nmt_sync_op_complete_boolean (op, error == NULL, error);
|
|
g_clear_error (&error);
|
|
}
|
|
|
|
NmtNewtForm *
|
|
nmtui_hostname (gboolean is_top, int argc, char **argv)
|
|
{
|
|
const char *hostname;
|
|
char *tmp = NULL;
|
|
NmtSyncOp op;
|
|
GError *error = NULL;
|
|
|
|
if (argc == 2)
|
|
hostname = argv[1];
|
|
else
|
|
hostname = tmp = nmtui_hostname_run_dialog ();
|
|
|
|
if (hostname) {
|
|
nmt_sync_op_init (&op);
|
|
nm_client_save_hostname_async (nm_client, hostname, NULL, hostname_set, &op);
|
|
if (nmt_sync_op_wait_boolean (&op, &error)) {
|
|
/* TRANSLATORS: this indicates the result. ie, "I have set the hostname to ..." */
|
|
nmt_newt_message_dialog (_("Set hostname to '%s'"), hostname);
|
|
} else {
|
|
nmt_newt_message_dialog (_("Unable to set hostname: %s"), error->message);
|
|
g_error_free (error);
|
|
}
|
|
|
|
g_free (tmp);
|
|
}
|
|
|
|
return NULL;
|
|
}
|