[gnome-commander/GSettings] Moves remaining functions from libgcmd/libgcmd-data.cc to src/gnome-cmd-data.cc
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/GSettings] Moves remaining functions from libgcmd/libgcmd-data.cc to src/gnome-cmd-data.cc
- Date: Sun, 22 May 2016 20:05:17 +0000 (UTC)
commit ff97db8380f85f6988a96f2ee98089c9649928c8
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sun May 22 22:04:19 2016 +0200
Moves remaining functions from libgcmd/libgcmd-data.cc to src/gnome-cmd-data.cc
libgcmd/Makefile.am | 1 -
libgcmd/libgcmd-data.cc | 113 -----------------------------------------------
libgcmd/libgcmd-data.h | 33 --------------
libgcmd/libgcmd.h | 1 -
src/gnome-cmd-data.cc | 78 ++++++++++++++++++++++++++++++++-
src/gnome-cmd-data.h | 9 ++++
6 files changed, 86 insertions(+), 149 deletions(-)
---
diff --git a/libgcmd/Makefile.am b/libgcmd/Makefile.am
index 618eb61..746e211 100644
--- a/libgcmd/Makefile.am
+++ b/libgcmd/Makefile.am
@@ -14,7 +14,6 @@ libgcmd_la_SOURCES = \
gnome-cmd-string-dialog.h gnome-cmd-string-dialog.cc \
gnome-cmd-state.h \
libgcmd-utils.h libgcmd-utils.cc \
- libgcmd-data.h libgcmd-data.cc \
libgcmd-widget-factory.h libgcmd-widget-factory.cc \
plugin-info.h \
libgcmd-deps.h \
diff --git a/libgcmd/libgcmd.h b/libgcmd/libgcmd.h
index 5f9be7d..ff97520 100644
--- a/libgcmd/libgcmd.h
+++ b/libgcmd/libgcmd.h
@@ -24,7 +24,6 @@
#include <libgcmd/libgcmd-deps.h>
#include <libgcmd/libgcmd-utils.h>
-#include <libgcmd/libgcmd-data.h>
#include <libgcmd/libgcmd-widget-factory.h>
#include <libgcmd/gnome-cmd-state.h>
#include <libgcmd/gnome-cmd-plugin.h>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 86c3cba..a24c136 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -517,6 +517,12 @@ inline gchar* GnomeCmdData::get_string (const gchar *path, const gchar *def)
}
+inline void GnomeCmdData::set_string (const gchar *path, const gchar *value)
+{
+ gnome_config_set_string (path, value);
+}
+
+
inline gboolean GnomeCmdData::get_bool (const gchar *path, gboolean def)
{
gboolean b = FALSE;
@@ -527,6 +533,41 @@ inline gboolean GnomeCmdData::get_bool (const gchar *path, gboolean def)
}
+inline void GnomeCmdData::set_bool (const gchar *path, gboolean value)
+{
+ gnome_config_set_bool (path, value);
+}
+
+
+inline void GnomeCmdData::set_color (const gchar *path, GdkColor *color)
+{
+ gchar *color_str;
+ color_str = g_strdup_printf ("%d %d %d", color->red, color->green, color->blue);
+ set_string (path, color_str);
+ g_free (color_str);
+}
+
+
+inline void GnomeCmdData::get_color (const gchar *path, GdkColor *color)
+{
+ gint red, green, blue;
+ gchar *def = g_strdup_printf ("%d %d %d",
+ color->red, color->green, color->blue);
+ gchar *color_str = get_string (path, def);
+ if (sscanf (color_str, "%u %u %u", &red, &green, &blue) != 3)
+ g_printerr ("Illegal color in config file\n");
+
+ if (color_str != def)
+ g_free (color_str);
+
+ color->red = (gushort) red;
+ color->green = (gushort) green;
+ color->blue = (gushort) blue;
+
+ g_free (def);
+}
+
+
inline XML::xstream &operator << (XML::xstream &xml, GnomeCmdBookmark &bookmark)
{
xml << XML::tag("Bookmark") << XML::attr("name") << XML::escape(bookmark.name);
@@ -1388,7 +1429,7 @@ static gboolean load_fav_apps_old (const gchar *fname)
}
-inline void gnome_cmd_data_set_string_history (const gchar *format, GList *strings)
+inline void GnomeCmdData::gnome_cmd_data_set_string_history (const gchar *format, GList *strings)
{
gchar key[128];
@@ -2604,6 +2645,15 @@ gchar* GnomeCmdData::gnome_cmd_data_get_string (const gchar *path, const gchar *
return v;
}
+void GnomeCmdData::gnome_cmd_data_set_string (const gchar *path, const gchar *value)
+{
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ set_string (s, value);
+
+ g_free (s);
+}
+
gboolean GnomeCmdData::gnome_cmd_data_get_bool (const gchar *path, gboolean def)
{
gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
@@ -2615,6 +2665,32 @@ gboolean GnomeCmdData::gnome_cmd_data_get_bool (const gchar *path, gboolean def)
return v;
}
+void GnomeCmdData::gnome_cmd_data_set_bool (const gchar *path, gboolean value)
+{
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ set_bool (s, value);
+
+ g_free (s);
+}
+
+void GnomeCmdData::gnome_cmd_data_set_color (const gchar *path, GdkColor *color)
+{
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ set_color (s, color);
+
+ g_free (s);
+}
+
+void GnomeCmdData::gnome_cmd_data_get_color (const gchar *path, GdkColor *color)
+{
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ get_color (s, color);
+
+ g_free (s);
+}
/**
* As GSettings enum-type is of GVARIANT_CLASS String, we need a seperate function for
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index ae506a3..99edaaa 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -481,7 +481,11 @@ struct GnomeCmdData
inline gint get_int (const gchar *path, int def);
inline void set_int (const gchar *path, int value);
inline gchar* get_string (const gchar *path, const gchar *def);
+ inline void set_string (const gchar *path, const gchar *value);
inline gboolean get_bool (const gchar *path, gboolean def);
+ inline void set_bool (const gchar *path, gboolean value);
+ inline void set_color (const gchar *path, GdkColor *color);
+ inline void get_color (const gchar *path, GdkColor *color);
public:
@@ -538,9 +542,14 @@ struct GnomeCmdData
gint gnome_cmd_data_get_int (const gchar *path, int def);
void gnome_cmd_data_set_int (const gchar *path, int value);
gchar* gnome_cmd_data_get_string (const gchar *path, const gchar *def);
+ void gnome_cmd_data_set_string (const gchar *path, const gchar *value);
+ void gnome_cmd_data_set_bool (const gchar *path, gboolean value);
+ void gnome_cmd_data_set_color (const gchar *path, GdkColor *color);
+ void gnome_cmd_data_get_color (const gchar *path, GdkColor *color);
gboolean gnome_cmd_data_get_bool (const gchar *path, gboolean def);
gboolean set_gsettings_when_changed (GSettings *settings, const char *key, gpointer value);
gboolean set_gsettings_enum_when_changed (GSettings *settings, const char *key, gint value);
+ inline void gnome_cmd_data_set_string_history (const gchar *format, GList *strings);
GnomeCmdConRemote *get_quick_connect() const { return quick_connect; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]