Use GSettings common functions from libmate-desktop

master-1.22
Stefano Karapetsas 2014-04-23 19:45:58 +02:00
parent 3debae5bc1
commit 05b55b122e
5 changed files with 8 additions and 168 deletions

View File

@ -27,8 +27,6 @@ mate_terminal_SOURCES= \
terminal-debug.h \ terminal-debug.h \
terminal-encoding.c \ terminal-encoding.c \
terminal-encoding.h \ terminal-encoding.h \
terminal-gsettings.c \
terminal-gsettings.h \
terminal-info-bar.c \ terminal-info-bar.c \
terminal-info-bar.h \ terminal-info-bar.h \
terminal-intl.h \ terminal-intl.h \

View File

@ -36,8 +36,8 @@
#include "terminal-util.h" #include "terminal-util.h"
#include "profile-editor.h" #include "profile-editor.h"
#include "terminal-encoding.h" #include "terminal-encoding.h"
#include "terminal-gsettings.h"
#include <libmate-desktop/mate-dconf.h> #include <libmate-desktop/mate-dconf.h>
#include <libmate-desktop/mate-gsettings.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@ -328,7 +328,7 @@ terminal_app_delete_profile (TerminalApp *app,
profile_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_NAME); profile_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_NAME);
profile_dir = g_strconcat (CONF_PROFILE_PREFIX, profile_name, "/", NULL); profile_dir = g_strconcat (CONF_PROFILE_PREFIX, profile_name, "/", NULL);
terminal_gsettings_remove_all_from_strv (app->settings_global, PROFILE_LIST_KEY, profile_name); mate_gsettings_remove_all_from_strv (app->settings_global, PROFILE_LIST_KEY, profile_name);
/* And remove the profile directory */ /* And remove the profile directory */
if (!mate_dconf_recursive_reset (profile_dir, &error)) if (!mate_dconf_recursive_reset (profile_dir, &error))
@ -756,7 +756,7 @@ terminal_app_profile_list_notify_cb (GSettings *settings,
!g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))) !g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)))
goto ensure_one_profile; goto ensure_one_profile;
value_list = terminal_gsettings_strv_to_gslist( g_variant_get_strv (val, NULL)); value_list = mate_gsettings_strv_to_gslist( g_variant_get_strv (val, NULL));
/* Add any new ones */ /* Add any new ones */
for (sl = value_list; sl != NULL; sl = sl->next) for (sl = value_list; sl != NULL; sl = sl->next)
@ -928,7 +928,7 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
val = g_settings_get_value (settings, key); val = g_settings_get_value (settings, key);
if (val != NULL && if (val != NULL &&
g_variant_is_of_type (val, G_VARIANT_TYPE_STRING_ARRAY)) g_variant_is_of_type (val, G_VARIANT_TYPE_STRING_ARRAY))
strings = terminal_gsettings_strv_to_gslist (g_variant_get_strv (val, NULL)); strings = mate_gsettings_strv_to_gslist (g_variant_get_strv (val, NULL));
else else
strings = NULL; strings = NULL;
@ -1088,7 +1088,7 @@ new_profile_response_cb (GtkWidget *new_profile_dialog,
new_profile /* adopts the refcount */); new_profile /* adopts the refcount */);
/* And now save the new profile name to GSettings */ /* And now save the new profile name to GSettings */
terminal_gsettings_append_strv (app->settings_global, mate_gsettings_append_strv (app->settings_global,
PROFILE_LIST_KEY, PROFILE_LIST_KEY,
new_profile_name); new_profile_name);

View File

@ -1,110 +0,0 @@
/*
* terminal-gsettings.c: terminal gsettings utility methods
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
* 2012 Stefano Karapetsas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors:
* Mark McLoughlin <mark@skynet.ie>
* Glynn Foster <glynn.foster@sun.com>
* Stefano Karapetsas <stefano@karapetsas.com>
*/
#include <config.h>
#include "terminal-gsettings.h"
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
/* copied from gnome-panel */
gboolean
terminal_gsettings_append_strv (GSettings *settings,
const gchar *key,
const gchar *value)
{
gchar **old;
gchar **new;
gint size;
gboolean retval;
old = g_settings_get_strv (settings, key);
for (size = 0; old[size] != NULL; size++);
size += 1; /* appended value */
size += 1; /* NULL */
new = g_realloc_n (old, size, sizeof (gchar *));
new[size - 2] = g_strdup (value);
new[size - 1] = NULL;
retval = g_settings_set_strv (settings, key,
(const gchar **) new);
g_strfreev (new);
return retval;
}
/* copied from gnome-panel */
gboolean
terminal_gsettings_remove_all_from_strv (GSettings *settings,
const gchar *key,
const gchar *value)
{
GArray *array;
gchar **old;
gint i;
gboolean retval;
old = g_settings_get_strv (settings, key);
array = g_array_new (TRUE, TRUE, sizeof (gchar *));
for (i = 0; old[i] != NULL; i++) {
if (g_strcmp0 (old[i], value) != 0)
array = g_array_append_val (array, old[i]);
}
retval = g_settings_set_strv (settings, key,
(const gchar **) array->data);
g_strfreev (old);
g_array_free (array, TRUE);
return retval;
}
/* convert a gchar ** to GList (taken from libmatekbd code) */
GSList*
terminal_gsettings_strv_to_gslist (const gchar *const *array)
{
GSList *list = NULL;
gint i;
if (array != NULL) {
for (i = 0; array[i]; i++) {
list = g_slist_append (list, g_strdup (array[i]));
}
}
return list;
}

View File

@ -1,49 +0,0 @@
/*
* terminal-gsettings.h: terminal gsettings utility methods
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
* 2012 Stefano Karapetsas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors:
* Mark McLoughlin <mark@skynet.ie>
* Glynn Foster <glynn.foster@sun.com>
* Stefano Karapetsas <stefano@karapetsas.com>
*/
#ifndef __TERMINAL_GSETTINGS_H__
#define __TERMINAL_GSETTINGS_H__
#include <glib.h>
#include <gio/gio.h>
G_BEGIN_DECLS
gboolean terminal_gsettings_append_strv (GSettings *settings,
const gchar *key,
const gchar *value);
gboolean terminal_gsettings_remove_all_from_strv (GSettings *settings,
const gchar *key,
const gchar *value);
GSList* terminal_gsettings_strv_to_gslist (const gchar *const *array);
G_END_DECLS
#endif /* __TEMRINAL_GSETTINGS_H__ */

View File

@ -37,9 +37,10 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
#include <libmate-desktop/mate-gsettings.h>
#include "terminal-accels.h" #include "terminal-accels.h"
#include "terminal-app.h" #include "terminal-app.h"
#include "terminal-gsettings.h"
#include "terminal-intl.h" #include "terminal-intl.h"
#include "terminal-util.h" #include "terminal-util.h"
#include "terminal-window.h" #include "terminal-window.h"
@ -611,7 +612,7 @@ setup_ignore_host_env (GHashTable *env_table,
GSList *ignore; GSList *ignore;
gchar **ignore_strv = g_settings_get_strv (settings, "ignore-hosts"); gchar **ignore_strv = g_settings_get_strv (settings, "ignore-hosts");
ignore = terminal_gsettings_strv_to_gslist ((const gchar *const *)ignore_strv); ignore = mate_gsettings_strv_to_gslist ((const gchar *const *)ignore_strv);
if (ignore) if (ignore)
{ {
GString *buf = g_string_sized_new (64); GString *buf = g_string_sized_new (64);