[gnome-terminal] all: Do not use '&s' format with g_variant_get



commit d8d71e0c1e7a8fb723becaa270334171e6730fc2
Author: Christian Persch <chpe gnome org>
Date:   Fri Dec 6 21:38:20 2013 +0100

    all: Do not use '&s' format with g_variant_get
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=708198 and
    https://bugzilla.redhat.com/show_bug.cgi?id=1036374 .

 src/migration.c              |    7 ++++---
 src/terminal-accels.c        |    8 ++++----
 src/terminal-app.c           |    8 ++++----
 src/terminal-prefs.c         |    8 ++++----
 src/terminal-profiles-list.c |   16 +++++++---------
 src/terminal-screen.c        |   18 ++++++++++--------
 src/terminal-util.c          |   22 +++++++++++-----------
 src/terminal-window.c        |    4 ++--
 8 files changed, 46 insertions(+), 45 deletions(-)
---
diff --git a/src/migration.c b/src/migration.c
index 12a4bef..d1d9715 100644
--- a/src/migration.c
+++ b/src/migration.c
@@ -31,6 +31,7 @@
 #include "terminal-profiles-list.h"
 #include "terminal-type-builtins.h"
 #include "terminal-debug.h"
+#include "terminal-libgsystem.h"
 
 static gboolean clean = FALSE;
 static gboolean dry_run = FALSE;
