Commit 7f88273c authored by Paolo Maggi's avatar Paolo Maggi Committed by Paolo Maggi

added restore_cursor_position key

2006-01-03  Paolo Maggi  <paolo@gnome.org>

	* data/gedit.schemas.in: added restore_cursor_position key

	* gedit/gedit-prefs-manager.c
	(gedit_prefs_manager_get_restore_cursor_position): new function

	* gedit/gedit-prefs-manager.h: add restore_cursor_position key and
	gedit_prefs_manager_get_restore_cursor_position function

	* gedit/gedit-document.c (document_loader_loaded): restore the previous
	cursor position if gedit_prefs_manager_get_restore_cursor_position
	return TRUE
parent 43e3f16a
2006-01-03 Paolo Maggi <paolo@gnome.org>
* data/gedit.schemas.in: added restore_cursor_position key
* gedit/gedit-prefs-manager.c
(gedit_prefs_manager_get_restore_cursor_position): new function
* gedit/gedit-prefs-manager.h: add restore_cursor_position key and
gedit_prefs_manager_get_restore_cursor_position function
* gedit/gedit-document.c (document_loader_loaded): restore the previous
cursor position if gedit_prefs_manager_get_restore_cursor_position
return TRUE
2006-01-03 Paolo Maggi <paolo@gnome.org>
* gedit/gedit-commands-search.c (phrase_found): modified the string
......
......@@ -604,5 +604,18 @@
is writable by default.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gedit-2/preferences/editor/cursor_position/restore_cursor_position</key>
<applyto>/apps/gedit-2/preferences/editor/cursor_position/restore_cursor_position</applyto>
<owner>gedit</owner>
<type>bool</type>
<default>TRUE</default>
<locale name="C">
<short>Restore Previous Cursor Position</short>
<long>Whether gedit should restore the previous cursor position when a file is loaded.</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>
......@@ -898,15 +898,15 @@ document_loader_loaded (GeditDocumentLoader *loader,
&iter,
doc->priv->requested_line_pos - 1);
}
/* else, if enabled, to the position stored in the metadata */
else if (0) // FIXME: should be a GConf option
else if (gedit_prefs_manager_get_restore_cursor_position ())
{
gchar *pos;
gint offset;
pos = gedit_metadata_manager_get (doc->priv->uri,
"position");
offset = pos ? atoi (pos) : 0;
g_free (pos);
......@@ -914,7 +914,6 @@ document_loader_loaded (GeditDocumentLoader *loader,
&iter,
MAX (offset, 0));
}
/* otherwise to the top */
else
{
......
......@@ -1275,6 +1275,15 @@ gedit_prefs_manager_get_writable_vfs_schemes (void)
return strings;
}
gboolean
gedit_prefs_manager_get_restore_cursor_position (void)
{
gedit_debug (DEBUG_PREFS);
return gedit_prefs_manager_get_bool (GPM_RESTORE_CURSOR_POSITION,
GPM_DEFAULT_RESTORE_CURSOR_POSITION);
}
/* The following functions are taken from gconf-client.c
* and partially modified.
* The licensing terms on these is:
......
......@@ -83,6 +83,8 @@
#define GPM_DISPLAY_RIGHT_MARGIN GPM_RIGHT_MARGIN_DIR "/display_right_margin"
#define GPM_RIGHT_MARGIN_POSITION GPM_RIGHT_MARGIN_DIR "/right_margin_position"
#define GPM_CURSOR_POSITION_DIR GPM_PREFS_DIR "/editor/cursor_position"
#define GPM_RESTORE_CURSOR_POSITION GPM_CURSOR_POSITION_DIR "/restore_cursor_position"
/* UI */
#define GPM_TOOLBAR_DIR GPM_PREFS_DIR "/ui/toolbar"
......@@ -209,6 +211,8 @@
#define GPM_DEFAULT_WRITABLE_VFS_SCHEMES {"ssh", "sftp", "smb", "dav", "davs", NULL}
#define GPM_DEFAULT_RESTORE_CURSOR_POSITION 1 /* TRUE */
typedef enum {
GEDIT_TOOLBAR_SYSTEM = 0,
GEDIT_TOOLBAR_ICONS,
......@@ -412,6 +416,9 @@ gboolean gedit_prefs_manager_enable_syntax_highlighting_can_set (void);
/* Writable VFS schemes */
GSList *gedit_prefs_manager_get_writable_vfs_schemes (void);
/* Restore cursor position */
gboolean gedit_prefs_manager_get_restore_cursor_position (void);
#endif /* __GEDIT_PREFS_MANAGER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment