Cambio los g_settings del encoding y proxy por configuraciones.

master-1.22
Félix Arreola Rodríguez 2021-07-24 01:23:42 -05:00
parent bf285963f3
commit 85424d6b5d
5 changed files with 52 additions and 41 deletions

View File

@ -942,7 +942,7 @@ encoding_mark_active (gpointer key,
encoding->is_active = active; encoding->is_active = active;
} }
static void void
terminal_app_encoding_list_notify_cb (GKeyFile *settings, terminal_app_encoding_list_notify_cb (GKeyFile *settings,
gchar *key, gchar *key,
gpointer user_data) gpointer user_data)

View File

@ -155,6 +155,10 @@ gboolean terminal_app_save_config_file (TerminalApp *app,
const char *file_name, const char *file_name,
GError **error); GError **error);
void
terminal_app_encoding_list_notify_cb (GKeyFile *settings,
gchar *key,
gpointer user_data);
G_END_DECLS G_END_DECLS
#endif /* !TERMINAL_APP_H */ #endif /* !TERMINAL_APP_H */

View File

@ -290,7 +290,7 @@ update_active_encodings_gsettings (void)
GSList *list, *l; GSList *list, *l;
GArray *strings; GArray *strings;
const gchar *id_string; const gchar *id_string;
GSettings *settings; GKeyFile *settings;
list = terminal_app_get_active_encodings (terminal_app_get ()); list = terminal_app_get_active_encodings (terminal_app_get ());
strings = g_array_new (TRUE, TRUE, sizeof (gchar *)); strings = g_array_new (TRUE, TRUE, sizeof (gchar *));
@ -302,13 +302,14 @@ update_active_encodings_gsettings (void)
strings = g_array_append_val (strings, id_string); strings = g_array_append_val (strings, id_string);
} }
settings = g_settings_new (CONF_GLOBAL_SCHEMA); settings = terminal_app_get_global_settings ();
g_settings_set_strv (settings, "active-encodings", (const gchar **) strings->data); g_key_file_set_string_list (settings, CONF_GLOBAL_SCHEMA, "active-encodings", (const gchar **) strings->data, g_strv_length ((const gchar **) strings->data));
g_object_unref (settings);
g_array_free (strings, TRUE); g_array_free (strings, TRUE);
g_slist_foreach (list, (GFunc) terminal_encoding_unref, NULL); g_slist_foreach (list, (GFunc) terminal_encoding_unref, NULL);
g_slist_free (list); g_slist_free (list);
terminal_app_encoding_list_notify_cb (settings, "active-encodings", terminal_app_get ());
} }
static void static void

View File