@@ -362,7 +363,7 @@ migrate_profile (TerminalSettingsList *list,
 {
   GSettings *settings;
   char *child_name, *path;
-  const char *name;
+  gs_free char *name;
   gboolean is_default;
 
   if (g_strcmp0 (gconf_id, default_gconf_id) == 0) {
@@ -381,8 +382,8 @@ migrate_profile (TerminalSettingsList *list,
   migrate_string (client, path, KEY_VISIBLE_NAME,
                   settings, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
 
-  g_settings_get (settings, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &name);
-  if (strlen (name) == 0)
+  g_settings_get (settings, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "s", &name);
+  if (name[0] == '\0')
     g_settings_set_string (settings, TERMINAL_PROFILE_VISIBLE_NAME_KEY,
                            is_default ? _("Default") : _("Unnamed"));
 
diff --git a/src/terminal-accels.c b/src/terminal-accels.c
index c39b4de..b782a4f 100644
--- a/src/terminal-accels.c
+++ b/src/terminal-accels.c
@@ -211,7 +211,7 @@ key_changed_cb (GSettings *settings,
 {
   GtkApplication *application = user_data;
   KeyEntry *key_entry;
-  const char *value;
+  gs_free char *value = NULL;
 
   _terminal_debug_print (TERMINAL_DEBUG_ACCELS,
                          "key %s changed\n",
@@ -226,7 +226,7 @@ key_changed_cb (GSettings *settings,
       return;
     }
 
-  g_settings_get (settings, settings_key, "&s", &value);
+  value = g_settings_get_string (settings, settings_key);
 
   if (g_str_equal (value, "disabled")) {
     if (key_entry->installed)
@@ -365,12 +365,12 @@ accel_set_func (GtkTreeViewColumn *tree_column,
                   "visible", FALSE,
                  NULL);
   } else {
-    const char *value;
+    gs_free char *value;
     guint key;
     GdkModifierType mods;
     gboolean writable;
 
-    g_settings_get (keybinding_settings, ke->settings_key, "&s", &value);
+    value = g_settings_get_string (keybinding_settings, ke->settings_key);
     gtk_accelerator_parse (value, &key, &mods);
 
     writable = g_settings_is_writable (keybinding_settings, ke->settings_key);
diff --git a/src/terminal-app.c b/src/terminal-app.c
index cc7c5c6..c06c454 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -209,7 +209,7 @@ terminal_app_encoding_list_notify_cb (GSettings   *settings,
                                       const char  *key,
                                       TerminalApp *app)
 {
-  gs_free char **encodings = NULL;
+  gs_strfreev char **encodings = NULL;
   int i;
   TerminalEncoding *encoding;
 
@@ -230,7 +230,7 @@ terminal_app_encoding_list_notify_cb (GSettings   *settings,
   if (terminal_encoding_is_valid (encoding))
     encoding->is_active = TRUE;
 
-  g_settings_get (settings, key, "^a&s", &encodings);
+  g_settings_get (settings, key, "^as", &encodings);
   for (i = 0; encodings[i] != NULL; ++i) {
       encoding = terminal_app_ensure_encoding (app, encodings[i]);
       if (!terminal_encoding_is_valid (encoding))
@@ -665,11 +665,11 @@ terminal_app_get_proxy_settings (TerminalApp *app)
 PangoFontDescription *
 terminal_app_get_system_font (TerminalApp *app)
 {
-  const char *font;
+  gs_free char *font = NULL;
 
   g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
 
-  g_settings_get (app->desktop_interface_settings, MONOSPACE_FONT_KEY_NAME, "&s", &font);
+  font = g_settings_get_string (app->desktop_interface_settings, MONOSPACE_FONT_KEY_NAME);
 
   return pango_font_description_from_string (font);
 }
diff --git a/src/terminal-prefs.c b/src/terminal-prefs.c
index 104aead..043f8a7 100644
--- a/src/terminal-prefs.c
+++ b/src/terminal-prefs.c
@@ -86,11 +86,11 @@ profile_cell_data_func (GtkTreeViewColumn *tree_column,
                         PrefData *data)
 {
   gs_unref_object GSettings *profile;
-  const char *text;
+  gs_free char *text;
   GValue value = { 0, };
 
   gtk_tree_model_get (tree_model, iter, (int) COL_PROFILE, &profile, (int) -1);
-  g_settings_get (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &text);
+  text = g_settings_get_string (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
 
   g_value_init (&value, G_TYPE_STRING);
   if (text[0])
@@ -357,13 +357,13 @@ profile_list_delete_button_clicked_cb (GtkWidget *button,
 {
   GtkWidget *dialog;
   gs_unref_object GSettings *selected_profile;
-  const char *name;
+  gs_free char *name = NULL;
 
   selected_profile = profile_list_ref_selected (data);
   if (selected_profile == NULL)
     return;
 
-  g_settings_get (selected_profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &name);
+  name = g_settings_get_string (selected_profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
   dialog = gtk_message_dialog_new (GTK_WINDOW (data->dialog),
                                    GTK_DIALOG_DESTROY_WITH_PARENT,
                                    GTK_MESSAGE_QUESTION,
diff --git a/src/terminal-profiles-list.c b/src/terminal-profiles-list.c
index 9da7654..64795d5 100644
--- a/src/terminal-profiles-list.c
+++ b/src/terminal-profiles-list.c
@@ -243,8 +243,10 @@ terminal_profiles_compare (gconstpointer pa,
 {
   GSettings *a = (GSettings *) pa;
   GSettings *b = (GSettings *) pb;
-  const char *na, *nb;
-  char *patha, *pathb;
+  gs_free char *na = NULL;
+  gs_free char *nb = NULL;
+  gs_free char *patha = NULL;
+  gs_free char *pathb = NULL;
   int result;
 
   if (pa == pb)
@@ -254,17 +256,13 @@ terminal_profiles_compare (gconstpointer pa,
   if (pb == NULL)
     return -1;
 
-  g_settings_get (a, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &na);
-  g_settings_get (b, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &nb);
+  na = g_settings_get_string (a, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
+  nb = g_settings_get_string (b, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
   result =  g_utf8_collate (na, nb);
   if (result != 0)
     return result;
 
   g_object_get (a, "path", &patha, NULL);
   g_object_get (b, "path", &pathb, NULL);
-  result = strcmp (patha, pathb);
-  g_free (patha);
-  g_free (pathb);
-
-  return result;
+  return strcmp (patha, pathb);
 }
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index b9c76c3..adfda2b 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -709,13 +709,14 @@ char *
 terminal_screen_get_description (TerminalScreen *screen)
 {
   TerminalScreenPrivate *priv = screen->priv;
+  gs_free char *title_string = NULL;
   const char *title;
 
   /* use --title argument if one was supplied, otherwise ask the profile */
   if (priv->title)
     title = priv->title;
   else
-    g_settings_get (priv->profile, TERMINAL_PROFILE_TITLE_KEY, "&s", &title);
+    title = title_string = g_settings_get_string (priv->profile, TERMINAL_PROFILE_TITLE_KEY);
 
   return g_strdup_printf ("%s — %d",
                           title && title[0] ? title : _("Terminal"),
@@ -749,9 +750,9 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_ENCODING))
     {
       TerminalEncoding *encoding;
-      const char *str;
+      gs_free char *str;
 
-      g_settings_get (profile, TERMINAL_PROFILE_ENCODING, "&s", &str);
+      str = g_settings_get_string (profile, TERMINAL_PROFILE_ENCODING);
       encoding = terminal_app_ensure_encoding (terminal_app_get (), str);
       vte_terminal_set_encoding (vte_terminal, terminal_encoding_get_charset (encoding));
     }
@@ -782,7 +783,8 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
 
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_WORD_CHARS_KEY))
     {
-      g_settings_get (profile, TERMINAL_PROFILE_WORD_CHARS_KEY, "&s", &string);
+      gs_free char *word_chars;
+      word_chars = g_settings_get_string (profile, TERMINAL_PROFILE_WORD_CHARS_KEY);
       vte_terminal_set_word_chars (vte_terminal, string);
     }
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE_KEY))
@@ -864,7 +866,6 @@ terminal_screen_set_font (TerminalScreen *screen)
 {
   TerminalScreenPrivate *priv = screen->priv;
   GSettings *profile = priv->profile;
-  const char *font;
   PangoFontDescription *desc;
   int size;
 
@@ -874,7 +875,8 @@ terminal_screen_set_font (TerminalScreen *screen)
     }
   else
     {
-      g_settings_get (profile, TERMINAL_PROFILE_FONT_KEY, "&s", &font);
+      gs_free char *font;
+      font = g_settings_get_string (profile, TERMINAL_PROFILE_FONT_KEY);
       desc = pango_font_description_from_string (font);
     }
 
@@ -1026,9 +1028,9 @@ get_child_command (TerminalScreen *screen,
     }
   else if (g_settings_get_boolean (profile, TERMINAL_PROFILE_USE_CUSTOM_COMMAND_KEY))
     {
-      const char *argv_str;
+      gs_free char *argv_str;
 
-      g_settings_get (profile, TERMINAL_PROFILE_CUSTOM_COMMAND_KEY, "&s", &argv_str);
+      argv_str = g_settings_get_string (profile, TERMINAL_PROFILE_CUSTOM_COMMAND_KEY);
       if (!g_shell_parse_argv (argv_str, NULL, &argv, err))
         return FALSE;
 
diff --git a/src/terminal-util.c b/src/terminal-util.c
index caf4125..c964db6 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -524,7 +524,7 @@ setup_proxy_env (GSettings  *proxy_settings,
 {
   gs_unref_object GSettings *child_settings;
   GString *buf;
-  const char *host;
+  gs_free char *host;
   int port;
   gboolean is_http;
 
@@ -532,7 +532,7 @@ setup_proxy_env (GSettings  *proxy_settings,
 
   child_settings = g_settings_get_child (proxy_settings, child_schema_id);
 
-  g_settings_get (child_settings, "host", "&s", &host);
+  host = g_settings_get_string (child_settings, "host");
   port = g_settings_get_int (child_settings, "port");
   if (host[0] == '\0' || port == 0)
     return;
@@ -544,16 +544,16 @@ setup_proxy_env (GSettings  *proxy_settings,
   if (is_http &&
       g_settings_get_boolean (child_settings, "use-authentication"))
     {
-      const char *user, *password;
-
-      g_settings_get (child_settings, "authentication-user", "&s", &user);
+      gs_free char *user;
 
+      user = g_settings_get_string (child_settings, "authentication-user");
       if (user[0])
         {
-          g_string_append_uri_escaped (buf, user, NULL, TRUE);
+          gs_free char *password;
 
-          g_settings_get (child_settings, "authentication-password", "&s", &password);
+          g_string_append_uri_escaped (buf, user, NULL, TRUE);
 
+          password = g_settings_get_string (child_settings, "authentication-password");
           if (password[0])
             {
               g_string_append_c (buf, ':');
@@ -572,9 +572,9 @@ setup_autoconfig_proxy_env (GSettings *proxy_settings,
                             GHashTable *env_table)
 {
   /* XXX  Not sure what to do with this.  See bug #596688.
-  const char *url;
+  gs_free char *url;
 
-  g_settings_get (proxy_settings, "autoconfig-url", "&s", &url);
+  url = g_settings_get_string (proxy_settings, "autoconfig-url");
   if (url[0])
     {
       char *proxy;
@@ -589,10 +589,10 @@ setup_ignore_proxy_env (GSettings *proxy_settings,
                         GHashTable *env_table)
 {
   GString *buf;
-  gs_free char **ignore; /* the strings themselves are const */
+  gs_strfreev char **ignore;
   int i;
 
-  g_settings_get (proxy_settings, "ignore-hosts", "^a&s", &ignore);
+  g_settings_get (proxy_settings, "ignore-hosts", "^as", &ignore);
   if (ignore == NULL)
     return;
 
diff --git a/src/terminal-window.c b/src/terminal-window.c
index e8cabda..00915ce 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -1163,12 +1163,12 @@ profile_visible_name_notify_cb (GSettings  *profile,
                                 const char *key,
                                 GtkAction  *action)
 {
-  const char *visible_name;
+  gs_free char *visible_name;
   char *dot;
   gs_free char *display_name;
   guint num;
 
-  g_settings_get (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &visible_name);
+  visible_name = g_settings_get_string (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
   display_name = escape_underscores (visible_name);
 
   dot = strchr (gtk_action_get_name (action), '.');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]