static gchar * device_status_to_localized_string (NMDevice *nm_device, const gchar *speed) { NMDeviceState state; GString *string; const gchar *state_str = NULL, *reason_str = NULL; string = g_string_new (NULL); state = nm_device_get_state (nm_device); if (state == NM_DEVICE_STATE_UNAVAILABLE) { if (nm_device_get_firmware_missing (nm_device)) { /* TRANSLATORS: device status */ state_str = _("Firmware missing"); } else if (NM_IS_DEVICE_ETHERNET (nm_device) && !nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (nm_device))) { /* TRANSLATORS: device status */ state_str = _("Cable unplugged"); } else if (NM_IS_DEVICE_INFINIBAND (nm_device) && !nm_device_infiniband_get_carrier (NM_DEVICE_INFINIBAND (nm_device))) { state_str = _("Cable unplugged"); } } if (!state_str) state_str = device_state_to_localized_string (state); if (state_str) g_string_append (string, state_str); if (state > NM_DEVICE_STATE_UNAVAILABLE && speed) { if (string->len) g_string_append (string, " - "); g_string_append (string, speed); } else if (state == NM_DEVICE_STATE_UNAVAILABLE || state == NM_DEVICE_STATE_DISCONNECTED || state == NM_DEVICE_STATE_DEACTIVATING || state == NM_DEVICE_STATE_FAILED) { reason_str = device_state_reason_to_localized_string (nm_device); if (*reason_str) { if (string->len) g_string_append (string, " - "); g_string_append (string, reason_str); } } return g_string_free (string, FALSE); }
/** * panel_device_state_to_localized_string: **/ const gchar * panel_device_state_to_localized_string (NMDevice *device) { NMDeviceType type; NMDeviceState state; type = nm_device_get_device_type (device); state = nm_device_get_state (device); const gchar *value = NULL; switch (state) { case NM_DEVICE_STATE_UNKNOWN: /* TRANSLATORS: device status */ value = _("Status unknown"); break; case NM_DEVICE_STATE_UNMANAGED: /* TRANSLATORS: device status */ value = _("Unmanaged"); break; case NM_DEVICE_STATE_UNAVAILABLE: /* TRANSLATORS: device status */ if (nm_device_get_firmware_missing (device)) value = _("Firmware missing"); else if (type == NM_DEVICE_TYPE_ETHERNET && !nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device))) value = _("Cable unplugged"); else value = _("Unavailable"); break; case NM_DEVICE_STATE_DISCONNECTED: /* TRANSLATORS: device status */ value = _("Disconnected"); break; case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_IP_CHECK: /* TRANSLATORS: device status */ value = _("Connecting"); break; case NM_DEVICE_STATE_NEED_AUTH: /* TRANSLATORS: device status */ value = _("Authentication required"); break; case NM_DEVICE_STATE_ACTIVATED: /* TRANSLATORS: device status */ value = _("Connected"); break; case NM_DEVICE_STATE_DEACTIVATING: /* TRANSLATORS: device status */ value = _("Disconnecting"); break; case NM_DEVICE_STATE_FAILED: /* TRANSLATORS: device status */ value = _("Connection failed"); break; default: /* TRANSLATORS: device status */ value = _("Status unknown (missing)"); break; } return value; }