[gnome-commander: 219/219] Merges GSettings branch into master branch
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander: 219/219] Merges GSettings branch into master branch
- Date: Sun, 7 Aug 2016 21:46:08 +0000 (UTC)
commit a9fd68a85f144b593bea2c1e8dcb8352be92c220
Merge: fefd5a3 906cfe6
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sun Aug 7 23:43:24 2016 +0200
Merges GSettings branch into master branch
.gitignore | 1 +
.travis.yml | 5 +-
Dockerfile | 1 +
NEWS | 1 +
TODO | 1 +
configure.ac | 10 +-
data/Makefile.am | 23 +-
data/org.gnome.gnome-commander.gschema.xml | 890 ++++++++
doc/C/releases.xml | 3 +
libgcmd/Makefile.am | 1 -
libgcmd/libgcmd-data.cc | 181 --
libgcmd/libgcmd-data.h | 41 -
libgcmd/libgcmd.h | 1 -
pixmaps/Makefile.am | 2 -
pixmaps/toggle_horizontal.xpm | 33 -
pixmaps/toggle_vertical.xpm | 33 -
plugins/fileroller/file-roller-plugin.cc | 62 +-
plugins/fileroller/file-roller-plugin.h | 4 +
po/POTFILES.in | 1 +
src/dialogs/gnome-cmd-delete-dialog.cc | 2 +-
src/dialogs/gnome-cmd-options-dialog.cc | 19 +-
src/gnome-cmd-combo.cc | 2 +-
src/gnome-cmd-data.cc | 3097 ++++++++++++++++++++++++----
src/gnome-cmd-data.h | 260 ++-
src/gnome-cmd-dir-indicator.cc | 4 +-
src/gnome-cmd-file-list.cc | 25 +-
src/gnome-cmd-file-list.h | 1 -
src/gnome-cmd-file-selector.cc | 14 +-
src/gnome-cmd-file-selector.h | 4 +-
src/gnome-cmd-gkeyfile-utils.h | 4 +-
src/gnome-cmd-main-menu.cc | 67 +-
src/gnome-cmd-main-win.cc | 49 +-
src/gnome-cmd-main-win.h | 5 +-
src/gnome-cmd-mime-config.cc | 2 +-
src/gnome-cmd-types.h | 35 +-
src/gnome-cmd-user-actions.cc | 147 +-
src/gnome-cmd-user-actions.h | 10 +-
src/imageloader.cc | 4 +-
src/intviewer/search-dlg.h | 4 +-
src/intviewer/viewer-utils.cc | 33 -
src/intviewer/viewer-utils.h | 4 -
src/intviewer/viewer-window.cc | 108 +-
src/intviewer/viewer-window.h | 4 +
src/main.cc | 7 +-
src/utils.cc | 8 +-
45 files changed, 4156 insertions(+), 1057 deletions(-)
---
diff --cc src/gnome-cmd-data.cc
index 740e361,e8c29a0..9c875fa
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@@ -2158,8 -4136,288 +4136,287 @@@ void GnomeCmdData::save(
save_xml ();
save_auto_load_plugins();
+ }
+
+ gint GnomeCmdData::gnome_cmd_data_get_int (const gchar *path, int def)
+ {
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ gint v = get_int (s, def);
+
+ g_free (s);
+
+ return v;
+ }
+
+
+ void GnomeCmdData::gnome_cmd_data_set_int (const gchar *path, int value)
+ {
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ set_int (s, value);
+
+ g_free (s);
+ }
+
+ gchar* GnomeCmdData::gnome_cmd_data_get_string (const gchar *path, const gchar *def)
+ {
+ gchar *s = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ gchar *v = get_string (s, def);
+
+ g_free (s);
+
+ 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);
+
+ gboolean v = get_bool (s, def);
+
+ g_free (s);
+
+ 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);
+ }
- gnome_config_sync ();
+ 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);
+ }
+
+ /**
+ * This function tests if the given colorstring enholds a valid color-describing string.
+ * See documentation of gdk_color_parse() for valid strings.
+ * @returns TRUE if the string is a valid color representation, else FALSE.
+ */
+ gboolean GnomeCmdData::is_valid_color_string(const char *colorstring)
+ {
+ g_return_val_if_fail(colorstring, FALSE);
+
+ gboolean return_value;
+ GdkColor *test_color;
+
+ test_color = gdk_color_new (0,0,0);
+ return_value = gdk_color_parse (colorstring, test_color);
+ g_free(test_color);
+
+ return return_value;
+ }
+
+ /**
+ * This function loads a color specification, stored at the char pointer spec,
+ * into *color if it is a valid color specification.
+ * @returns the return value of gdk_color_parse function.
+ */
+ gboolean GnomeCmdData::gnome_cmd_data_parse_color (const gchar *spec, GdkColor *color)
+ {
+ g_return_val_if_fail(spec,FALSE);
+ g_return_val_if_fail(color,FALSE);
+
+ if (is_valid_color_string(spec) == TRUE)
+ return gdk_color_parse (spec, color);
+ else
+ return FALSE;
+ }
+
+ /**
+ * The task of this function is to store red, green and blue color
+ * values in the GdkColor variable to which color is pointing to, based
+ * on the GSettings value of key. First, it is tested if this value is a
+ * valid GdkColor string. If yes, color is updated; if not, the current
+ * string representing color is used to set back the string in the
+ * GSettings key.
+ */
+ gboolean GnomeCmdData::set_color_if_valid_key_value(GdkColor *color, GSettings *settings, const char *key)
+ {
+ gboolean return_value;
+ gchar *colorstring_new;
+ gchar *colorstring_old;
+
+ colorstring_new = g_settings_get_string (settings, key);
+ if (!gnome_cmd_data.is_valid_color_string(colorstring_new))
+ {
+ colorstring_old = gdk_color_to_string (color);
+ g_settings_set_string (settings, key, colorstring_old);
+ g_warning("Illegal color string \'%s\'. Resetting to old value \'%s\'", colorstring_new,
colorstring_old);
+ g_free(colorstring_old);
+ return_value = TRUE;
+ }
+ else
+ {
+ gnome_cmd_data.gnome_cmd_data_parse_color(colorstring_new, color);
+ return_value = FALSE;
+ }
+ g_free(colorstring_new);
+ return return_value;
+ }
+
+ /**
+ * This function loads a color specification into color by using gnome_config.
+ * It will be obsolete in GCMD > 1.6.0
+ */
+ void GnomeCmdData::gnome_cmd_data_get_color_gnome_config (const gchar *path, GdkColor *color)
+ {
+ gchar *def = g_strdup_printf ("%d %d %d",
+ color->red, color->green, color->blue);
+
+ gchar *gcmd_path = g_build_path (G_DIR_SEPARATOR_S, PACKAGE, path, NULL);
+
+ gchar *color_str = get_string (gcmd_path, def);
+
+ gint red, green, blue;
+ 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);
+ g_free (def);
+
+ color->red = (gushort) red;
+ color->green = (gushort) green;
+ color->blue = (gushort) blue;
+
+ g_free (gcmd_path);
+ }
+
+ /**
+ * As GSettings enum-type is of GVARIANT_CLASS String, we need a seperate function for
+ * finding out if a key value has changed. This is done here. For storing the other GSettings
+ * types, see @link set_gsettings_when_changed @endlink .
+ * @returns TRUE if new value could be stored, else FALSE
+ */
+ gboolean GnomeCmdData::set_gsettings_enum_when_changed (GSettings *settings, const char *key, gint
new_value)
+ {
+ GVariant *default_val;
+ gboolean rv = true;
+
+ default_val = g_settings_get_default_value (settings, key);
+
+ // An enum key must be of type G_VARIANT_CLASS_STRING
+ if (g_variant_classify(default_val) == G_VARIANT_CLASS_STRING)
+ {
+ gint old_value;
+ old_value = g_settings_get_enum(settings, key);
+ if (old_value != new_value)
+ rv = g_settings_set_enum (settings, key, new_value);
+ }
+ else
+ {
+ g_warning("Could not store value of type '%s' for key '%s'\n", g_variant_get_type_string
(default_val), key);
+ rv = false;
+ }
+
+ if (default_val)
+ g_variant_unref (default_val);
+
+ return rv;
+ }
+
+
+ /**
+ * This method stores the value for a given key if the value is different from the currently stored one
+ * under the keys value. This function is able of storing several types of GSettings values (except enums
+ * which is done in @link set_gsettings_enum_when_changed @endlink ). Therefore, it first checks the type
+ * of GVariant of the default value of the given key. Depending on the result, the gpointer is than casted
+ * to the correct type so that *value can be saved.
+ * @returns TRUE if new value could be stored, else FALSE
+ */
+ gboolean GnomeCmdData::set_gsettings_when_changed (GSettings *settings, const char *key, gpointer value)
+ {
+ GVariant *default_val;
+ gboolean rv = true;
+ default_val = g_settings_get_default_value (settings, key);
+
+ switch (g_variant_classify(default_val))
+ {
+ case G_VARIANT_CLASS_INT32:
+ {
+ gint old_value;
+ gint new_value = *(gint*) value;
+
+ old_value = g_settings_get_int (settings, key);
+ if (old_value != new_value)
+ rv = g_settings_set_int (settings, key, new_value);
+ break;
+ }
+ case G_VARIANT_CLASS_UINT32:
+ {
+ gint old_value;
+ gint new_value = *(gint*) value;
+
+ old_value = g_settings_get_uint (settings, key);
+ if (old_value != new_value)
+ rv = g_settings_set_uint (settings, key, new_value);
+ break;
+ }
+ case G_VARIANT_CLASS_STRING:
+ {
+ gchar *old_value;
+ gchar *new_value = (char*) value;
+
+ old_value = g_settings_get_string (settings, key);
+ if (strcmp(old_value, new_value) != 0)
+ rv = g_settings_set_string (settings, key, new_value);
+ g_free(old_value);
+ break;
+ }
+ case G_VARIANT_CLASS_BOOLEAN:
+ {
+ gboolean old_value;
+ gboolean new_value = *(gboolean*) value;
+
+ old_value = g_settings_get_boolean (settings, key);
+ if (old_value != new_value)
+ rv = g_settings_set_boolean (settings, key, new_value);
+ break;
+ }
+ default:
+ {
+ g_warning("Could not store value of type '%s' for key '%s'\n", g_variant_get_type_string
(default_val), key);
+ rv = false;
+ break;
+ }
+ }
+ if (default_val)
+ g_variant_unref (default_val);
+
+ return rv;
+ }
+
+ gboolean GnomeCmdData::set_gsettings_color_when_changed (GSettings *settings, const char *key, GdkColor
*color)
+ {
+ gboolean return_value;
+ gchar *colorstring;
+
-
+ colorstring = gdk_color_to_string (color);
+ return_value = set_gsettings_when_changed (settings, key, colorstring);
+ g_free(colorstring);
+
+ return return_value;
}
diff --cc src/gnome-cmd-data.h
index a0d3fcf,ebe2d0e..029ed79
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@@ -417,15 -576,19 +576,19 @@@ struct GnomeCmdDat
void load_auto_load_plugins();
void load_cmdline_history();
- void load_local_bookmarks();
void load_rename_history();
- void load_search_defaults();
void load_intviewer_defaults();
- void load_smb_bookmarks();
- void save_auto_load_plugins();
+ gboolean save_auto_load_plugins();
void save_cmdline_history();
void save_intviewer_defaults();
- void set_settings_monitor (const char *file_path);
++ void set_settings_monitor (const char *file_path);
+ 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);
- void set_settings_monitor (const char *file_path);
public:
@@@ -473,10 -638,29 +638,29 @@@
void free(); // FIXME: free() -> ~GnomeCmdData()
void load();
+ void migrate_all_data_to_gsettings();
+ gint migrate_data_int_value_into_gsettings(gint user_value, GSettings *settings, const char *key);
+ gboolean migrate_data_string_value_into_gsettings(const char* user_value, GSettings *settings, const
char *key);
void load_more();
+ inline GList* load_string_history (const gchar *format, gint size);
void save();
-
- void save_xml ();
++ void save_xml ();
+ 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);
+ gboolean gnome_cmd_data_parse_color (const gchar *spec, GdkColor *color);
+ gboolean set_color_if_valid_key_value(GdkColor *color, GSettings *settings, const char *key);
+ void gnome_cmd_data_get_color_gnome_config (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_color_when_changed (GSettings *settings, const char *key, GdkColor *color);
+ 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);
+ gboolean is_valid_color_string(const char *colorstring);
+ gboolean set_valid_color_string(GSettings *settings, const char* key);
- void save_xml ();
GnomeCmdConRemote *get_quick_connect() const { return quick_connect; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]