summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-05-26 15:38:59 +0300
committermonsta <[email protected]>2016-05-26 15:38:59 +0300
commit8bb732366213934278401bf245f5ba265348b310 (patch)
tree64cea71a96b4ec94b14f5e93ef678d061c598999
parent072da32f99166bcaf932c4401826825e8155d0d8 (diff)
downloadmate-terminal-8bb732366213934278401bf245f5ba265348b310.tar.bz2
mate-terminal-8bb732366213934278401bf245f5ba265348b310.tar.xz
copy gsettings helpers from libmate-desktop (see also FIXME there)
-rw-r--r--src/terminal-app.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 495405d..af9ac39 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -37,7 +37,6 @@
#include "terminal-util.h"
#include "profile-editor.h"
#include "terminal-encoding.h"
-#include <libmate-desktop/mate-gsettings.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
@@ -155,6 +154,70 @@ static TerminalApp *global_app = NULL;
#define ENCODING_LIST_KEY "active-encodings"
+
+/* two following functions were copied from libmate-desktop to get rid
+ * of dependency on it
+ *
+ * FIXME: I suspect there's no need for excessive copies, we might use
+ * existing profile list to form GVariant's and write them to GSettings
+ */
+static gboolean
+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;
+}
+
+static gboolean
+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;
+}
+
/* Helper functions */
static GdkScreen*
@@ -324,7 +387,7 @@ terminal_app_delete_profile (TerminalApp *app,
profile_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_NAME);
profile_dir = g_strconcat (CONF_PROFILE_PREFIX, profile_name, "/", NULL);
- mate_gsettings_remove_all_from_strv (app->settings_global, PROFILE_LIST_KEY, profile_name);
+ gsettings_remove_all_from_strv (app->settings_global, PROFILE_LIST_KEY, profile_name);
/* And remove the profile directory */
DConfClient *client = dconf_client_new ();
@@ -1101,7 +1164,7 @@ new_profile_response_cb (GtkWidget *new_profile_dialog,
new_profile /* adopts the refcount */);
/* And now save the new profile name to GSettings */
- mate_gsettings_append_strv (app->settings_global,
+ gsettings_append_strv (app->settings_global,
PROFILE_LIST_KEY,
new_profile_name);