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 *
|
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;
|
GSList *names = NULL, *l;
|
||||||
gchar *cname = NULL;
|
gchar *cname = NULL;
|
||||||
|
@ -535,7 +537,17 @@ ce_page_get_next_available_name (GSList *connections, const gchar *format)
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
gboolean found = FALSE;
|
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) {
|
for (l = names; l; l = l->next) {
|
||||||
if (!strcmp (l->data, temp)) {
|
if (!strcmp (l->data, temp)) {
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
|
|
|
@ -105,7 +105,14 @@ gint ce_get_property_default (NMSetting *setting,
|
||||||
gint ce_spin_output_with_default (GtkSpinButton *spin,
|
gint ce_spin_output_with_default (GtkSpinButton *spin,
|
||||||
gpointer user_data);
|
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)) {
|
if (!nm_setting_connection_get_id (s_con)) {
|
||||||
GSList *connections;
|
GSList *connections;
|
||||||
gchar *id, *id_pattern;
|
gchar *id;
|
||||||
|
|
||||||
connections = nm_remote_settings_list_connections (editor->settings);
|
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, NAME_FORMAT_TYPE, _(connection_type->name));
|
||||||
id = ce_page_get_next_available_name (connections, id_pattern);
|
|
||||||
g_object_set (s_con,
|
g_object_set (s_con,
|
||||||
NM_SETTING_CONNECTION_ID, id,
|
NM_SETTING_CONNECTION_ID, id,
|
||||||
NULL);
|
NULL);
|
||||||
g_free (id);
|
g_free (id);
|
||||||
g_free (id_pattern);
|
|
||||||
g_slist_free (connections);
|
g_slist_free (connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -470,7 +470,7 @@ add_profile (GtkButton *button, NetDeviceEthernet *device)
|
||||||
|
|
||||||
settings = net_object_get_remote_settings (NET_OBJECT (device));
|
settings = net_object_get_remote_settings (NET_OBJECT (device));
|
||||||
connections = nm_remote_settings_list_connections (settings);
|
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_slist_free (connections);
|
||||||
|
|
||||||
g_object_set (sc,
|
g_object_set (sc,
|
||||||
|
|
Loading…
Add table
Reference in a new issue