[gnome-commander/GSettings] Adds symlink_prefix option to GSettings (now known as symlink-string)
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/GSettings] Adds symlink_prefix option to GSettings (now known as symlink-string)
- Date: Sun, 5 Jun 2016 20:15:49 +0000 (UTC)
commit cfa1e87c2112055f36b1fb079337f9bc15909fb8
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sun Jun 5 22:15:24 2016 +0200
Adds symlink_prefix option to GSettings (now known as symlink-string)
data/org.gnome.gnome-commander.gschema.xml | 10 +++++--
src/gnome-cmd-data.cc | 39 +++++++++++++++------------
src/gnome-cmd-data.h | 4 +++
3 files changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 503e4c0..dd99d33 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -215,10 +215,14 @@
<summary>Show buttonbar</summary>
<description>Defines if the buttonbar is shown.</description>
</key>
- <key name="symlink-prefix" type="s">
+ <key name="symlink-string" type="s">
<default l10n="messages">''</default>
- <summary></summary>
- <description></description>
+ <summary>Symlink string</summary>
+ <description>
+ This string defines the default name of a newly created symlink. Leave the string
+ empty to use the default value which is hard coded into the program code. A '%s'
+ will be expanded to the item name for which a link should be created.
+ </description>
</key>
<key name="main-win-pos-x" type="i">
<default l10n="messages">0</default>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 200c4e6..a007fe7 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -254,6 +254,11 @@ void on_horizontal_orientation_changed ()
main_win->focus_file_lists();
}
+void on_symlink_string_changed ()
+{
+ gnome_cmd_data.options.symlink_prefix = g_settings_get_string
(gnome_cmd_data.options.gcmd_settings->general, GCMD_SETTINGS_SYMLINK_PREFIX);
+}
+
static void gcmd_settings_class_init (GcmdSettingsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -390,6 +395,11 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
G_CALLBACK (on_horizontal_orientation_changed),
NULL);
+ g_signal_connect (gs->general,
+ "changed::symlink-string",
+ G_CALLBACK (on_symlink_string_changed),
+ NULL);
+
}
@@ -409,7 +419,6 @@ struct GnomeCmdData::Private
gint sort_column[2];
gboolean sort_direction[2];
gint main_win_pos[2];
- gchar *symlink_prefix;
gchar *ftp_anonymous_password;
};
@@ -435,6 +444,7 @@ GnomeCmdData::Options::Options(const Options &cfg)
save_dirs_on_exit = cfg.save_dirs_on_exit;
save_tabs_on_exit = cfg.save_tabs_on_exit;
save_dir_history_on_exit = cfg.save_dir_history_on_exit;
+ symlink_prefix = g_strdup (cfg.symlink_prefix);
size_disp_mode = cfg.size_disp_mode;
perm_disp_mode = cfg.perm_disp_mode;
date_format = g_strdup (cfg.date_format);
@@ -492,6 +502,7 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
save_dirs_on_exit = cfg.save_dirs_on_exit;
save_tabs_on_exit = cfg.save_tabs_on_exit;
save_dir_history_on_exit = cfg.save_dir_history_on_exit;
+ symlink_prefix = g_strdup (cfg.symlink_prefix);
size_disp_mode = cfg.size_disp_mode;
perm_disp_mode = cfg.perm_disp_mode;
date_format = g_strdup (cfg.date_format);
@@ -1865,6 +1876,9 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
if (temp_value > MAX_GUI_UPDATE_RATE)
temp_value = MAX_GUI_UPDATE_RATE;
migrate_data_int_value_into_gsettings(temp_value, options.gcmd_settings->general,
GCMD_SETTINGS_GUI_UPDATE_RATE);
+ //symlink_prefix
+ migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string ("/options/symlink_prefix", ""),
+ options.gcmd_settings->general,
GCMD_SETTINGS_SYMLINK_PREFIX);
// ToDo: Move old xml-file to ~/.gnome-commander/gnome-commander.xml.backup
// à la save_devices_old ("devices.backup");
// and move .gnome2/gnome-commander to .gnome2/gnome-commander.backup
@@ -2065,11 +2079,11 @@ void GnomeCmdData::load()
options.quick_search_exact_match_end = gnome_cmd_data_get_bool
("/programs/quick_search_exact_match_end", FALSE);
options.skip_mounting = gnome_cmd_data_get_bool ("/programs/skip_mounting", FALSE);
- priv->symlink_prefix = gnome_cmd_data_get_string ("/options/symlink_prefix", _("link to %s"));
- if (!*priv->symlink_prefix || strcmp(priv->symlink_prefix, _("link to %s"))==0)
+ options.symlink_prefix = g_settings_get_string(options.gcmd_settings->general,
GCMD_SETTINGS_SYMLINK_PREFIX);
+ if (!*options.symlink_prefix || strcmp(options.symlink_prefix, _("link to %s"))==0)
{
- g_free (priv->symlink_prefix);
- priv->symlink_prefix = NULL;
+ g_free (options.symlink_prefix);
+ options.symlink_prefix = NULL;
}
options.viewer = gnome_cmd_data_get_string ("/programs/viewer", "gedit %s");
@@ -2588,11 +2602,6 @@ void GnomeCmdData::save()
set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_CMDLINE,
&(cmdline_visibility));
set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_BUTTONBAR,
&(buttonbar_visibility));
- if (priv->symlink_prefix && *priv->symlink_prefix && strcmp(priv->symlink_prefix, _("link to %s"))!=0)
- gnome_cmd_data_set_string ("/options/symlink_prefix", priv->symlink_prefix);
- else
- gnome_cmd_data_set_string ("/options/symlink_prefix", "");
-
gnome_cmd_data_set_int ("/options/main_win_pos_x", priv->main_win_pos[0]);
gnome_cmd_data_set_int ("/options/main_win_pos_y", priv->main_win_pos[1]);
@@ -2953,13 +2962,9 @@ void gnome_cmd_data_get_main_win_pos (gint *x, gint *y)
const gchar *gnome_cmd_data_get_symlink_prefix ()
{
- return gnome_cmd_data.priv->symlink_prefix ? gnome_cmd_data.priv->symlink_prefix : _("link to %s");
-}
-
-
-void gnome_cmd_data_set_symlink_prefix (const gchar *value)
-{
- gnome_cmd_data.priv->symlink_prefix = g_strdup (value);
+ char *symlink_prefix;
+ symlink_prefix = g_settings_get_string (gnome_cmd_data.options.gcmd_settings->general,
GCMD_SETTINGS_SYMLINK_PREFIX);
+ return (strlen(symlink_prefix) > 0) ? symlink_prefix : _("link to %s");
}
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index b7d0636..5a4d06d 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -80,6 +80,7 @@ GcmdSettings *gcmd_settings_new (void);
#define GCMD_SETTINGS_SHOW_TOOLBAR "show-toolbar"
#define GCMD_SETTINGS_SHOW_BUTTONBAR "show-buttonbar"
#define GCMD_SETTINGS_GUI_UPDATE_RATE "gui-update-rate"
+#define GCMD_SETTINGS_SYMLINK_PREFIX "symlink-string"
#define GCMD_PREF_FILTER "org.gnome.gnome-commander.preferences.filter"
#define GCMD_SETTINGS_FILTER_HIDE_UNKNOWN "hide-unknown"
@@ -160,6 +161,7 @@ struct GnomeCmdData
gboolean save_dirs_on_exit;
gboolean save_tabs_on_exit;
gboolean save_dir_history_on_exit;
+ gchar *symlink_prefix;
// Format
GnomeCmdSizeDispMode size_disp_mode;
GnomeCmdPermDispMode perm_disp_mode;
@@ -216,6 +218,7 @@ struct GnomeCmdData
save_dirs_on_exit(FALSE),
save_tabs_on_exit(TRUE),
save_dir_history_on_exit(TRUE),
+ symlink_prefix(NULL),
size_disp_mode(GNOME_CMD_SIZE_DISP_MODE_POWERED),
perm_disp_mode(GNOME_CMD_PERM_DISP_MODE_TEXT),
date_format(NULL),
@@ -257,6 +260,7 @@ struct GnomeCmdData
~Options()
{
+ g_free (symlink_prefix);
g_free (date_format);
g_free (list_font);
g_free (theme_icon_dir);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]