[gnome-commander/gcmd-1-10: 2/8] Remove gnome-cmd-xml-config
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-10: 2/8] Remove gnome-cmd-xml-config
- Date: Sat, 13 Apr 2019 10:44:55 +0000 (UTC)
commit 240c177f5061737014bab0579d3062fcf0d39f8e
Author: Uwe Scholz <u scholz83 gmx de>
Date: Fri Apr 12 23:16:52 2019 +0200
Remove gnome-cmd-xml-config
po/POTFILES.in | 1 -
src/Makefile.am | 1 -
src/gnome-cmd-data.cc | 316 +---------------------
src/gnome-cmd-data.h | 9 +-
src/gnome-cmd-file-list.h | 1 -
src/gnome-cmd-file-selector.h | 1 -
src/gnome-cmd-main-win.h | 1 -
src/gnome-cmd-user-actions.h | 1 -
src/gnome-cmd-xml-config.cc | 616 ------------------------------------------
src/gnome-cmd-xml-config.h | 295 --------------------
10 files changed, 17 insertions(+), 1225 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b46fff66..82c94b9d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,7 +57,6 @@ src/gnome-cmd-smb-path.cc
src/gnome-cmd-user-actions.cc
src/gnome-cmd-xfer.cc
src/gnome-cmd-xfer-progress-win.cc
-src/gnome-cmd-xml-config.cc
src/imageloader.cc
src/intviewer/cp437.cc
src/intviewer/datapresentation.cc
diff --git a/src/Makefile.am b/src/Makefile.am
index b4820082..a8798ef0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,7 +74,6 @@ gnome_commander_SOURCES = \
gnome-cmd-user-actions.h gnome-cmd-user-actions.cc \
gnome-cmd-xfer.h gnome-cmd-xfer.cc \
gnome-cmd-xfer-progress-win.h gnome-cmd-xfer-progress-win.cc \
- gnome-cmd-xml-config.h gnome-cmd-xml-config.cc \
handle.h \
history.h history.cc \
imageloader.cc imageloader.h \
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index e7d72384..eefd3e2a 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1734,7 +1734,7 @@ void GnomeCmdData::add_advrename_profile_to_gvariant_builder(GVariantBuilder *bu
/**
* Save devices in gSettings
*/
-void GnomeCmdData::save_devices_via_gsettings()
+void GnomeCmdData::save_devices()
{
GVariant* devicesToStore;
GList *devices;
@@ -1777,7 +1777,7 @@ void GnomeCmdData::save_devices_via_gsettings()
/**
* Save tabs in given gSettings and in given key
*/
-static void save_tabs_via_gsettings(GSettings *gSettings, const char *gSettingsKey)
+static void save_tabs(GSettings *gSettings, const char *gSettingsKey)
{
GVariant* fileListTabs;
GVariantBuilder gVariantBuilder;
@@ -1847,10 +1847,7 @@ static void save_tabs_via_gsettings(GSettings *gSettings, const char *gSettingsK
}
-/**
- * Save devices
- */
- void GnomeCmdData::save_fav_apps_via_gsettings()
+ void GnomeCmdData::save_fav_apps()
{
if (gnome_cmd_data.options.fav_apps)
{
@@ -2035,105 +2032,6 @@ void GnomeCmdData::load_keybindings()
}
-/**
- * Save favourite applications in the given file by means of GKeyFile.
- */
-static void save_devices_old (const gchar *fname)
-{
- GList *devices;
- gchar *path = config_dir ?
- g_build_filename (config_dir, fname, nullptr) :
- g_build_filename (get_package_config_dir(), fname, nullptr);
- GKeyFile *key_file;
- key_file = g_key_file_new ();
-
- devices = gnome_cmd_con_list_get_all_dev (gnome_cmd_data.priv->con_list);
-
- if (devices)
- {
- for (; devices; devices = devices->next)
- {
- GnomeCmdConDevice *device = GNOME_CMD_CON_DEVICE (devices->data);
- if (device && !gnome_cmd_con_device_get_autovol (device))
- {
- gchar *alias = g_strescape (gnome_cmd_con_device_get_alias (device), nullptr);
-
- gchar *device_fn = (gchar *) gnome_cmd_con_device_get_device_fn (device);
- if (device_fn && device_fn[0] != '\0')
- device_fn = g_strescape (device_fn, nullptr);
- else
- device_fn = g_strdup ("x");
-
- gchar *mountp = g_strescape (gnome_cmd_con_device_get_mountp (device), nullptr);
-
- gchar *icon_path = (gchar *) gnome_cmd_con_device_get_icon_path (device);
- if (icon_path && icon_path[0] != '\0')
- icon_path = g_strescape (icon_path, nullptr);
- else
- icon_path = g_strdup ("x");
-
- g_key_file_set_string(key_file, alias, DEVICES_DEVICE, device_fn);
- g_key_file_set_string(key_file, alias, DEVICES_MOUNT_POINT, mountp);
- g_key_file_set_string(key_file, alias, DEVICES_ICON_PATH, icon_path);
-
- g_free (alias);
- g_free (device_fn);
- g_free (mountp);
- g_free (icon_path);
- }
- }
-
- gcmd_key_file_save_to_file (path, key_file);
- }
-
- g_key_file_free(key_file);
- g_free (path);
-}
-
-
-/**
- * Save favourite applications in the given file by means of GKeyFile.
- */
-static void save_fav_apps_old (const gchar *fname)
-{
- gchar *path = config_dir ?
- g_build_filename (config_dir, fname, nullptr) :
- g_build_filename (get_package_config_dir(), fname, nullptr);
- GKeyFile *key_file;
- key_file = g_key_file_new ();
-
- /* Now save the list */
- for (GList *i = gnome_cmd_data.options.fav_apps; i; i = i->next)
- {
- auto app = static_cast<GnomeCmdApp*> (i->data);
- if (app)
- {
- gchar *group_name = g_strdup(gnome_cmd_app_get_name(app));
- gchar *icon = g_strdup(gnome_cmd_app_get_icon_path(app));
- if (!icon)
- icon = g_strdup("");
-
- g_key_file_set_string(key_file, group_name, FAV_APPS_CMD, gnome_cmd_app_get_command(app));
- g_key_file_set_string(key_file, group_name, FAV_APPS_ICON, icon);
- g_key_file_set_string(key_file, group_name, FAV_APPS_PATTERN,
gnome_cmd_app_get_pattern_string(app));
- g_key_file_set_integer(key_file, group_name, FAV_APPS_TARGET, gnome_cmd_app_get_target(app));
- g_key_file_set_integer(key_file, group_name, FAV_APPS_HANDLES_URIS,
gnome_cmd_app_get_handles_uris(app));
- g_key_file_set_integer(key_file, group_name, FAV_APPS_HANDLES_MULTIPLE,
gnome_cmd_app_get_handles_multiple(app));
- g_key_file_set_integer(key_file, group_name, FAV_APPS_REQUIRES_TERMINAL,
gnome_cmd_app_get_requires_terminal(app));
-
- g_free (icon);
- g_free (group_name);
- }
- }
-
- if (gnome_cmd_data.options.fav_apps)
- gcmd_key_file_save_to_file (path, key_file);
-
- g_key_file_free(key_file);
- g_free (path);
-}
-
-
inline gboolean vfs_is_uri_local (const char *uri)
{
GnomeVFSURI *pURI = gnome_vfs_uri_new (uri);
@@ -2366,82 +2264,6 @@ void GnomeCmdData::load_bookmarks()
}
-/**
- * This function reads the given file and sets up additional devices by
- * means of GKeyFile.
- */
-static gboolean load_devices (const gchar *fname)
-{
- gchar *path = config_dir ?
- g_build_filename (config_dir, fname, nullptr) :
- g_build_filename (get_package_config_dir(), fname, nullptr);
-
- ifstream f(path);
-
- //Device file does not exist
- if(f.fail())
- {
- g_free (path);
- return FALSE;
- }
-
- GKeyFile *keyfile;
- gsize length;
- gchar **groups;
-
- keyfile = gcmd_key_file_load_from_file(path, 0);
-
- // keyfile exists but it is empty, no need to do anything here
- if (keyfile == nullptr)
- {
- remove(path);
- g_free (path);
- return TRUE;
- }
-
- groups = g_key_file_get_groups (keyfile, &length);
-
- for (guint i = 0; i < length; i++)
- {
- gchar *alias = nullptr;
- gchar *device_fn = nullptr;
- gchar *mountp = nullptr;
- gchar *icon_path = nullptr;
- GError *error = nullptr;
-
- alias = g_strdup(groups[i]);
- device_fn = g_key_file_get_string (keyfile, groups[i], DEVICES_DEVICE, &error);
- mountp = g_key_file_get_string (keyfile, groups[i], DEVICES_MOUNT_POINT, &error);
- icon_path = g_key_file_get_string (keyfile, groups[i], DEVICES_ICON_PATH, &error);
-
- if (error != nullptr)
- {
- fprintf (stderr, "Unable to read file: %s\n", error->message);
- g_error_free (error);
- }
- else
- {
- gnome_cmd_data.priv->con_list->add (gnome_cmd_con_device_new (alias, device_fn, mountp,
icon_path));
- }
- g_free(alias);
- g_free(device_fn);
- g_free(mountp);
- g_free(icon_path);
- }
-
- load_vfs_auto_devices ();
-
- // delete deprecated file
- remove(path);
-
- g_free (path);
-
- save_devices_old ("devices.gkeyfile_deprecated");
-
- return TRUE;
-}
-
-
/**
* This method reads the gsettings section of the advance rename tool
*/
@@ -2608,7 +2430,7 @@ void GnomeCmdData::load_search_profiles ()
/**
* Loads devices from gSettings into gcmd options
*/
-void GnomeCmdData::load_fav_apps_from_gsettings()
+void GnomeCmdData::load_fav_apps()
{
GVariant *gvFavApps, *favApp;
GVariantIter iter;
@@ -2644,83 +2466,6 @@ void GnomeCmdData::load_fav_apps_from_gsettings()
}
-/**
- * This function reads the given file and sets up favourite applications
- * by means of GKeyFile and by filling gnome_cmd_data.options.fav_apps.
- */
-static gboolean load_fav_apps_old (const gchar *fname)
-{
- GKeyFile *keyfile;
- gchar *path = config_dir ?
- g_build_filename (config_dir, fname, nullptr) :
- g_build_filename (get_package_config_dir(), fname, nullptr);
-
- gnome_cmd_data.options.fav_apps = nullptr;
-
- keyfile = gcmd_key_file_load_from_file(path, 0);
-
- if (keyfile == nullptr)
- {
- g_free(path);
- return FALSE;
- }
-
- gsize length;
- gchar **groups;
-
- groups = g_key_file_get_groups (keyfile, &length);
-
- for (guint i = 0; i < length; i++)
- {
- gchar *name = nullptr;
- gchar *cmd = nullptr;
- gchar *icon_path = nullptr;
- gchar *pattern = nullptr;
- guint target;
- guint handles_uris;
- guint handles_multiple;
- guint requires_terminal;
- GError *error = nullptr;
-
- name = g_strdup(groups[i]);
- cmd = g_key_file_get_string (keyfile, groups[i], FAV_APPS_CMD, &error);
- icon_path = g_key_file_get_string (keyfile, groups[i], FAV_APPS_ICON, &error);
- pattern = g_key_file_get_string (keyfile, groups[i], FAV_APPS_PATTERN, &error);
- target = g_key_file_get_integer (keyfile, groups[i], FAV_APPS_TARGET, &error);
- handles_uris = g_key_file_get_boolean (keyfile, groups[i], FAV_APPS_HANDLES_URIS, &error);
- handles_multiple = g_key_file_get_boolean (keyfile, groups[i], FAV_APPS_HANDLES_MULTIPLE, &error);
- requires_terminal = g_key_file_get_boolean (keyfile, groups[i], FAV_APPS_REQUIRES_TERMINAL, &error);
-
- if (error != nullptr)
- {
- fprintf (stderr, "Unable to read file: %s\n", error->message);
- g_error_free (error);
- }
- else
- {
- gnome_cmd_data.options.fav_apps = g_list_append (
- gnome_cmd_data.options.fav_apps,
- gnome_cmd_app_new_with_values (
- name, cmd, icon_path, (AppTarget) target, pattern,
- handles_uris, handles_multiple, requires_terminal));
- }
-
- g_free (name);
- g_free (cmd);
- g_free (icon_path);
- g_free (pattern);
- }
-
- remove(path);
-
- g_free(path);
- g_strfreev(groups);
- g_key_file_free(keyfile);
-
- save_fav_apps_old("fav-apps.gkeyfile_deprecated");
- return TRUE;
-}
-
/**
* This function converts a GList into a NULL terminated array of char pointers.
* This array is stored into the given GSettings key.
@@ -3011,7 +2756,7 @@ void GnomeCmdData::load_tabs_from_gsettings()
/**
* Loads devices from gSettings into gcmd options
*/
-void GnomeCmdData::load_devices_from_gsettings()
+void GnomeCmdData::load_devices()
{
GVariant *gvDevices, *device;
GVariantIter iter;
@@ -3682,18 +3427,12 @@ void GnomeCmdData::load()
}
priv->con_list->lock();
- if (load_devices (DEVICES_FILENAME) == FALSE)
- load_devices_from_gsettings();
- else // This is done for migration to gSettings. Can be deleted in gcmd 1.10.
- save_devices_via_gsettings();
-
- g_autofree gchar *xml_cfg_path = config_dir ? g_build_filename (config_dir, PACKAGE ".xml", nullptr) :
g_build_filename (get_package_config_dir(), PACKAGE ".xml", nullptr);
+ load_devices();
// ToDo: Remove the check for connections file in gcmd version > 1.10.1
// Move connections to connections.deprecated
g_autofree gchar *connections_path_old = g_build_filename (get_package_config_dir(), "connections",
nullptr);
ifstream f(connections_path_old);
-
// If connections file does exist - rename it so that the user know it can be removed
if(!f.fail())
{
@@ -3701,40 +3440,12 @@ void GnomeCmdData::load()
rename (connections_path_old, connections_path_new);
}
- // ToDo: Remove the check for xml cfg file in gcmd version >= 1.10.0
- if (gnome_cmd_xml_config_load (xml_cfg_path, *this))
- {
- // Convert advrename history from xml into gsettings
- set_gsettings_string_array_from_glist(options.gcmd_settings->general,
GCMD_SETTINGS_ADVRENAME_TOOL_TEMPLATE_HISTORY, advrename_defaults.templates.ents);
-
- // Convert xml to keyfiles by using the save methods.
- save_advrename_profiles();
-
- // Convert directory history
- save_directory_history();
-
- // Move gnome-commander.xml to gnome-commander.xml.deprecated
- g_autofree gchar *xml_cfg_path_old = config_dir ? g_build_filename (config_dir, PACKAGE ".xml",
nullptr) : g_build_filename (get_package_config_dir(), PACKAGE ".xml", nullptr);
- g_autofree gchar *xml_cfg_path_new = config_dir ? g_build_filename (config_dir, PACKAGE ".xml",
nullptr) : g_build_filename (get_package_config_dir(), PACKAGE ".xml.deprecated", nullptr);
-
- auto rv = rename (xml_cfg_path_old, xml_cfg_path_new);
- if (rv == -1)
- {
- g_warning("xml config file could not be renamed to \"%s\".", xml_cfg_path_new);
- }
- }
-
load_advrename_profiles ();
load_search_profiles ();
load_connections ();
load_bookmarks ();
load_keybindings ();
-
- if (load_fav_apps_old(FAV_APPS_FILENAME) == FALSE)
- load_fav_apps_from_gsettings();
- else // This is done for migration to gSettings. Can be deleted in gcmd 1.10.
- save_fav_apps_via_gsettings();
-
+ load_fav_apps ();
load_directory_history ();
priv->con_list->unlock();
@@ -3983,9 +3694,9 @@ void GnomeCmdData::save()
set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_ADVRENAME_TOOL_HEIGHT,
&(advrename_defaults.height));
set_gsettings_string_array_from_glist(options.gcmd_settings->general,
GCMD_SETTINGS_ADVRENAME_TOOL_TEMPLATE_HISTORY, advrename_defaults.templates.ents);
- save_tabs_via_gsettings (options.gcmd_settings->general, GCMD_SETTINGS_FILE_LIST_TABS);
- save_devices_via_gsettings ();
- save_fav_apps_via_gsettings ();
+ save_tabs (options.gcmd_settings->general, GCMD_SETTINGS_FILE_LIST_TABS);
+ save_devices ();
+ save_fav_apps ();
save_cmdline_history ();
save_directory_history ();
save_search_history ();
@@ -3993,11 +3704,10 @@ void GnomeCmdData::save()
save_connections ();
save_bookmarks ();
save_keybindings ();
+ save_advrename_profiles ();
+ save_intviewer_defaults ();
+ save_auto_load_plugins ();
- save_advrename_profiles();
- save_intviewer_defaults();
-
- save_auto_load_plugins();
g_settings_sync ();
}
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 7bddc2c0..fc7fd906 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -34,7 +34,6 @@
#include "gnome-cmd-types.h"
#include "gnome-cmd-file-list.h"
#include "gnome-cmd-regex.h"
-#include "gnome-cmd-xml-config.h"
#include "filter.h"
#include "history.h"
#include "dict.h"
@@ -644,8 +643,8 @@ struct GnomeCmdData
void save_directory_history();
void save_search_history();
void save_intviewer_defaults();
- void save_devices_via_gsettings();
- void save_fav_apps_via_gsettings();
+ void save_devices();
+ void save_fav_apps();
void add_advrename_profile_to_gvariant_builder(GVariantBuilder *builder, AdvrenameConfig::Profile
profile);
gboolean add_bookmark_to_gvariant_builder(GVariantBuilder *builder, std::string bookmarkName,
GnomeCmdCon *con);
void add_search_profile_to_gvariant_builder(GVariantBuilder *builder, SearchProfile searchProfile);
@@ -705,8 +704,8 @@ struct GnomeCmdData
void load_colors();
void load_color_themes();
void load_tabs_from_gsettings();
- void load_devices_from_gsettings();
- void load_fav_apps_from_gsettings();
+ void load_devices();
+ void load_fav_apps();
void gsettings_init();
void migrate_all_data_to_gsettings();
gint migrate_data_int_value_into_gsettings(gint user_value, GSettings *settings, const char *key);
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index eaee834b..d747312c 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -24,7 +24,6 @@
#include "gnome-cmd-dir.h"
#include "gnome-cmd-clist.h"
#include "gnome-cmd-collection.h"
-#include "gnome-cmd-xml-config.h"
#include "filter.h"
#define GNOME_CMD_TYPE_FILE_LIST (gnome_cmd_file_list_get_type ())
diff --git a/src/gnome-cmd-file-selector.h b/src/gnome-cmd-file-selector.h
index 4d8dddc4..42791116 100644
--- a/src/gnome-cmd-file-selector.h
+++ b/src/gnome-cmd-file-selector.h
@@ -34,7 +34,6 @@ struct GnomeCmdMainWin;
#include "gnome-cmd-con.h"
#include "gnome-cmd-dir.h"
#include "gnome-cmd-notebook.h"
-#include "gnome-cmd-xml-config.h"
struct GnomeCmdCombo;
diff --git a/src/gnome-cmd-main-win.h b/src/gnome-cmd-main-win.h
index d617c0bf..265a7b54 100644
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -23,7 +23,6 @@
#include "gnome-cmd-file-selector.h"
#include "gnome-cmd-cmdline.h"
-#include "gnome-cmd-xml-config.h"
#include "plugin_manager.h"
#include "dialogs/gnome-cmd-advrename-dialog.h"
#include "dialogs/gnome-cmd-search-dialog.h"
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index a39fffeb..a25b330e 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -30,7 +30,6 @@
#include "gnome-cmd-file-selector.h"
#include "gnome-cmd-data.h"
#include "gnome-cmd-main-win.h"
-#include "gnome-cmd-xml-config.h"
#include "dict.h"
#define GNOME_CMD_USER_ACTION(f) void f(GtkMenuItem *menuitem=NULL, gpointer user_data=NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]