Commit a63c4d08 authored by Thomas Haller's avatar Thomas Haller

cli: use designated initializers for setting NmcOutputField fields

Otherwise, changing the structure is difficult because it all depends
on the order (and you don't immdiately see which field is used where).

Also, drop the name_l10n field.
parent f5a0b627
......@@ -37,44 +37,46 @@
extern GMainLoop *loop;
#define OUTPUT_FIELD_WITH_NAME(n) { .name = N_ (n), }
/* Available fields for IPv4 group */
NmcOutputField nmc_fields_ip4_config[] = {
{"GROUP", N_("GROUP")}, /* 0 */
{"ADDRESS", N_("ADDRESS")}, /* 1 */
{"GATEWAY", N_("GATEWAY")}, /* 2 */
{"ROUTE", N_("ROUTE")}, /* 3 */
{"DNS", N_("DNS")}, /* 4 */
{"DOMAIN", N_("DOMAIN")}, /* 5 */
{"WINS", N_("WINS")}, /* 6 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("GROUP"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("ADDRESS"), /* 1 */
OUTPUT_FIELD_WITH_NAME ("GATEWAY"), /* 2 */
OUTPUT_FIELD_WITH_NAME ("ROUTE"), /* 3 */
OUTPUT_FIELD_WITH_NAME ("DNS"), /* 4 */
OUTPUT_FIELD_WITH_NAME ("DOMAIN"), /* 5 */
OUTPUT_FIELD_WITH_NAME ("WINS"), /* 6 */
{ 0 }
};
#define NMC_FIELDS_IP4_CONFIG_ALL "GROUP,ADDRESS,GATEWAY,ROUTE,DNS,DOMAIN,WINS"
/* Available fields for DHCPv4 group */
NmcOutputField nmc_fields_dhcp4_config[] = {
{"GROUP", N_("GROUP")}, /* 0 */
{"OPTION", N_("OPTION")}, /* 1 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("GROUP"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("OPTION"), /* 1 */
{ 0 }
};
#define NMC_FIELDS_DHCP4_CONFIG_ALL "GROUP,OPTION"
/* Available fields for IPv6 group */
NmcOutputField nmc_fields_ip6_config[] = {
{"GROUP", N_("GROUP")}, /* 0 */
{"ADDRESS", N_("ADDRESS")}, /* 1 */
{"GATEWAY", N_("GATEWAY")}, /* 2 */
{"ROUTE", N_("ROUTE")}, /* 3 */
{"DNS", N_("DNS")}, /* 4 */
{"DOMAIN", N_("DOMAIN")}, /* 5 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("GROUP"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("ADDRESS"), /* 1 */
OUTPUT_FIELD_WITH_NAME ("GATEWAY"), /* 2 */
OUTPUT_FIELD_WITH_NAME ("ROUTE"), /* 3 */
OUTPUT_FIELD_WITH_NAME ("DNS"), /* 4 */
OUTPUT_FIELD_WITH_NAME ("DOMAIN"), /* 5 */
{ 0 }
};
#define NMC_FIELDS_IP6_CONFIG_ALL "GROUP,ADDRESS,GATEWAY,ROUTE,DNS,DOMAIN"
/* Available fields for DHCPv6 group */
NmcOutputField nmc_fields_dhcp6_config[] = {
{"GROUP", N_("GROUP")}, /* 0 */
{"OPTION", N_("OPTION")}, /* 1 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("GROUP"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("OPTION"), /* 1 */
{ 0 }
};
#define NMC_FIELDS_DHCP6_CONFIG_ALL "GROUP,OPTION"
......
This diff is collapsed.
This diff is collapsed.
......@@ -34,21 +34,23 @@
#include "devices.h"
#include "connections.h"
#define OUTPUT_FIELD_WITH_NAME(n) { .name = N_ (n), }
/* Available fields for 'general status' */
static NmcOutputField nmc_fields_nm_status[] = {
{"RUNNING", N_("RUNNING")}, /* 0 */
{"VERSION", N_("VERSION")}, /* 1 */
{"STATE", N_("STATE")}, /* 2 */
{"STARTUP", N_("STARTUP")}, /* 3 */
{"CONNECTIVITY", N_("CONNECTIVITY")}, /* 4 */
{"NETWORKING", N_("NETWORKING")}, /* 5 */
{"WIFI-HW", N_("WIFI-HW")}, /* 6 */
{"WIFI", N_("WIFI")}, /* 7 */
{"WWAN-HW", N_("WWAN-HW")}, /* 8 */
{"WWAN", N_("WWAN")}, /* 9 */
{"WIMAX-HW", N_("WIMAX-HW")}, /* 10 */
{"WIMAX", N_("WIMAX")}, /* 11 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("RUNNING"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("VERSION"), /* 1 */
OUTPUT_FIELD_WITH_NAME ("STATE"), /* 2 */
OUTPUT_FIELD_WITH_NAME ("STARTUP"), /* 3 */
OUTPUT_FIELD_WITH_NAME ("CONNECTIVITY"), /* 4 */
OUTPUT_FIELD_WITH_NAME ("NETWORKING"), /* 5 */
OUTPUT_FIELD_WITH_NAME ("WIFI-HW"), /* 6 */
OUTPUT_FIELD_WITH_NAME ("WIFI"), /* 7 */
OUTPUT_FIELD_WITH_NAME ("WWAN-HW"), /* 8 */
OUTPUT_FIELD_WITH_NAME ("WWAN"), /* 9 */
OUTPUT_FIELD_WITH_NAME ("WIMAX-HW"), /* 10 */
OUTPUT_FIELD_WITH_NAME ("WIMAX"), /* 11 */
{ 0 }
};
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,VERSION,STATE,STARTUP,CONNECTIVITY,NETWORKING,WIFI-HW,WIFI,WWAN-HW,WWAN"
#define NMC_FIELDS_NM_STATUS_SWITCH "NETWORKING,WIFI-HW,WIFI,WWAN-HW,WWAN"
......@@ -63,18 +65,18 @@ static NmcOutputField nmc_fields_nm_status[] = {
/* Available fields for 'general permissions' */
static NmcOutputField nmc_fields_nm_permissions[] = {
{"PERMISSION", N_("PERMISSION")}, /* 0 */
{"VALUE", N_("VALUE")}, /* 1 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("PERMISSION"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("VALUE"), /* 1 */
{ 0 }
};
#define NMC_FIELDS_NM_PERMISSIONS_ALL "PERMISSION,VALUE"
#define NMC_FIELDS_NM_PERMISSIONS_COMMON "PERMISSION,VALUE"
/* Available fields for 'general logging' */
static NmcOutputField nmc_fields_nm_logging[] = {
{"LEVEL", N_("LEVEL")}, /* 0 */
{"DOMAINS", N_("DOMAINS")}, /* 1 */
{NULL, NULL}
OUTPUT_FIELD_WITH_NAME ("LEVEL"), /* 0 */
OUTPUT_FIELD_WITH_NAME ("DOMAINS"), /* 1 */
{ 0 }
};
#define NMC_FIELDS_NM_LOGGING_ALL "LEVEL,DOMAINS"
#define NMC_FIELDS_NM_LOGGING_COMMON "LEVEL,DOMAINS"
......
......@@ -108,7 +108,6 @@ struct _NMMetaSettingInfoEditor;
typedef struct _NmcOutputField {
const char *name; /* Field's name */
const char *name_l10n; /* Field's name for translation */
int width; /* Width in screen columns */
const struct _NmcOutputField *group_list; /* Points to an array with available section field names if this is a section (group) field */
void *value; /* Value of current field - char* or char** (NULL-terminated array) */
......
......@@ -167,7 +167,6 @@ _get_nmc_output_fields (const NMMetaSettingInfoEditor *setting_info)
NmcOutputField *f = &(*field)[i];
f->name = setting_info->properties[i].property_name;
f->name_l10n = setting_info->properties[i].property_name;
}
}
......
......@@ -831,7 +831,7 @@ get_value_to_print (NmCli *nmc,
gboolean free_value;
if (field_name)
value = _(field->name_l10n);
value = _(field->name);
else
value = field->value
? (is_array
......@@ -941,7 +941,7 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
tmp = g_strdup_printf ("%s%s%s[%d]:",
section_prefix ? (const char*) field_values[0].value : "",
section_prefix ? "." : "",
_(field_values[idx].name_l10n),
_(field_values[idx].name),
j);
width1 = strlen (tmp);
width2 = nmc_string_screen_width (tmp, NULL);
......@@ -961,7 +961,7 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
tmp = g_strdup_printf ("%s%s%s:",
section_prefix ? hdr_name : "",
section_prefix ? "." : "",
_(field_values[idx].name_l10n));
_(field_values[idx].name));
width1 = strlen (tmp);
width2 = nmc_string_screen_width (tmp, NULL);
g_print ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp, print_val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment