[gnome-commander/GSettings] Adds remaining internal viewer specific options to GSettings
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/GSettings] Adds remaining internal viewer specific options to GSettings
- Date: Fri, 5 Aug 2016 18:53:01 +0000 (UTC)
commit 4de8cd6b80abe2e54ad19b77c66984832181cbe1
Author: Uwe Scholz <uwescholz src gnome org>
Date: Fri Aug 5 20:48:28 2016 +0200
Adds remaining internal viewer specific options to GSettings
data/org.gnome.gnome-commander.gschema.xml | 177 ++++++++++------------------
src/gnome-cmd-data.cc | 36 ++++++
src/gnome-cmd-data.h | 12 ++
src/intviewer/viewer-window.cc | 107 +++++++++++++----
src/intviewer/viewer-window.h | 4 +
5 files changed, 195 insertions(+), 141 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 16273e4..b0e67b7 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -1005,138 +1005,87 @@
</key>
<key name="charset" type="s">
<default l10n="messages">'UTF8'</default>
- <summary></summary>
- <description></description>
+ <summary>Character set</summary>
+ <description>
+ This option defines the default character encoding.
+ </description>
</key>
<key name="fixed-font-name" type="s">
- <default l10n="messages">'UTF8'</default>
- <summary></summary>
- <description></description>
+ <default l10n="messages">'Monospace'</default>
+ <summary>Fixed font name</summary>
+ <description>
+ Name of the default font with fixed character width.
+ </description>
</key>
<key name="variable-font-name" type="s">
- <default l10n="messages">'UTF8'</default>
- <summary></summary>
- <description></description>
+ <default l10n="messages">'Sans'</default>
+ <summary>Variable font name</summary>
+ <description>
+ Name of the default font with variable character width.
+ </description>
</key>
- <key name="hex-offset-display" type="b">
+ <key name="display-hex-offset" type="b">
<default l10n="messages">true</default>
- <summary></summary>
- <description></description>
+ <summary>Display hex offset</summary>
+ <description>
+ This option defines if the hexadecimal offset should be displayed in hex mode.
+ </description>
</key>
<key name="wrap-mode" type="b">
<default l10n="messages">true</default>
- <summary></summary>
- <description></description>
+ <summary>Wrap mode</summary>
+ <description>
+ This option defines if too long text lines should be wrapped.
+ </description>
</key>
- <key name="font-size" type="i">
- <default l10n="messages">8</default>
- <summary></summary>
- <description></description>
+ <key name="font-size" type="u">
+ <default l10n="messages">12</default>
+ <summary>Font size</summary>
+ <description>
+ This option defines the default font size.
+ </description>
</key>
- <key name="tab-size" type="i">
+ <key name="tab-size" type="u">
<default l10n="messages">8</default>
- <summary></summary>
- <description></description>
+ <summary>Tab size</summary>
+ <description>
+ This option defines the indentation width in terms of characters for a tabulator character.
+ </description>
</key>
- <key name="binary-bytes-per-line" type="i">
+ <key name="binary-bytes-per-line" type="u">
<default l10n="messages">80</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="x" type="i">
- <default l10n="messages">330</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="y" type="i">
- <default l10n="messages">183</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="width" type="i">
- <default l10n="messages">838</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="height" type="i">
- <default l10n="messages">451</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern0" type="s">
- <default l10n="messages">'sans'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern1" type="s">
- <default l10n="messages">'layout'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="hex-pattern0" type="s">
- <default l10n="messages">'AB'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern2" type="s">
- <default l10n="messages">'monospace'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern3" type="s">
- <default l10n="messages">'FAIL'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern4" type="s">
- <default l10n="messages">'file'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern5" type="s">
- <default l10n="messages">'libgviewer.h'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern6" type="s">
- <default l10n="messages">'gnome-cmd-file-new-from-uri'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern7" type="s">
- <default l10n="messages">'xinput'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern8" type="s">
- <default l10n="messages">'fileops.c'</default>
- <summary></summary>
- <description></description>
- </key>
- <key name="text-pattern9" type="s">
- <default l10n="messages">'libops.c'</default>
- <summary></summary>
- <description></description>
+ <summary>Bytes per line in binray mode</summary>
+ <description>
+ This option defines how many bytes should be displayed in one line in binary mode.
+ </description>
</key>
- <key name="text-pattern10" type="s">
- <default l10n="messages">'Selections'</default>
- <summary></summary>
- <description></description>
+ <key name="offset-x" type="i">
+ <default l10n="messages">20</default>
+ <summary>Horizontal offset</summary>
+ <description>
+ This option defines the visual offset of the internal file viewer in horizontal direction.
+ </description>
</key>
- <key name="text-pattern11" type="s">
- <default l10n="messages">'fritz'</default>
- <summary></summary>
- <description></description>
+ <key name="offset-y" type="i">
+ <default l10n="messages">20</default>
+ <summary>Vertical offset</summary>
+ <description>
+ This option defines the visual offset of the internal file viewer in vertical direction.
+ </description>
</key>
- <key name="text-pattern12" type="s">
- <default l10n="messages">'green'</default>
- <summary></summary>
- <description></description>
+ <key name="window-width" type="u">
+ <default l10n="messages">400</default>
+ <summary>Window width</summary>
+ <description>
+ The width of the internal file viewer window.
+ </description>
</key>
- <key name="text-pattern13" type="s">
- <default l10n="messages">'colors'</default>
- <summary></summary>
- <description></description>
+ <key name="window-height" type="u">
+ <default l10n="messages">400</default>
+ <summary>Window height</summary>
+ <description>
+ The height of the internal file viewer window.
+ </description>
</key>
<key name="search-pattern-text" type="as">
<default l10n="messages">[]</default>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 6f31880..fced6ab 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -3025,6 +3025,42 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
//last_mode
migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/last_mode", 0),
options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_SEARCH_MODE);
+ //charset
+ migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string ("/internal_viewer/charset",
"UTF8"),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_CHARSET);
+ //fixed_font_name
+ migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string
("/internal_viewer/fixed_font_name", "Monospace"),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_FIXED_FONT_NAME);
+ //variable_font_name
+ migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string
("/internal_viewer/variable_font_name", "Sans"),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_VARIABLE_FONT_NAME);
+ //hex_offset_display
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool
("/internal_viewer/hex_offset_display", TRUE) ? 1 : 0,
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_DISPLAY_HEX_OFFSET);
+ //wrap_mode
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/internal_viewer/wrap_mode", TRUE) ?
1 : 0,
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_WRAP_MODE);
+ //font_size
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/font_size", 12),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_FONT_SIZE);
+ //tab_size
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/tab_size", 8),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_TAB_SIZE);
+ //binary_bytes_per_line
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int
("/internal_viewer/binary_bytes_per_line", 80),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_BINARY_BYTES_PER_LINE);
+ //x
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/x", 20),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_X_OFFSET);
+ //y
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/y", 20),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_Y_OFFSET);
+ //width
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/width", 400),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_WINDOW_WIDTH);
+ //height
+ migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/internal_viewer/height", 400),
+ options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_WINDOW_HEIGHT);
//text_pattern0
migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string
("/internal_viewer/text_pattern0", ""),
options.gcmd_settings->internalviewer,
GCMD_SETTINGS_IV_SEARCH_PATTERN_TEXT);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 3b98895..599c785 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -168,6 +168,18 @@ GcmdSettings *gcmd_settings_new (void);
#define GCMD_PREF_INTERNAL_VIEWER "org.gnome.gnome-commander.preferences.internal-viewer"
#define GCMD_SETTINGS_IV_CASE_SENSITIVE "case-sensitive-search"
#define GCMD_SETTINGS_IV_SEARCH_MODE "search-mode"
+#define GCMD_SETTINGS_IV_CHARSET "charset"
+#define GCMD_SETTINGS_IV_FIXED_FONT_NAME "fixed-font-name"
+#define GCMD_SETTINGS_IV_VARIABLE_FONT_NAME "variable-font-name"
+#define GCMD_SETTINGS_IV_DISPLAY_HEX_OFFSET "display-hex-offset"
+#define GCMD_SETTINGS_IV_WRAP_MODE "wrap-mode"
+#define GCMD_SETTINGS_IV_FONT_SIZE "font-size"
+#define GCMD_SETTINGS_IV_TAB_SIZE "tab-size"
+#define GCMD_SETTINGS_IV_BINARY_BYTES_PER_LINE "binary-bytes-per-line"
+#define GCMD_SETTINGS_IV_X_OFFSET "offset-y"
+#define GCMD_SETTINGS_IV_Y_OFFSET "offset-y"
+#define GCMD_SETTINGS_IV_WINDOW_WIDTH "window-width"
+#define GCMD_SETTINGS_IV_WINDOW_HEIGHT "window-height"
#define GCMD_SETTINGS_IV_SEARCH_PATTERN_TEXT "search-pattern-text"
#define GCMD_SETTINGS_IV_SEARCH_PATTERN_HEX "search-pattern-hex"
diff --git a/src/intviewer/viewer-window.cc b/src/intviewer/viewer-window.cc
index 59a69b5..f8de84e 100644
--- a/src/intviewer/viewer-window.cc
+++ b/src/intviewer/viewer-window.cc
@@ -39,7 +39,7 @@
#include "gnome-cmd-treeview.h"
#include "utils.h"
#include "tags/gnome-cmd-tags.h"
-
+#include "gnome-cmd-data.h"
using namespace std;
@@ -50,6 +50,55 @@ using namespace std;
#define G_OBJ_IMAGE_OP_KEY "imageop"
#define G_OBJ_EXTERNAL_TOOL_KEY "exttool"
+#define GCMD_INTERNAL_VIEWER "org.gnome.gnome-commander.preferences.internal-viewer"
+#define GCMD_GSETTINGS_IV_CHARSET "charset"
+
+/***********************************
+ * Functions for using GSettings
+ ***********************************/
+
+struct _InternalViewerSettings
+{
+ GObject parent;
+ GSettings *internalviewer;
+};
+
+G_DEFINE_TYPE (InternalViewerSettings, iv_settings, G_TYPE_OBJECT)
+
+static void iv_settings_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (iv_settings_parent_class)->finalize (object);
+}
+
+static void iv_settings_dispose (GObject *object)
+{
+ InternalViewerSettings *gs = GCMD_IV_SETTINGS (object);
+
+ g_clear_object (&gs->internalviewer);
+
+ G_OBJECT_CLASS (iv_settings_parent_class)->dispose (object);
+}
+
+static void iv_settings_class_init (InternalViewerSettingsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = iv_settings_finalize;
+ object_class->dispose = iv_settings_dispose;
+}
+
+InternalViewerSettings *iv_settings_new ()
+{
+ return (InternalViewerSettings *) g_object_new (INTERNAL_VIEWER_SETTINGS, NULL);
+}
+
+static void iv_settings_init (InternalViewerSettings *gs)
+{
+ gs->internalviewer = g_settings_new (GCMD_INTERNAL_VIEWER);
+}
+
+/***********************************/
+
static GtkWindowClass *parent_class = NULL;
static double image_scale_factors[] = {0.1, 0.2, 0.33, 0.5, 0.67, 1, 1.25, 1.50, 2, 3, 4, 5, 6, 7, 8};
@@ -1246,29 +1295,32 @@ void gviewer_window_load_settings(/* out */ GViewerWindowSettings *settings)
{
g_return_if_fail (settings!=NULL);
- gchar *temp = gviewer_get_string (GVIEWER_DEFAULT_PATH_PREFIX "charset", "UTF8");
+ InternalViewerSettings *iv_settings;
+ iv_settings = iv_settings_new();
+
+ gchar *temp = g_settings_get_string (iv_settings->internalviewer, GCMD_GSETTINGS_IV_CHARSET);
strncpy(settings->charset, temp, sizeof(settings->charset));
g_free (temp);
- temp = gviewer_get_string (GVIEWER_DEFAULT_PATH_PREFIX "fixed_font_name", "Monospace");
+ temp = g_settings_get_string (iv_settings->internalviewer, GCMD_SETTINGS_IV_FIXED_FONT_NAME);
strncpy(settings->fixed_font_name, temp, sizeof(settings->fixed_font_name));
g_free (temp);
- temp = gviewer_get_string (GVIEWER_DEFAULT_PATH_PREFIX "variable_font_name", "Sans");
+ temp = g_settings_get_string (iv_settings->internalviewer, GCMD_SETTINGS_IV_VARIABLE_FONT_NAME);
strncpy(settings->variable_font_name, temp, sizeof(settings->variable_font_name));
g_free (temp);
- settings->hex_decimal_offset = gviewer_get_bool (GVIEWER_DEFAULT_PATH_PREFIX "hex_offset_display", TRUE);
- settings->wrap_mode = gviewer_get_bool (GVIEWER_DEFAULT_PATH_PREFIX "wrap_mode", TRUE);
+ settings->hex_decimal_offset = g_settings_get_boolean (iv_settings->internalviewer,
GCMD_SETTINGS_IV_DISPLAY_HEX_OFFSET);
+ settings->wrap_mode = g_settings_get_boolean (iv_settings->internalviewer, GCMD_SETTINGS_IV_WRAP_MODE);
- settings->font_size = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "font_size", 12);
- settings->tab_size = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "tab_size ", 8);
- settings->binary_bytes_per_line = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "binary_bytes_per_line",
80);
+ settings->font_size = g_settings_get_uint (iv_settings->internalviewer, GCMD_SETTINGS_IV_FONT_SIZE);
+ settings->tab_size = g_settings_get_uint (iv_settings->internalviewer, GCMD_SETTINGS_IV_TAB_SIZE);
+ settings->binary_bytes_per_line = g_settings_get_uint (iv_settings->internalviewer,
GCMD_SETTINGS_IV_BINARY_BYTES_PER_LINE);
- settings->rect.x = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "x", -2);
- settings->rect.y = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "y", -2);
- settings->rect.width = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "width", -1);
- settings->rect.height = gviewer_get_int (GVIEWER_DEFAULT_PATH_PREFIX "height", -1);
+ settings->rect.x = g_settings_get_int (iv_settings->internalviewer, GCMD_SETTINGS_IV_X_OFFSET);
+ settings->rect.y = g_settings_get_int (iv_settings->internalviewer, GCMD_SETTINGS_IV_Y_OFFSET);
+ settings->rect.width = g_settings_get_uint (iv_settings->internalviewer, GCMD_SETTINGS_IV_WINDOW_WIDTH);
+ settings->rect.height = g_settings_get_uint (iv_settings->internalviewer,
GCMD_SETTINGS_IV_WINDOW_HEIGHT);
}
@@ -1276,28 +1328,29 @@ static void menu_settings_save_settings(GtkMenuItem *item, GViewerWindow *obj)
{
GViewerWindowSettings settings;
+ InternalViewerSettings *iv_settings;
+ iv_settings = iv_settings_new();
+
g_return_if_fail (obj);
g_return_if_fail (obj->priv->viewer);
gviewer_window_get_current_settings(obj, &settings);
- gnome_config_set_string (GVIEWER_DEFAULT_PATH_PREFIX "charset", settings.charset);
- gnome_config_set_string (GVIEWER_DEFAULT_PATH_PREFIX "fixed_font_name", settings.fixed_font_name);
- gnome_config_set_string (GVIEWER_DEFAULT_PATH_PREFIX "variable_font_name", settings.variable_font_name);
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_GSETTINGS_IV_CHARSET,
settings.charset);
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer,
GCMD_SETTINGS_IV_FIXED_FONT_NAME, settings.fixed_font_name);
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer,
GCMD_SETTINGS_IV_VARIABLE_FONT_NAME, settings.variable_font_name);
- gnome_config_set_bool (GVIEWER_DEFAULT_PATH_PREFIX "hex_offset_display", settings.hex_decimal_offset);
- gnome_config_set_bool (GVIEWER_DEFAULT_PATH_PREFIX "wrap_mode", settings.wrap_mode);
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer,
GCMD_SETTINGS_IV_DISPLAY_HEX_OFFSET, &(settings.hex_decimal_offset));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_WRAP_MODE,
&(settings.wrap_mode));
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "font_size", settings.font_size);
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "tab_size ", settings.tab_size);
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "binary_bytes_per_line",
settings.binary_bytes_per_line);
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_FONT_SIZE,
&(settings.font_size));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_TAB_SIZE,
&(settings.tab_size));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer,
GCMD_SETTINGS_IV_BINARY_BYTES_PER_LINE, &(settings.binary_bytes_per_line));
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "x", settings.rect.x);
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "y", settings.rect.y);
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "width", settings.rect.width);
- gnome_config_set_int (GVIEWER_DEFAULT_PATH_PREFIX "height", settings.rect.height);
-
- gnome_config_sync ();
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_X_OFFSET,
&(settings.rect.x));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_Y_OFFSET,
&(settings.rect.y));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_WINDOW_WIDTH,
&(settings.rect.width));
+ gnome_cmd_data.set_gsettings_when_changed (iv_settings->internalviewer, GCMD_SETTINGS_IV_WINDOW_HEIGHT,
&(settings.rect.height));
}
diff --git a/src/intviewer/viewer-window.h b/src/intviewer/viewer-window.h
index 7062ccd..daada1f 100644
--- a/src/intviewer/viewer-window.h
+++ b/src/intviewer/viewer-window.h
@@ -28,6 +28,10 @@
#include "gnome-cmd-includes.h"
#include "gnome-cmd-file.h"
+#define INTERNAL_VIEWER_SETTINGS (iv_settings_get_type ())
+G_DECLARE_FINAL_TYPE (InternalViewerSettings, iv_settings, GCMD_IV, SETTINGS, GObject)
+InternalViewerSettings *iv_settings_new (void);
+
#define GVIEWER_WINDOW(obj) \
GTK_CHECK_CAST (obj, gviewer_window_get_type (), GViewerWindow)
#define GVIEWER_WINDOW_CLASS(clss) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]