network: Fix "format not a string literal" error
https://bugzilla.gnome.org/show_bug.cgi?id=764727
This commit is contained in:
parent
ec5d9d05a7
commit
9c70369a34
4 changed files with 25 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue