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



commit 77e463abe80dc5980e5b3b019c7795e31c374005
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 .
    
    (cherry picked from commit ac62dbbda2630d1d963d399317d59cf7b78dc7f2)

 src/migration.c              |    8 +++++---
 src/terminal-app.c           |   10 +++++-----
 src/terminal-prefs.c         |    9 +++++----
 src/terminal-profiles-list.c |   17 ++++++++---------
 src/terminal-screen.c        |   26 ++++++++++++++------------
 src/terminal-util.c          |   24 ++++++++++++------------
 src/terminal-window.c        |    5 +++--
 7 files changed, 52 insertions(+), 47 deletions(-)
---
diff --git a/src/migration.c b/src/migration.c
index 437471a..0546b33 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;
@@ -363,7 +364,8 @@ 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) {
     /* Re-use the default list child */
@@ -379,8 +381,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, _("Unnamed"));
 
   migrate_string (client, path, KEY_FOREGROUND_COLOR,
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 54a4ccd..38f6022 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -40,6 +40,7 @@
 #include "terminal-gdbus.h"
 #include "terminal-defines.h"
 #include "terminal-prefs.h"
+#include "terminal-libgsystem.h"
 
 #include <errno.h>
 #include <string.h>
@@ -210,7 +211,7 @@ terminal_app_encoding_list_notify_cb (GSettings   *settings,
                                       const char  *key,
                                       TerminalApp *app)
 {
-  char **encodings;
+  gs_strfreev char **encodings = NULL;
   int i;
   TerminalEncoding *encoding;
 
@@ -231,7 +232,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))
@@ -239,7 +240,6 @@ terminal_app_encoding_list_notify_cb (GSettings   *settings,
 
       encoding->is_active = TRUE;
     }
-  g_free (encodings);
 
   g_signal_emit (app, signals[ENCODING_LIST_CHANGED], 0);
 }
@@ -655,11 +655,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 226895f..04abb2c 100644
--- a/src/terminal-prefs.c
+++ b/src/terminal-prefs.c
@@ -35,6 +35,7 @@
 #include "terminal-util.h"
 #include "terminal-profiles-list.h"
 #include "terminal-encoding.h"
+#include "terminal-libgsystem.h"
 
 typedef struct {
   TerminalSettingsList *profiles_list;
@@ -85,11 +86,11 @@ profile_cell_data_func (GtkTreeViewColumn *tree_column,
                         PrefData *data)
 {
   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])
@@ -379,13 +380,13 @@ profile_list_delete_button_clicked_cb (GtkWidget *button,
 {
   GtkWidget *dialog;
   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 d68545c..31f43c1 100644
--- a/src/terminal-profiles-list.c
+++ b/src/terminal-profiles-list.c
@@ -23,6 +23,7 @@
 
 #include "terminal-profiles-list.h"
 #include "terminal-schemas.h"
+#include "terminal-libgsystem.h"
 
 #include <string.h>
 #include <uuid.h>
@@ -244,8 +245,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)
@@ -255,17 +258,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 9535866..e2a4836 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -50,6 +50,7 @@
 #include "terminal-util.h"
 #include "terminal-window.h"
 #include "terminal-info-bar.h"
+#include "terminal-libgsystem.h"
 
 #include "eggshell.h"
 
@@ -771,6 +772,7 @@ terminal_screen_format_title (TerminalScreen *screen,
   const char *static_title = NULL;
   GString *title;
   gboolean add_sep = FALSE;
+  gs_free char *title_string = NULL;
 
   g_assert (titleptr);
 
@@ -778,7 +780,7 @@ terminal_screen_format_title (TerminalScreen *screen,
   if (priv->override_title)
     static_title = priv->override_title;
   else
-    g_settings_get (priv->profile, TERMINAL_PROFILE_TITLE_KEY, "&s", &static_title);
+    static_title = title_string = g_settings_get_string (priv->profile, TERMINAL_PROFILE_TITLE_KEY);
 
   title = g_string_sized_new (128);
 
@@ -856,7 +858,6 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
   GObject *object = G_OBJECT (screen);
   VteTerminal *vte_terminal = VTE_TERMINAL (screen);
   TerminalWindow *window;
-  const char *string;
 
   g_object_freeze_notify (object);
 
@@ -874,9 +875,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));
     }
@@ -909,8 +910,9 @@ 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);
-      vte_terminal_set_word_chars (vte_terminal, 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, word_chars);
     }
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE_KEY))
     vte_terminal_set_scroll_on_keystroke (vte_terminal,
@@ -989,7 +991,6 @@ terminal_screen_set_font (TerminalScreen *screen)
 {
   TerminalScreenPrivate *priv = screen->priv;
   GSettings *profile = priv->profile;
-  const char *font;
   PangoFontDescription *desc;
   int size;
 
@@ -999,7 +1000,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);
     }
 
@@ -1141,9 +1143,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;
 
@@ -2116,10 +2118,10 @@ terminal_screen_save_config (TerminalScreen *screen,
 {
   TerminalScreenPrivate *priv = screen->priv;
   VteTerminal *terminal = VTE_TERMINAL (screen);
-  const char *profile_id;
+  gs_free char *profile_id;
   char *working_directory;
 
-  g_settings_get (priv->profile, TERMINAL_PROFILE_NAME_KEY, "&s", &profile_id);
+  profile_id = g_settings_get_string (priv->profile, TERMINAL_PROFILE_NAME_KEY);
   g_key_file_set_string (key_file, group, TERMINAL_CONFIG_TERMINAL_PROP_PROFILE_ID, profile_id);
 
   if (priv->override_command)
diff --git a/src/terminal-util.c b/src/terminal-util.c
index 8dfa79d..b70a722 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -47,6 +47,7 @@
 #include "terminal-screen.h"
 #include "terminal-util.h"
 #include "terminal-window.h"
+#include "terminal-libgsystem.h"
 
 void
 terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
@@ -595,7 +596,7 @@ setup_proxy_env (GSettings  *proxy_settings,
 {
   GSettings *child_settings;
   GString *buf;
-  const char *host;
+  gs_free char *host;
   int port;
   gboolean is_http;
 
@@ -603,7 +604,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)
     goto out;
@@ -615,16 +616,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, ':');
@@ -646,9 +647,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;
@@ -663,10 +664,10 @@ setup_ignore_proxy_env (GSettings *proxy_settings,
                         GHashTable *env_table)
 {
   GString *buf;
-  char **ignore;
+  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;
 
@@ -677,7 +678,6 @@ setup_ignore_proxy_env (GSettings *proxy_settings,
         g_string_append_c (buf, ',');
       g_string_append (buf, ignore[i]);
     }
-  g_free (ignore);
 
   set_proxy_env (env_table, "no_proxy", g_string_free (buf, FALSE));
 }
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 10a5462..db55b09 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -44,6 +44,7 @@
 #include "terminal-tabs-menu.h"
 #include "terminal-util.h"
 #include "terminal-window.h"
+#include "terminal-libgsystem.h"
 
 struct _TerminalWindowPrivate
 {
@@ -411,11 +412,11 @@ profile_visible_name_notify_cb (GSettings  *profile,
                                 const char *key,
                                 GtkAction  *action)
 {
-  const char *visible_name;
+  gs_free char *visible_name;
   char *dot, *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]