@ -470,11 +470,12 @@ terminal_util_key_file_get_argv (GKeyFile *key_file,
/* Proxy stuff */ /* Proxy stuff */
static char * static char *
gsettings_get_string (GSettings *settings, gsettings_get_string (GKeyFile *settings,
const char *group,
const char *key) const char *key)
{ {
char *value; char *value;
value = g_settings_get_string (settings, key); value = g_key_file_get_string (settings, group, key, NULL);
if (G_UNLIKELY (value && *value == '\0')) if (G_UNLIKELY (value && *value == '\0'))
{ {
g_free (value); g_free (value);
@ -533,27 +534,27 @@ set_proxy_env (GHashTable *env_table,
static void static void
setup_http_proxy_env (GHashTable *env_table, setup_http_proxy_env (GHashTable *env_table,
GSettings *settings_http) GKeyFile *settings_global)
{ {
gchar *host; gchar *host;
gint port; gint port;
host = gsettings_get_string (settings_http, "host"); host = gsettings_get_string (settings_global, CONF_HTTP_PROXY_SCHEMA, "host");
port = g_settings_get_int (settings_http, "port"); port = g_key_file_get_integer (settings_global, CONF_HTTP_PROXY_SCHEMA, "port", NULL);
if (host && port) if (host && port)
{ {
GString *buf = g_string_sized_new (64); GString *buf = g_string_sized_new (64);
g_string_append (buf, "http://"); g_string_append (buf, "http://");
if (g_settings_get_boolean (settings_http, "use-authentication")) if (g_key_file_get_boolean (settings_global, CONF_HTTP_PROXY_SCHEMA, "use-authentication", NULL))
{ {
char *user, *password; char *user, *password;
user = gsettings_get_string (settings_http, "authentication-user"); user = gsettings_get_string (settings_global, CONF_HTTP_PROXY_SCHEMA, "authentication-user");
if (user) if (user)
{ {
g_string_append_uri_escaped (buf, user, NULL, TRUE); g_string_append_uri_escaped (buf, user, NULL, TRUE);
password = gsettings_get_string (settings_http, "authentication-password"); password = gsettings_get_string (settings_global, CONF_HTTP_PROXY_SCHEMA, "authentication-password");
if (password) if (password)
{ {
g_string_append_c (buf, ':'); g_string_append_c (buf, ':');
@ -573,9 +574,9 @@ setup_http_proxy_env (GHashTable *env_table,
static void static void
setup_ignore_host_env (GHashTable *env_table, setup_ignore_host_env (GHashTable *env_table,
GSettings *settings) GKeyFile *settings_global)
{ {
gchar **ignore = g_settings_get_strv (settings, "ignore-hosts"); gchar **ignore = g_key_file_get_string_list (settings_global, CONF_PROXY_SCHEMA, "ignore-hosts", NULL, NULL);
if (ignore == NULL) if (ignore == NULL)
return; return;
@ -596,13 +597,13 @@ setup_ignore_host_env (GHashTable *env_table,
static void static void
setup_https_proxy_env (GHashTable *env_table, setup_https_proxy_env (GHashTable *env_table,
GSettings *settings_https) GKeyFile *settings_global)
{ {
gchar *host; gchar *host;
gint port; gint port;
host = gsettings_get_string (settings_https, "host"); host = gsettings_get_string (settings_global, CONF_HTTPS_PROXY_SCHEMA, "host");
port = g_settings_get_int (settings_https, "port"); port = g_key_file_get_integer (settings_global, CONF_HTTPS_PROXY_SCHEMA, "port", NULL);
if (host && port) if (host && port)
{ {
char *proxy; char *proxy;
@ -615,13 +616,13 @@ setup_https_proxy_env (GHashTable *env_table,
static void static void
setup_ftp_proxy_env (GHashTable *env_table, setup_ftp_proxy_env (GHashTable *env_table,
GSettings *settings_ftp) GKeyFile *settings_global)
{ {
gchar *host; gchar *host;
gint port; gint port;
host = gsettings_get_string (settings_ftp, "host"); host = gsettings_get_string (settings_global, CONF_FTP_PROXY_SCHEMA, "host");
port = g_settings_get_int (settings_ftp, "port"); port = g_key_file_get_integer (settings_global, CONF_FTP_PROXY_SCHEMA, "port", NULL);
if (host && port) if (host && port)
{ {
char *proxy; char *proxy;
@ -634,13 +635,13 @@ setup_ftp_proxy_env (GHashTable *env_table,
static void static void
setup_socks_proxy_env (GHashTable *env_table, setup_socks_proxy_env (GHashTable *env_table,
GSettings *settings_socks) GKeyFile *settings_global)
{ {
gchar *host; gchar *host;
gint port; gint port;
host = gsettings_get_string (settings_socks, "host"); host = gsettings_get_string (settings_global, CONF_SOCKS_PROXY_SCHEMA, "host");
port = g_settings_get_int (settings_socks, "port"); port = g_key_file_get_integer (settings_global, CONF_SOCKS_PROXY_SCHEMA, "port", NULL);
if (host && port) if (host && port)
{ {
char *proxy; char *proxy;
@ -652,7 +653,7 @@ setup_socks_proxy_env (GHashTable *env_table,
static void static void
setup_autoconfig_proxy_env (GHashTable *env_table, setup_autoconfig_proxy_env (GHashTable *env_table,
GSettings *settings) GKeyFile *settings_global)
{ {
/* XXX Not sure what to do with this. See bug #596688. /* XXX Not sure what to do with this. See bug #596688.
gchar *url; gchar *url;
@ -678,33 +679,38 @@ void
terminal_util_add_proxy_env (GHashTable *env_table) terminal_util_add_proxy_env (GHashTable *env_table)
{ {
char *proxymode; char *proxymode;
/* Trasladar estos gsettings al único fichero global */
GKeyFile *settings_global = terminal_app_get_global_settings ();
/*
TODO: Sería ideal trasladar estas configuraciones a un archivo global
GSettings *settings = g_settings_new (CONF_PROXY_SCHEMA); GSettings *settings = g_settings_new (CONF_PROXY_SCHEMA);
GSettings *settings_http = g_settings_new (CONF_HTTP_PROXY_SCHEMA); GSettings *settings_http = g_settings_new (CONF_HTTP_PROXY_SCHEMA);
GSettings *settings_https = g_settings_new (CONF_HTTPS_PROXY_SCHEMA); GSettings *settings_https = g_settings_new (CONF_HTTPS_PROXY_SCHEMA);
GSettings *settings_ftp = g_settings_new (CONF_FTP_PROXY_SCHEMA); GSettings *settings_ftp = g_settings_new (CONF_FTP_PROXY_SCHEMA);
GSettings *settings_socks = g_settings_new (CONF_SOCKS_PROXY_SCHEMA); GSettings *settings_socks = g_settings_new (CONF_SOCKS_PROXY_SCHEMA);
*/
/* If mode is not manual, nothing to set */ /* If mode is not manual, nothing to set */
proxymode = gsettings_get_string (settings, "mode"); proxymode = g_key_file_get_string (settings_global, CONF_PROXY_SCHEMA, "mode", NULL);
if (proxymode && 0 == strcmp (proxymode, "manual")) if (proxymode && 0 == strcmp (proxymode, "manual"))
{ {
setup_http_proxy_env (env_table, settings_http); setup_http_proxy_env (env_table, settings_global);
setup_ignore_host_env (env_table, settings); setup_ignore_host_env (env_table, settings_global);
setup_https_proxy_env (env_table, settings_https); setup_https_proxy_env (env_table, settings_global);
setup_ftp_proxy_env (env_table, settings_ftp); setup_ftp_proxy_env (env_table, settings_global);
setup_socks_proxy_env (env_table, settings_socks); setup_socks_proxy_env (env_table, settings_global);
} }
else if (proxymode && 0 == strcmp (proxymode, "auto")) else if (proxymode && 0 == strcmp (proxymode, "auto"))
{ {
setup_autoconfig_proxy_env (env_table, settings); setup_autoconfig_proxy_env (env_table, settings_global);
} }
g_free (proxymode); g_free (proxymode);
g_object_unref (settings); /*g_object_unref (settings);
g_object_unref (settings_http); g_object_unref (settings_http);
g_object_unref (settings_https); g_object_unref (settings_https);
g_object_unref (settings_ftp); g_object_unref (settings_ftp);
g_object_unref (settings_socks); g_object_unref (settings_socks);*/
} }
/* Bidirectional object/widget binding */ /* Bidirectional object/widget binding */

View File

@ -27,11 +27,11 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define CONF_PROXY_SCHEMA "org.gnome.system.proxy" #define CONF_PROXY_SCHEMA "proxy"
#define CONF_HTTP_PROXY_SCHEMA "org.gnome.system.proxy.http" #define CONF_HTTP_PROXY_SCHEMA "proxy.http"
#define CONF_HTTPS_PROXY_SCHEMA "org.gnome.system.proxy.https" #define CONF_HTTPS_PROXY_SCHEMA "proxy.https"
#define CONF_FTP_PROXY_SCHEMA "org.gnome.system.proxy.ftp" #define CONF_FTP_PROXY_SCHEMA "proxy.ftp"
#define CONF_SOCKS_PROXY_SCHEMA "org.gnome.system.proxy.socks" #define CONF_SOCKS_PROXY_SCHEMA "proxy.socks"
void terminal_util_set_unique_role (GtkWindow *window, const char *prefix); void terminal_util_set_unique_role (GtkWindow *window, const char *prefix);