[gnome-control-center] network: Fix "format not a string literal" error
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Fix "format not a string literal" error
- Date: Fri, 8 Apr 2016 09:32:41 +0000 (UTC)
commit 9c70369a34877eaac31396a21d572c6a435e142d
Author: Bastien Nocera <hadess hadess net>
Date: Thu Apr 7 15:07:36 2016 +0200
network: Fix "format not a string literal" error
https://bugzilla.gnome.org/show_bug.cgi?id=764727
panels/network/connection-editor/ce-page.c | 16 ++++++++++++++--
panels/network/connection-editor/ce-page.h | 9 ++++++++-
.../connection-editor/net-connection-editor.c | 6 ++----
panels/network/net-device-ethernet.c | 2 +-
4 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page.c b/panels/network/connection-editor/ce-page.c
index f5caa32..59a6df6 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 036ddfa..2d064bb 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 d8a20a0..047f7f2 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 06bc218..ed3f0a5 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]