diff --git a/panels/network/connection-editor/ce-page.c b/panels/network/connection-editor/ce-page.c index f5caa3280..59a6df6c2 100644 --- a/panels/network/connection-editor/ce-page.c +++ b/panels/network/connection-editor/ce-page.c @@ -516,7 +516,9 @@ ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data) } gchar * -ce_page_get_next_available_name (GSList *connections, const gchar *format) +ce_page_get_next_available_name (GSList *connections, + NameFormat format, + const gchar *type_name) { GSList *names = NULL, *l; gchar *cname = NULL; @@ -535,7 +537,17 @@ ce_page_get_next_available_name (GSList *connections, const gchar *format) gchar *temp; gboolean found = FALSE; - temp = g_strdup_printf (format, i); + switch (format) { + case NAME_FORMAT_TYPE: + temp = g_strdup_printf ("%s %d", type_name, i); + break; + case NAME_FORMAT_PROFILE: + temp = g_strdup_printf (_("Profile %d"), i); + break; + default: + g_assert_not_reached (); + } + for (l = names; l; l = l->next) { if (!strcmp (l->data, temp)) { found = TRUE; diff --git a/panels/network/connection-editor/ce-page.h b/panels/network/connection-editor/ce-page.h index 036ddfa72..2d064bb11 100644 --- a/panels/network/connection-editor/ce-page.h +++ b/panels/network/connection-editor/ce-page.h @@ -105,7 +105,14 @@ gint ce_get_property_default (NMSetting *setting, gint ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data); -gchar * ce_page_get_next_available_name (GSList *connections, const gchar *format); +typedef enum { + NAME_FORMAT_TYPE, + NAME_FORMAT_PROFILE +} NameFormat; + +gchar * ce_page_get_next_available_name (GSList *connections, + NameFormat format, + const gchar *type_name); diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c index d8a20a044..047f7f2af 100644 --- a/panels/network/connection-editor/net-connection-editor.c +++ b/panels/network/connection-editor/net-connection-editor.c @@ -617,16 +617,14 @@ complete_connection_for_type (NetConnectionEditor *editor, NMConnection *connect if (!nm_setting_connection_get_id (s_con)) { GSList *connections; - gchar *id, *id_pattern; + gchar *id; connections = nm_remote_settings_list_connections (editor->settings); - id_pattern = g_strdup_printf ("%s %%d", _(connection_type->name)); - id = ce_page_get_next_available_name (connections, id_pattern); + id = ce_page_get_next_available_name (connections, NAME_FORMAT_TYPE, _(connection_type->name)); g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL); g_free (id); - g_free (id_pattern); g_slist_free (connections); } diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c index 06bc21872..ed3f0a549 100644 --- a/panels/network/net-device-ethernet.c +++ b/panels/network/net-device-ethernet.c @@ -470,7 +470,7 @@ add_profile (GtkButton *button, NetDeviceEthernet *device) settings = net_object_get_remote_settings (NET_OBJECT (device)); connections = nm_remote_settings_list_connections (settings); - id = ce_page_get_next_available_name (connections, _("Profile %d")); + id = ce_page_get_next_available_name (connections, NAME_FORMAT_PROFILE, NULL); g_slist_free (connections); g_object_set (sc,