Revamp our handling of settings
The current handling of settings is a very roundabout leftover from the days of gconf. Simplify and handle the setting more directly. At the same time move handling of saving the window state to gsettings instead of saving it to a config file.
This commit is contained in:
parent
f21c6e9361
commit
490303557a
|
@ -4,11 +4,13 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
||||||
@INTLTOOL_DESKTOP_RULE@
|
@INTLTOOL_DESKTOP_RULE@
|
||||||
|
|
||||||
@INTLTOOL_XML_RULE@
|
@INTLTOOL_XML_RULE@
|
||||||
|
|
||||||
appdatadir = $(datadir)/appdata
|
appdatadir = $(datadir)/appdata
|
||||||
appdata_in_files = xed.appdata.xml.in
|
appdata_in_files = xed.appdata.xml.in
|
||||||
appdata_DATA = $(appdata_in_files:.xml.in=.xml)
|
appdata_DATA = $(appdata_in_files:.xml.in=.xml)
|
||||||
|
|
||||||
gsettings_SCHEMAS = org.x.editor.gschema.xml
|
gsettings_SCHEMAS = org.x.editor.gschema.xml
|
||||||
|
|
||||||
@GSETTINGS_RULES@
|
@GSETTINGS_RULES@
|
||||||
|
|
||||||
man_MANS = xed.1
|
man_MANS = xed.1
|
||||||
|
|
|
@ -1,200 +1,330 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<schemalist gettext-domain="@GETTEXT_PACKAGE@">
|
<schemalist>
|
||||||
<schema id="org.x.editor" path="/org/x/editor/">
|
<enum id="org.x.editor.WrapMode">
|
||||||
|
<value nick="none" value="0"/>
|
||||||
|
<value nick="char" value="1"/>
|
||||||
|
<value nick="word" value="2"/>
|
||||||
|
<value nick="word-char" value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum id="org.x.editor.SmartHomeEnd">
|
||||||
|
<value nick="disabled" value="0"/>
|
||||||
|
<value nick="before" value="1"/>
|
||||||
|
<value nick="after" value="2"/>
|
||||||
|
<value nick="always" value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor" path="/org/x/editor/">
|
||||||
|
<child name="preferences" schema="org.x.editor.preferences"/>
|
||||||
|
<child name="state" schema="org.x.editor.state"/>
|
||||||
|
<child name="plugins" schema="org.x.editor.plugins"/>
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences" path="/org/x/editor/preferences/">
|
||||||
|
<child name="editor" schema="org.x.editor.preferences.editor"/>
|
||||||
|
<child name="ui" schema="org.x.editor.preferences.ui"/>
|
||||||
|
<child name="print" schema="org.x.editor.preferences.print"/>
|
||||||
|
<child name="encodings" schema="org.x.editor.preferences.encodings"/>
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences.editor" path="/org/x/editor/preferences/editor/">
|
||||||
|
|
||||||
<key name="use-default-font" type="b">
|
<key name="use-default-font" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Use Default Font</summary>
|
<summary>Use Default Font</summary>
|
||||||
<description>Whether to use the system's default fixed width font for editing text instead of a font specific to xed. If this option is turned off, then the font named in the "Editor Font" option will be used instead of the system font.</description>
|
<description>Whether to use the system's default fixed width font for editing text instead of a font specific to xed. If this option is turned off, then the font named in the "Editor Font" option will be used instead of the system font.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="editor-font" type="s">
|
<key name="editor-font" type="s">
|
||||||
<default context="editor-font" l10n="messages">'Monospace 12'</default>
|
<default context="editor-font" l10n="messages">'Monospace 12'</default>
|
||||||
<summary>Editor Font</summary>
|
<summary>Editor Font</summary>
|
||||||
<description>A custom font that will be used for the editing area. This will only take effect if the "Use Default Font" option is turned off.</description>
|
<description>A custom font that will be used for the editing area. This will only take effect if the "Use Default Font" option is turned off.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="color-scheme" type="s">
|
|
||||||
|
<key name="scheme" type="s">
|
||||||
<default>'tango'</default>
|
<default>'tango'</default>
|
||||||
<summary>Style Scheme</summary>
|
<summary>Style Scheme</summary>
|
||||||
<description>The ID of a GtkSourceView Style Scheme used to color the text.</description>
|
<description>The ID of a GtkSourceView Style Scheme used to color the text.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="create-backup-copy" type="b">
|
<key name="create-backup-copy" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Create Backup Copies</summary>
|
<summary>Create Backup Copies</summary>
|
||||||
<description>Whether xed should create backup copies for the files it saves. You can set the backup file extension with the "Backup Copy Extension" option.</description>
|
<description>Whether xed should create backup copies for the files it saves. You can set the backup file extension with the "Backup Copy Extension" option.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="auto-save" type="b">
|
<key name="auto-save" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Autosave</summary>
|
<summary>Autosave</summary>
|
||||||
<description>Whether xed should automatically save modified files after a time interval. You can set the time interval with the "Autosave Interval" option.</description>
|
<description>Whether xed should automatically save modified files after a time interval. You can set the time interval with the "Autosave Interval" option.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="auto-save-interval" type="i">
|
|
||||||
|
<key name="auto-save-interval" type="u">
|
||||||
<default>10</default>
|
<default>10</default>
|
||||||
<summary>Autosave Interval</summary>
|
<summary>Autosave Interval</summary>
|
||||||
<description>Number of minutes after which xed will automatically save modified files. This will only take effect if the "Autosave" option is turned on.</description>
|
<description>Number of minutes after which xed will automatically save modified files. This will only take effect if the "Autosave" option is turned on.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="writable-vfs-schemes" type="as">
|
<key name="writable-vfs-schemes" type="as">
|
||||||
<default>[ 'dav', 'davs', 'ftp', 'sftp', 'smb', 'ssh' ]</default>
|
<default>[ 'dav', 'davs', 'ftp', 'sftp', 'smb', 'ssh' ]</default>
|
||||||
<summary>Writable VFS schemes</summary>
|
<summary>Writable VFS schemes</summary>
|
||||||
<description>List of VFS schemes xed supports in write mode. The 'file' scheme is writable by default.</description>
|
<description>List of VFS schemes xed supports in write mode. The 'file' scheme is writable by default.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="max-undo-actions" type="i">
|
<key name="max-undo-actions" type="i">
|
||||||
<default>2000</default>
|
<default>2000</default>
|
||||||
<summary>Maximum Number of Undo Actions</summary>
|
<summary>Maximum Number of Undo Actions</summary>
|
||||||
<description>Maximum number of actions that xed will be able to undo or redo. Use "-1" for unlimited number of actions.</description>
|
<description>Maximum number of actions that xed will be able to undo or redo. Use "-1" for unlimited number of actions.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="wrap-mode" type="s">
|
|
||||||
<default>'GTK_WRAP_WORD'</default>
|
<key name="wrap-mode" enum="org.x.editor.WrapMode">
|
||||||
|
<default>'word'</default>
|
||||||
<summary>Line Wrapping Mode</summary>
|
<summary>Line Wrapping Mode</summary>
|
||||||
<description>Specifies how to wrap long lines in the editing area. Use "GTK_WRAP_NONE" for no wrapping, "GTK_WRAP_WORD" for wrapping at word boundaries, and "GTK_WRAP_CHAR" for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
<description>Specifies how to wrap long lines in the editing area. Use "none" for no wrapping, "word" for wrapping at word boundaries, and "char" for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="tabs-size" type="i">
|
|
||||||
|
<key name="tabs-size" type="u">
|
||||||
<default>4</default>
|
<default>4</default>
|
||||||
<summary>Tab Size</summary>
|
<summary>Tab Size</summary>
|
||||||
<description>Specifies the number of spaces that should be displayed instead of Tab characters.</description>
|
<description>Specifies the number of spaces that should be displayed instead of Tab characters.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="insert-spaces" type="b">
|
<key name="insert-spaces" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Insert spaces</summary>
|
<summary>Insert spaces</summary>
|
||||||
<description>Whether xed should insert spaces instead of tabs.</description>
|
<description>Whether xed should insert spaces instead of tabs.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="auto-indent" type="b">
|
<key name="auto-indent" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Automatic indent</summary>
|
<summary>Automatic indent</summary>
|
||||||
<description>Whether xed should enable automatic indentation.</description>
|
<description>Whether xed should enable automatic indentation.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="display-line-numbers" type="b">
|
<key name="display-line-numbers" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Display Line Numbers</summary>
|
<summary>Display Line Numbers</summary>
|
||||||
<description>Whether xed should display line numbers in the editing area.</description>
|
<description>Whether xed should display line numbers in the editing area.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="highlight-current-line" type="b">
|
<key name="highlight-current-line" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Highlight Current Line</summary>
|
<summary>Highlight Current Line</summary>
|
||||||
<description>Whether xed should highlight the current line.</description>
|
<description>Whether xed should highlight the current line.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="bracket-matching" type="b">
|
<key name="bracket-matching" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Highlight Matching Bracket</summary>
|
<summary>Highlight Matching Bracket</summary>
|
||||||
<description>Whether xed should highlight the bracket matching the selected one.</description>
|
<description>Whether xed should highlight the bracket matching the selected one.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="display-right-margin" type="b">
|
<key name="display-right-margin" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Display Right Margin</summary>
|
<summary>Display Right Margin</summary>
|
||||||
<description>Whether xed should display the right margin in the editing area.</description>
|
<description>Whether xed should display the right margin in the editing area.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="right-margin-position" type="i">
|
|
||||||
|
<key name="right-margin-position" type="u">
|
||||||
<default>120</default>
|
<default>120</default>
|
||||||
<summary>Right Margin Position</summary>
|
<summary>Right Margin Position</summary>
|
||||||
<description>Specifies the position of the right margin.</description>
|
<description>Specifies the position of the right margin.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="smart-home-end" type="s">
|
|
||||||
|
<key name="smart-home-end" enum="org.x.editor.SmartHomeEnd">
|
||||||
<default>'after'</default>
|
<default>'after'</default>
|
||||||
<summary>Smart Home End</summary>
|
<summary>Smart Home End</summary>
|
||||||
<description>Specifies how the cursor moves when the HOME and END keys are pressed. Use "DISABLED" to always move at the start/end of the line, "AFTER" to move to the start/end of the line the first time the keys are pressed and to the start/end of the text ignoring whitespaces the second time the keys are pressed, "BEFORE" to move to the start/end of the text before moving to the start/end of the line and "ALWAYS" to always move to the start/end of the text instead of the start/end of the line.</description>
|
<description>Specifies how the cursor moves when the HOME and END keys are pressed. Use "disabled" to always move at the start/end of the line, "after" to move to the start/end of the line the first time the keys are pressed and to the start/end of the text ignoring whitespaces the second time the keys are pressed, "before" to move to the start/end of the text before moving to the start/end of the line and "always" to always move to the start/end of the text instead of the start/end of the line.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="restore-cursor-position" type="b">
|
<key name="restore-cursor-position" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Restore Previous Cursor Position</summary>
|
<summary>Restore Previous Cursor Position</summary>
|
||||||
<description>Whether xed should restore the previous cursor position when a file is loaded.</description>
|
<description>Whether xed should restore the previous cursor position when a file is loaded.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="enable-search-highlighting" type="b">
|
|
||||||
|
<key name="search-highlighting" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Enable Search Highlighting</summary>
|
<summary>Enable Search Highlighting</summary>
|
||||||
<description>Whether xed should highlight all the occurrences of the searched text.</description>
|
<description>Whether xed should highlight all the occurrences of the searched text.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="enable-syntax-highlighting" type="b">
|
|
||||||
|
<key name="syntax-highlighting" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Enable Syntax Highlighting</summary>
|
<summary>Enable Syntax Highlighting</summary>
|
||||||
<description>Whether xed should enable syntax highlighting.</description>
|
<description>Whether xed should enable syntax highlighting.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences.ui" path="/org/x/editor/preferences/ui/">
|
||||||
|
|
||||||
<key name="toolbar-visible" type="b">
|
<key name="toolbar-visible" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Toolbar is Visible</summary>
|
<summary>Toolbar is Visible</summary>
|
||||||
<description>Whether the toolbar should be visible in editing windows.</description>
|
<description>Whether the toolbar should be visible in editing windows.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="statusbar-visible" type="b">
|
<key name="statusbar-visible" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Status Bar is Visible</summary>
|
<summary>Status Bar is Visible</summary>
|
||||||
<description>Whether the status bar at the bottom of editing windows should be visible.</description>
|
<description>Whether the status bar at the bottom of editing windows should be visible.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="side-pane-visible" type="b">
|
|
||||||
|
<key name="side-panel-visible" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Side Pane is Visible</summary>
|
<summary>Side Pane is Visible</summary>
|
||||||
<description>Whether the side pane at the left of editing windows should be visible.</description>
|
<description>Whether the side pane at the left of editing windows should be visible.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="bottom-panel-visible" type="b">
|
<key name="bottom-panel-visible" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Bottom Panel is Visible</summary>
|
<summary>Bottom Panel is Visible</summary>
|
||||||
<description>Whether the bottom panel at the bottom of editing windows should be visible.</description>
|
<description>Whether the bottom panel at the bottom of editing windows should be visible.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="enable-tab-scrolling" type="b">
|
<key name="enable-tab-scrolling" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Allow changing active tabs by scrolling</summary>
|
<summary>Allow changing active tabs by scrolling</summary>
|
||||||
<description>Whether you can change active tabs by scrolling.</description>
|
<description>Whether you can change active tabs by scrolling.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="max-recents" type="i">
|
|
||||||
|
<key name="max-recents" type="u">
|
||||||
<default>5</default>
|
<default>5</default>
|
||||||
<summary>Maximum Recent Files</summary>
|
<summary>Maximum Recent Files</summary>
|
||||||
<description>Specifies the maximum number of recently opened files that will be displayed in the "Recent Files" submenu.</description>
|
<description>Specifies the maximum number of recently opened files that will be displayed in the "Recent Files" submenu.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences.print" path="/org/x/editor/preferences/print/">
|
||||||
|
|
||||||
<key name="print-syntax-highlighting" type="b">
|
<key name="print-syntax-highlighting" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Print Syntax Highlighting</summary>
|
<summary>Print Syntax Highlighting</summary>
|
||||||
<description>Whether xed should print syntax highlighting when printing documents.</description>
|
<description>Whether xed should print syntax highlighting when printing documents.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="print-header" type="b">
|
<key name="print-header" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<summary>Print Header</summary>
|
<summary>Print Header</summary>
|
||||||
<description>Whether xed should include a document header when printing documents.</description>
|
<description>Whether xed should include a document header when printing documents.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="print-wrap-mode" type="s">
|
|
||||||
<default>'GTK_WRAP_WORD'</default>
|
<key name="print-wrap-mode" enum="org.x.editor.WrapMode">
|
||||||
|
<default>'word'</default>
|
||||||
<summary>Printing Line Wrapping Mode</summary>
|
<summary>Printing Line Wrapping Mode</summary>
|
||||||
<description>Specifies how to wrap long lines for printing. Use "GTK_WRAP_NONE" for no wrapping, "GTK_WRAP_WORD" for wrapping at word boundaries, and "GTK_WRAP_CHAR" for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
<description>Specifies how to wrap long lines for printing. Use "none" for no wrapping, "word" for wrapping at word boundaries, and "char" for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="print-line-numbers" type="i">
|
|
||||||
|
<key name="print-line-numbers" type="u">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<summary>Print Line Numbers</summary>
|
<summary>Print Line Numbers</summary>
|
||||||
<description>If this value is 0, then no line numbers will be inserted when printing a document. Otherwise, xed will print line numbers every such number of lines.</description>
|
<description>If this value is 0, then no line numbers will be inserted when printing a document. Otherwise, xed will print line numbers every such number of lines.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="print-font-body-pango" type="s">
|
<key name="print-font-body-pango" type="s">
|
||||||
<default context="print-font-body-pango" l10n="messages">'Monospace 9'</default>
|
<default context="print-font-body-pango" l10n="messages">'Monospace 9'</default>
|
||||||
<summary>Body Font for Printing</summary>
|
<summary>Body Font for Printing</summary>
|
||||||
<description>Specifies the font to use for a document's body when printing documents.</description>
|
<description>Specifies the font to use for a document's body when printing documents.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="print-font-header-pango" type="s">
|
<key name="print-font-header-pango" type="s">
|
||||||
<default context="print-font-header-pango" l10n="messages">'Sans 11'</default>
|
<default context="print-font-header-pango" l10n="messages">'Sans 11'</default>
|
||||||
<summary>Header Font for Printing</summary>
|
<summary>Header Font for Printing</summary>
|
||||||
<description>Specifies the font to use for page headers when printing a document. This will only take effect if the "Print Header" option is turned on.</description>
|
<description>Specifies the font to use for page headers when printing a document. This will only take effect if the "Print Header" option is turned on.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="print-font-numbers-pango" type="s">
|
<key name="print-font-numbers-pango" type="s">
|
||||||
<default context="print-font-numbers-pango" l10n="messages">'Sans 8'</default>
|
<default context="print-font-numbers-pango" l10n="messages">'Sans 8'</default>
|
||||||
<summary>Line Number Font for Printing</summary>
|
<summary>Line Number Font for Printing</summary>
|
||||||
<description>Specifies the font to use for line numbers when printing. This will only take effect if the "Print Line Numbers" option is non-zero.</description>
|
<description>Specifies the font to use for line numbers when printing. This will only take effect if the "Print Line Numbers" option is non-zero.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="auto-detected-encodings" type="as">
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences.encodings" path="/org/x/editor/preferences/encodings/">
|
||||||
|
|
||||||
|
<key name="auto-detected" type="as">
|
||||||
<default context="auto-detected" l10n="messages">[ 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16' ]</default>
|
<default context="auto-detected" l10n="messages">[ 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16' ]</default>
|
||||||
<summary>Automatically Detected Encodings</summary>
|
<summary>Automatically Detected Encodings</summary>
|
||||||
<description>Sorted list of encodings used by xed for automatically detecting the encoding of a file. "CURRENT" represents the current locale encoding. Only recognized encodings are used.</description>
|
<description>Sorted list of encodings used by xed for automatically detecting the encoding of a file. "CURRENT" represents the current locale encoding. Only recognized encodings are used.</description>
|
||||||
</key>
|
</key>
|
||||||
<key name="shown-in-menu-encodings" type="as">
|
|
||||||
|
<key name="shown-in-menu" type="as">
|
||||||
<default context="shown-in-menu" l10n="messages">[ 'ISO-8859-15' ]</default>
|
<default context="shown-in-menu" l10n="messages">[ 'ISO-8859-15' ]</default>
|
||||||
<summary>Encodings shown in menu</summary>
|
<summary>Encodings shown in menu</summary>
|
||||||
<description>List of encodings shown in the Character Encoding menu in open/save file selector. Only recognized encodings are used.</description>
|
<description>List of encodings shown in the Character Encoding menu in open/save file selector. Only recognized encodings are used.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema id="org.x.editor.state" path="/org/x/editor/state/">
|
||||||
|
<child name="window" schema="org.x.editor.state.window"/>
|
||||||
|
<child name="file-filter" schema="org.x.editor.state.file-filter"/>
|
||||||
|
<child name="history-entry" schema="org.x.editor.state.history-entry"/>
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema id="org.x.editor.state.window" path="/org/x/editor/state/window/">
|
||||||
|
|
||||||
|
<key name="state" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="size" type="(ii)">
|
||||||
|
<default>(650,500)</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="side-panel-size" type="i">
|
||||||
|
<default>200</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="side-panel-active-page" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="bottom-panel-size" type="i">
|
||||||
|
<default>140</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="bottom-panel-active-page" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema id="org.x.editor.state.file-filter" path="/org/x/editor/state/file-filter/">
|
||||||
|
|
||||||
|
<key name="filter-id" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema id="org.x.editor.state.history-entry" path="/org/x/editor/state/history-entry/">
|
||||||
|
|
||||||
<key name="history-search-for" type="as">
|
<key name="history-search-for" type="as">
|
||||||
<default>[]</default>
|
<default>[]</default>
|
||||||
<summary>History for "search for" entries</summary>
|
<summary>History for "search for" entries</summary>
|
||||||
<description>List of entries in "search for" textbox.</description>
|
<description>List of entries in "search for" textbox.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="history-replace-with" type="as">
|
<key name="history-replace-with" type="as">
|
||||||
<default>[]</default>
|
<default>[]</default>
|
||||||
<summary>History for "replace with" entries</summary>
|
<summary>History for "replace with" entries</summary>
|
||||||
<description>List of entries in "replace with" textbox.</description>
|
<description>List of entries in "replace with" textbox.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.plugins" path="/org/x/editor/plugins/">
|
||||||
|
|
||||||
<key name="active-plugins" type="as">
|
<key name="active-plugins" type="as">
|
||||||
<default>[ 'docinfo', 'modelines', 'filebrowser', 'spell', 'time' ]</default>
|
<default>[ 'docinfo', 'modelines', 'filebrowser', 'spell', 'time' ]</default>
|
||||||
<summary>Active plugins</summary>
|
<summary>Active plugins</summary>
|
||||||
<description>List of active plugins. It contains the "Location" of the active plugins. See the .xed-plugin file for obtaining the "Location" of a given plugin.</description>
|
<description>List of active plugins. It contains the "Location" of the active plugins. See the .xed-plugin file for obtaining the "Location" of a given plugin.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
#include <xed/xed-language-manager.h>
|
#include <xed/xed-language-manager.h>
|
||||||
#include <xed/xed-prefs-manager.h>
|
|
||||||
#include <xed/xed-debug.h>
|
#include <xed/xed-debug.h>
|
||||||
|
#include <xed/xed-settings.h>
|
||||||
|
#include <xed/xed-utils.h>
|
||||||
#include "modeline-parser.h"
|
#include "modeline-parser.h"
|
||||||
|
|
||||||
#define MODELINES_LANGUAGE_MAPPINGS_FILE "language-mappings"
|
#define MODELINES_LANGUAGE_MAPPINGS_FILE "language-mappings"
|
||||||
|
@ -678,6 +679,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GtkTextIter iter, liter;
|
GtkTextIter iter, liter;
|
||||||
gint line_count;
|
gint line_count;
|
||||||
|
GSettings *settings;
|
||||||
|
|
||||||
options.language_id = NULL;
|
options.language_id = NULL;
|
||||||
options.set = MODELINE_SET_NONE;
|
options.set = MODELINE_SET_NONE;
|
||||||
|
@ -764,6 +766,8 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
|
ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
|
||||||
MODELINE_OPTIONS_DATA_KEY);
|
MODELINE_OPTIONS_DATA_KEY);
|
||||||
|
|
||||||
|
settings = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
|
|
||||||
/* Apply the options we got from modelines and restore defaults if
|
/* Apply the options we got from modelines and restore defaults if
|
||||||
we set them before */
|
we set them before */
|
||||||
if (has_option (&options, MODELINE_SET_INSERT_SPACES))
|
if (has_option (&options, MODELINE_SET_INSERT_SPACES))
|
||||||
|
@ -773,9 +777,10 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES))
|
else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_insert_spaces_instead_of_tabs
|
gboolean insert_spaces;
|
||||||
(view,
|
|
||||||
xed_prefs_manager_get_insert_spaces ());
|
insert_spaces = g_settings_get_boolean (settings, XED_SETTINGS_INSERT_SPACES);
|
||||||
|
gtk_source_view_set_insert_spaces_instead_of_tabs (view, insert_spaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
|
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
|
||||||
|
@ -784,8 +789,10 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
|
else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_tab_width (view,
|
guint tab_width;
|
||||||
xed_prefs_manager_get_tabs_size ());
|
|
||||||
|
tab_width = g_settings_get_uint (settings, XED_SETTINGS_TABS_SIZE);
|
||||||
|
gtk_source_view_set_tab_width (view, tab_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
|
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
|
||||||
|
@ -803,8 +810,10 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
|
else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
|
||||||
{
|
{
|
||||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
|
GtkWrapMode mode;
|
||||||
xed_prefs_manager_get_wrap_mode ());
|
|
||||||
|
mode = g_settings_get_enum (settings, XED_SETTINGS_WRAP_MODE);
|
||||||
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
||||||
|
@ -813,8 +822,10 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_right_margin_position (view,
|
guint right_margin_pos;
|
||||||
xed_prefs_manager_get_right_margin_position ());
|
|
||||||
|
right_margin_pos = g_settings_get_uint (settings, XED_SETTINGS_RIGHT_MARGIN_POSITION);
|
||||||
|
gtk_source_view_set_right_margin_position (view, right_margin_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
||||||
|
@ -823,8 +834,10 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_show_right_margin (view,
|
gboolean display_right_margin;
|
||||||
xed_prefs_manager_get_display_right_margin ());
|
|
||||||
|
display_right_margin = g_settings_get_boolean (settings, XED_SETTINGS_DISPLAY_RIGHT_MARGIN);
|
||||||
|
gtk_source_view_set_show_right_margin (view, display_right_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previous)
|
if (previous)
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xed-document-loader.h"
|
#include "xed-document-loader.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -241,8 +240,6 @@ int main (int argc,
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
xed_prefs_manager_app_init ();
|
|
||||||
|
|
||||||
g_test_add_func ("/document-loader/end-line-stripping", test_end_line_stripping);
|
g_test_add_func ("/document-loader/end-line-stripping", test_end_line_stripping);
|
||||||
g_test_add_func ("/document-loader/end-new-line-detection", test_end_new_line_detection);
|
g_test_add_func ("/document-loader/end-new-line-detection", test_end_new_line_detection);
|
||||||
g_test_add_func ("/document-loader/begin-new-line-detection", test_begin_new_line_detection);
|
g_test_add_func ("/document-loader/begin-new-line-detection", test_begin_new_line_detection);
|
||||||
|
|
|
@ -16,13 +16,12 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with xed; if not, write to the Free Software
|
* along with xed; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "xed-document-output-stream.h"
|
#include "xed-document-output-stream.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -125,8 +124,6 @@ int main (int argc,
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
xed_prefs_manager_app_init ();
|
|
||||||
|
|
||||||
g_test_add_func ("/document-output-stream/empty", test_empty);
|
g_test_add_func ("/document-output-stream/empty", test_empty);
|
||||||
|
|
||||||
g_test_add_func ("/document-output-stream/consecutive", test_consecutive);
|
g_test_add_func ("/document-output-stream/consecutive", test_consecutive);
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xed-document-loader.h"
|
#include "xed-document-loader.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -684,8 +683,6 @@ int main (int argc,
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
xed_prefs_manager_app_init ();
|
|
||||||
|
|
||||||
g_printf ("\n***\n");
|
g_printf ("\n***\n");
|
||||||
have_unowned = check_unowned_directory ();
|
have_unowned = check_unowned_directory ();
|
||||||
have_unowned_group = check_unowned_group ();
|
have_unowned_group = check_unowned_group ();
|
||||||
|
|
|
@ -55,10 +55,10 @@ NOINST_H_FILES = \
|
||||||
xed-io-error-message-area.h \
|
xed-io-error-message-area.h \
|
||||||
xed-language-manager.h \
|
xed-language-manager.h \
|
||||||
xed-plugins-engine.h \
|
xed-plugins-engine.h \
|
||||||
xed-prefs-manager-private.h \
|
|
||||||
xed-print-job.h \
|
xed-print-job.h \
|
||||||
xed-print-preview.h \
|
xed-print-preview.h \
|
||||||
xed-session.h \
|
xed-session.h \
|
||||||
|
xed-settings.h \
|
||||||
xed-smart-charset-converter.h \
|
xed-smart-charset-converter.h \
|
||||||
xed-style-scheme-manager.h \
|
xed-style-scheme-manager.h \
|
||||||
xed-tab-label.h \
|
xed-tab-label.h \
|
||||||
|
@ -81,8 +81,6 @@ INST_H_FILES = \
|
||||||
xed-message.h \
|
xed-message.h \
|
||||||
xed-notebook.h \
|
xed-notebook.h \
|
||||||
xed-panel.h \
|
xed-panel.h \
|
||||||
xed-prefs-manager-app.h \
|
|
||||||
xed-prefs-manager.h \
|
|
||||||
xed-progress-message-area.h \
|
xed-progress-message-area.h \
|
||||||
xed-searchbar.h \
|
xed-searchbar.h \
|
||||||
xed-statusbar.h \
|
xed-statusbar.h \
|
||||||
|
@ -136,13 +134,11 @@ libxed_c_files = \
|
||||||
xed-notebook.c \
|
xed-notebook.c \
|
||||||
xed-panel.c \
|
xed-panel.c \
|
||||||
xed-plugins-engine.c \
|
xed-plugins-engine.c \
|
||||||
xed-prefs-manager-app.c \
|
|
||||||
xed-prefs-manager.c \
|
|
||||||
xed-prefs-manager-private.h \
|
|
||||||
xed-print-job.c \
|
xed-print-job.c \
|
||||||
xed-print-preview.c \
|
xed-print-preview.c \
|
||||||
xed-progress-message-area.c \
|
xed-progress-message-area.c \
|
||||||
xed-session.c \
|
xed-session.c \
|
||||||
|
xed-settings.c \
|
||||||
xed-smart-charset-converter.c \
|
xed-smart-charset-converter.c \
|
||||||
xed-searchbar.c \
|
xed-searchbar.c \
|
||||||
xed-statusbar.c \
|
xed-statusbar.c \
|
||||||
|
|
|
@ -40,11 +40,11 @@
|
||||||
|
|
||||||
#include "xed-encodings-dialog.h"
|
#include "xed-encodings-dialog.h"
|
||||||
#include "xed-encodings.h"
|
#include "xed-encodings.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-help.h"
|
#include "xed-help.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define XED_ENCODINGS_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
#define XED_ENCODINGS_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||||
XED_TYPE_ENCODINGS_DIALOG, \
|
XED_TYPE_ENCODINGS_DIALOG, \
|
||||||
|
@ -52,12 +52,15 @@
|
||||||
|
|
||||||
struct _XedEncodingsDialogPrivate
|
struct _XedEncodingsDialogPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *enc_settings;
|
||||||
|
|
||||||
GtkListStore *available_liststore;
|
GtkListStore *available_liststore;
|
||||||
GtkListStore *displayed_liststore;
|
GtkListStore *displayed_liststore;
|
||||||
GtkWidget *available_treeview;
|
|
||||||
GtkWidget *displayed_treeview;
|
GtkWidget *available_treeview;
|
||||||
GtkWidget *add_button;
|
GtkWidget *displayed_treeview;
|
||||||
GtkWidget *remove_button;
|
GtkWidget *add_button;
|
||||||
|
GtkWidget *remove_button;
|
||||||
|
|
||||||
GSList *show_in_menu_list;
|
GSList *show_in_menu_list;
|
||||||
};
|
};
|
||||||
|
@ -74,12 +77,23 @@ xed_encodings_dialog_finalize (GObject *object)
|
||||||
G_OBJECT_CLASS (xed_encodings_dialog_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xed_encodings_dialog_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_encodings_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedEncodingsDialogPrivate *priv = XED_ENCODINGS_DIALOG (object)->priv;
|
||||||
|
|
||||||
|
g_clear_object (&priv->enc_settings);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_encodings_dialog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_encodings_dialog_class_init (XedEncodingsDialogClass *klass)
|
xed_encodings_dialog_class_init (XedEncodingsDialogClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = xed_encodings_dialog_finalize;
|
object_class->finalize = xed_encodings_dialog_finalize;
|
||||||
|
object_class->dispose = xed_encodings_dialog_dispose;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedEncodingsDialogPrivate));
|
g_type_class_add_private (object_class, sizeof (XedEncodingsDialogPrivate));
|
||||||
}
|
}
|
||||||
|
@ -228,14 +242,15 @@ static void
|
||||||
init_shown_in_menu_tree_model (XedEncodingsDialog *dialog)
|
init_shown_in_menu_tree_model (XedEncodingsDialog *dialog)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gchar **enc_strv;
|
||||||
GSList *list, *tmp;
|
GSList *list, *tmp;
|
||||||
|
|
||||||
/* add data to the list store */
|
/* add data to the list store */
|
||||||
list = xed_prefs_manager_get_shown_in_menu_encodings ();
|
enc_strv = g_settings_get_strv (dialog->priv->enc_settings, XED_SETTINGS_ENCODING_SHOWN_IN_MENU);
|
||||||
|
|
||||||
tmp = list;
|
list = _xed_encoding_strv_to_list ((const gchar * const *)enc_strv);
|
||||||
|
|
||||||
while (tmp != NULL)
|
for (tmp = list; tmp != NULL; tmp = g_slist_next (tmp))
|
||||||
{
|
{
|
||||||
const XedEncoding *enc;
|
const XedEncoding *enc;
|
||||||
|
|
||||||
|
@ -248,8 +263,6 @@ init_shown_in_menu_tree_model (XedEncodingsDialog *dialog)
|
||||||
COLUMN_CHARSET, xed_encoding_get_charset (enc),
|
COLUMN_CHARSET, xed_encoding_get_charset (enc),
|
||||||
COLUMN_NAME, xed_encoding_get_name (enc),
|
COLUMN_NAME, xed_encoding_get_name (enc),
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
tmp = g_slist_next (tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slist_free (list);
|
g_slist_free (list);
|
||||||
|
@ -269,8 +282,14 @@ response_handler (GtkDialog *dialog,
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
g_return_if_fail (xed_prefs_manager_shown_in_menu_encodings_can_set ());
|
gchar **encs;
|
||||||
xed_prefs_manager_set_shown_in_menu_encodings (dlg->priv->show_in_menu_list);
|
|
||||||
|
encs = _xed_encoding_list_to_strv (dlg->priv->show_in_menu_list);
|
||||||
|
g_settings_set_strv (dlg->priv->enc_settings,
|
||||||
|
XED_SETTINGS_ENCODING_SHOWN_IN_MENU,
|
||||||
|
(const gchar * const *)encs);
|
||||||
|
|
||||||
|
g_strfreev (encs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +313,7 @@ xed_encodings_dialog_init (XedEncodingsDialog *dlg)
|
||||||
};
|
};
|
||||||
|
|
||||||
dlg->priv = XED_ENCODINGS_DIALOG_GET_PRIVATE (dlg);
|
dlg->priv = XED_ENCODINGS_DIALOG_GET_PRIVATE (dlg);
|
||||||
|
dlg->priv->enc_settings = g_settings_new ("org.x.editor.preferences.encodings");
|
||||||
|
|
||||||
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
||||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
#include <libpeas-gtk/peas-gtk-plugin-manager.h>
|
#include <libpeas-gtk/peas-gtk-plugin-manager.h>
|
||||||
|
|
||||||
#include <xed/xed-prefs-manager.h>
|
|
||||||
|
|
||||||
#include "xed-preferences-dialog.h"
|
#include "xed-preferences-dialog.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
|
@ -50,6 +48,8 @@
|
||||||
#include "xed-style-scheme-manager.h"
|
#include "xed-style-scheme-manager.h"
|
||||||
#include "xed-help.h"
|
#include "xed-help.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
#include "xed-utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xed-preferences dialog is a singleton since we don't
|
* xed-preferences dialog is a singleton since we don't
|
||||||
|
@ -78,72 +78,87 @@ enum
|
||||||
|
|
||||||
struct _XedPreferencesDialogPrivate
|
struct _XedPreferencesDialogPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *editor;
|
||||||
|
GSettings *ui;
|
||||||
|
|
||||||
GtkWidget *notebook;
|
GtkWidget *notebook;
|
||||||
|
|
||||||
/* Font */
|
/* Font */
|
||||||
GtkWidget *default_font_checkbutton;
|
GtkWidget *default_font_checkbutton;
|
||||||
GtkWidget *font_button;
|
GtkWidget *font_button;
|
||||||
GtkWidget *font_hbox;
|
GtkWidget *font_hbox;
|
||||||
|
|
||||||
/* Style Scheme */
|
/* Style Scheme */
|
||||||
GtkListStore *schemes_treeview_model;
|
GtkListStore *schemes_treeview_model;
|
||||||
GtkWidget *schemes_treeview;
|
GtkWidget *schemes_treeview;
|
||||||
GtkWidget *install_scheme_button;
|
GtkWidget *install_scheme_button;
|
||||||
GtkWidget *uninstall_scheme_button;
|
GtkWidget *uninstall_scheme_button;
|
||||||
|
|
||||||
GtkWidget *install_scheme_file_schooser;
|
GtkWidget *install_scheme_file_schooser;
|
||||||
|
|
||||||
/* Tabs */
|
/* Tabs */
|
||||||
GtkWidget *tabs_width_spinbutton;
|
GtkWidget *tabs_width_spinbutton;
|
||||||
GtkWidget *insert_spaces_checkbutton;
|
GtkWidget *insert_spaces_checkbutton;
|
||||||
GtkWidget *tabs_width_hbox;
|
GtkWidget *tabs_width_hbox;
|
||||||
|
|
||||||
/* Auto indentation */
|
/* Auto indentation */
|
||||||
GtkWidget *auto_indent_checkbutton;
|
GtkWidget *auto_indent_checkbutton;
|
||||||
|
|
||||||
/* Text Wrapping */
|
/* Text Wrapping */
|
||||||
GtkWidget *wrap_text_checkbutton;
|
GtkWidget *wrap_text_checkbutton;
|
||||||
GtkWidget *split_checkbutton;
|
GtkWidget *split_checkbutton;
|
||||||
|
|
||||||
/* File Saving */
|
/* File Saving */
|
||||||
GtkWidget *backup_copy_checkbutton;
|
GtkWidget *backup_copy_checkbutton;
|
||||||
GtkWidget *auto_save_checkbutton;
|
GtkWidget *auto_save_checkbutton;
|
||||||
GtkWidget *auto_save_spinbutton;
|
GtkWidget *auto_save_spinbutton;
|
||||||
GtkWidget *autosave_hbox;
|
GtkWidget *autosave_hbox;
|
||||||
|
|
||||||
/* Line numbers */
|
/* Line numbers */
|
||||||
GtkWidget *display_line_numbers_checkbutton;
|
GtkWidget *display_line_numbers_checkbutton;
|
||||||
|
|
||||||
/* Highlight current line */
|
/* Highlight current line */
|
||||||
GtkWidget *highlight_current_line_checkbutton;
|
GtkWidget *highlight_current_line_checkbutton;
|
||||||
|
|
||||||
/* Highlight matching bracket */
|
/* Highlight matching bracket */
|
||||||
GtkWidget *bracket_matching_checkbutton;
|
GtkWidget *bracket_matching_checkbutton;
|
||||||
|
|
||||||
/* Right margin */
|
/* Right margin */
|
||||||
GtkWidget *right_margin_checkbutton;
|
GtkWidget *right_margin_checkbutton;
|
||||||
GtkWidget *right_margin_position_spinbutton;
|
GtkWidget *right_margin_position_spinbutton;
|
||||||
GtkWidget *right_margin_position_hbox;
|
GtkWidget *right_margin_position_hbox;
|
||||||
|
|
||||||
/* Tab scrolling */
|
/* Tab scrolling */
|
||||||
GtkWidget *tab_scrolling_checkbutton;
|
GtkWidget *tab_scrolling_checkbutton;
|
||||||
|
|
||||||
/* Plugins manager */
|
/* Plugins manager */
|
||||||
GtkWidget *plugin_manager_place_holder;
|
GtkWidget *plugin_manager_place_holder;
|
||||||
|
|
||||||
/* Style Scheme editor dialog */
|
/* Style Scheme editor dialog */
|
||||||
GtkWidget *style_scheme_dialog;
|
GtkWidget *style_scheme_dialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedPreferencesDialog, xed_preferences_dialog, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE(XedPreferencesDialog, xed_preferences_dialog, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_preferences_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedPreferencesDialog *dlg = XED_PREFERENCES_DIALOG (object);
|
||||||
|
|
||||||
|
g_clear_object (&dlg->priv->editor);
|
||||||
|
g_clear_object (&dlg->priv->ui);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_preferences_dialog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_preferences_dialog_class_init (XedPreferencesDialogClass *klass)
|
xed_preferences_dialog_class_init (XedPreferencesDialogClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = xed_preferences_dialog_dispose;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedPreferencesDialogPrivate));
|
g_type_class_add_private (object_class, sizeof (XedPreferencesDialogPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,172 +180,75 @@ dialog_response_handler (GtkDialog *dlg,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tabs_width_spinbutton_value_changed (GtkSpinButton *spin_button,
|
on_auto_save_changed (GSettings *settings,
|
||||||
XedPreferencesDialog *dlg)
|
const gchar *key,
|
||||||
|
XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
|
gboolean value;
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->tabs_width_spinbutton));
|
value = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
xed_prefs_manager_set_tabs_size (gtk_spin_button_get_value_as_int (spin_button));
|
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, value);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
insert_spaces_checkbutton_toggled (GtkToggleButton *button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->insert_spaces_checkbutton));
|
|
||||||
|
|
||||||
xed_prefs_manager_set_insert_spaces (gtk_toggle_button_get_active (button));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
auto_indent_checkbutton_toggled (GtkToggleButton *button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->auto_indent_checkbutton));
|
|
||||||
|
|
||||||
xed_prefs_manager_set_auto_indent (gtk_toggle_button_get_active (button));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
auto_save_checkbutton_toggled (GtkToggleButton *button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton));
|
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (button))
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, xed_prefs_manager_auto_save_interval_can_set());
|
|
||||||
xed_prefs_manager_set_auto_save (TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, FALSE);
|
|
||||||
xed_prefs_manager_set_auto_save (FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
backup_copy_checkbutton_toggled (GtkToggleButton *button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton));
|
|
||||||
|
|
||||||
xed_prefs_manager_set_create_backup_copy (gtk_toggle_button_get_active (button));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
auto_save_spinbutton_value_changed (GtkSpinButton *spin_button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton));
|
|
||||||
|
|
||||||
xed_prefs_manager_set_auto_save_interval (MAX (1, gtk_spin_button_get_value_as_int (spin_button)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
tab_scrolling_checkbutton_toggled (GtkToggleButton *button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->tab_scrolling_checkbutton));
|
|
||||||
|
|
||||||
xed_prefs_manager_set_enable_tab_scrolling (gtk_toggle_button_get_active (button));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_editor_page (XedPreferencesDialog *dlg)
|
setup_editor_page (XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
gboolean auto_save;
|
gboolean auto_save;
|
||||||
gint auto_save_interval;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
/* Set initial state */
|
/* Get values */
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->tabs_width_spinbutton),
|
auto_save = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_AUTO_SAVE);
|
||||||
(guint) xed_prefs_manager_get_tabs_size ());
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->insert_spaces_checkbutton),
|
|
||||||
xed_prefs_manager_get_insert_spaces ());
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_indent_checkbutton),
|
|
||||||
xed_prefs_manager_get_auto_indent ());
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton),
|
|
||||||
xed_prefs_manager_get_create_backup_copy ());
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->tab_scrolling_checkbutton),
|
|
||||||
xed_prefs_manager_get_enable_tab_scrolling ());
|
|
||||||
|
|
||||||
auto_save = xed_prefs_manager_get_auto_save ();
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton), auto_save);
|
|
||||||
|
|
||||||
auto_save_interval = xed_prefs_manager_get_auto_save_interval ();
|
|
||||||
if (auto_save_interval <= 0)
|
|
||||||
{
|
|
||||||
auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton), auto_save_interval);
|
|
||||||
|
|
||||||
/* Set widget sensitivity */
|
/* Set widget sensitivity */
|
||||||
gtk_widget_set_sensitive (dlg->priv->tabs_width_hbox, xed_prefs_manager_tabs_size_can_set ());
|
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, auto_save);
|
||||||
gtk_widget_set_sensitive (dlg->priv->insert_spaces_checkbutton, xed_prefs_manager_insert_spaces_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->auto_indent_checkbutton, xed_prefs_manager_auto_indent_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->backup_copy_checkbutton, xed_prefs_manager_create_backup_copy_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->autosave_hbox, xed_prefs_manager_auto_save_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton,
|
|
||||||
auto_save && xed_prefs_manager_auto_save_interval_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->tab_scrolling_checkbutton, xed_prefs_manager_enable_tab_scrolling_can_set ());
|
|
||||||
|
|
||||||
/* Connect signal */
|
/* Connect signal */
|
||||||
g_signal_connect (dlg->priv->tabs_width_spinbutton, "value_changed",
|
g_settings_bind (dlg->priv->editor,
|
||||||
G_CALLBACK (tabs_width_spinbutton_value_changed), dlg);
|
XED_SETTINGS_TABS_SIZE,
|
||||||
g_signal_connect (dlg->priv->insert_spaces_checkbutton, "toggled",
|
dlg->priv->tabs_width_spinbutton,
|
||||||
G_CALLBACK (insert_spaces_checkbutton_toggled), dlg);
|
"value",
|
||||||
g_signal_connect (dlg->priv->auto_indent_checkbutton, "toggled",
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
G_CALLBACK (auto_indent_checkbutton_toggled), dlg);
|
g_settings_bind (dlg->priv->editor,
|
||||||
g_signal_connect (dlg->priv->auto_save_checkbutton, "toggled",
|
XED_SETTINGS_INSERT_SPACES,
|
||||||
G_CALLBACK (auto_save_checkbutton_toggled), dlg);
|
dlg->priv->insert_spaces_checkbutton,
|
||||||
g_signal_connect (dlg->priv->backup_copy_checkbutton, "toggled",
|
"active",
|
||||||
G_CALLBACK (backup_copy_checkbutton_toggled), dlg);
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
g_signal_connect (dlg->priv->auto_save_spinbutton, "value_changed",
|
g_settings_bind (dlg->priv->editor,
|
||||||
G_CALLBACK (auto_save_spinbutton_value_changed), dlg);
|
XED_SETTINGS_AUTO_INDENT,
|
||||||
g_signal_connect (dlg->priv->tab_scrolling_checkbutton, "toggled",
|
dlg->priv->auto_indent_checkbutton,
|
||||||
G_CALLBACK (tab_scrolling_checkbutton_toggled), dlg);
|
"active",
|
||||||
}
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
g_settings_bind (dlg->priv->editor,
|
||||||
static void
|
XED_SETTINGS_CREATE_BACKUP_COPY,
|
||||||
display_line_numbers_checkbutton_toggled (GtkToggleButton *button,
|
dlg->priv->backup_copy_checkbutton,
|
||||||
XedPreferencesDialog *dlg)
|
"active",
|
||||||
{
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton));
|
g_settings_bind (dlg->priv->editor,
|
||||||
|
XED_SETTINGS_BRACKET_MATCHING,
|
||||||
xed_prefs_manager_set_display_line_numbers (gtk_toggle_button_get_active (button));
|
dlg->priv->bracket_matching_checkbutton,
|
||||||
}
|
"active",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
static void
|
g_settings_bind (dlg->priv->editor,
|
||||||
highlight_current_line_checkbutton_toggled (GtkToggleButton *button,
|
XED_SETTINGS_AUTO_SAVE_INTERVAL,
|
||||||
XedPreferencesDialog *dlg)
|
dlg->priv->auto_save_spinbutton,
|
||||||
{
|
"value",
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->highlight_current_line_checkbutton));
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
g_signal_connect (dlg->priv->editor, "changed::auto_save",
|
||||||
xed_prefs_manager_set_highlight_current_line (gtk_toggle_button_get_active (button));
|
G_CALLBACK (on_auto_save_changed), dlg);
|
||||||
}
|
g_settings_bind (dlg->priv->editor,
|
||||||
|
XED_SETTINGS_AUTO_SAVE,
|
||||||
static void
|
dlg->priv->auto_save_checkbutton,
|
||||||
bracket_matching_checkbutton_toggled (GtkToggleButton *button,
|
"active",
|
||||||
XedPreferencesDialog *dlg)
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
{
|
g_settings_bind (dlg->priv->ui,
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->bracket_matching_checkbutton));
|
XED_SETTINGS_ENABLE_TAB_SCROLLING,
|
||||||
|
dlg->priv->tab_scrolling_checkbutton,
|
||||||
xed_prefs_manager_set_bracket_matching (gtk_toggle_button_get_active (button));
|
"active",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean split_button_state = TRUE;
|
static gboolean split_button_state = TRUE;
|
||||||
|
@ -339,9 +257,11 @@ static void
|
||||||
wrap_mode_checkbutton_toggled (GtkToggleButton *button,
|
wrap_mode_checkbutton_toggled (GtkToggleButton *button,
|
||||||
XedPreferencesDialog *dlg)
|
XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
|
GtkWrapMode mode;
|
||||||
|
|
||||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton)))
|
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton)))
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_wrap_mode (GTK_WRAP_NONE);
|
mode = GTK_WRAP_NONE;
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, FALSE);
|
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, FALSE);
|
||||||
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
|
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
|
||||||
|
@ -355,14 +275,16 @@ wrap_mode_checkbutton_toggled (GtkToggleButton *button,
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton)))
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton)))
|
||||||
{
|
{
|
||||||
split_button_state = TRUE;
|
split_button_state = TRUE;
|
||||||
xed_prefs_manager_set_wrap_mode (GTK_WRAP_WORD);
|
mode = GTK_WRAP_WORD;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
split_button_state = FALSE;
|
split_button_state = FALSE;
|
||||||
xed_prefs_manager_set_wrap_mode (GTK_WRAP_CHAR);
|
mode = GTK_WRAP_CHAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_settings_set_enum (dlg->priv->editor, XED_SETTINGS_WRAP_MODE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -375,23 +297,9 @@ right_margin_checkbutton_toggled (GtkToggleButton *button,
|
||||||
|
|
||||||
active = gtk_toggle_button_get_active (button);
|
active = gtk_toggle_button_get_active (button);
|
||||||
|
|
||||||
xed_prefs_manager_set_display_right_margin (active);
|
g_settings_set_boolean (dlg->priv->editor, XED_SETTINGS_DISPLAY_RIGHT_MARGIN, active);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox,
|
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox, active);
|
||||||
active && xed_prefs_manager_right_margin_position_can_set ());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
right_margin_position_spinbutton_value_changed (GtkSpinButton *spin_button,
|
|
||||||
XedPreferencesDialog *dlg)
|
|
||||||
{
|
|
||||||
gint value;
|
|
||||||
|
|
||||||
g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->right_margin_position_spinbutton));
|
|
||||||
|
|
||||||
value = CLAMP (gtk_spin_button_get_value_as_int (spin_button), 1, 160);
|
|
||||||
|
|
||||||
xed_prefs_manager_set_right_margin_position (value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -399,22 +307,18 @@ setup_view_page (XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
GtkWrapMode wrap_mode;
|
GtkWrapMode wrap_mode;
|
||||||
gboolean display_right_margin;
|
gboolean display_right_margin;
|
||||||
gboolean wrap_mode_can_set;
|
guint right_margin_position;
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
|
/* Get values */
|
||||||
|
display_right_margin = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_DISPLAY_RIGHT_MARGIN);
|
||||||
|
right_margin_position = g_settings_get_uint (dlg->priv->editor, XED_SETTINGS_RIGHT_MARGIN_POSITION);
|
||||||
|
|
||||||
/* Set initial state */
|
/* Set initial state */
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton),
|
wrap_mode = g_settings_get_enum (dlg->priv->editor, XED_SETTINGS_WRAP_MODE);
|
||||||
xed_prefs_manager_get_display_line_numbers ());
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->highlight_current_line_checkbutton),
|
switch (wrap_mode)
|
||||||
xed_prefs_manager_get_highlight_current_line ());
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->bracket_matching_checkbutton),
|
|
||||||
xed_prefs_manager_get_bracket_matching ());
|
|
||||||
|
|
||||||
wrap_mode = xed_prefs_manager_get_wrap_mode ();
|
|
||||||
switch (wrap_mode )
|
|
||||||
{
|
{
|
||||||
case GTK_WRAP_WORD:
|
case GTK_WRAP_WORD:
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
|
||||||
|
@ -431,89 +335,55 @@ setup_view_page (XedPreferencesDialog *dlg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display_right_margin = xed_prefs_manager_get_display_right_margin ();
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton), display_right_margin);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton), display_right_margin);
|
||||||
|
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->right_margin_position_spinbutton),
|
|
||||||
(guint)CLAMP (xed_prefs_manager_get_right_margin_position (), 1, 160));
|
|
||||||
|
|
||||||
/* Set widgets sensitivity */
|
/* Set widgets sensitivity */
|
||||||
gtk_widget_set_sensitive (dlg->priv->display_line_numbers_checkbutton,
|
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, (wrap_mode != GTK_WRAP_NONE));
|
||||||
xed_prefs_manager_display_line_numbers_can_set ());
|
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox, display_right_margin);
|
||||||
gtk_widget_set_sensitive (dlg->priv->highlight_current_line_checkbutton,
|
|
||||||
xed_prefs_manager_highlight_current_line_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->bracket_matching_checkbutton, xed_prefs_manager_bracket_matching_can_set ());
|
|
||||||
wrap_mode_can_set = xed_prefs_manager_wrap_mode_can_set ();
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->wrap_text_checkbutton, wrap_mode_can_set);
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->split_checkbutton, wrap_mode_can_set && (wrap_mode != GTK_WRAP_NONE));
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->right_margin_checkbutton, xed_prefs_manager_display_right_margin_can_set ());
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox,
|
|
||||||
display_right_margin && xed_prefs_manager_right_margin_position_can_set ());
|
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
g_signal_connect (dlg->priv->display_line_numbers_checkbutton, "toggled",
|
g_settings_bind (dlg->priv->editor,
|
||||||
G_CALLBACK (display_line_numbers_checkbutton_toggled), dlg);
|
XED_SETTINGS_DISPLAY_LINE_NUMBERS,
|
||||||
g_signal_connect (dlg->priv->highlight_current_line_checkbutton, "toggled",
|
dlg->priv->display_line_numbers_checkbutton,
|
||||||
G_CALLBACK (highlight_current_line_checkbutton_toggled), dlg);
|
"active",
|
||||||
g_signal_connect (dlg->priv->bracket_matching_checkbutton, "toggled",
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
G_CALLBACK (bracket_matching_checkbutton_toggled), dlg);
|
g_settings_bind (dlg->priv->editor,
|
||||||
|
XED_SETTINGS_HIGHLIGHT_CURRENT_LINE,
|
||||||
|
dlg->priv->highlight_current_line_checkbutton,
|
||||||
|
"active",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
g_settings_bind (dlg->priv->editor,
|
||||||
|
XED_SETTINGS_RIGHT_MARGIN_POSITION,
|
||||||
|
dlg->priv->right_margin_position_spinbutton,
|
||||||
|
"value",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
|
||||||
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
||||||
g_signal_connect (dlg->priv->split_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->split_checkbutton, "toggled",
|
||||||
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
|
||||||
g_signal_connect (dlg->priv->right_margin_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->right_margin_checkbutton, "toggled",
|
||||||
G_CALLBACK (right_margin_checkbutton_toggled), dlg);
|
G_CALLBACK (right_margin_checkbutton_toggled), dlg);
|
||||||
g_signal_connect (dlg->priv->right_margin_position_spinbutton, "value_changed",
|
|
||||||
G_CALLBACK (right_margin_position_spinbutton_value_changed), dlg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_font_font_checkbutton_toggled (GtkToggleButton *button,
|
on_use_default_font_changed (GSettings *settings,
|
||||||
XedPreferencesDialog *dlg)
|
const gchar *key,
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton));
|
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (button))
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->font_hbox, FALSE);
|
|
||||||
xed_prefs_manager_set_use_default_font (TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->font_hbox, xed_prefs_manager_editor_font_can_set ());
|
|
||||||
xed_prefs_manager_set_use_default_font (FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
editor_font_button_font_set (GtkFontButton *font_button,
|
|
||||||
XedPreferencesDialog *dlg)
|
XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
const gchar *font_name;
|
gboolean value;
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
g_return_if_fail (font_button == GTK_FONT_BUTTON (dlg->priv->font_button));
|
value = g_settings_get_boolean (settings, key);
|
||||||
|
gtk_widget_set_sensitive (dlg->priv->font_hbox, value);
|
||||||
/* FIXME: Can this fail? Gtk docs are a bit terse... 21-02-2004 pbor */
|
|
||||||
font_name = gtk_font_button_get_font_name (font_button);
|
|
||||||
if (!font_name)
|
|
||||||
{
|
|
||||||
g_warning ("Could not get font name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
xed_prefs_manager_set_editor_font (font_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_font_colors_page_font_section (XedPreferencesDialog *dlg)
|
setup_font_colors_page_font_section (XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
|
GSettings *settings;
|
||||||
gboolean use_default_font;
|
gboolean use_default_font;
|
||||||
gchar *editor_font = NULL;
|
gchar *system_font = NULL;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
@ -528,40 +398,35 @@ setup_font_colors_page_font_section (XedPreferencesDialog *dlg)
|
||||||
dlg->priv->font_button,
|
dlg->priv->font_button,
|
||||||
ATK_RELATION_CONTROLLER_FOR);
|
ATK_RELATION_CONTROLLER_FOR);
|
||||||
|
|
||||||
editor_font = xed_prefs_manager_get_system_font ();
|
/* Get values */
|
||||||
label = g_strdup_printf(_("_Use the system fixed width font (%s)"), editor_font);
|
settings = _xed_app_get_settings (xed_app_get_default ());
|
||||||
|
system_font = xed_settings_get_system_font (XED_SETTINGS (settings));
|
||||||
|
use_default_font = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_USE_DEFAULT_FONT);
|
||||||
|
|
||||||
|
label = g_strdup_printf(_("_Use the system fixed width font (%s)"), system_font);
|
||||||
gtk_button_set_label (GTK_BUTTON (dlg->priv->default_font_checkbutton), label);
|
gtk_button_set_label (GTK_BUTTON (dlg->priv->default_font_checkbutton), label);
|
||||||
g_free (editor_font);
|
g_free (system_font);
|
||||||
g_free (label);
|
g_free (label);
|
||||||
|
|
||||||
/* read current config and setup initial state */
|
/* read current config and setup initial state */
|
||||||
use_default_font = xed_prefs_manager_get_use_default_font ();
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton), use_default_font);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton), use_default_font);
|
||||||
|
|
||||||
editor_font = xed_prefs_manager_get_editor_font ();
|
|
||||||
if (editor_font != NULL)
|
|
||||||
{
|
|
||||||
gtk_font_button_set_font_name (GTK_FONT_BUTTON (dlg->priv->font_button), editor_font);
|
|
||||||
g_free (editor_font);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
g_signal_connect (dlg->priv->default_font_checkbutton, "toggled",
|
g_signal_connect (dlg->priv->editor, "changed::use-default-font",
|
||||||
G_CALLBACK (default_font_font_checkbutton_toggled), dlg);
|
G_CALLBACK (on_use_default_font_changed), dlg);
|
||||||
g_signal_connect (dlg->priv->font_button, "font_set",
|
g_settings_bind (dlg->priv->editor,
|
||||||
G_CALLBACK (editor_font_button_font_set), dlg);
|
XED_SETTINGS_USE_DEFAULT_FONT,
|
||||||
|
dlg->priv->default_font_checkbutton,
|
||||||
|
"active",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
g_settings_bind (dlg->priv->editor,
|
||||||
|
XED_SETTINGS_EDITOR_FONT,
|
||||||
|
dlg->priv->font_button,
|
||||||
|
"font-name",
|
||||||
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
|
|
||||||
/* Set initial widget sensitivity */
|
/* Set initial widget sensitivity */
|
||||||
gtk_widget_set_sensitive (dlg->priv->default_font_checkbutton, xed_prefs_manager_use_default_font_can_set ());
|
gtk_widget_set_sensitive (dlg->priv->font_hbox, use_default_font);
|
||||||
|
|
||||||
if (use_default_font)
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->font_hbox, FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (dlg->priv->font_hbox, xed_prefs_manager_editor_font_can_set ());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -589,7 +454,7 @@ style_scheme_changed (GtkWidget *treeview,
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, ID_COLUMN, &id, -1);
|
gtk_tree_model_get (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, ID_COLUMN, &id, -1);
|
||||||
|
|
||||||
xed_prefs_manager_set_source_style_scheme (id);
|
g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, id);
|
||||||
|
|
||||||
set_buttons_sensisitivity_according_to_scheme (dlg, id);
|
set_buttons_sensisitivity_according_to_scheme (dlg, id);
|
||||||
|
|
||||||
|
@ -597,7 +462,8 @@ style_scheme_changed (GtkWidget *treeview,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar *
|
static const gchar *
|
||||||
ensure_color_scheme_id (const gchar *id)
|
ensure_color_scheme_id (XedPreferencesDialog *dlg,
|
||||||
|
const gchar *id)
|
||||||
{
|
{
|
||||||
GtkSourceStyleScheme *scheme = NULL;
|
GtkSourceStyleScheme *scheme = NULL;
|
||||||
GtkSourceStyleSchemeManager *manager = xed_get_style_scheme_manager ();
|
GtkSourceStyleSchemeManager *manager = xed_get_style_scheme_manager ();
|
||||||
|
@ -606,7 +472,7 @@ ensure_color_scheme_id (const gchar *id)
|
||||||
{
|
{
|
||||||
gchar *pref_id;
|
gchar *pref_id;
|
||||||
|
|
||||||
pref_id = xed_prefs_manager_get_source_style_scheme ();
|
pref_id = g_settings_get_string (dlg->priv->editor, XED_SETTINGS_SCHEME);
|
||||||
scheme = gtk_source_style_scheme_manager_get_scheme (manager, pref_id);
|
scheme = gtk_source_style_scheme_manager_get_scheme (manager, pref_id);
|
||||||
g_free (pref_id);
|
g_free (pref_id);
|
||||||
}
|
}
|
||||||
|
@ -642,7 +508,7 @@ populate_color_scheme_list (XedPreferencesDialog *dlg,
|
||||||
|
|
||||||
gtk_list_store_clear (dlg->priv->schemes_treeview_model);
|
gtk_list_store_clear (dlg->priv->schemes_treeview_model);
|
||||||
|
|
||||||
def_id = ensure_color_scheme_id (def_id);
|
def_id = ensure_color_scheme_id (dlg, def_id);
|
||||||
if (def_id == NULL)
|
if (def_id == NULL)
|
||||||
{
|
{
|
||||||
g_warning ("Cannot build the list of available color schemes.\n"
|
g_warning ("Cannot build the list of available color schemes.\n"
|
||||||
|
@ -720,7 +586,7 @@ add_scheme_chooser_response_cb (GtkDialog *chooser,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xed_prefs_manager_set_source_style_scheme (scheme_id);
|
g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, scheme_id);
|
||||||
|
|
||||||
scheme_id = populate_color_scheme_list (dlg, scheme_id);
|
scheme_id = populate_color_scheme_list (dlg, scheme_id);
|
||||||
|
|
||||||
|
@ -852,7 +718,7 @@ uninstall_scheme_clicked (GtkButton *button,
|
||||||
|
|
||||||
if (real_new_id != NULL)
|
if (real_new_id != NULL)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_source_style_scheme (real_new_id);
|
g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, real_new_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -983,6 +849,8 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
|
||||||
xed_debug (DEBUG_PREFS);
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
dlg->priv = XED_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
|
dlg->priv = XED_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
|
||||||
|
dlg->priv->editor = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
|
dlg->priv->ui = g_settings_new ("org.x.editor.preferences.ui");
|
||||||
|
|
||||||
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
||||||
_("Close"), GTK_RESPONSE_CLOSE,
|
_("Close"), GTK_RESPONSE_CLOSE,
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include <libpeas/peas-extension-set.h>
|
#include <libpeas/peas-extension-set.h>
|
||||||
|
|
||||||
#include "xed-app.h"
|
#include "xed-app.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-commands.h"
|
#include "xed-commands.h"
|
||||||
#include "xed-notebook.h"
|
#include "xed-notebook.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
|
@ -48,6 +47,7 @@
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
#include "xed-app-activatable.h"
|
#include "xed-app-activatable.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
||||||
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
||||||
|
@ -62,12 +62,15 @@ enum
|
||||||
|
|
||||||
struct _XedAppPrivate
|
struct _XedAppPrivate
|
||||||
{
|
{
|
||||||
GList *windows;
|
GList *windows;
|
||||||
XedWindow *active_window;
|
XedWindow *active_window;
|
||||||
|
|
||||||
GtkPageSetup *page_setup;
|
GtkPageSetup *page_setup;
|
||||||
GtkPrintSettings *print_settings;
|
GtkPrintSettings *print_settings;
|
||||||
|
|
||||||
|
GSettings *settings;
|
||||||
|
GSettings *window_settings;
|
||||||
|
|
||||||
PeasExtensionSet *extensions;
|
PeasExtensionSet *extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,6 +101,8 @@ xed_app_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
XedApp *app = XED_APP (object);
|
XedApp *app = XED_APP (object);
|
||||||
|
|
||||||
|
g_clear_object (&app->priv->window_settings);
|
||||||
|
g_clear_object (&app->priv->settings);
|
||||||
g_clear_object (&app->priv->extensions);
|
g_clear_object (&app->priv->extensions);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_app_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_app_parent_class)->dispose (object);
|
||||||
|
@ -350,6 +355,8 @@ xed_app_init (XedApp *app)
|
||||||
|
|
||||||
load_accels ();
|
load_accels ();
|
||||||
|
|
||||||
|
app->priv->settings = xed_settings_new ();
|
||||||
|
app->priv->window_settings = g_settings_new ("org.x.editor.state.window");
|
||||||
app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||||
XED_TYPE_APP_ACTIVATABLE, "app", app, NULL);
|
XED_TYPE_APP_ACTIVATABLE, "app", app, NULL);
|
||||||
|
|
||||||
|
@ -525,17 +532,17 @@ xed_app_create_window_real (XedApp *app,
|
||||||
GdkWindowState state;
|
GdkWindowState state;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
|
|
||||||
state = xed_prefs_manager_get_window_state ();
|
state = g_settings_get_int (app->priv->window_settings, XED_SETTINGS_WINDOW_STATE);
|
||||||
|
|
||||||
if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
|
if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_get_default_window_size (&w, &h);
|
_xed_window_get_default_size (&w, &h);
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), w, h);
|
gtk_window_set_default_size (GTK_WINDOW (window), w, h);
|
||||||
gtk_window_maximize (GTK_WINDOW (window));
|
gtk_window_maximize (GTK_WINDOW (window));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xed_prefs_manager_get_window_size (&w, &h);
|
g_settings_get (app->priv->window_settings, XED_SETTINGS_WINDOW_SIZE, "(ii)", &w, &h);
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), w, h);
|
gtk_window_set_default_size (GTK_WINDOW (window), w, h);
|
||||||
gtk_window_unmaximize (GTK_WINDOW (window));
|
gtk_window_unmaximize (GTK_WINDOW (window));
|
||||||
}
|
}
|
||||||
|
@ -867,3 +874,10 @@ _xed_app_set_default_print_settings (XedApp *app,
|
||||||
app->priv->print_settings = g_object_ref (settings);
|
app->priv->print_settings = g_object_ref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSettings *
|
||||||
|
_xed_app_get_settings (XedApp *app)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (XED_IS_APP (app), NULL);
|
||||||
|
|
||||||
|
return app->priv->settings;
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* xed-app.h
|
* xed-app.h
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 - Paolo Maggi
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2005. See the AUTHORS file for a
|
* Modified by the xed Team, 2005. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -37,9 +37,6 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/*
|
|
||||||
* Type checking and casting macros
|
|
||||||
*/
|
|
||||||
#define XED_TYPE_APP (xed_app_get_type())
|
#define XED_TYPE_APP (xed_app_get_type())
|
||||||
#define XED_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_APP, XedApp))
|
#define XED_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_APP, XedApp))
|
||||||
#define XED_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_APP, XedAppClass))
|
#define XED_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_APP, XedAppClass))
|
||||||
|
@ -47,69 +44,62 @@ G_BEGIN_DECLS
|
||||||
#define XED_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_APP))
|
#define XED_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_APP))
|
||||||
#define XED_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_APP, XedAppClass))
|
#define XED_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_APP, XedAppClass))
|
||||||
|
|
||||||
/* Private structure type */
|
typedef struct _XedApp XedApp;
|
||||||
typedef struct _XedAppPrivate XedAppPrivate;
|
typedef struct _XedAppPrivate XedAppPrivate;
|
||||||
|
typedef struct _XedAppClass XedAppClass;
|
||||||
|
|
||||||
/*
|
struct _XedApp
|
||||||
* Main object structure
|
|
||||||
*/
|
|
||||||
typedef struct _XedApp XedApp;
|
|
||||||
|
|
||||||
struct _XedApp
|
|
||||||
{
|
{
|
||||||
GObject object;
|
GObject object;
|
||||||
|
|
||||||
/*< private > */
|
/*< private > */
|
||||||
XedAppPrivate *priv;
|
XedAppPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
struct _XedAppClass
|
||||||
* Class definition
|
|
||||||
*/
|
|
||||||
typedef struct _XedAppClass XedAppClass;
|
|
||||||
|
|
||||||
struct _XedAppClass
|
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public methods
|
* Public methods
|
||||||
*/
|
*/
|
||||||
GType xed_app_get_type (void) G_GNUC_CONST;
|
GType xed_app_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
XedApp *xed_app_get_default (void);
|
XedApp *xed_app_get_default (void);
|
||||||
|
|
||||||
XedWindow *xed_app_create_window (XedApp *app,
|
XedWindow *xed_app_create_window (XedApp *app,
|
||||||
GdkScreen *screen);
|
GdkScreen *screen);
|
||||||
|
|
||||||
const GList *xed_app_get_windows (XedApp *app);
|
const GList *xed_app_get_windows (XedApp *app);
|
||||||
XedWindow *xed_app_get_active_window (XedApp *app);
|
XedWindow *xed_app_get_active_window (XedApp *app);
|
||||||
|
|
||||||
/* Returns a newly allocated list with all the documents */
|
/* Returns a newly allocated list with all the documents */
|
||||||
GList *xed_app_get_documents (XedApp *app);
|
GList *xed_app_get_documents (XedApp *app);
|
||||||
|
|
||||||
/* Returns a newly allocated list with all the views */
|
/* Returns a newly allocated list with all the views */
|
||||||
GList *xed_app_get_views (XedApp *app);
|
GList *xed_app_get_views (XedApp *app);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Non exported functions
|
* Non exported functions
|
||||||
*/
|
*/
|
||||||
XedWindow *_xed_app_restore_window (XedApp *app,
|
XedWindow *_xed_app_restore_window (XedApp *app,
|
||||||
const gchar *role);
|
const gchar *role);
|
||||||
XedWindow *_xed_app_get_window_in_viewport (XedApp *app,
|
XedWindow *_xed_app_get_window_in_viewport (XedApp *app,
|
||||||
GdkScreen *screen,
|
GdkScreen *screen,
|
||||||
gint workspace,
|
gint workspace,
|
||||||
gint viewport_x,
|
gint viewport_x,
|
||||||
gint viewport_y);
|
gint viewport_y);
|
||||||
|
|
||||||
/* global print config */
|
/* global print config */
|
||||||
GtkPageSetup *_xed_app_get_default_page_setup (XedApp *app);
|
GtkPageSetup *_xed_app_get_default_page_setup (XedApp *app);
|
||||||
void _xed_app_set_default_page_setup (XedApp *app,
|
void _xed_app_set_default_page_setup (XedApp *app,
|
||||||
GtkPageSetup *page_setup);
|
GtkPageSetup *page_setup);
|
||||||
GtkPrintSettings *_xed_app_get_default_print_settings (XedApp *app);
|
GtkPrintSettings *_xed_app_get_default_print_settings (XedApp *app);
|
||||||
void _xed_app_set_default_print_settings (XedApp *app,
|
void _xed_app_set_default_print_settings (XedApp *app,
|
||||||
GtkPrintSettings *settings);
|
GtkPrintSettings *settings);
|
||||||
|
|
||||||
|
GSettings *_xed_app_get_settings (XedApp *app);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,12 @@
|
||||||
#include "xed-document-loader.h"
|
#include "xed-document-loader.h"
|
||||||
#include "xed-document-output-stream.h"
|
#include "xed-document-output-stream.h"
|
||||||
#include "xed-smart-charset-converter.h"
|
#include "xed-smart-charset-converter.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-metadata-manager.h"
|
#include "xed-metadata-manager.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-marshal.h"
|
#include "xed-marshal.h"
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
#ifndef ENABLE_GVFS_METADATA
|
||||||
#include "xed_metadata-manager.h"
|
#include "xed_metadata-manager.h"
|
||||||
|
@ -94,6 +94,8 @@ static void open_async_read (AsyncData *async);
|
||||||
|
|
||||||
struct _XedDocumentLoaderPrivate
|
struct _XedDocumentLoaderPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *enc_settings;
|
||||||
|
|
||||||
XedDocument *document;
|
XedDocument *document;
|
||||||
gboolean used;
|
gboolean used;
|
||||||
|
|
||||||
|
@ -228,6 +230,8 @@ xed_document_loader_dispose (GObject *object)
|
||||||
priv->location = NULL;
|
priv->location = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&priv->enc_settings);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_document_loader_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_document_loader_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +307,7 @@ xed_document_loader_init (XedDocumentLoader *loader)
|
||||||
loader->priv->auto_detected_newline_type = XED_DOCUMENT_NEWLINE_TYPE_DEFAULT;
|
loader->priv->auto_detected_newline_type = XED_DOCUMENT_NEWLINE_TYPE_DEFAULT;
|
||||||
loader->priv->converter = NULL;
|
loader->priv->converter = NULL;
|
||||||
loader->priv->error = NULL;
|
loader->priv->error = NULL;
|
||||||
|
loader->priv->enc_settings = g_settings_new ("org.x.editor.preferences.encodings");
|
||||||
}
|
}
|
||||||
|
|
||||||
XedDocumentLoader *
|
XedDocumentLoader *
|
||||||
|
@ -585,9 +590,12 @@ static GSList *
|
||||||
get_candidate_encodings (XedDocumentLoader *loader)
|
get_candidate_encodings (XedDocumentLoader *loader)
|
||||||
{
|
{
|
||||||
const XedEncoding *metadata;
|
const XedEncoding *metadata;
|
||||||
GSList *encodings = NULL;
|
GSList *encodings;
|
||||||
|
gchar **enc_strv;
|
||||||
|
|
||||||
encodings = xed_prefs_manager_get_auto_detected_encodings ();
|
enc_strv = g_settings_get_strv (loader->priv->enc_settings, XED_SETTINGS_ENCODING_AUTO_DETECTED);
|
||||||
|
encodings = _xed_encoding_strv_to_list ((const gchar * const *)enc_strv);
|
||||||
|
g_free (enc_strv);
|
||||||
|
|
||||||
metadata = get_metadata_encoding (loader);
|
metadata = get_metadata_encoding (loader);
|
||||||
if (metadata != NULL)
|
if (metadata != NULL)
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
#include "xed-document-saver.h"
|
#include "xed-document-saver.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-document-input-stream.h"
|
#include "xed-document-input-stream.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-marshal.h"
|
#include "xed-marshal.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define WRITE_CHUNK_SIZE 8192
|
#define WRITE_CHUNK_SIZE 8192
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@ static void check_modified_async (AsyncData *async);
|
||||||
|
|
||||||
struct _XedDocumentSaverPrivate
|
struct _XedDocumentSaverPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *editor_settings;
|
||||||
|
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
XedDocument *document;
|
XedDocument *document;
|
||||||
gboolean used;
|
gboolean used;
|
||||||
|
@ -219,6 +221,8 @@ xed_document_saver_dispose (GObject *object)
|
||||||
priv->location = NULL;
|
priv->location = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&priv->editor_settings);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_document_saver_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_document_saver_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,17 +318,16 @@ xed_document_saver_class_init (XedDocumentSaverClass *klass)
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
signals[SAVING] =
|
signals[SAVING] = g_signal_new ("saving",
|
||||||
g_signal_new ("saving",
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
G_SIGNAL_RUN_LAST,
|
||||||
G_SIGNAL_RUN_LAST,
|
G_STRUCT_OFFSET (XedDocumentSaverClass, saving),
|
||||||
G_STRUCT_OFFSET (XedDocumentSaverClass, saving),
|
NULL, NULL,
|
||||||
NULL, NULL,
|
xed_marshal_VOID__BOOLEAN_POINTER,
|
||||||
xed_marshal_VOID__BOOLEAN_POINTER,
|
G_TYPE_NONE,
|
||||||
G_TYPE_NONE,
|
2,
|
||||||
2,
|
G_TYPE_BOOLEAN,
|
||||||
G_TYPE_BOOLEAN,
|
G_TYPE_POINTER);
|
||||||
G_TYPE_POINTER);
|
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedDocumentSaverPrivate));
|
g_type_class_add_private (object_class, sizeof (XedDocumentSaverPrivate));
|
||||||
}
|
}
|
||||||
|
@ -337,6 +340,7 @@ xed_document_saver_init (XedDocumentSaver *saver)
|
||||||
saver->priv->cancellable = g_cancellable_new ();
|
saver->priv->cancellable = g_cancellable_new ();
|
||||||
saver->priv->error = NULL;
|
saver->priv->error = NULL;
|
||||||
saver->priv->used = FALSE;
|
saver->priv->used = FALSE;
|
||||||
|
saver->priv->editor_settings = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
XedDocumentSaver *
|
XedDocumentSaver *
|
||||||
|
@ -940,7 +944,8 @@ xed_document_saver_save (XedDocumentSaver *saver,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
saver->priv->keep_backup = xed_prefs_manager_get_create_backup_copy ();
|
saver->priv->keep_backup = g_settings_get_boolean (saver->priv->editor_settings,
|
||||||
|
XED_SETTINGS_CREATE_BACKUP_COPY);
|
||||||
}
|
}
|
||||||
|
|
||||||
saver->priv->old_mtime = *old_mtime;
|
saver->priv->old_mtime = *old_mtime;
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
#include "xed-prefs-manager-app.h"
|
#include "xed-settings.h"
|
||||||
#include "xed-document.h"
|
#include "xed-document.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
|
@ -102,7 +102,10 @@ static void delete_range_cb (XedDocument *doc,
|
||||||
|
|
||||||
struct _XedDocumentPrivate
|
struct _XedDocumentPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *editor_settings;
|
||||||
|
|
||||||
GFile *location;
|
GFile *location;
|
||||||
|
|
||||||
gint untitled_number;
|
gint untitled_number;
|
||||||
gchar *short_name;
|
gchar *short_name;
|
||||||
|
|
||||||
|
@ -284,6 +287,8 @@ xed_document_dispose (GObject *object)
|
||||||
doc->priv->loader = NULL;
|
doc->priv->loader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&doc->priv->editor_settings);
|
||||||
|
|
||||||
if (doc->priv->metadata_info != NULL)
|
if (doc->priv->metadata_info != NULL)
|
||||||
{
|
{
|
||||||
g_object_unref (doc->priv->metadata_info);
|
g_object_unref (doc->priv->metadata_info);
|
||||||
|
@ -676,8 +681,11 @@ set_language (XedDocument *doc,
|
||||||
|
|
||||||
if (lang != NULL)
|
if (lang != NULL)
|
||||||
{
|
{
|
||||||
gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (doc),
|
gboolean syntax_hl;
|
||||||
xed_prefs_manager_get_enable_syntax_highlighting ());
|
|
||||||
|
syntax_hl = g_settings_get_boolean (doc->priv->editor_settings,
|
||||||
|
XED_SETTINGS_SYNTAX_HIGHLIGHTING);
|
||||||
|
gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (doc), syntax_hl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -723,16 +731,15 @@ set_encoding (XedDocument *doc,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkSourceStyleScheme *
|
static GtkSourceStyleScheme *
|
||||||
get_default_style_scheme (void)
|
get_default_style_scheme (GSettings *editor_settings)
|
||||||
{
|
{
|
||||||
gchar *scheme_id;
|
gchar *scheme_id;
|
||||||
GtkSourceStyleScheme *def_style;
|
GtkSourceStyleScheme *def_style;
|
||||||
GtkSourceStyleSchemeManager *manager;
|
GtkSourceStyleSchemeManager *manager;
|
||||||
|
|
||||||
manager = xed_get_style_scheme_manager ();
|
manager = xed_get_style_scheme_manager ();
|
||||||
scheme_id = xed_prefs_manager_get_source_style_scheme ();
|
scheme_id = g_settings_get_string (editor_settings, XED_SETTINGS_SCHEME);
|
||||||
def_style = gtk_source_style_scheme_manager_get_scheme (manager,
|
def_style = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
|
||||||
scheme_id);
|
|
||||||
|
|
||||||
if (def_style == NULL)
|
if (def_style == NULL)
|
||||||
{
|
{
|
||||||
|
@ -874,11 +881,16 @@ static void
|
||||||
xed_document_init (XedDocument *doc)
|
xed_document_init (XedDocument *doc)
|
||||||
{
|
{
|
||||||
GtkSourceStyleScheme *style_scheme;
|
GtkSourceStyleScheme *style_scheme;
|
||||||
|
gint undo_actions;
|
||||||
|
gboolean bracket_matching;
|
||||||
|
gboolean search_hl;
|
||||||
|
|
||||||
xed_debug (DEBUG_DOCUMENT);
|
xed_debug (DEBUG_DOCUMENT);
|
||||||
|
|
||||||
doc->priv = XED_DOCUMENT_GET_PRIVATE (doc);
|
doc->priv = XED_DOCUMENT_GET_PRIVATE (doc);
|
||||||
|
|
||||||
|
doc->priv->editor_settings = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
|
|
||||||
doc->priv->location = NULL;
|
doc->priv->location = NULL;
|
||||||
doc->priv->untitled_number = get_untitled_number ();
|
doc->priv->untitled_number = get_untitled_number ();
|
||||||
|
|
||||||
|
@ -904,12 +916,15 @@ xed_document_init (XedDocument *doc)
|
||||||
|
|
||||||
doc->priv->newline_type = XED_DOCUMENT_NEWLINE_TYPE_DEFAULT;
|
doc->priv->newline_type = XED_DOCUMENT_NEWLINE_TYPE_DEFAULT;
|
||||||
|
|
||||||
gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (doc), xed_prefs_manager_get_undo_actions_limit ());
|
undo_actions = g_settings_get_int (doc->priv->editor_settings, XED_SETTINGS_MAX_UNDO_ACTIONS);
|
||||||
gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (doc),
|
bracket_matching = g_settings_get_boolean (doc->priv->editor_settings, XED_SETTINGS_BRACKET_MATCHING);
|
||||||
xed_prefs_manager_get_bracket_matching ());
|
search_hl = g_settings_get_boolean (doc->priv->editor_settings, XED_SETTINGS_SEARCH_HIGHLIGHTING);
|
||||||
xed_document_set_enable_search_highlighting (doc, xed_prefs_manager_get_enable_search_highlighting ());
|
|
||||||
|
|
||||||
style_scheme = get_default_style_scheme ();
|
gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (doc), undo_actions);
|
||||||
|
gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (doc), bracket_matching);
|
||||||
|
xed_document_set_enable_search_highlighting (doc, search_hl);
|
||||||
|
|
||||||
|
style_scheme = get_default_style_scheme (doc->priv->editor_settings);
|
||||||
if (style_scheme != NULL)
|
if (style_scheme != NULL)
|
||||||
{
|
{
|
||||||
gtk_source_buffer_set_style_scheme (GTK_SOURCE_BUFFER (doc), style_scheme);
|
gtk_source_buffer_set_style_scheme (GTK_SOURCE_BUFFER (doc), style_scheme);
|
||||||
|
@ -1275,6 +1290,7 @@ document_loader_loaded (XedDocumentLoader *loader,
|
||||||
{
|
{
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
|
gboolean restore_cursor;
|
||||||
const gchar *content_type = NULL;
|
const gchar *content_type = NULL;
|
||||||
gboolean read_only = FALSE;
|
gboolean read_only = FALSE;
|
||||||
GTimeVal mtime = {0, 0};
|
GTimeVal mtime = {0, 0};
|
||||||
|
@ -1309,6 +1325,8 @@ document_loader_loaded (XedDocumentLoader *loader,
|
||||||
|
|
||||||
xed_document_set_newline_type (doc, xed_document_loader_get_newline_type (loader));
|
xed_document_set_newline_type (doc, xed_document_loader_get_newline_type (loader));
|
||||||
|
|
||||||
|
restore_cursor = g_settings_get_boolean (doc->priv->editor_settings, XED_SETTINGS_RESTORE_CURSOR_POSITION);
|
||||||
|
|
||||||
/* move the cursor at the requested line if any */
|
/* move the cursor at the requested line if any */
|
||||||
if (doc->priv->requested_line_pos > 0)
|
if (doc->priv->requested_line_pos > 0)
|
||||||
{
|
{
|
||||||
|
@ -1318,7 +1336,7 @@ document_loader_loaded (XedDocumentLoader *loader,
|
||||||
doc->priv->requested_line_pos - 1);
|
doc->priv->requested_line_pos - 1);
|
||||||
}
|
}
|
||||||
/* else, if enabled, to the position stored in the metadata */
|
/* else, if enabled, to the position stored in the metadata */
|
||||||
else if (xed_prefs_manager_get_restore_cursor_position ())
|
else if (restore_cursor)
|
||||||
{
|
{
|
||||||
gchar *pos;
|
gchar *pos;
|
||||||
gint offset;
|
gint offset;
|
||||||
|
|
|
@ -37,8 +37,9 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <xed/xed-encodings-combo-box.h>
|
#include <xed/xed-encodings-combo-box.h>
|
||||||
#include <xed/xed-prefs-manager.h>
|
|
||||||
#include <xed/dialogs/xed-encodings-dialog.h>
|
#include <xed/dialogs/xed-encodings-dialog.h>
|
||||||
|
#include "xed-settings.h"
|
||||||
|
#include "xed-utils.h"
|
||||||
|
|
||||||
#define ENCODING_KEY "Enconding"
|
#define ENCODING_KEY "Enconding"
|
||||||
|
|
||||||
|
@ -48,6 +49,8 @@
|
||||||
|
|
||||||
struct _XedEncodingsComboBoxPrivate
|
struct _XedEncodingsComboBoxPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *enc_settings;
|
||||||
|
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
glong changed_id;
|
glong changed_id;
|
||||||
|
|
||||||
|
@ -248,6 +251,7 @@ update_menu (XedEncodingsComboBox *menu)
|
||||||
gchar *str;
|
gchar *str;
|
||||||
const XedEncoding *utf8_encoding;
|
const XedEncoding *utf8_encoding;
|
||||||
const XedEncoding *current_encoding;
|
const XedEncoding *current_encoding;
|
||||||
|
gchar **enc_strv;
|
||||||
|
|
||||||
store = menu->priv->store;
|
store = menu->priv->store;
|
||||||
|
|
||||||
|
@ -308,7 +312,9 @@ update_menu (XedEncodingsComboBox *menu)
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
encodings = xed_prefs_manager_get_shown_in_menu_encodings ();
|
enc_strv = g_settings_get_strv (menu->priv->enc_settings, XED_SETTINGS_ENCODING_SHOWN_IN_MENU);
|
||||||
|
encodings = _xed_encoding_strv_to_list ((const gchar * const *)enc_strv);
|
||||||
|
g_strfreev (enc_strv);
|
||||||
|
|
||||||
for (l = encodings; l != NULL; l = g_slist_next (l))
|
for (l = encodings; l != NULL; l = g_slist_next (l))
|
||||||
{
|
{
|
||||||
|
@ -331,23 +337,20 @@ update_menu (XedEncodingsComboBox *menu)
|
||||||
|
|
||||||
g_slist_free (encodings);
|
g_slist_free (encodings);
|
||||||
|
|
||||||
if (xed_prefs_manager_shown_in_menu_encodings_can_set ())
|
gtk_list_store_append (store, &iter);
|
||||||
{
|
/* Separator */
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_set (store, &iter,
|
||||||
/* separator */
|
NAME_COLUMN, "",
|
||||||
gtk_list_store_set (store, &iter,
|
ENCODING_COLUMN, NULL,
|
||||||
NAME_COLUMN, "",
|
ADD_COLUMN, FALSE,
|
||||||
ENCODING_COLUMN, NULL,
|
-1);
|
||||||
ADD_COLUMN, FALSE,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_append (store, &iter);
|
||||||
gtk_list_store_set (store, &iter,
|
gtk_list_store_set (store, &iter,
|
||||||
NAME_COLUMN, _("Add or Remove..."),
|
NAME_COLUMN, _("Add or Remove..."),
|
||||||
ENCODING_COLUMN, NULL,
|
ENCODING_COLUMN, NULL,
|
||||||
ADD_COLUMN, TRUE,
|
ADD_COLUMN, TRUE,
|
||||||
-1);
|
-1);
|
||||||
}
|
|
||||||
|
|
||||||
/* set the model back */
|
/* set the model back */
|
||||||
gtk_combo_box_set_model (GTK_COMBO_BOX (menu), GTK_TREE_MODEL (menu->priv->store));
|
gtk_combo_box_set_model (GTK_COMBO_BOX (menu), GTK_TREE_MODEL (menu->priv->store));
|
||||||
|
@ -363,6 +366,7 @@ xed_encodings_combo_box_init (XedEncodingsComboBox *menu)
|
||||||
|
|
||||||
menu->priv = XED_ENCODINGS_COMBO_BOX_GET_PRIVATE (menu);
|
menu->priv = XED_ENCODINGS_COMBO_BOX_GET_PRIVATE (menu);
|
||||||
|
|
||||||
|
menu->priv->enc_settings = g_settings_new ("org.x.editor.preferences.encodings");
|
||||||
menu->priv->store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
menu->priv->store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
/* Setup up the cells */
|
/* Setup up the cells */
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* xed-encodings.c
|
* xed-encodings.c
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002-2005 Paolo Maggi
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -46,8 +46,8 @@ struct _XedEncoding
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The original versions of the following tables are taken from profterm
|
* The original versions of the following tables are taken from profterm
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Red Hat, Inc.
|
* Copyright (C) 2002 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
@ -108,7 +108,7 @@ typedef enum
|
||||||
XED_ENCODING_KOI8_R,
|
XED_ENCODING_KOI8_R,
|
||||||
XED_ENCODING_KOI8__R,
|
XED_ENCODING_KOI8__R,
|
||||||
XED_ENCODING_KOI8_U,
|
XED_ENCODING_KOI8_U,
|
||||||
|
|
||||||
XED_ENCODING_SHIFT_JIS,
|
XED_ENCODING_SHIFT_JIS,
|
||||||
XED_ENCODING_TCVN,
|
XED_ENCODING_TCVN,
|
||||||
XED_ENCODING_TIS_620,
|
XED_ENCODING_TIS_620,
|
||||||
|
@ -129,7 +129,7 @@ typedef enum
|
||||||
|
|
||||||
XED_ENCODING_UTF_8,
|
XED_ENCODING_UTF_8,
|
||||||
XED_ENCODING_UNKNOWN
|
XED_ENCODING_UNKNOWN
|
||||||
|
|
||||||
} XedEncodingIndex;
|
} XedEncodingIndex;
|
||||||
|
|
||||||
static const XedEncoding utf8_encoding = {
|
static const XedEncoding utf8_encoding = {
|
||||||
|
@ -141,8 +141,8 @@ static const XedEncoding utf8_encoding = {
|
||||||
/* initialized in xed_encoding_lazy_init() */
|
/* initialized in xed_encoding_lazy_init() */
|
||||||
static XedEncoding unknown_encoding = {
|
static XedEncoding unknown_encoding = {
|
||||||
XED_ENCODING_UNKNOWN,
|
XED_ENCODING_UNKNOWN,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const XedEncoding encodings [] = {
|
static const XedEncoding encodings [] = {
|
||||||
|
@ -248,7 +248,7 @@ static const XedEncoding encodings [] = {
|
||||||
"KOI8-R", N_("Cyrillic") },
|
"KOI8-R", N_("Cyrillic") },
|
||||||
{ XED_ENCODING_KOI8_U,
|
{ XED_ENCODING_KOI8_U,
|
||||||
"KOI8U", N_("Cyrillic/Ukrainian") },
|
"KOI8U", N_("Cyrillic/Ukrainian") },
|
||||||
|
|
||||||
{ XED_ENCODING_SHIFT_JIS,
|
{ XED_ENCODING_SHIFT_JIS,
|
||||||
"SHIFT_JIS", N_("Japanese") },
|
"SHIFT_JIS", N_("Japanese") },
|
||||||
{ XED_ENCODING_TCVN,
|
{ XED_ENCODING_TCVN,
|
||||||
|
@ -312,12 +312,12 @@ xed_encoding_get_from_charset (const gchar *charset)
|
||||||
if (g_ascii_strcasecmp (charset, "UTF-8") == 0)
|
if (g_ascii_strcasecmp (charset, "UTF-8") == 0)
|
||||||
return xed_encoding_get_utf8 ();
|
return xed_encoding_get_utf8 ();
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < XED_ENCODING_LAST)
|
while (i < XED_ENCODING_LAST)
|
||||||
{
|
{
|
||||||
if (g_ascii_strcasecmp (charset, encodings[i].charset) == 0)
|
if (g_ascii_strcasecmp (charset, encodings[i].charset) == 0)
|
||||||
return &encodings[i];
|
return &encodings[i];
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,17 +364,17 @@ xed_encoding_get_current (void)
|
||||||
if (initialized != FALSE)
|
if (initialized != FALSE)
|
||||||
return locale_encoding;
|
return locale_encoding;
|
||||||
|
|
||||||
if (g_get_charset (&locale_charset) == FALSE)
|
if (g_get_charset (&locale_charset) == FALSE)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (locale_charset != NULL, &utf8_encoding);
|
g_return_val_if_fail (locale_charset != NULL, &utf8_encoding);
|
||||||
|
|
||||||
locale_encoding = xed_encoding_get_from_charset (locale_charset);
|
locale_encoding = xed_encoding_get_from_charset (locale_charset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
locale_encoding = &utf8_encoding;
|
locale_encoding = &utf8_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locale_encoding == NULL)
|
if (locale_encoding == NULL)
|
||||||
{
|
{
|
||||||
locale_encoding = &unknown_encoding;
|
locale_encoding = &unknown_encoding;
|
||||||
|
@ -391,7 +391,7 @@ gchar *
|
||||||
xed_encoding_to_string (const XedEncoding* enc)
|
xed_encoding_to_string (const XedEncoding* enc)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (enc != NULL, NULL);
|
g_return_val_if_fail (enc != NULL, NULL);
|
||||||
|
|
||||||
xed_encoding_lazy_init ();
|
xed_encoding_lazy_init ();
|
||||||
|
|
||||||
g_return_val_if_fail (enc->charset != NULL, NULL);
|
g_return_val_if_fail (enc->charset != NULL, NULL);
|
||||||
|
@ -443,7 +443,7 @@ xed_encoding_copy (const XedEncoding *enc)
|
||||||
return (XedEncoding *) enc;
|
return (XedEncoding *) enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_encoding_free (XedEncoding *enc)
|
xed_encoding_free (XedEncoding *enc)
|
||||||
{
|
{
|
||||||
g_return_if_fail (enc != NULL);
|
g_return_if_fail (enc != NULL);
|
||||||
|
@ -451,13 +451,13 @@ xed_encoding_free (XedEncoding *enc)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xed_encoding_get_type:
|
* xed_encoding_get_type:
|
||||||
*
|
*
|
||||||
* Retrieves the GType object which is associated with the
|
* Retrieves the GType object which is associated with the
|
||||||
* #XedEncoding class.
|
* #XedEncoding class.
|
||||||
*
|
*
|
||||||
* Return value: the GType associated with #XedEncoding.
|
* Return value: the GType associated with #XedEncoding.
|
||||||
**/
|
**/
|
||||||
GType
|
GType
|
||||||
xed_encoding_get_type (void)
|
xed_encoding_get_type (void)
|
||||||
{
|
{
|
||||||
static GType our_type = 0;
|
static GType our_type = 0;
|
||||||
|
@ -469,5 +469,77 @@ xed_encoding_get_type (void)
|
||||||
(GBoxedFreeFunc) xed_encoding_free);
|
(GBoxedFreeFunc) xed_encoding_free);
|
||||||
|
|
||||||
return our_type;
|
return our_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
data_exists (GSList *list,
|
||||||
|
const gpointer data)
|
||||||
|
{
|
||||||
|
while (list != NULL)
|
||||||
|
{
|
||||||
|
if (list->data == data)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
list = g_slist_next (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
_xed_encoding_strv_to_list (const gchar * const *enc_str)
|
||||||
|
{
|
||||||
|
GSList *res = NULL;
|
||||||
|
gchar **p;
|
||||||
|
const XedEncoding *enc;
|
||||||
|
|
||||||
|
for (p = (gchar **)enc_str; p != NULL && *p != NULL; p++)
|
||||||
|
{
|
||||||
|
const gchar *charset = *p;
|
||||||
|
|
||||||
|
if (strcmp (charset, "CURRENT") == 0)
|
||||||
|
{
|
||||||
|
g_get_charset (&charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_return_val_if_fail (charset != NULL, NULL);
|
||||||
|
enc = xed_encoding_get_from_charset (charset);
|
||||||
|
|
||||||
|
if (enc != NULL)
|
||||||
|
{
|
||||||
|
if (!data_exists (res, (gpointer)enc))
|
||||||
|
{
|
||||||
|
res = g_slist_prepend (res, (gpointer)enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_slist_reverse (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar **
|
||||||
|
_xed_encoding_list_to_strv (const GSList *enc_list)
|
||||||
|
{
|
||||||
|
GSList *l;
|
||||||
|
GPtrArray *array;
|
||||||
|
|
||||||
|
array = g_ptr_array_sized_new (g_slist_length ((GSList *)enc_list) + 1);
|
||||||
|
|
||||||
|
for (l = (GSList *)enc_list; l != NULL; l = g_slist_next (l))
|
||||||
|
{
|
||||||
|
const XedEncoding *enc;
|
||||||
|
const gchar *charset;
|
||||||
|
|
||||||
|
enc = (const XedEncoding *)l->data;
|
||||||
|
|
||||||
|
charset = xed_encoding_get_charset (enc);
|
||||||
|
g_return_val_if_fail (charset != NULL, NULL);
|
||||||
|
|
||||||
|
g_ptr_array_add (array, g_strdup (charset));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ptr_array_add (array, NULL);
|
||||||
|
|
||||||
|
return (gchar **)g_ptr_array_free (array, FALSE);
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* xed-encodings.h
|
* xed-encodings.h
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002-2005 Paolo Maggi
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -57,6 +57,9 @@ const XedEncoding *xed_encoding_get_current (void);
|
||||||
XedEncoding *xed_encoding_copy (const XedEncoding *enc);
|
XedEncoding *xed_encoding_copy (const XedEncoding *enc);
|
||||||
void xed_encoding_free (XedEncoding *enc);
|
void xed_encoding_free (XedEncoding *enc);
|
||||||
|
|
||||||
|
GSList *_xed_encoding_strv_to_list (const gchar * const *enc_str);
|
||||||
|
gchar **_xed_encoding_list_to_strv (const GSList *enc);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __XED_ENCODINGS_H__ */
|
#endif /* __XED_ENCODINGS_H__ */
|
||||||
|
|
|
@ -44,9 +44,9 @@
|
||||||
#include "xed-file-chooser-dialog.h"
|
#include "xed-file-chooser-dialog.h"
|
||||||
#include "xed-encodings-combo-box.h"
|
#include "xed-encodings-combo-box.h"
|
||||||
#include "xed-language-manager.h"
|
#include "xed-language-manager.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define XED_FILE_CHOOSER_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_FILE_CHOOSER_DIALOG, XedFileChooserDialogPrivate))
|
#define XED_FILE_CHOOSER_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_FILE_CHOOSER_DIALOG, XedFileChooserDialogPrivate))
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@
|
||||||
|
|
||||||
struct _XedFileChooserDialogPrivate
|
struct _XedFileChooserDialogPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *filter_settings;
|
||||||
|
|
||||||
GtkWidget *option_menu;
|
GtkWidget *option_menu;
|
||||||
GtkWidget *extra_widget;
|
GtkWidget *extra_widget;
|
||||||
|
|
||||||
|
@ -65,11 +67,23 @@ struct _XedFileChooserDialogPrivate
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedFileChooserDialog, xed_file_chooser_dialog, GTK_TYPE_FILE_CHOOSER_DIALOG)
|
G_DEFINE_TYPE(XedFileChooserDialog, xed_file_chooser_dialog, GTK_TYPE_FILE_CHOOSER_DIALOG)
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_file_chooser_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedFileChooserDialog *dialog = XED_FILE_CHOOSER_DIALOG (object);
|
||||||
|
|
||||||
|
g_clear_object (&dialog->priv->filter_settings);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_file_chooser_dialog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_file_chooser_dialog_class_init (XedFileChooserDialogClass *klass)
|
xed_file_chooser_dialog_class_init (XedFileChooserDialogClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = xed_file_chooser_dialog_dispose;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof(XedFileChooserDialogPrivate));
|
g_type_class_add_private (object_class, sizeof(XedFileChooserDialogPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,11 +223,6 @@ filter_changed (XedFileChooserDialog *dialog,
|
||||||
{
|
{
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
|
|
||||||
if (!xed_prefs_manager_active_file_filter_can_set ())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
|
filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
|
||||||
if (filter != NULL)
|
if (filter != NULL)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +239,7 @@ filter_changed (XedFileChooserDialog *dialog,
|
||||||
|
|
||||||
xed_debug_message (DEBUG_COMMANDS, "Active filter: %s (%d)", name, id);
|
xed_debug_message (DEBUG_COMMANDS, "Active filter: %s (%d)", name, id);
|
||||||
|
|
||||||
xed_prefs_manager_set_active_file_filter (id);
|
g_settings_set_int (dialog->priv->filter_settings, XED_SETTINGS_ACTIVE_FILE_FILTER, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +332,8 @@ static void
|
||||||
xed_file_chooser_dialog_init (XedFileChooserDialog *dialog)
|
xed_file_chooser_dialog_init (XedFileChooserDialog *dialog)
|
||||||
{
|
{
|
||||||
dialog->priv = XED_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
|
dialog->priv = XED_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
|
||||||
|
|
||||||
|
dialog->priv->filter_settings = g_settings_new ("org.x.editor.state.file-filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
|
@ -359,7 +370,8 @@ xed_file_chooser_dialog_new_valist (const gchar *title,
|
||||||
XED_ENCODINGS_COMBO_BOX (XED_FILE_CHOOSER_DIALOG (result)->priv->option_menu), encoding);
|
XED_ENCODINGS_COMBO_BOX (XED_FILE_CHOOSER_DIALOG (result)->priv->option_menu), encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
active_filter = xed_prefs_manager_get_active_file_filter ();
|
active_filter = g_settings_get_int (XED_FILE_CHOOSER_DIALOG (result)->priv->filter_settings,
|
||||||
|
XED_SETTINGS_ACTIVE_FILE_FILTER);
|
||||||
xed_debug_message (DEBUG_COMMANDS, "Active filter: %d", active_filter);
|
xed_debug_message (DEBUG_COMMANDS, "Active filter: %d", active_filter);
|
||||||
|
|
||||||
/* Filters */
|
/* Filters */
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -38,12 +38,12 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include "xed-history-entry.h"
|
#include "xed-history-entry.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
PROP_0,
|
{
|
||||||
PROP_HISTORY_ID,
|
PROP_0,
|
||||||
PROP_HISTORY_LENGTH
|
PROP_HISTORY_ID,
|
||||||
|
PROP_HISTORY_LENGTH
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MIN_ITEM_LEN 3
|
#define MIN_ITEM_LEN 3
|
||||||
|
@ -51,494 +51,460 @@ enum {
|
||||||
#define XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT 10
|
#define XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT 10
|
||||||
|
|
||||||
#define XED_HISTORY_ENTRY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
#define XED_HISTORY_ENTRY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||||
XED_TYPE_HISTORY_ENTRY, \
|
XED_TYPE_HISTORY_ENTRY, \
|
||||||
XedHistoryEntryPrivate))
|
XedHistoryEntryPrivate))
|
||||||
|
|
||||||
struct _XedHistoryEntryPrivate
|
struct _XedHistoryEntryPrivate
|
||||||
{
|
{
|
||||||
gchar *history_id;
|
gchar *history_id;
|
||||||
guint history_length;
|
guint history_length;
|
||||||
|
GtkEntryCompletion *completion;
|
||||||
GtkEntryCompletion *completion;
|
GSettings *settings;
|
||||||
|
|
||||||
GSettings *settings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedHistoryEntry, xed_history_entry, GTK_TYPE_COMBO_BOX_TEXT)
|
G_DEFINE_TYPE(XedHistoryEntry, xed_history_entry, GTK_TYPE_COMBO_BOX_TEXT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_set_property (GObject *object,
|
xed_history_entry_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *spec)
|
GParamSpec *spec)
|
||||||
{
|
{
|
||||||
XedHistoryEntry *entry;
|
XedHistoryEntry *entry;
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (object));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (object));
|
||||||
|
|
||||||
entry = XED_HISTORY_ENTRY (object);
|
entry = XED_HISTORY_ENTRY (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id)
|
||||||
case PROP_HISTORY_ID:
|
{
|
||||||
entry->priv->history_id = g_value_dup_string (value);
|
case PROP_HISTORY_ID:
|
||||||
break;
|
entry->priv->history_id = g_value_dup_string (value);
|
||||||
case PROP_HISTORY_LENGTH:
|
break;
|
||||||
xed_history_entry_set_history_length (entry,
|
case PROP_HISTORY_LENGTH:
|
||||||
g_value_get_uint (value));
|
xed_history_entry_set_history_length (entry, g_value_get_uint (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_get_property (GObject *object,
|
xed_history_entry_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *spec)
|
GParamSpec *spec)
|
||||||
{
|
{
|
||||||
XedHistoryEntryPrivate *priv;
|
XedHistoryEntryPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (object));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (object));
|
||||||
|
|
||||||
priv = XED_HISTORY_ENTRY (object)->priv;
|
priv = XED_HISTORY_ENTRY (object)->priv;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id)
|
||||||
case PROP_HISTORY_ID:
|
{
|
||||||
g_value_set_string (value, priv->history_id);
|
case PROP_HISTORY_ID:
|
||||||
break;
|
g_value_set_string (value, priv->history_id);
|
||||||
case PROP_HISTORY_LENGTH:
|
break;
|
||||||
g_value_set_uint (value, priv->history_length);
|
case PROP_HISTORY_LENGTH:
|
||||||
break;
|
g_value_set_uint (value, priv->history_length);
|
||||||
default:
|
break;
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
default:
|
||||||
}
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_dispose (GObject *object)
|
xed_history_entry_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
xed_history_entry_set_enable_completion (XED_HISTORY_ENTRY (object),
|
XedHistoryEntryPrivate *priv;
|
||||||
FALSE);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_history_entry_parent_class)->dispose (object);
|
priv = XED_HISTORY_ENTRY (object)->priv;
|
||||||
|
xed_history_entry_set_enable_completion (XED_HISTORY_ENTRY (object), FALSE);
|
||||||
|
|
||||||
|
g_clear_object (&priv->settings);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_history_entry_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_finalize (GObject *object)
|
xed_history_entry_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
XedHistoryEntryPrivate *priv;
|
XedHistoryEntryPrivate *priv;
|
||||||
|
|
||||||
priv = XED_HISTORY_ENTRY (object)->priv;
|
priv = XED_HISTORY_ENTRY (object)->priv;
|
||||||
|
|
||||||
g_free (priv->history_id);
|
|
||||||
|
|
||||||
if (priv->settings != NULL)
|
g_free (priv->history_id);
|
||||||
{
|
|
||||||
g_object_unref (G_OBJECT (priv->settings));
|
|
||||||
priv->settings = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_history_entry_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xed_history_entry_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_class_init (XedHistoryEntryClass *klass)
|
xed_history_entry_class_init (XedHistoryEntryClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->set_property = xed_history_entry_set_property;
|
|
||||||
object_class->get_property = xed_history_entry_get_property;
|
|
||||||
object_class->finalize = xed_history_entry_finalize;
|
|
||||||
object_class->dispose = xed_history_entry_dispose;
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
|
||||||
PROP_HISTORY_ID,
|
|
||||||
g_param_spec_string ("history-id",
|
|
||||||
"History ID",
|
|
||||||
"History ID",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
object_class->set_property = xed_history_entry_set_property;
|
||||||
PROP_HISTORY_LENGTH,
|
object_class->get_property = xed_history_entry_get_property;
|
||||||
g_param_spec_uint ("history-length",
|
object_class->finalize = xed_history_entry_finalize;
|
||||||
"Max History Length",
|
object_class->dispose = xed_history_entry_dispose;
|
||||||
"Max History Length",
|
|
||||||
0,
|
|
||||||
G_MAXUINT,
|
|
||||||
XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
/* TODO: Add enable-completion property */
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_HISTORY_ID,
|
||||||
|
g_param_spec_string ("history-id",
|
||||||
|
"History ID",
|
||||||
|
"History ID",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof(XedHistoryEntryPrivate));
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_HISTORY_LENGTH,
|
||||||
|
g_param_spec_uint ("history-length",
|
||||||
|
"Max History Length",
|
||||||
|
"Max History Length",
|
||||||
|
0,
|
||||||
|
G_MAXUINT,
|
||||||
|
XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
/* TODO: Add enable-completion property */
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof(XedHistoryEntryPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkListStore *
|
static GtkListStore *
|
||||||
get_history_store (XedHistoryEntry *entry)
|
get_history_store (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
GtkTreeModel *store;
|
GtkTreeModel *store;
|
||||||
|
|
||||||
store = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
|
store = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
|
||||||
g_return_val_if_fail (GTK_IS_LIST_STORE (store), NULL);
|
g_return_val_if_fail (GTK_IS_LIST_STORE (store), NULL);
|
||||||
|
|
||||||
return (GtkListStore *) store;
|
return (GtkListStore *) store;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSList *
|
static gchar **
|
||||||
get_history_list (XedHistoryEntry *entry)
|
get_history_items (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gboolean valid;
|
GPtrArray *array;
|
||||||
GSList *list = NULL;
|
gboolean valid;
|
||||||
|
gint n_children;
|
||||||
|
gint text_column;
|
||||||
|
|
||||||
store = get_history_store (entry);
|
store = get_history_store (entry);
|
||||||
|
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (entry));
|
||||||
|
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
|
||||||
|
n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL);
|
||||||
|
array = g_ptr_array_sized_new (n_children + 1);
|
||||||
|
|
||||||
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store),
|
while (valid)
|
||||||
&iter);
|
{
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
while (valid)
|
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, text_column, &str, -1);
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (store),
|
g_ptr_array_add (array, str);
|
||||||
&iter,
|
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
|
||||||
0, &str,
|
}
|
||||||
-1);
|
|
||||||
|
|
||||||
list = g_slist_prepend (list, str);
|
g_ptr_array_add (array, NULL);
|
||||||
|
|
||||||
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store),
|
return (gchar **)g_ptr_array_free (array, FALSE);
|
||||||
&iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_slist_reverse (list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_save_history (XedHistoryEntry *entry)
|
xed_history_entry_save_history (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
GSList *settings_items;
|
gchar **items;
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
|
|
||||||
settings_items = get_history_list (entry);
|
items = get_history_items (entry);
|
||||||
|
|
||||||
xed_prefs_manager_set_gslist (entry->priv->settings,
|
g_settings_set_strv (entry->priv->settings, entry->priv->history_id, (const gchar * const *)items);
|
||||||
entry->priv->history_id,
|
|
||||||
settings_items);
|
|
||||||
|
|
||||||
g_slist_foreach (settings_items, (GFunc) g_free, NULL);
|
g_strfreev (items);
|
||||||
g_slist_free (settings_items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
remove_item (GtkListStore *store,
|
remove_item (XedHistoryEntry *entry,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkListStore *store;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gint text_column;
|
||||||
|
|
||||||
g_return_val_if_fail (text != NULL, FALSE);
|
g_return_val_if_fail (text != NULL, FALSE);
|
||||||
|
|
||||||
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
|
store = get_history_store (entry);
|
||||||
return FALSE;
|
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (entry));
|
||||||
|
|
||||||
do
|
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
|
||||||
{
|
{
|
||||||
gchar *item_text;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (store),
|
do
|
||||||
&iter,
|
{
|
||||||
0,
|
gchar *item_text;
|
||||||
&item_text,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
if (item_text != NULL &&
|
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, text_column, &item_text, -1);
|
||||||
strcmp (item_text, text) == 0)
|
|
||||||
{
|
|
||||||
gtk_list_store_remove (store, &iter);
|
|
||||||
g_free (item_text);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (item_text);
|
if (item_text != NULL && strcmp (item_text, text) == 0)
|
||||||
|
{
|
||||||
|
gtk_list_store_remove (store, &iter);
|
||||||
|
g_free (item_text);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
|
g_free (item_text);
|
||||||
|
|
||||||
return FALSE;
|
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clamp_list_store (GtkListStore *store,
|
clamp_list_store (GtkListStore *store,
|
||||||
guint max)
|
guint max)
|
||||||
{
|
{
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
/* -1 because TreePath counts from 0 */
|
/* -1 because TreePath counts from 0 */
|
||||||
path = gtk_tree_path_new_from_indices (max - 1, -1);
|
path = gtk_tree_path_new_from_indices (max - 1, -1);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
|
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (!gtk_list_store_remove (store, &iter))
|
if (!gtk_list_store_remove (store, &iter))
|
||||||
break;
|
{
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
insert_history_item (XedHistoryEntry *entry,
|
insert_history_item (XedHistoryEntry *entry,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gboolean prepend)
|
gboolean prepend)
|
||||||
{
|
{
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
if (g_utf8_strlen (text, -1) <= MIN_ITEM_LEN)
|
if (g_utf8_strlen (text, -1) <= MIN_ITEM_LEN)
|
||||||
return;
|
{
|
||||||
|
return;
|
||||||
store = get_history_store (entry);
|
}
|
||||||
|
|
||||||
/* remove the text from the store if it was already
|
store = get_history_store (entry);
|
||||||
* present. If it wasn't, clamp to max history - 1
|
|
||||||
* before inserting the new row, otherwise appending
|
|
||||||
* would not work */
|
|
||||||
|
|
||||||
if (!remove_item (store, text))
|
/* remove the text from the store if it was already
|
||||||
clamp_list_store (store,
|
* present. If it wasn't, clamp to max history - 1
|
||||||
entry->priv->history_length - 1);
|
* before inserting the new row, otherwise appending
|
||||||
|
* would not work */
|
||||||
|
|
||||||
if (prepend)
|
if (!remove_item (entry, text))
|
||||||
gtk_list_store_insert (store, &iter, 0);
|
{
|
||||||
else
|
clamp_list_store (store, entry->priv->history_length - 1);
|
||||||
gtk_list_store_append (store, &iter);
|
}
|
||||||
|
|
||||||
gtk_list_store_set (store,
|
if (prepend)
|
||||||
&iter,
|
{
|
||||||
0,
|
gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), text);
|
||||||
text,
|
}
|
||||||
-1);
|
else
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), text);
|
||||||
|
}
|
||||||
|
|
||||||
xed_history_entry_save_history (entry);
|
xed_history_entry_save_history (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_prepend_text (XedHistoryEntry *entry,
|
xed_history_entry_prepend_text (XedHistoryEntry *entry,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
g_return_if_fail (text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
|
|
||||||
insert_history_item (entry, text, TRUE);
|
insert_history_item (entry, text, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_append_text (XedHistoryEntry *entry,
|
xed_history_entry_append_text (XedHistoryEntry *entry,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
g_return_if_fail (text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
|
|
||||||
insert_history_item (entry, text, FALSE);
|
insert_history_item (entry, text, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_load_history (XedHistoryEntry *entry)
|
xed_history_entry_load_history (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
GSList *settings_items, *l;
|
gchar **items;
|
||||||
GtkListStore *store;
|
gsize i;
|
||||||
GtkTreeIter iter;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
|
|
||||||
store = get_history_store (entry);
|
items = g_settings_get_strv (entry->priv->settings, entry->priv->history_id);
|
||||||
|
i = 0;
|
||||||
|
|
||||||
settings_items = xed_prefs_manager_get_gslist (entry->priv->settings,
|
gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (entry));
|
||||||
entry->priv->history_id);
|
|
||||||
|
|
||||||
gtk_list_store_clear (store);
|
/* Now the default value is an empty string so we have to take care of it to not
|
||||||
|
add the empty string in the search list */
|
||||||
|
while (items[i] != NULL && *items[i] != '\0' && i < entry->priv->history_length)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), items[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
for (l = settings_items, i = 0;
|
g_strfreev (items);
|
||||||
l != NULL && i < entry->priv->history_length;
|
|
||||||
l = l->next, i++)
|
|
||||||
{
|
|
||||||
gtk_list_store_append (store, &iter);
|
|
||||||
gtk_list_store_set (store,
|
|
||||||
&iter,
|
|
||||||
0,
|
|
||||||
l->data,
|
|
||||||
-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_foreach (settings_items, (GFunc) g_free, NULL);
|
|
||||||
g_slist_free (settings_items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_clear (XedHistoryEntry *entry)
|
xed_history_entry_clear (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
GtkListStore *store;
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (entry));
|
||||||
|
|
||||||
store = get_history_store (entry);
|
xed_history_entry_save_history (entry);
|
||||||
gtk_list_store_clear (store);
|
|
||||||
|
|
||||||
xed_history_entry_save_history (entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_history_entry_init (XedHistoryEntry *entry)
|
xed_history_entry_init (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
XedHistoryEntryPrivate *priv;
|
XedHistoryEntryPrivate *priv;
|
||||||
|
|
||||||
priv = XED_HISTORY_ENTRY_GET_PRIVATE (entry);
|
priv = XED_HISTORY_ENTRY_GET_PRIVATE (entry);
|
||||||
entry->priv = priv;
|
entry->priv = priv;
|
||||||
|
|
||||||
priv->history_id = NULL;
|
priv->history_id = NULL;
|
||||||
priv->history_length = XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT;
|
priv->history_length = XED_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT;
|
||||||
|
|
||||||
priv->completion = NULL;
|
priv->completion = NULL;
|
||||||
|
|
||||||
priv->settings = g_settings_new (XED_SCHEMA);
|
priv->settings = g_settings_new ("org.x.editor.state.history-entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_set_history_length (XedHistoryEntry *entry,
|
xed_history_entry_set_history_length (XedHistoryEntry *entry,
|
||||||
guint history_length)
|
guint history_length)
|
||||||
{
|
{
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
g_return_if_fail (history_length > 0);
|
g_return_if_fail (history_length > 0);
|
||||||
|
|
||||||
entry->priv->history_length = history_length;
|
entry->priv->history_length = history_length;
|
||||||
|
|
||||||
/* TODO: update if we currently have more items than max */
|
/* TODO: update if we currently have more items than max */
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
xed_history_entry_get_history_length (XedHistoryEntry *entry)
|
xed_history_entry_get_history_length (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), 0);
|
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), 0);
|
||||||
|
|
||||||
return entry->priv->history_length;
|
return entry->priv->history_length;
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
xed_history_entry_get_history_id (XedHistoryEntry *entry)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), NULL);
|
|
||||||
|
|
||||||
return g_strdup (entry->priv->history_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_set_enable_completion (XedHistoryEntry *entry,
|
xed_history_entry_set_enable_completion (XedHistoryEntry *entry,
|
||||||
gboolean enable)
|
gboolean enable)
|
||||||
{
|
{
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
|
|
||||||
if (enable)
|
|
||||||
{
|
|
||||||
if (entry->priv->completion != NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
entry->priv->completion = gtk_entry_completion_new ();
|
|
||||||
gtk_entry_completion_set_model (entry->priv->completion,
|
|
||||||
GTK_TREE_MODEL (get_history_store (entry)));
|
|
||||||
|
|
||||||
/* Use model column 0 as the text column */
|
|
||||||
gtk_entry_completion_set_text_column (entry->priv->completion, 0);
|
|
||||||
|
|
||||||
gtk_entry_completion_set_minimum_key_length (entry->priv->completion,
|
if (enable)
|
||||||
MIN_ITEM_LEN);
|
{
|
||||||
|
if (entry->priv->completion != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_entry_completion_set_popup_completion (entry->priv->completion, FALSE);
|
entry->priv->completion = gtk_entry_completion_new ();
|
||||||
gtk_entry_completion_set_inline_completion (entry->priv->completion, TRUE);
|
gtk_entry_completion_set_model (entry->priv->completion, GTK_TREE_MODEL (get_history_store (entry)));
|
||||||
|
|
||||||
/* Assign the completion to the entry */
|
|
||||||
gtk_entry_set_completion (GTK_ENTRY (xed_history_entry_get_entry(entry)),
|
|
||||||
entry->priv->completion);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (entry->priv->completion == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gtk_entry_set_completion (GTK_ENTRY (xed_history_entry_get_entry (entry)),
|
/* Use model column 0 as the text column */
|
||||||
NULL);
|
gtk_entry_completion_set_text_column (entry->priv->completion, 0);
|
||||||
|
|
||||||
g_object_unref (entry->priv->completion);
|
gtk_entry_completion_set_minimum_key_length (entry->priv->completion, MIN_ITEM_LEN);
|
||||||
|
|
||||||
entry->priv->completion = NULL;
|
gtk_entry_completion_set_popup_completion (entry->priv->completion, FALSE);
|
||||||
}
|
gtk_entry_completion_set_inline_completion (entry->priv->completion, TRUE);
|
||||||
|
|
||||||
|
/* Assign the completion to the entry */
|
||||||
|
gtk_entry_set_completion (GTK_ENTRY (xed_history_entry_get_entry(entry)), entry->priv->completion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (entry->priv->completion == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_entry_set_completion (GTK_ENTRY (xed_history_entry_get_entry (entry)), NULL);
|
||||||
|
|
||||||
|
g_object_unref (entry->priv->completion);
|
||||||
|
|
||||||
|
entry->priv->completion = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xed_history_entry_get_enable_completion (XedHistoryEntry *entry)
|
xed_history_entry_get_enable_completion (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), FALSE);
|
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), FALSE);
|
||||||
|
|
||||||
return entry->priv->completion != NULL;
|
return entry->priv->completion != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
xed_history_entry_new (const gchar *history_id,
|
xed_history_entry_new (const gchar *history_id,
|
||||||
gboolean enable_completion)
|
gboolean enable_completion)
|
||||||
{
|
{
|
||||||
GtkWidget *ret;
|
GtkWidget *ret;
|
||||||
GtkListStore *store;
|
|
||||||
|
|
||||||
g_return_val_if_fail (history_id != NULL, NULL);
|
g_return_val_if_fail (history_id != NULL, NULL);
|
||||||
|
|
||||||
/* Note that we are setting the model, so
|
ret = g_object_new (XED_TYPE_HISTORY_ENTRY,
|
||||||
* user must be careful to always manipulate
|
"has-entry", TRUE,
|
||||||
* data in the history through xed_history_entry_
|
"entry-text-column", 0,
|
||||||
* functions.
|
"id-column", 1,
|
||||||
*/
|
"history-id", history_id,
|
||||||
|
NULL);
|
||||||
|
|
||||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
/* loading has to happen after the model
|
||||||
|
* has been set. However the model is not a
|
||||||
|
* G_PARAM_CONSTRUCT property of GtkComboBox
|
||||||
|
* so we cannot do this in the constructor.
|
||||||
|
* For now we simply do here since this widget is
|
||||||
|
* not bound to other programming languages.
|
||||||
|
* A maybe better alternative is to override the
|
||||||
|
* model property of combobox and mark CONTRUCT_ONLY.
|
||||||
|
* This would also ensure that the model cannot be
|
||||||
|
* set explicitely at a later time.
|
||||||
|
*/
|
||||||
|
xed_history_entry_load_history (XED_HISTORY_ENTRY (ret));
|
||||||
|
|
||||||
ret = g_object_new (XED_TYPE_HISTORY_ENTRY,
|
xed_history_entry_set_enable_completion (XED_HISTORY_ENTRY (ret), enable_completion);
|
||||||
"history-id", history_id,
|
|
||||||
"model", store,
|
|
||||||
"has-entry", TRUE,
|
|
||||||
"entry-text-column", 0,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_object_unref (store);
|
return ret;
|
||||||
|
|
||||||
/* loading has to happen after the model
|
|
||||||
* has been set. However the model is not a
|
|
||||||
* G_PARAM_CONSTRUCT property of GtkComboBox
|
|
||||||
* so we cannot do this in the constructor.
|
|
||||||
* For now we simply do here since this widget is
|
|
||||||
* not bound to other programming languages.
|
|
||||||
* A maybe better alternative is to override the
|
|
||||||
* model property of combobox and mark CONTRUCT_ONLY.
|
|
||||||
* This would also ensure that the model cannot be
|
|
||||||
* set explicitely at a later time.
|
|
||||||
*/
|
|
||||||
xed_history_entry_load_history (XED_HISTORY_ENTRY (ret));
|
|
||||||
|
|
||||||
xed_history_entry_set_enable_completion (XED_HISTORY_ENTRY (ret),
|
|
||||||
enable_completion);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility function to get the editable text entry internal widget.
|
* Utility function to get the editable text entry internal widget.
|
||||||
* I would prefer to not expose this implementation detail and
|
* I would prefer to not expose this implementation detail and
|
||||||
* simply make the XedHistoryEntry widget implement the
|
* simply make the XedHistoryEntry widget implement the
|
||||||
* GtkEditable interface. Unfortunately both GtkEditable and
|
* GtkEditable interface. Unfortunately both GtkEditable and
|
||||||
* GtkComboBox have a "changed" signal and I am not sure how to
|
* GtkComboBox have a "changed" signal and I am not sure how to
|
||||||
* handle the conflict.
|
* handle the conflict.
|
||||||
|
@ -546,54 +512,58 @@ xed_history_entry_new (const gchar *history_id,
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
xed_history_entry_get_entry (XedHistoryEntry *entry)
|
xed_history_entry_get_entry (XedHistoryEntry *entry)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), NULL);
|
g_return_val_if_fail (XED_IS_HISTORY_ENTRY (entry), NULL);
|
||||||
|
|
||||||
return gtk_bin_get_child (GTK_BIN (entry));
|
return gtk_bin_get_child (GTK_BIN (entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
escape_cell_data_func (GtkTreeViewColumn *col,
|
escape_cell_data_func (GtkTreeViewColumn *col,
|
||||||
GtkCellRenderer *renderer,
|
GtkCellRenderer *renderer,
|
||||||
GtkTreeModel *model,
|
GtkTreeModel *model,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
XedHistoryEntryEscapeFunc escape_func)
|
XedHistoryEntryEscapeFunc escape_func)
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gchar *escaped;
|
gchar *escaped;
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter, 0, &str, -1);
|
gtk_tree_model_get (model, iter, 0, &str, -1);
|
||||||
escaped = escape_func (str);
|
escaped = escape_func (str);
|
||||||
g_object_set (renderer, "text", escaped, NULL);
|
g_object_set (renderer, "text", escaped, NULL);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
g_free (escaped);
|
g_free (escaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_history_entry_set_escape_func (XedHistoryEntry *entry,
|
xed_history_entry_set_escape_func (XedHistoryEntry *entry,
|
||||||
XedHistoryEntryEscapeFunc escape_func)
|
XedHistoryEntryEscapeFunc escape_func)
|
||||||
{
|
{
|
||||||
GList *cells;
|
GList *cells;
|
||||||
|
|
||||||
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
g_return_if_fail (XED_IS_HISTORY_ENTRY (entry));
|
||||||
|
|
||||||
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (entry));
|
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (entry));
|
||||||
|
|
||||||
/* We only have one cell renderer */
|
/* We only have one cell renderer */
|
||||||
g_return_if_fail (cells->data != NULL && cells->next == NULL);
|
g_return_if_fail (cells->data != NULL && cells->next == NULL);
|
||||||
|
|
||||||
if (escape_func != NULL)
|
if (escape_func != NULL)
|
||||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
|
{
|
||||||
GTK_CELL_RENDERER (cells->data),
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
|
||||||
(GtkCellLayoutDataFunc) escape_cell_data_func,
|
GTK_CELL_RENDERER (cells->data),
|
||||||
escape_func,
|
(GtkCellLayoutDataFunc) escape_cell_data_func,
|
||||||
NULL);
|
escape_func,
|
||||||
else
|
NULL);
|
||||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
|
}
|
||||||
GTK_CELL_RENDERER (cells->data),
|
else
|
||||||
NULL,
|
{
|
||||||
NULL,
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
|
||||||
NULL);
|
GTK_CELL_RENDERER (cells->data),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
g_list_free (cells);
|
g_list_free (cells);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -48,48 +48,41 @@ typedef struct _XedHistoryEntryPrivate XedHistoryEntryPrivate;
|
||||||
|
|
||||||
struct _XedHistoryEntryClass
|
struct _XedHistoryEntryClass
|
||||||
{
|
{
|
||||||
GtkComboBoxTextClass parent_class;
|
GtkComboBoxTextClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _XedHistoryEntry
|
struct _XedHistoryEntry
|
||||||
{
|
{
|
||||||
GtkComboBoxText parent_instance;
|
GtkComboBoxText parent_instance;
|
||||||
|
|
||||||
XedHistoryEntryPrivate *priv;
|
XedHistoryEntryPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType xed_history_entry_get_type (void) G_GNUC_CONST;
|
GType xed_history_entry_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget *xed_history_entry_new (const gchar *history_id,
|
GtkWidget *xed_history_entry_new (const gchar *history_id,
|
||||||
gboolean enable_completion);
|
gboolean enable_completion);
|
||||||
|
|
||||||
void xed_history_entry_prepend_text (XedHistoryEntry *entry,
|
void xed_history_entry_prepend_text (XedHistoryEntry *entry,
|
||||||
const gchar *text);
|
const gchar *text);
|
||||||
|
void xed_history_entry_append_text (XedHistoryEntry *entry,
|
||||||
|
const gchar *text);
|
||||||
|
|
||||||
void xed_history_entry_append_text (XedHistoryEntry *entry,
|
void xed_history_entry_clear (XedHistoryEntry *entry);
|
||||||
const gchar *text);
|
|
||||||
|
|
||||||
void xed_history_entry_clear (XedHistoryEntry *entry);
|
void xed_history_entry_set_history_length (XedHistoryEntry *entry,
|
||||||
|
guint max_saved);
|
||||||
|
guint xed_history_entry_get_history_length (XedHistoryEntry *gentry);
|
||||||
|
|
||||||
void xed_history_entry_set_history_length (XedHistoryEntry *entry,
|
void xed_history_entry_set_enable_completion (XedHistoryEntry *entry,
|
||||||
guint max_saved);
|
gboolean enable);
|
||||||
|
gboolean xed_history_entry_get_enable_completion (XedHistoryEntry *entry);
|
||||||
|
|
||||||
guint xed_history_entry_get_history_length (XedHistoryEntry *gentry);
|
GtkWidget *xed_history_entry_get_entry (XedHistoryEntry *entry);
|
||||||
|
|
||||||
gchar *xed_history_entry_get_history_id (XedHistoryEntry *entry);
|
|
||||||
|
|
||||||
void xed_history_entry_set_enable_completion
|
|
||||||
(XedHistoryEntry *entry,
|
|
||||||
gboolean enable);
|
|
||||||
|
|
||||||
gboolean xed_history_entry_get_enable_completion
|
|
||||||
(XedHistoryEntry *entry);
|
|
||||||
|
|
||||||
GtkWidget *xed_history_entry_get_entry (XedHistoryEntry *entry);
|
|
||||||
|
|
||||||
typedef gchar * (* XedHistoryEntryEscapeFunc) (const gchar *str);
|
typedef gchar * (* XedHistoryEntryEscapeFunc) (const gchar *str);
|
||||||
void xed_history_entry_set_escape_func (XedHistoryEntry *entry,
|
void xed_history_entry_set_escape_func (XedHistoryEntry *entry,
|
||||||
XedHistoryEntryEscapeFunc escape_func);
|
XedHistoryEntryEscapeFunc escape_func);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,10 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "xed-settings.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-document.h"
|
#include "xed-document.h"
|
||||||
#include "xed-io-error-message-area.h"
|
#include "xed-io-error-message-area.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include <xed/xed-encodings-combo-box.h>
|
#include <xed/xed-encodings-combo-box.h>
|
||||||
|
|
||||||
#define MAX_URI_IN_DIALOG_LENGTH 50
|
#define MAX_URI_IN_DIALOG_LENGTH 50
|
||||||
|
@ -856,6 +856,8 @@ xed_no_backup_saving_error_message_area_new (GFile *location,
|
||||||
gchar *full_formatted_uri;
|
gchar *full_formatted_uri;
|
||||||
gchar *uri_for_display;
|
gchar *uri_for_display;
|
||||||
gchar *temp_uri_for_display;
|
gchar *temp_uri_for_display;
|
||||||
|
gboolean create_backup_copy;
|
||||||
|
GSettings *editor_settings;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
||||||
g_return_val_if_fail (error != NULL, NULL);
|
g_return_val_if_fail (error != NULL, NULL);
|
||||||
|
@ -893,9 +895,12 @@ xed_no_backup_saving_error_message_area_new (GFile *location,
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
||||||
|
|
||||||
// FIXME: review this messages
|
editor_settings = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
|
create_backup_copy = g_settings_get_boolean (editor_settings, XED_SETTINGS_CREATE_BACKUP_COPY);
|
||||||
|
g_object_unref (editor_settings);
|
||||||
|
|
||||||
if (xed_prefs_manager_get_create_backup_copy ())
|
// FIXME: review this messages
|
||||||
|
if (create_backup_copy)
|
||||||
{
|
{
|
||||||
primary_text = g_strdup_printf (_("Could not create a backup file while saving %s"), uri_for_display);
|
primary_text = g_strdup_printf (_("Could not create a backup file while saving %s"), uri_for_display);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* xed-languages-manager.c
|
* xed-languages-manager.c
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003-2006 - Paolo Maggi
|
* Copyright (C) 2003-2006 - Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,14 +17,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2003-2006. See the AUTHORS file for a
|
* Modified by the xed Team, 2003-2006. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,6 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
#include "xed-language-manager.h"
|
#include "xed-language-manager.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
|
|
||||||
|
|
|
@ -56,15 +56,16 @@
|
||||||
|
|
||||||
struct _XedNotebookPrivate
|
struct _XedNotebookPrivate
|
||||||
{
|
{
|
||||||
GList *focused_pages;
|
GSettings *ui_settings;
|
||||||
gulong motion_notify_handler_id;
|
GList *focused_pages;
|
||||||
gint x_start;
|
gulong motion_notify_handler_id;
|
||||||
gint y_start;
|
gint x_start;
|
||||||
gint drag_in_progress : 1;
|
gint y_start;
|
||||||
gint close_buttons_sensitive : 1;
|
gint drag_in_progress : 1;
|
||||||
gint tab_drag_and_drop_enabled : 1;
|
gint close_buttons_sensitive : 1;
|
||||||
gint tab_scrolling_enabled : 1;
|
gint tab_drag_and_drop_enabled : 1;
|
||||||
guint destroy_has_run : 1;
|
gint tab_scrolling_enabled : 1;
|
||||||
|
guint destroy_has_run : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedNotebook, xed_notebook, GTK_TYPE_NOTEBOOK)
|
G_DEFINE_TYPE(XedNotebook, xed_notebook, GTK_TYPE_NOTEBOOK)
|
||||||
|
@ -115,6 +116,8 @@ xed_notebook_dispose (GObject *object)
|
||||||
notebook->priv->destroy_has_run = TRUE;
|
notebook->priv->destroy_has_run = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (¬ebook->priv->ui_settings);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_notebook_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_notebook_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,7 +710,8 @@ xed_notebook_init (XedNotebook *notebook)
|
||||||
|
|
||||||
notebook->priv->close_buttons_sensitive = TRUE;
|
notebook->priv->close_buttons_sensitive = TRUE;
|
||||||
notebook->priv->tab_drag_and_drop_enabled = TRUE;
|
notebook->priv->tab_drag_and_drop_enabled = TRUE;
|
||||||
notebook->priv->tab_scrolling_enabled = TRUE;
|
notebook->priv->ui_settings = g_settings_new ("org.x.editor.preferences.ui");
|
||||||
|
notebook->priv->tab_scrolling_enabled = g_settings_get_boolean (notebook->priv->ui_settings, "enable-tab-scrolling");
|
||||||
|
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
||||||
// gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
// gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
||||||
|
|
|
@ -40,8 +40,9 @@
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-app.h"
|
#include "xed-app.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
#include "xed-utils.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (XedPluginsEngine, xed_plugins_engine, PEAS_TYPE_ENGINE)
|
G_DEFINE_TYPE (XedPluginsEngine, xed_plugins_engine, PEAS_TYPE_ENGINE)
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ xed_plugins_engine_init (XedPluginsEngine *engine)
|
||||||
|
|
||||||
engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, XED_TYPE_PLUGINS_ENGINE, XedPluginsEnginePrivate);
|
engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, XED_TYPE_PLUGINS_ENGINE, XedPluginsEnginePrivate);
|
||||||
|
|
||||||
engine->priv->plugin_settings = g_settings_new (XED_SCHEMA);
|
engine->priv->plugin_settings = g_settings_new ("org.x.editor.plugins");
|
||||||
|
|
||||||
peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
|
peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
|
||||||
|
|
||||||
|
@ -111,8 +112,11 @@ xed_plugins_engine_init (XedPluginsEngine *engine)
|
||||||
xed_dirs_get_xed_plugins_dir(),
|
xed_dirs_get_xed_plugins_dir(),
|
||||||
xed_dirs_get_xed_plugins_data_dir());
|
xed_dirs_get_xed_plugins_data_dir());
|
||||||
|
|
||||||
g_settings_bind (engine->priv->plugin_settings, GPM_ACTIVE_PLUGINS,
|
g_settings_bind (engine->priv->plugin_settings,
|
||||||
engine, "loaded-plugins", G_SETTINGS_BIND_DEFAULT);
|
XED_SETTINGS_ACTIVE_PLUGINS,
|
||||||
|
engine,
|
||||||
|
"loaded-plugins",
|
||||||
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
* xed-prefs-manager-app.h
|
|
||||||
* This file is part of xed
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002-2005 Paolo Maggi
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the xed Team, 2002-2005. See the AUTHORS file for a
|
|
||||||
* list of people on the xed Team.
|
|
||||||
* See the ChangeLog files for a list of changes.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XED_PREFS_MANAGER_APP_H__
|
|
||||||
#define __XED_PREFS_MANAGER_APP_H__
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <xed/xed-prefs-manager.h>
|
|
||||||
|
|
||||||
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/
|
|
||||||
|
|
||||||
gboolean xed_prefs_manager_app_init (void);
|
|
||||||
|
|
||||||
/* This function must be called before exiting xed */
|
|
||||||
void xed_prefs_manager_app_shutdown (void);
|
|
||||||
|
|
||||||
|
|
||||||
/* Window state */
|
|
||||||
gint xed_prefs_manager_get_window_state (void);
|
|
||||||
void xed_prefs_manager_set_window_state (gint ws);
|
|
||||||
gboolean xed_prefs_manager_window_state_can_set (void);
|
|
||||||
|
|
||||||
/* Window size */
|
|
||||||
void xed_prefs_manager_get_window_size (gint *width,
|
|
||||||
gint *height);
|
|
||||||
void xed_prefs_manager_get_default_window_size (gint *width,
|
|
||||||
gint *height);
|
|
||||||
void xed_prefs_manager_set_window_size (gint width,
|
|
||||||
gint height);
|
|
||||||
gboolean xed_prefs_manager_window_size_can_set (void);
|
|
||||||
|
|
||||||
/* Side panel */
|
|
||||||
gint xed_prefs_manager_get_side_panel_size (void);
|
|
||||||
gint xed_prefs_manager_get_default_side_panel_size(void);
|
|
||||||
void xed_prefs_manager_set_side_panel_size (gint ps);
|
|
||||||
gboolean xed_prefs_manager_side_panel_size_can_set (void);
|
|
||||||
gint xed_prefs_manager_get_side_panel_active_page (void);
|
|
||||||
void xed_prefs_manager_set_side_panel_active_page (gint id);
|
|
||||||
gboolean xed_prefs_manager_side_panel_active_page_can_set (void);
|
|
||||||
|
|
||||||
/* Bottom panel */
|
|
||||||
gint xed_prefs_manager_get_bottom_panel_size (void);
|
|
||||||
gint xed_prefs_manager_get_default_bottom_panel_size(void);
|
|
||||||
void xed_prefs_manager_set_bottom_panel_size (gint ps);
|
|
||||||
gboolean xed_prefs_manager_bottom_panel_size_can_set (void);
|
|
||||||
gint xed_prefs_manager_get_bottom_panel_active_page (void);
|
|
||||||
void xed_prefs_manager_set_bottom_panel_active_page (gint id);
|
|
||||||
gboolean xed_prefs_manager_bottom_panel_active_page_can_set (void);
|
|
||||||
|
|
||||||
/* File filter */
|
|
||||||
gint xed_prefs_manager_get_active_file_filter (void);
|
|
||||||
void xed_prefs_manager_set_active_file_filter (gint id);
|
|
||||||
gboolean xed_prefs_manager_active_file_filter_can_set (void);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __XED_PREFS_MANAGER_APP_H__ */
|
|
|
@ -1,849 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
||||||
/*
|
|
||||||
* xed-prefs-manager.c
|
|
||||||
* This file is part of xed
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 Paolo Maggi
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
|
||||||
* list of people on the xed Team.
|
|
||||||
* See the ChangeLog files for a list of changes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-prefs-manager-private.h"
|
|
||||||
#include "xed-debug.h"
|
|
||||||
#include "xed-encodings.h"
|
|
||||||
#include "xed-utils.h"
|
|
||||||
|
|
||||||
#define DEFINE_BOOL_PREF(name, key) gboolean \
|
|
||||||
xed_prefs_manager_get_ ## name (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_get_bool (key); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void \
|
|
||||||
xed_prefs_manager_set_ ## name (gboolean v) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
xed_prefs_manager_set_bool (key, \
|
|
||||||
v); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
gboolean \
|
|
||||||
xed_prefs_manager_ ## name ## _can_set (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_key_is_writable (key); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFINE_INT_PREF(name, key) gint \
|
|
||||||
xed_prefs_manager_get_ ## name (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_get_int (key); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void \
|
|
||||||
xed_prefs_manager_set_ ## name (gint v) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
xed_prefs_manager_set_int (key, \
|
|
||||||
v); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
gboolean \
|
|
||||||
xed_prefs_manager_ ## name ## _can_set (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_key_is_writable (key); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFINE_STRING_PREF(name, key) gchar* \
|
|
||||||
xed_prefs_manager_get_ ## name (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_get_string (key); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void \
|
|
||||||
xed_prefs_manager_set_ ## name (const gchar* v) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
xed_prefs_manager_set_string (key, \
|
|
||||||
v); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
gboolean \
|
|
||||||
xed_prefs_manager_ ## name ## _can_set (void) \
|
|
||||||
{ \
|
|
||||||
xed_debug (DEBUG_PREFS); \
|
|
||||||
\
|
|
||||||
return xed_prefs_manager_key_is_writable (key); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
XedPrefsManager *xed_prefs_manager = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
static GtkWrapMode get_wrap_mode_from_string (const gchar* str);
|
|
||||||
|
|
||||||
static gboolean xed_prefs_manager_get_bool (const gchar* key);
|
|
||||||
|
|
||||||
static gint xed_prefs_manager_get_int (const gchar* key);
|
|
||||||
|
|
||||||
static gchar *xed_prefs_manager_get_string (const gchar* key);
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_init (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
if (xed_prefs_manager == NULL)
|
|
||||||
{
|
|
||||||
xed_prefs_manager = g_new0 (XedPrefsManager, 1);
|
|
||||||
xed_prefs_manager->settings = g_settings_new (XED_SCHEMA);
|
|
||||||
xed_prefs_manager->interface_settings = g_settings_new (GPM_INTERFACE_SCHEMA);
|
|
||||||
}
|
|
||||||
|
|
||||||
return xed_prefs_manager != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_shutdown (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (xed_prefs_manager != NULL);
|
|
||||||
|
|
||||||
g_object_unref (xed_prefs_manager->settings);
|
|
||||||
xed_prefs_manager->settings = NULL;
|
|
||||||
g_object_unref (xed_prefs_manager->interface_settings);
|
|
||||||
xed_prefs_manager->interface_settings = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
xed_prefs_manager_get_bool (const gchar* key)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return g_settings_get_boolean (xed_prefs_manager->settings, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
|
||||||
xed_prefs_manager_get_int (const gchar* key)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return g_settings_get_int (xed_prefs_manager->settings, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
xed_prefs_manager_get_string (const gchar* key)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return g_settings_get_string (xed_prefs_manager->settings, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xed_prefs_manager_set_bool (const gchar* key, gboolean value)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (g_settings_is_writable (
|
|
||||||
xed_prefs_manager->settings, key));
|
|
||||||
|
|
||||||
g_settings_set_boolean (xed_prefs_manager->settings, key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xed_prefs_manager_set_int (const gchar* key, gint value)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (g_settings_is_writable (
|
|
||||||
xed_prefs_manager->settings, key));
|
|
||||||
|
|
||||||
g_settings_set_int (xed_prefs_manager->settings, key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xed_prefs_manager_set_string (const gchar* key, const gchar* value)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_if_fail (value != NULL);
|
|
||||||
|
|
||||||
g_return_if_fail (g_settings_is_writable (
|
|
||||||
xed_prefs_manager->settings, key));
|
|
||||||
|
|
||||||
g_settings_set_string (xed_prefs_manager->settings, key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
xed_prefs_manager_key_is_writable (const gchar* key)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_val_if_fail (xed_prefs_manager != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (xed_prefs_manager->settings != NULL, FALSE);
|
|
||||||
|
|
||||||
return g_settings_is_writable (xed_prefs_manager->settings, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use default font */
|
|
||||||
DEFINE_BOOL_PREF (use_default_font,
|
|
||||||
GPM_USE_DEFAULT_FONT)
|
|
||||||
|
|
||||||
/* Editor font */
|
|
||||||
DEFINE_STRING_PREF (editor_font,
|
|
||||||
GPM_EDITOR_FONT)
|
|
||||||
|
|
||||||
/* System font */
|
|
||||||
gchar *
|
|
||||||
xed_prefs_manager_get_system_font (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return g_settings_get_string (xed_prefs_manager->interface_settings,
|
|
||||||
GPM_SYSTEM_FONT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create backup copy */
|
|
||||||
DEFINE_BOOL_PREF (create_backup_copy,
|
|
||||||
GPM_CREATE_BACKUP_COPY)
|
|
||||||
|
|
||||||
/* Auto save */
|
|
||||||
DEFINE_BOOL_PREF (auto_save,
|
|
||||||
GPM_AUTO_SAVE)
|
|
||||||
|
|
||||||
/* Auto save interval */
|
|
||||||
DEFINE_INT_PREF (auto_save_interval,
|
|
||||||
GPM_AUTO_SAVE_INTERVAL)
|
|
||||||
|
|
||||||
|
|
||||||
/* Undo actions limit: if < 1 then no limits */
|
|
||||||
DEFINE_INT_PREF (undo_actions_limit,
|
|
||||||
GPM_UNDO_ACTIONS_LIMIT)
|
|
||||||
|
|
||||||
static GtkWrapMode
|
|
||||||
get_wrap_mode_from_string (const gchar* str)
|
|
||||||
{
|
|
||||||
GtkWrapMode res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (str != NULL, GTK_WRAP_WORD);
|
|
||||||
|
|
||||||
if (strcmp (str, "GTK_WRAP_NONE") == 0)
|
|
||||||
res = GTK_WRAP_NONE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (strcmp (str, "GTK_WRAP_CHAR") == 0)
|
|
||||||
res = GTK_WRAP_CHAR;
|
|
||||||
else
|
|
||||||
res = GTK_WRAP_WORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wrap mode */
|
|
||||||
GtkWrapMode
|
|
||||||
xed_prefs_manager_get_wrap_mode (void)
|
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
GtkWrapMode res;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
str = xed_prefs_manager_get_string (GPM_WRAP_MODE);
|
|
||||||
|
|
||||||
res = get_wrap_mode_from_string (str);
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_wrap_mode (GtkWrapMode wp)
|
|
||||||
{
|
|
||||||
const gchar * str;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
switch (wp)
|
|
||||||
{
|
|
||||||
case GTK_WRAP_NONE:
|
|
||||||
str = "GTK_WRAP_NONE";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_WRAP_CHAR:
|
|
||||||
str = "GTK_WRAP_CHAR";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* GTK_WRAP_WORD */
|
|
||||||
str = "GTK_WRAP_WORD";
|
|
||||||
}
|
|
||||||
|
|
||||||
xed_prefs_manager_set_string (GPM_WRAP_MODE,
|
|
||||||
str);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_wrap_mode_can_set (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_key_is_writable (GPM_WRAP_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Tabs size */
|
|
||||||
DEFINE_INT_PREF (tabs_size,
|
|
||||||
GPM_TABS_SIZE)
|
|
||||||
|
|
||||||
/* Insert spaces */
|
|
||||||
DEFINE_BOOL_PREF (insert_spaces,
|
|
||||||
GPM_INSERT_SPACES)
|
|
||||||
|
|
||||||
/* Auto indent */
|
|
||||||
DEFINE_BOOL_PREF (auto_indent,
|
|
||||||
GPM_AUTO_INDENT)
|
|
||||||
|
|
||||||
/* Display line numbers */
|
|
||||||
DEFINE_BOOL_PREF (display_line_numbers,
|
|
||||||
GPM_DISPLAY_LINE_NUMBERS)
|
|
||||||
|
|
||||||
/* Toolbar visibility */
|
|
||||||
DEFINE_BOOL_PREF (toolbar_visible,
|
|
||||||
GPM_TOOLBAR_VISIBLE)
|
|
||||||
|
|
||||||
/* Statusbar visiblity */
|
|
||||||
DEFINE_BOOL_PREF (statusbar_visible,
|
|
||||||
GPM_STATUSBAR_VISIBLE)
|
|
||||||
|
|
||||||
/* Side Pane visiblity */
|
|
||||||
DEFINE_BOOL_PREF (side_pane_visible,
|
|
||||||
GPM_SIDE_PANE_VISIBLE)
|
|
||||||
|
|
||||||
/* Bottom Panel visiblity */
|
|
||||||
DEFINE_BOOL_PREF (bottom_panel_visible,
|
|
||||||
GPM_BOTTOM_PANEL_VISIBLE)
|
|
||||||
|
|
||||||
/* Tab scrolling */
|
|
||||||
DEFINE_BOOL_PREF (enable_tab_scrolling, GPM_ENABLE_TAB_SCROLLING)
|
|
||||||
|
|
||||||
/* Print syntax highlighting */
|
|
||||||
DEFINE_BOOL_PREF (print_syntax_hl,
|
|
||||||
GPM_PRINT_SYNTAX)
|
|
||||||
|
|
||||||
/* Print header */
|
|
||||||
DEFINE_BOOL_PREF (print_header,
|
|
||||||
GPM_PRINT_HEADER)
|
|
||||||
|
|
||||||
|
|
||||||
/* Print Wrap mode */
|
|
||||||
GtkWrapMode
|
|
||||||
xed_prefs_manager_get_print_wrap_mode (void)
|
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
GtkWrapMode res;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
str = xed_prefs_manager_get_string (GPM_PRINT_WRAP_MODE);
|
|
||||||
|
|
||||||
if (strcmp (str, "GTK_WRAP_NONE") == 0)
|
|
||||||
res = GTK_WRAP_NONE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (strcmp (str, "GTK_WRAP_WORD") == 0)
|
|
||||||
res = GTK_WRAP_WORD;
|
|
||||||
else
|
|
||||||
res = GTK_WRAP_CHAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_print_wrap_mode (GtkWrapMode pwp)
|
|
||||||
{
|
|
||||||
const gchar *str;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
switch (pwp)
|
|
||||||
{
|
|
||||||
case GTK_WRAP_NONE:
|
|
||||||
str = "GTK_WRAP_NONE";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_WRAP_WORD:
|
|
||||||
str = "GTK_WRAP_WORD";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* GTK_WRAP_CHAR */
|
|
||||||
str = "GTK_WRAP_CHAR";
|
|
||||||
}
|
|
||||||
|
|
||||||
xed_prefs_manager_set_string (GPM_PRINT_WRAP_MODE, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_print_wrap_mode_can_set (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_key_is_writable (GPM_PRINT_WRAP_MODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print line numbers */
|
|
||||||
DEFINE_INT_PREF (print_line_numbers,
|
|
||||||
GPM_PRINT_LINE_NUMBERS)
|
|
||||||
|
|
||||||
/* Printing fonts */
|
|
||||||
DEFINE_STRING_PREF (print_font_body,
|
|
||||||
GPM_PRINT_FONT_BODY)
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
xed_prefs_manager_get_default_string_value (const gchar *key)
|
|
||||||
{
|
|
||||||
gchar *font = NULL;
|
|
||||||
g_settings_delay (xed_prefs_manager->settings);
|
|
||||||
g_settings_reset (xed_prefs_manager->settings, key);
|
|
||||||
font = g_settings_get_string (xed_prefs_manager->settings, key);
|
|
||||||
g_settings_revert (xed_prefs_manager->settings);
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
xed_prefs_manager_get_default_print_font_body (void)
|
|
||||||
{
|
|
||||||
return xed_prefs_manager_get_default_string_value (GPM_PRINT_FONT_BODY);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_STRING_PREF (print_font_header,
|
|
||||||
GPM_PRINT_FONT_HEADER)
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
xed_prefs_manager_get_default_print_font_header (void)
|
|
||||||
{
|
|
||||||
return xed_prefs_manager_get_default_string_value (GPM_PRINT_FONT_HEADER);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_STRING_PREF (print_font_numbers,
|
|
||||||
GPM_PRINT_FONT_NUMBERS)
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
xed_prefs_manager_get_default_print_font_numbers (void)
|
|
||||||
{
|
|
||||||
return xed_prefs_manager_get_default_string_value (GPM_PRINT_FONT_NUMBERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Max number of files in "Recent Files" menu.
|
|
||||||
* This is configurable only using gsettings, dconf or dconf-editor
|
|
||||||
*/
|
|
||||||
gint
|
|
||||||
xed_prefs_manager_get_max_recents (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_get_int (GPM_MAX_RECENTS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GSettings/GSList utility functions from mate-panel */
|
|
||||||
|
|
||||||
GSList*
|
|
||||||
xed_prefs_manager_get_gslist (GSettings *settings, const gchar *key)
|
|
||||||
{
|
|
||||||
gchar **array;
|
|
||||||
GSList *list = NULL;
|
|
||||||
gint i;
|
|
||||||
array = g_settings_get_strv (settings, key);
|
|
||||||
if (array != NULL) {
|
|
||||||
for (i = 0; array[i]; i++) {
|
|
||||||
list = g_slist_append (list, g_strdup (array[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_strfreev (array);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list)
|
|
||||||
{
|
|
||||||
GArray *array;
|
|
||||||
GSList *l;
|
|
||||||
array = g_array_new (TRUE, TRUE, sizeof (gchar *));
|
|
||||||
for (l = list; l; l = l->next) {
|
|
||||||
array = g_array_append_val (array, l->data);
|
|
||||||
}
|
|
||||||
g_settings_set_strv (settings, key, (const gchar **) array->data);
|
|
||||||
g_array_free (array, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Encodings */
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
data_exists (GSList *list,
|
|
||||||
const gpointer data)
|
|
||||||
{
|
|
||||||
while (list != NULL)
|
|
||||||
{
|
|
||||||
if (list->data == data)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
list = g_slist_next (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSList *
|
|
||||||
xed_prefs_manager_get_auto_detected_encodings (void)
|
|
||||||
{
|
|
||||||
GSList *strings;
|
|
||||||
GSList *res = NULL;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_val_if_fail (xed_prefs_manager != NULL, NULL);
|
|
||||||
g_return_val_if_fail (xed_prefs_manager->settings != NULL, NULL);
|
|
||||||
|
|
||||||
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_AUTO_DETECTED_ENCODINGS);
|
|
||||||
|
|
||||||
if (strings != NULL)
|
|
||||||
{
|
|
||||||
GSList *tmp;
|
|
||||||
const XedEncoding *enc;
|
|
||||||
|
|
||||||
tmp = strings;
|
|
||||||
|
|
||||||
while (tmp)
|
|
||||||
{
|
|
||||||
const char *charset = tmp->data;
|
|
||||||
|
|
||||||
if (strcmp (charset, "CURRENT") == 0)
|
|
||||||
g_get_charset (&charset);
|
|
||||||
|
|
||||||
g_return_val_if_fail (charset != NULL, NULL);
|
|
||||||
enc = xed_encoding_get_from_charset (charset);
|
|
||||||
|
|
||||||
if (enc != NULL)
|
|
||||||
{
|
|
||||||
if (!data_exists (res, (gpointer)enc))
|
|
||||||
res = g_slist_prepend (res, (gpointer)enc);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = g_slist_next (tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_foreach (strings, (GFunc) g_free, NULL);
|
|
||||||
g_slist_free (strings);
|
|
||||||
|
|
||||||
res = g_slist_reverse (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PREFS, "Done");
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSList *
|
|
||||||
xed_prefs_manager_get_shown_in_menu_encodings (void)
|
|
||||||
{
|
|
||||||
GSList *strings;
|
|
||||||
GSList *res = NULL;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_val_if_fail (xed_prefs_manager != NULL, NULL);
|
|
||||||
g_return_val_if_fail (xed_prefs_manager->settings != NULL, NULL);
|
|
||||||
|
|
||||||
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_SHOWN_IN_MENU_ENCODINGS);
|
|
||||||
|
|
||||||
if (strings != NULL)
|
|
||||||
{
|
|
||||||
GSList *tmp;
|
|
||||||
const XedEncoding *enc;
|
|
||||||
|
|
||||||
tmp = strings;
|
|
||||||
|
|
||||||
while (tmp)
|
|
||||||
{
|
|
||||||
const char *charset = tmp->data;
|
|
||||||
|
|
||||||
if (strcmp (charset, "CURRENT") == 0)
|
|
||||||
g_get_charset (&charset);
|
|
||||||
|
|
||||||
g_return_val_if_fail (charset != NULL, NULL);
|
|
||||||
enc = xed_encoding_get_from_charset (charset);
|
|
||||||
|
|
||||||
if (enc != NULL)
|
|
||||||
{
|
|
||||||
if (!data_exists (res, (gpointer)enc))
|
|
||||||
res = g_slist_prepend (res, (gpointer)enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = g_slist_next (tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_foreach (strings, (GFunc) g_free, NULL);
|
|
||||||
g_slist_free (strings);
|
|
||||||
|
|
||||||
res = g_slist_reverse (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_shown_in_menu_encodings (const GSList *encs)
|
|
||||||
{
|
|
||||||
GSList *list = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (xed_prefs_manager != NULL);
|
|
||||||
g_return_if_fail (xed_prefs_manager->settings != NULL);
|
|
||||||
g_return_if_fail (xed_prefs_manager_shown_in_menu_encodings_can_set ());
|
|
||||||
|
|
||||||
while (encs != NULL)
|
|
||||||
{
|
|
||||||
const XedEncoding *enc;
|
|
||||||
const gchar *charset;
|
|
||||||
|
|
||||||
enc = (const XedEncoding *)encs->data;
|
|
||||||
|
|
||||||
charset = xed_encoding_get_charset (enc);
|
|
||||||
g_return_if_fail (charset != NULL);
|
|
||||||
|
|
||||||
list = g_slist_prepend (list, (gpointer)charset);
|
|
||||||
|
|
||||||
encs = g_slist_next (encs);
|
|
||||||
}
|
|
||||||
|
|
||||||
list = g_slist_reverse (list);
|
|
||||||
|
|
||||||
xed_prefs_manager_set_gslist (xed_prefs_manager->settings, GPM_SHOWN_IN_MENU_ENCODINGS, list);
|
|
||||||
|
|
||||||
g_slist_free (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_shown_in_menu_encodings_can_set (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_key_is_writable (GPM_SHOWN_IN_MENU_ENCODINGS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Highlight current line */
|
|
||||||
DEFINE_BOOL_PREF (highlight_current_line,
|
|
||||||
GPM_HIGHLIGHT_CURRENT_LINE)
|
|
||||||
|
|
||||||
/* Highlight matching bracket */
|
|
||||||
DEFINE_BOOL_PREF (bracket_matching,
|
|
||||||
GPM_BRACKET_MATCHING)
|
|
||||||
|
|
||||||
/* Display Right Margin */
|
|
||||||
DEFINE_BOOL_PREF (display_right_margin,
|
|
||||||
GPM_DISPLAY_RIGHT_MARGIN)
|
|
||||||
|
|
||||||
/* Right Margin Position */
|
|
||||||
DEFINE_INT_PREF (right_margin_position,
|
|
||||||
GPM_RIGHT_MARGIN_POSITION)
|
|
||||||
|
|
||||||
static GtkSourceSmartHomeEndType
|
|
||||||
get_smart_home_end_from_string (const gchar *str)
|
|
||||||
{
|
|
||||||
GtkSourceSmartHomeEndType res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (str != NULL, GTK_SOURCE_SMART_HOME_END_AFTER);
|
|
||||||
|
|
||||||
if (strcmp (str, "DISABLED") == 0)
|
|
||||||
res = GTK_SOURCE_SMART_HOME_END_DISABLED;
|
|
||||||
else if (strcmp (str, "BEFORE") == 0)
|
|
||||||
res = GTK_SOURCE_SMART_HOME_END_BEFORE;
|
|
||||||
else if (strcmp (str, "ALWAYS") == 0)
|
|
||||||
res = GTK_SOURCE_SMART_HOME_END_ALWAYS;
|
|
||||||
else
|
|
||||||
res = GTK_SOURCE_SMART_HOME_END_AFTER;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkSourceSmartHomeEndType
|
|
||||||
xed_prefs_manager_get_smart_home_end (void)
|
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
GtkSourceSmartHomeEndType res;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
str = xed_prefs_manager_get_string (GPM_SMART_HOME_END);
|
|
||||||
|
|
||||||
res = get_smart_home_end_from_string (str);
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_smart_home_end (GtkSourceSmartHomeEndType smart_he)
|
|
||||||
{
|
|
||||||
const gchar *str;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
switch (smart_he)
|
|
||||||
{
|
|
||||||
case GTK_SOURCE_SMART_HOME_END_DISABLED:
|
|
||||||
str = "DISABLED";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_SOURCE_SMART_HOME_END_BEFORE:
|
|
||||||
str = "BEFORE";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_SOURCE_SMART_HOME_END_ALWAYS:
|
|
||||||
str = "ALWAYS";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* GTK_SOURCE_SMART_HOME_END_AFTER */
|
|
||||||
str = "AFTER";
|
|
||||||
}
|
|
||||||
|
|
||||||
xed_prefs_manager_set_string (GPM_WRAP_MODE, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_smart_home_end_can_set (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_key_is_writable (GPM_SMART_HOME_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable syntax highlighting */
|
|
||||||
DEFINE_BOOL_PREF (enable_syntax_highlighting,
|
|
||||||
GPM_SYNTAX_HL_ENABLE)
|
|
||||||
|
|
||||||
/* Enable search highlighting */
|
|
||||||
DEFINE_BOOL_PREF (enable_search_highlighting,
|
|
||||||
GPM_SEARCH_HIGHLIGHTING_ENABLE)
|
|
||||||
|
|
||||||
/* Source style scheme */
|
|
||||||
DEFINE_STRING_PREF (source_style_scheme,
|
|
||||||
GPM_SOURCE_STYLE_SCHEME)
|
|
||||||
|
|
||||||
GSList *
|
|
||||||
xed_prefs_manager_get_writable_vfs_schemes (void)
|
|
||||||
{
|
|
||||||
GSList *strings;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_val_if_fail (xed_prefs_manager != NULL, NULL);
|
|
||||||
g_return_val_if_fail (xed_prefs_manager->settings != NULL, NULL);
|
|
||||||
|
|
||||||
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_WRITABLE_VFS_SCHEMES);
|
|
||||||
|
|
||||||
/* The 'file' scheme is writable by default. */
|
|
||||||
strings = g_slist_prepend (strings, g_strdup ("file"));
|
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PREFS, "Done");
|
|
||||||
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_get_restore_cursor_position (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_get_bool (GPM_RESTORE_CURSOR_POSITION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Plugins: we just store/return a list of strings, all the magic has to
|
|
||||||
* happen in the plugin engine */
|
|
||||||
|
|
||||||
GSList *
|
|
||||||
xed_prefs_manager_get_active_plugins (void)
|
|
||||||
{
|
|
||||||
GSList *plugins;
|
|
||||||
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
g_return_val_if_fail (xed_prefs_manager != NULL, NULL);
|
|
||||||
g_return_val_if_fail (xed_prefs_manager->settings != NULL, NULL);
|
|
||||||
|
|
||||||
plugins = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_ACTIVE_PLUGINS);
|
|
||||||
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xed_prefs_manager_set_active_plugins (const GSList *plugins)
|
|
||||||
{
|
|
||||||
g_return_if_fail (xed_prefs_manager != NULL);
|
|
||||||
g_return_if_fail (xed_prefs_manager->settings != NULL);
|
|
||||||
g_return_if_fail (xed_prefs_manager_active_plugins_can_set ());
|
|
||||||
|
|
||||||
xed_prefs_manager_set_gslist (xed_prefs_manager->settings, GPM_ACTIVE_PLUGINS, (GSList *) plugins);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
xed_prefs_manager_active_plugins_can_set (void)
|
|
||||||
{
|
|
||||||
xed_debug (DEBUG_PREFS);
|
|
||||||
|
|
||||||
return xed_prefs_manager_key_is_writable (GPM_ACTIVE_PLUGINS);
|
|
||||||
}
|
|
|
@ -1,321 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
||||||
/*
|
|
||||||
* xed-prefs-manager.h
|
|
||||||
* This file is part of xed
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 Paolo Maggi
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
|
||||||
* list of people on the xed Team.
|
|
||||||
* See the ChangeLog files for a list of changes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XED_PREFS_MANAGER_H__
|
|
||||||
#define __XED_PREFS_MANAGER_H__
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <gtksourceview/gtksourceview.h>
|
|
||||||
#include "xed-app.h"
|
|
||||||
|
|
||||||
#define XED_SCHEMA "org.x.editor"
|
|
||||||
|
|
||||||
/* Editor */
|
|
||||||
#define GPM_USE_DEFAULT_FONT "use-default-font"
|
|
||||||
#define GPM_EDITOR_FONT "editor-font"
|
|
||||||
|
|
||||||
#define GPM_CREATE_BACKUP_COPY "create-backup-copy"
|
|
||||||
|
|
||||||
#define GPM_AUTO_SAVE "auto-save"
|
|
||||||
#define GPM_AUTO_SAVE_INTERVAL "auto-save-interval"
|
|
||||||
|
|
||||||
#define GPM_UNDO_ACTIONS_LIMIT "max-undo-actions"
|
|
||||||
|
|
||||||
#define GPM_WRAP_MODE "wrap-mode"
|
|
||||||
|
|
||||||
#define GPM_TABS_SIZE "tabs-size"
|
|
||||||
#define GPM_INSERT_SPACES "insert-spaces"
|
|
||||||
|
|
||||||
#define GPM_AUTO_INDENT "auto-indent"
|
|
||||||
|
|
||||||
#define GPM_DISPLAY_LINE_NUMBERS "display-line-numbers"
|
|
||||||
|
|
||||||
#define GPM_HIGHLIGHT_CURRENT_LINE "highlight-current-line"
|
|
||||||
|
|
||||||
#define GPM_BRACKET_MATCHING "bracket-matching"
|
|
||||||
|
|
||||||
#define GPM_DISPLAY_RIGHT_MARGIN "display-right-margin"
|
|
||||||
#define GPM_RIGHT_MARGIN_POSITION "right-margin-position"
|
|
||||||
|
|
||||||
#define GPM_SMART_HOME_END "smart-home-end"
|
|
||||||
|
|
||||||
#define GPM_RESTORE_CURSOR_POSITION "restore-cursor-position"
|
|
||||||
|
|
||||||
#define GPM_SEARCH_HIGHLIGHTING_ENABLE "enable-search-highlighting"
|
|
||||||
|
|
||||||
#define GPM_SOURCE_STYLE_SCHEME "color-scheme"
|
|
||||||
|
|
||||||
/* UI */
|
|
||||||
#define GPM_TOOLBAR_VISIBLE "toolbar-visible"
|
|
||||||
|
|
||||||
#define GPM_STATUSBAR_VISIBLE "statusbar-visible"
|
|
||||||
|
|
||||||
#define GPM_SIDE_PANE_VISIBLE "side-pane-visible"
|
|
||||||
|
|
||||||
#define GPM_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
|
||||||
|
|
||||||
#define GPM_ENABLE_TAB_SCROLLING "enable-tab-scrolling"
|
|
||||||
|
|
||||||
#define GPM_MAX_RECENTS "max-recents"
|
|
||||||
|
|
||||||
/* Print */
|
|
||||||
#define GPM_PRINT_SYNTAX "print-syntax-highlighting"
|
|
||||||
#define GPM_PRINT_HEADER "print-header"
|
|
||||||
#define GPM_PRINT_WRAP_MODE "print-wrap-mode"
|
|
||||||
#define GPM_PRINT_LINE_NUMBERS "print-line-numbers"
|
|
||||||
|
|
||||||
#define GPM_PRINT_FONT_BODY "print-font-body-pango"
|
|
||||||
#define GPM_PRINT_FONT_HEADER "print-font-header-pango"
|
|
||||||
#define GPM_PRINT_FONT_NUMBERS "print-font-numbers-pango"
|
|
||||||
|
|
||||||
/* Encodings */
|
|
||||||
#define GPM_AUTO_DETECTED_ENCODINGS "auto-detected-encodings"
|
|
||||||
#define GPM_SHOWN_IN_MENU_ENCODINGS "shown-in-menu-encodings"
|
|
||||||
|
|
||||||
/* Syntax highlighting */
|
|
||||||
#define GPM_SYNTAX_HL_ENABLE "enable-syntax-highlighting"
|
|
||||||
|
|
||||||
/* White list of writable mate-vfs methods */
|
|
||||||
#define GPM_WRITABLE_VFS_SCHEMES "writable-vfs-schemes"
|
|
||||||
|
|
||||||
/* Plugins */
|
|
||||||
#define GPM_ACTIVE_PLUGINS "active-plugins"
|
|
||||||
|
|
||||||
/* Global Interface keys */
|
|
||||||
#define GPM_INTERFACE_SCHEMA "org.gnome.desktop.interface"
|
|
||||||
#define GPM_SYSTEM_FONT "monospace-font-name"
|
|
||||||
|
|
||||||
/* Fallback default values. Keep in sync with org.x.editor.gschema.xml */
|
|
||||||
#define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */
|
|
||||||
#define GPM_DEFAULT_MAX_RECENTS 5
|
|
||||||
|
|
||||||
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/
|
|
||||||
|
|
||||||
gboolean xed_prefs_manager_init (void);
|
|
||||||
|
|
||||||
/* This function must be called before exiting xed */
|
|
||||||
void xed_prefs_manager_shutdown (void);
|
|
||||||
|
|
||||||
|
|
||||||
/** PREFS MANAGEMENT FUNCTIONS **/
|
|
||||||
|
|
||||||
/* Use default font */
|
|
||||||
gboolean xed_prefs_manager_get_use_default_font (void);
|
|
||||||
void xed_prefs_manager_set_use_default_font (gboolean udf);
|
|
||||||
gboolean xed_prefs_manager_use_default_font_can_set (void);
|
|
||||||
|
|
||||||
/* Editor font */
|
|
||||||
gchar *xed_prefs_manager_get_editor_font (void);
|
|
||||||
void xed_prefs_manager_set_editor_font (const gchar *font);
|
|
||||||
gboolean xed_prefs_manager_editor_font_can_set (void);
|
|
||||||
|
|
||||||
/* System font */
|
|
||||||
gchar *xed_prefs_manager_get_system_font (void);
|
|
||||||
|
|
||||||
/* Create backup copy */
|
|
||||||
gboolean xed_prefs_manager_get_create_backup_copy (void);
|
|
||||||
void xed_prefs_manager_set_create_backup_copy (gboolean cbc);
|
|
||||||
gboolean xed_prefs_manager_create_backup_copy_can_set (void);
|
|
||||||
|
|
||||||
/* Auto save */
|
|
||||||
gboolean xed_prefs_manager_get_auto_save (void);
|
|
||||||
void xed_prefs_manager_set_auto_save (gboolean as);
|
|
||||||
gboolean xed_prefs_manager_auto_save_can_set (void);
|
|
||||||
|
|
||||||
/* Auto save interval */
|
|
||||||
gint xed_prefs_manager_get_auto_save_interval (void);
|
|
||||||
void xed_prefs_manager_set_auto_save_interval (gint asi);
|
|
||||||
gboolean xed_prefs_manager_auto_save_interval_can_set (void);
|
|
||||||
|
|
||||||
/* Undo actions limit: if < 1 then no limits */
|
|
||||||
gint xed_prefs_manager_get_undo_actions_limit (void);
|
|
||||||
void xed_prefs_manager_set_undo_actions_limit (gint ual);
|
|
||||||
gboolean xed_prefs_manager_undo_actions_limit_can_set (void);
|
|
||||||
|
|
||||||
/* Wrap mode */
|
|
||||||
GtkWrapMode xed_prefs_manager_get_wrap_mode (void);
|
|
||||||
void xed_prefs_manager_set_wrap_mode (GtkWrapMode wp);
|
|
||||||
gboolean xed_prefs_manager_wrap_mode_can_set (void);
|
|
||||||
|
|
||||||
/* Tabs size */
|
|
||||||
gint xed_prefs_manager_get_tabs_size (void);
|
|
||||||
void xed_prefs_manager_set_tabs_size (gint ts);
|
|
||||||
gboolean xed_prefs_manager_tabs_size_can_set (void);
|
|
||||||
|
|
||||||
/* Insert spaces */
|
|
||||||
gboolean xed_prefs_manager_get_insert_spaces (void);
|
|
||||||
void xed_prefs_manager_set_insert_spaces (gboolean ai);
|
|
||||||
gboolean xed_prefs_manager_insert_spaces_can_set (void);
|
|
||||||
|
|
||||||
/* Auto indent */
|
|
||||||
gboolean xed_prefs_manager_get_auto_indent (void);
|
|
||||||
void xed_prefs_manager_set_auto_indent (gboolean ai);
|
|
||||||
gboolean xed_prefs_manager_auto_indent_can_set (void);
|
|
||||||
|
|
||||||
/* Display line numbers */
|
|
||||||
gboolean xed_prefs_manager_get_display_line_numbers (void);
|
|
||||||
void xed_prefs_manager_set_display_line_numbers (gboolean dln);
|
|
||||||
gboolean xed_prefs_manager_display_line_numbers_can_set (void);
|
|
||||||
|
|
||||||
/* Toolbar visible */
|
|
||||||
gboolean xed_prefs_manager_get_toolbar_visible (void);
|
|
||||||
void xed_prefs_manager_set_toolbar_visible (gboolean tv);
|
|
||||||
gboolean xed_prefs_manager_toolbar_visible_can_set (void);
|
|
||||||
|
|
||||||
/* Statusbar visible */
|
|
||||||
gboolean xed_prefs_manager_get_statusbar_visible (void);
|
|
||||||
void xed_prefs_manager_set_statusbar_visible (gboolean sv);
|
|
||||||
gboolean xed_prefs_manager_statusbar_visible_can_set (void);
|
|
||||||
|
|
||||||
/* Side pane visible */
|
|
||||||
gboolean xed_prefs_manager_get_side_pane_visible (void);
|
|
||||||
void xed_prefs_manager_set_side_pane_visible (gboolean tv);
|
|
||||||
gboolean xed_prefs_manager_side_pane_visible_can_set (void);
|
|
||||||
|
|
||||||
/* Bottom panel visible */
|
|
||||||
gboolean xed_prefs_manager_get_bottom_panel_visible (void);
|
|
||||||
void xed_prefs_manager_set_bottom_panel_visible (gboolean tv);
|
|
||||||
gboolean xed_prefs_manager_bottom_panel_visible_can_set(void);
|
|
||||||
|
|
||||||
/* Tab scrolling enabled */
|
|
||||||
gboolean xed_prefs_manager_get_enable_tab_scrolling (void);
|
|
||||||
void xed_prefs_manager_set_enable_tab_scrolling (gboolean tv);
|
|
||||||
gboolean xed_prefs_manager_enable_tab_scrolling_can_set (void);
|
|
||||||
|
|
||||||
/* Print syntax highlighting */
|
|
||||||
gboolean xed_prefs_manager_get_print_syntax_hl (void);
|
|
||||||
void xed_prefs_manager_set_print_syntax_hl (gboolean ps);
|
|
||||||
gboolean xed_prefs_manager_print_syntax_hl_can_set (void);
|
|
||||||
|
|
||||||
/* Print header */
|
|
||||||
gboolean xed_prefs_manager_get_print_header (void);
|
|
||||||
void xed_prefs_manager_set_print_header (gboolean ph);
|
|
||||||
gboolean xed_prefs_manager_print_header_can_set (void);
|
|
||||||
|
|
||||||
/* Wrap mode while printing */
|
|
||||||
GtkWrapMode xed_prefs_manager_get_print_wrap_mode (void);
|
|
||||||
void xed_prefs_manager_set_print_wrap_mode (GtkWrapMode pwm);
|
|
||||||
gboolean xed_prefs_manager_print_wrap_mode_can_set (void);
|
|
||||||
|
|
||||||
/* Print line numbers */
|
|
||||||
gint xed_prefs_manager_get_print_line_numbers (void);
|
|
||||||
void xed_prefs_manager_set_print_line_numbers (gint pln);
|
|
||||||
gboolean xed_prefs_manager_print_line_numbers_can_set (void);
|
|
||||||
|
|
||||||
/* Font used to print the body of documents */
|
|
||||||
gchar *xed_prefs_manager_get_print_font_body (void);
|
|
||||||
void xed_prefs_manager_set_print_font_body (const gchar *font);
|
|
||||||
gboolean xed_prefs_manager_print_font_body_can_set (void);
|
|
||||||
gchar *xed_prefs_manager_get_default_print_font_body (void);
|
|
||||||
|
|
||||||
/* Font used to print headers */
|
|
||||||
gchar *xed_prefs_manager_get_print_font_header (void);
|
|
||||||
void xed_prefs_manager_set_print_font_header (const gchar *font);
|
|
||||||
gboolean xed_prefs_manager_print_font_header_can_set (void);
|
|
||||||
gchar *xed_prefs_manager_get_default_print_font_header (void);
|
|
||||||
|
|
||||||
/* Font used to print line numbers */
|
|
||||||
gchar *xed_prefs_manager_get_print_font_numbers (void);
|
|
||||||
void xed_prefs_manager_set_print_font_numbers (const gchar *font);
|
|
||||||
gboolean xed_prefs_manager_print_font_numbers_can_set (void);
|
|
||||||
gchar *xed_prefs_manager_get_default_print_font_numbers (void);
|
|
||||||
|
|
||||||
/* Max number of files in "Recent Files" menu.
|
|
||||||
* This is configurable only using gsettings, dconf or dconf-editor
|
|
||||||
*/
|
|
||||||
gint xed_prefs_manager_get_max_recents (void);
|
|
||||||
|
|
||||||
/* Encodings */
|
|
||||||
GSList *xed_prefs_manager_get_auto_detected_encodings (void);
|
|
||||||
|
|
||||||
GSList *xed_prefs_manager_get_shown_in_menu_encodings (void);
|
|
||||||
void xed_prefs_manager_set_shown_in_menu_encodings (const GSList *encs);
|
|
||||||
gboolean xed_prefs_manager_shown_in_menu_encodings_can_set (void);
|
|
||||||
|
|
||||||
/* Highlight current line */
|
|
||||||
gboolean xed_prefs_manager_get_highlight_current_line (void);
|
|
||||||
void xed_prefs_manager_set_highlight_current_line (gboolean hl);
|
|
||||||
gboolean xed_prefs_manager_highlight_current_line_can_set (void);
|
|
||||||
|
|
||||||
/* Highlight matching bracket */
|
|
||||||
gboolean xed_prefs_manager_get_bracket_matching (void);
|
|
||||||
void xed_prefs_manager_set_bracket_matching (gboolean bm);
|
|
||||||
gboolean xed_prefs_manager_bracket_matching_can_set (void);
|
|
||||||
|
|
||||||
/* Display right margin */
|
|
||||||
gboolean xed_prefs_manager_get_display_right_margin (void);
|
|
||||||
void xed_prefs_manager_set_display_right_margin (gboolean drm);
|
|
||||||
gboolean xed_prefs_manager_display_right_margin_can_set (void);
|
|
||||||
|
|
||||||
/* Right margin position */
|
|
||||||
gint xed_prefs_manager_get_right_margin_position (void);
|
|
||||||
void xed_prefs_manager_set_right_margin_position (gint rmp);
|
|
||||||
gboolean xed_prefs_manager_right_margin_position_can_set (void);
|
|
||||||
|
|
||||||
/* Smart home end */
|
|
||||||
GtkSourceSmartHomeEndType
|
|
||||||
xed_prefs_manager_get_smart_home_end (void);
|
|
||||||
void xed_prefs_manager_set_smart_home_end (GtkSourceSmartHomeEndType smart_he);
|
|
||||||
gboolean xed_prefs_manager_smart_home_end_can_set (void);
|
|
||||||
|
|
||||||
/* Enable syntax highlighting */
|
|
||||||
gboolean xed_prefs_manager_get_enable_syntax_highlighting (void);
|
|
||||||
void xed_prefs_manager_set_enable_syntax_highlighting (gboolean esh);
|
|
||||||
gboolean xed_prefs_manager_enable_syntax_highlighting_can_set (void);
|
|
||||||
|
|
||||||
/* Writable VFS schemes */
|
|
||||||
GSList *xed_prefs_manager_get_writable_vfs_schemes (void);
|
|
||||||
|
|
||||||
/* Restore cursor position */
|
|
||||||
gboolean xed_prefs_manager_get_restore_cursor_position (void);
|
|
||||||
|
|
||||||
/* Enable search highlighting */
|
|
||||||
gboolean xed_prefs_manager_get_enable_search_highlighting (void);
|
|
||||||
void xed_prefs_manager_set_enable_search_highlighting (gboolean esh);
|
|
||||||
gboolean xed_prefs_manager_enable_search_highlighting_can_set (void);
|
|
||||||
|
|
||||||
/* Style scheme */
|
|
||||||
gchar *xed_prefs_manager_get_source_style_scheme (void);
|
|
||||||
void xed_prefs_manager_set_source_style_scheme (const gchar *scheme);
|
|
||||||
gboolean xed_prefs_manager_source_style_scheme_can_set(void);
|
|
||||||
|
|
||||||
/* Plugins */
|
|
||||||
GSList *xed_prefs_manager_get_active_plugins (void);
|
|
||||||
void xed_prefs_manager_set_active_plugins (const GSList *plugins);
|
|
||||||
gboolean xed_prefs_manager_active_plugins_can_set (void);
|
|
||||||
|
|
||||||
/* GSettings utilities */
|
|
||||||
GSList* xed_prefs_manager_get_gslist (GSettings *settings, const gchar *key);
|
|
||||||
void xed_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __XED_PREFS_MANAGER_H__ */
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000-2001 Chema Celorio, Paolo Maggi
|
* Copyright (C) 2000-2001 Chema Celorio, Paolo Maggi
|
||||||
* Copyright (C) 2002-2008 Paolo Maggi
|
* Copyright (C) 2002-2008 Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,14 +17,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
|
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id: xed-print.c 6022 2007-12-09 14:38:57Z pborelli $
|
* $Id: xed-print.c 6022 2007-12-09 14:38:57Z pborelli $
|
||||||
*/
|
*/
|
||||||
|
@ -38,11 +38,11 @@
|
||||||
|
|
||||||
#include "xed-print-job.h"
|
#include "xed-print-job.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-print-preview.h"
|
#include "xed-print-preview.h"
|
||||||
#include "xed-marshal.h"
|
#include "xed-marshal.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
|
|
||||||
#define XED_PRINT_JOB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
#define XED_PRINT_JOB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||||
|
@ -51,6 +51,8 @@
|
||||||
|
|
||||||
struct _XedPrintJobPrivate
|
struct _XedPrintJobPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *print_settings;
|
||||||
|
|
||||||
XedView *view;
|
XedView *view;
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ struct _XedPrintJobPrivate
|
||||||
GtkWidget *preview;
|
GtkWidget *preview;
|
||||||
|
|
||||||
XedPrintJobStatus status;
|
XedPrintJobStatus status;
|
||||||
|
|
||||||
gchar *status_string;
|
gchar *status_string;
|
||||||
|
|
||||||
gdouble progress;
|
gdouble progress;
|
||||||
|
@ -94,7 +96,7 @@ enum
|
||||||
PROP_VIEW
|
PROP_VIEW
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PRINTING,
|
PRINTING,
|
||||||
SHOW_PREVIEW,
|
SHOW_PREVIEW,
|
||||||
|
@ -113,7 +115,7 @@ set_view (XedPrintJob *job, XedView *view)
|
||||||
job->priv->doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
job->priv->doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_print_job_get_property (GObject *object,
|
xed_print_job_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
|
@ -132,7 +134,7 @@ xed_print_job_get_property (GObject *object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_print_job_set_property (GObject *object,
|
xed_print_job_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
|
@ -157,7 +159,7 @@ xed_print_job_finalize (GObject *object)
|
||||||
XedPrintJob *job = XED_PRINT_JOB (object);
|
XedPrintJob *job = XED_PRINT_JOB (object);
|
||||||
|
|
||||||
g_free (job->priv->status_string);
|
g_free (job->priv->status_string);
|
||||||
|
|
||||||
if (job->priv->compositor != NULL)
|
if (job->priv->compositor != NULL)
|
||||||
g_object_unref (job->priv->compositor);
|
g_object_unref (job->priv->compositor);
|
||||||
|
|
||||||
|
@ -167,7 +169,17 @@ xed_print_job_finalize (GObject *object)
|
||||||
G_OBJECT_CLASS (xed_print_job_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xed_print_job_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
xed_print_job_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedPrintJob *job = XED_PRINT_JOB (object);
|
||||||
|
|
||||||
|
g_clear_object (&job->priv->print_settings);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_print_job_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
xed_print_job_class_init (XedPrintJobClass *klass)
|
xed_print_job_class_init (XedPrintJobClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
|
@ -177,6 +189,7 @@ xed_print_job_class_init (XedPrintJobClass *klass)
|
||||||
object_class->get_property = xed_print_job_get_property;
|
object_class->get_property = xed_print_job_get_property;
|
||||||
object_class->set_property = xed_print_job_set_property;
|
object_class->set_property = xed_print_job_set_property;
|
||||||
object_class->finalize = xed_print_job_finalize;
|
object_class->finalize = xed_print_job_finalize;
|
||||||
|
object_class->dispose = xed_print_job_dispose;
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
g_object_class_install_property (object_class,
|
||||||
PROP_VIEW,
|
PROP_VIEW,
|
||||||
|
@ -221,7 +234,7 @@ xed_print_job_class_init (XedPrintJobClass *klass)
|
||||||
2,
|
2,
|
||||||
G_TYPE_UINT,
|
G_TYPE_UINT,
|
||||||
G_TYPE_POINTER);
|
G_TYPE_POINTER);
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (XedPrintJobPrivate));
|
g_type_class_add_private (object_class, sizeof (XedPrintJobPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,15 +242,7 @@ static void
|
||||||
line_numbers_checkbutton_toggled (GtkToggleButton *button,
|
line_numbers_checkbutton_toggled (GtkToggleButton *button,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
if (gtk_toggle_button_get_active (button))
|
gtk_widget_set_sensitive (job->priv->line_numbers_hbox, gtk_toggle_button_get_active (button));
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (job->priv->line_numbers_hbox,
|
|
||||||
xed_prefs_manager_print_line_numbers_can_set ());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_set_sensitive (job->priv->line_numbers_hbox, FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -246,7 +251,7 @@ wrap_mode_checkbutton_toggled (GtkToggleButton *button,
|
||||||
{
|
{
|
||||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
|
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton,
|
gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton,
|
||||||
FALSE);
|
FALSE);
|
||||||
gtk_toggle_button_set_inconsistent (
|
gtk_toggle_button_set_inconsistent (
|
||||||
GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton),
|
GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton),
|
||||||
|
@ -267,58 +272,36 @@ restore_button_clicked (GtkButton *button,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (xed_prefs_manager_print_font_body_can_set ())
|
gchar *body;
|
||||||
{
|
gchar *header;
|
||||||
gchar *font;
|
gchar *numbers;
|
||||||
|
|
||||||
font = xed_prefs_manager_get_default_print_font_body ();
|
body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
|
||||||
|
header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
|
||||||
|
numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
|
||||||
|
|
||||||
gtk_font_button_set_font_name (
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton), body);
|
||||||
GTK_FONT_BUTTON (job->priv->body_fontbutton),
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton), header);
|
||||||
font);
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton), numbers);
|
||||||
|
|
||||||
g_free (font);
|
g_free (body);
|
||||||
}
|
g_free (header);
|
||||||
|
g_free (numbers);
|
||||||
if (xed_prefs_manager_print_font_header_can_set ())
|
|
||||||
{
|
|
||||||
gchar *font;
|
|
||||||
|
|
||||||
font = xed_prefs_manager_get_default_print_font_header ();
|
|
||||||
|
|
||||||
gtk_font_button_set_font_name (
|
|
||||||
GTK_FONT_BUTTON (job->priv->headers_fontbutton),
|
|
||||||
font);
|
|
||||||
|
|
||||||
g_free (font);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xed_prefs_manager_print_font_numbers_can_set ())
|
|
||||||
{
|
|
||||||
gchar *font;
|
|
||||||
|
|
||||||
font = xed_prefs_manager_get_default_print_font_numbers ();
|
|
||||||
|
|
||||||
gtk_font_button_set_font_name (
|
|
||||||
GTK_FONT_BUTTON (job->priv->numbers_fontbutton),
|
|
||||||
font);
|
|
||||||
|
|
||||||
g_free (font);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GObject *
|
static GObject *
|
||||||
create_custom_widget_cb (GtkPrintOperation *operation,
|
create_custom_widget_cb (GtkPrintOperation *operation,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkWidget *error_widget;
|
GtkWidget *error_widget;
|
||||||
gchar *font;
|
guint line_numbers;
|
||||||
gint line_numbers;
|
|
||||||
gboolean can_set;
|
|
||||||
GtkWrapMode wrap_mode;
|
GtkWrapMode wrap_mode;
|
||||||
gchar *file;
|
gchar *file;
|
||||||
|
gboolean syntax_hl;
|
||||||
|
gboolean print_header;
|
||||||
|
gchar *font_body, *font_header, *font_numbers;
|
||||||
gchar *root_objects[] = {
|
gchar *root_objects[] = {
|
||||||
"adjustment1",
|
"adjustment1",
|
||||||
"contents",
|
"contents",
|
||||||
|
@ -353,31 +336,27 @@ create_custom_widget_cb (GtkPrintOperation *operation,
|
||||||
return G_OBJECT (error_widget);
|
return G_OBJECT (error_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get all settings values */
|
||||||
|
syntax_hl = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING);
|
||||||
|
print_header = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_HEADER);
|
||||||
|
line_numbers = g_settings_get_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS);
|
||||||
|
font_body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
|
||||||
|
font_header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
|
||||||
|
font_numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
|
||||||
|
|
||||||
/* Print syntax */
|
/* Print syntax */
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton), syntax_hl);
|
||||||
xed_prefs_manager_get_print_syntax_hl ());
|
|
||||||
gtk_widget_set_sensitive (job->priv->syntax_checkbutton,
|
|
||||||
xed_prefs_manager_print_syntax_hl_can_set ());
|
|
||||||
|
|
||||||
/* Print page headers */
|
/* Print page headers */
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton), print_header);
|
||||||
xed_prefs_manager_get_print_header ());
|
|
||||||
gtk_widget_set_sensitive (job->priv->page_header_checkbutton,
|
|
||||||
xed_prefs_manager_print_header_can_set ());
|
|
||||||
|
|
||||||
/* Line numbers */
|
/* Line numbers */
|
||||||
line_numbers = xed_prefs_manager_get_print_line_numbers ();
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton), line_numbers > 0);
|
||||||
can_set = xed_prefs_manager_print_line_numbers_can_set ();
|
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton),
|
|
||||||
line_numbers > 0);
|
|
||||||
gtk_widget_set_sensitive (job->priv->line_numbers_checkbutton, can_set);
|
|
||||||
|
|
||||||
if (line_numbers > 0)
|
if (line_numbers > 0)
|
||||||
{
|
{
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton),
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton), (guint) line_numbers);
|
||||||
(guint) line_numbers);
|
gtk_widget_set_sensitive (job->priv->line_numbers_hbox, TRUE);
|
||||||
gtk_widget_set_sensitive (job->priv->line_numbers_hbox, can_set);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -387,7 +366,7 @@ create_custom_widget_cb (GtkPrintOperation *operation,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Text wrapping */
|
/* Text wrapping */
|
||||||
wrap_mode = xed_prefs_manager_get_print_wrap_mode ();
|
wrap_mode = g_settings_get_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE);
|
||||||
|
|
||||||
switch (wrap_mode)
|
switch (wrap_mode)
|
||||||
{
|
{
|
||||||
|
@ -410,39 +389,17 @@ create_custom_widget_cb (GtkPrintOperation *operation,
|
||||||
GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
|
GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
can_set = xed_prefs_manager_print_wrap_mode_can_set ();
|
gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton, wrap_mode != GTK_WRAP_NONE);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (job->priv->text_wrapping_checkbutton, can_set);
|
|
||||||
gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton,
|
|
||||||
can_set && (wrap_mode != GTK_WRAP_NONE));
|
|
||||||
|
|
||||||
/* Set initial values */
|
/* Set initial values */
|
||||||
font = xed_prefs_manager_get_print_font_body ();
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton), font_body);
|
||||||
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton),
|
g_free (font_body);
|
||||||
font);
|
|
||||||
g_free (font);
|
|
||||||
|
|
||||||
font = xed_prefs_manager_get_print_font_header ();
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton), font_header);
|
||||||
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton),
|
g_free (font_header);
|
||||||
font);
|
|
||||||
g_free (font);
|
|
||||||
|
|
||||||
font = xed_prefs_manager_get_print_font_numbers ();
|
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton), font_numbers);
|
||||||
gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton),
|
g_free (font_numbers);
|
||||||
font);
|
|
||||||
g_free (font);
|
|
||||||
|
|
||||||
can_set = xed_prefs_manager_print_font_body_can_set ();
|
|
||||||
gtk_widget_set_sensitive (job->priv->body_fontbutton, can_set);
|
|
||||||
gtk_widget_set_sensitive (job->priv->body_font_label, can_set);
|
|
||||||
|
|
||||||
can_set = xed_prefs_manager_print_font_header_can_set ();
|
|
||||||
gtk_widget_set_sensitive (job->priv->headers_fontbutton, can_set);
|
|
||||||
gtk_widget_set_sensitive (job->priv->headers_font_label, can_set);
|
|
||||||
|
|
||||||
can_set = xed_prefs_manager_print_font_numbers_can_set ();
|
|
||||||
gtk_widget_set_sensitive (job->priv->numbers_fontbutton, can_set);
|
|
||||||
gtk_widget_set_sensitive (job->priv->numbers_font_label, can_set);
|
|
||||||
|
|
||||||
g_signal_connect (job->priv->line_numbers_checkbutton,
|
g_signal_connect (job->priv->line_numbers_checkbutton,
|
||||||
"toggled",
|
"toggled",
|
||||||
|
@ -469,39 +426,49 @@ custom_widget_apply_cb (GtkPrintOperation *operation,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_syntax_hl (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton)));
|
gboolean syntax, page_header;
|
||||||
|
const gchar *body, *header, *numbers;
|
||||||
|
GtkWrapMode wrap_mode;
|
||||||
|
|
||||||
xed_prefs_manager_set_print_header (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton)));
|
syntax = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton));
|
||||||
|
page_header = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton));
|
||||||
|
body = gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton));
|
||||||
|
header = gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton));
|
||||||
|
numbers = gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton));
|
||||||
|
|
||||||
|
g_settings_set_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING, syntax);
|
||||||
|
g_settings_set_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_HEADER, page_header);
|
||||||
|
g_settings_set_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO, body);
|
||||||
|
g_settings_set_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO, header);
|
||||||
|
g_settings_set_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO, numbers);
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton)))
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton)))
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_line_numbers (
|
g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS,
|
||||||
MAX (1, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton))));
|
MAX (1, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_line_numbers (0);
|
g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
|
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_wrap_mode (GTK_WRAP_NONE);
|
wrap_mode = GTK_WRAP_NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton)))
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton)))
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_wrap_mode (GTK_WRAP_WORD);
|
wrap_mode = GTK_WRAP_WORD;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_print_wrap_mode (GTK_WRAP_CHAR);
|
wrap_mode = GTK_WRAP_CHAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xed_prefs_manager_set_print_font_body (gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton)));
|
g_settings_set_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE, wrap_mode);
|
||||||
xed_prefs_manager_set_print_font_header (gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton)));
|
|
||||||
xed_prefs_manager_set_print_font_numbers (gtk_font_button_get_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -510,21 +477,29 @@ create_compositor (XedPrintJob *job)
|
||||||
gchar *print_font_body;
|
gchar *print_font_body;
|
||||||
gchar *print_font_header;
|
gchar *print_font_header;
|
||||||
gchar *print_font_numbers;
|
gchar *print_font_numbers;
|
||||||
|
gboolean syntax_hl;
|
||||||
|
GtkWrapMode wrap_mode;
|
||||||
|
guint print_line_numbers;
|
||||||
|
gboolean print_header;
|
||||||
|
|
||||||
/* Create and initialize print compositor */
|
/* Create and initialize print compositor */
|
||||||
print_font_body = xed_prefs_manager_get_print_font_body ();
|
print_font_body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
|
||||||
print_font_header = xed_prefs_manager_get_print_font_header ();
|
print_font_header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
|
||||||
print_font_numbers = xed_prefs_manager_get_print_font_numbers ();
|
print_font_numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
|
||||||
|
syntax_hl = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING);
|
||||||
|
print_line_numbers = g_settings_get_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS);
|
||||||
|
print_header = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_HEADER);
|
||||||
|
wrap_mode = g_settings_get_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE);
|
||||||
|
|
||||||
job->priv->compositor = GTK_SOURCE_PRINT_COMPOSITOR (
|
job->priv->compositor = GTK_SOURCE_PRINT_COMPOSITOR (
|
||||||
g_object_new (GTK_SOURCE_TYPE_PRINT_COMPOSITOR,
|
g_object_new (GTK_SOURCE_TYPE_PRINT_COMPOSITOR,
|
||||||
"buffer", GTK_SOURCE_BUFFER (job->priv->doc),
|
"buffer", GTK_SOURCE_BUFFER (job->priv->doc),
|
||||||
"tab-width", gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (job->priv->view)),
|
"tab-width", gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (job->priv->view)),
|
||||||
"highlight-syntax", gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (job->priv->doc)) &&
|
"highlight-syntax", gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (job->priv->doc)) &&
|
||||||
xed_prefs_manager_get_print_syntax_hl (),
|
syntax_hl,
|
||||||
"wrap-mode", xed_prefs_manager_get_print_wrap_mode (),
|
"wrap-mode", wrap_mode,
|
||||||
"print-line-numbers", xed_prefs_manager_get_print_line_numbers (),
|
"print-line-numbers", print_line_numbers,
|
||||||
"print-header", xed_prefs_manager_get_print_header (),
|
"print-header", print_header,
|
||||||
"print-footer", FALSE,
|
"print-footer", FALSE,
|
||||||
"body-font-name", print_font_body,
|
"body-font-name", print_font_body,
|
||||||
"line-numbers-font-name", print_font_numbers,
|
"line-numbers-font-name", print_font_numbers,
|
||||||
|
@ -534,8 +509,8 @@ create_compositor (XedPrintJob *job)
|
||||||
g_free (print_font_body);
|
g_free (print_font_body);
|
||||||
g_free (print_font_header);
|
g_free (print_font_header);
|
||||||
g_free (print_font_numbers);
|
g_free (print_font_numbers);
|
||||||
|
|
||||||
if (xed_prefs_manager_get_print_header ())
|
if (print_header)
|
||||||
{
|
{
|
||||||
gchar *doc_name;
|
gchar *doc_name;
|
||||||
gchar *name_to_display;
|
gchar *name_to_display;
|
||||||
|
@ -547,7 +522,7 @@ create_compositor (XedPrintJob *job)
|
||||||
left = g_strdup_printf (_("File: %s"), name_to_display);
|
left = g_strdup_printf (_("File: %s"), name_to_display);
|
||||||
|
|
||||||
/* Translators: %N is the current page number, %Q is the total
|
/* Translators: %N is the current page number, %Q is the total
|
||||||
* number of pages (ex. Page 2 of 10)
|
* number of pages (ex. Page 2 of 10)
|
||||||
*/
|
*/
|
||||||
gtk_source_print_compositor_set_header_format (job->priv->compositor,
|
gtk_source_print_compositor_set_header_format (job->priv->compositor,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -558,11 +533,11 @@ create_compositor (XedPrintJob *job)
|
||||||
g_free (doc_name);
|
g_free (doc_name);
|
||||||
g_free (name_to_display);
|
g_free (name_to_display);
|
||||||
g_free (left);
|
g_free (left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
begin_print_cb (GtkPrintOperation *operation,
|
begin_print_cb (GtkPrintOperation *operation,
|
||||||
GtkPrintContext *context,
|
GtkPrintContext *context,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
|
@ -571,7 +546,7 @@ begin_print_cb (GtkPrintOperation *operation,
|
||||||
job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
|
job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
|
||||||
|
|
||||||
job->priv->progress = 0.0;
|
job->priv->progress = 0.0;
|
||||||
|
|
||||||
g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
|
g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,7 +567,7 @@ preview_destroyed (GtkWidget *preview,
|
||||||
gtk_print_operation_preview_end_preview (gtk_preview);
|
gtk_print_operation_preview_end_preview (gtk_preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
preview_cb (GtkPrintOperation *op,
|
preview_cb (GtkPrintOperation *op,
|
||||||
GtkPrintOperationPreview *gtk_preview,
|
GtkPrintOperationPreview *gtk_preview,
|
||||||
GtkPrintContext *context,
|
GtkPrintContext *context,
|
||||||
|
@ -616,16 +591,16 @@ preview_cb (GtkPrintOperation *op,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
paginate_cb (GtkPrintOperation *operation,
|
paginate_cb (GtkPrintOperation *operation,
|
||||||
GtkPrintContext *context,
|
GtkPrintContext *context,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
|
job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
|
||||||
|
|
||||||
res = gtk_source_print_compositor_paginate (job->priv->compositor, context);
|
res = gtk_source_print_compositor_paginate (job->priv->compositor, context);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
gint n_pages;
|
gint n_pages;
|
||||||
|
@ -659,25 +634,25 @@ draw_page_cb (GtkPrintOperation *operation,
|
||||||
if (!job->priv->is_preview)
|
if (!job->priv->is_preview)
|
||||||
{
|
{
|
||||||
g_free (job->priv->status_string);
|
g_free (job->priv->status_string);
|
||||||
|
|
||||||
n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
|
n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
|
||||||
|
|
||||||
job->priv->status = XED_PRINT_JOB_STATUS_DRAWING;
|
job->priv->status = XED_PRINT_JOB_STATUS_DRAWING;
|
||||||
|
|
||||||
job->priv->status_string = g_strdup_printf ("Rendering page %d of %d...",
|
job->priv->status_string = g_strdup_printf ("Rendering page %d of %d...",
|
||||||
page_nr + 1,
|
page_nr + 1,
|
||||||
n_pages);
|
n_pages);
|
||||||
|
|
||||||
job->priv->progress = page_nr / (2.0 * n_pages) + 0.5;
|
job->priv->progress = page_nr / (2.0 * n_pages) + 0.5;
|
||||||
|
|
||||||
g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
|
g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_source_print_compositor_draw_page (job->priv->compositor, context, page_nr);
|
gtk_source_print_compositor_draw_page (job->priv->compositor, context, page_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
end_print_cb (GtkPrintOperation *operation,
|
end_print_cb (GtkPrintOperation *operation,
|
||||||
GtkPrintContext *context,
|
GtkPrintContext *context,
|
||||||
XedPrintJob *job)
|
XedPrintJob *job)
|
||||||
{
|
{
|
||||||
|
@ -693,7 +668,7 @@ done_cb (GtkPrintOperation *operation,
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
XedPrintJobResult print_result;
|
XedPrintJobResult print_result;
|
||||||
|
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case GTK_PRINT_OPERATION_RESULT_CANCEL:
|
case GTK_PRINT_OPERATION_RESULT_CANCEL:
|
||||||
print_result = XED_PRINT_JOB_RESULT_CANCEL;
|
print_result = XED_PRINT_JOB_RESULT_CANCEL;
|
||||||
|
@ -711,20 +686,20 @@ done_cb (GtkPrintOperation *operation,
|
||||||
default:
|
default:
|
||||||
g_return_if_reached ();
|
g_return_if_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid job is destroyed in the handler of the "done" message */
|
/* Avoid job is destroyed in the handler of the "done" message */
|
||||||
g_object_ref (job);
|
g_object_ref (job);
|
||||||
|
|
||||||
g_signal_emit (job, print_job_signals[DONE], 0, print_result, error);
|
g_signal_emit (job, print_job_signals[DONE], 0, print_result, error);
|
||||||
|
|
||||||
g_object_unref (operation);
|
g_object_unref (operation);
|
||||||
job->priv->operation = NULL;
|
job->priv->operation = NULL;
|
||||||
|
|
||||||
g_object_unref (job);
|
g_object_unref (job);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that xed_print_job_print can can only be called once on a given XedPrintJob */
|
/* Note that xed_print_job_print can can only be called once on a given XedPrintJob */
|
||||||
GtkPrintOperationResult
|
GtkPrintOperationResult
|
||||||
xed_print_job_print (XedPrintJob *job,
|
xed_print_job_print (XedPrintJob *job,
|
||||||
GtkPrintOperationAction action,
|
GtkPrintOperationAction action,
|
||||||
GtkPageSetup *page_setup,
|
GtkPageSetup *page_setup,
|
||||||
|
@ -765,15 +740,15 @@ xed_print_job_print (XedPrintJob *job,
|
||||||
gtk_print_operation_set_allow_async (priv->operation, TRUE);
|
gtk_print_operation_set_allow_async (priv->operation, TRUE);
|
||||||
|
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"create-custom-widget",
|
"create-custom-widget",
|
||||||
G_CALLBACK (create_custom_widget_cb),
|
G_CALLBACK (create_custom_widget_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"custom-widget-apply",
|
"custom-widget-apply",
|
||||||
G_CALLBACK (custom_widget_apply_cb),
|
G_CALLBACK (custom_widget_apply_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"begin-print",
|
"begin-print",
|
||||||
G_CALLBACK (begin_print_cb),
|
G_CALLBACK (begin_print_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
|
@ -781,23 +756,23 @@ xed_print_job_print (XedPrintJob *job,
|
||||||
G_CALLBACK (preview_cb),
|
G_CALLBACK (preview_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"paginate",
|
"paginate",
|
||||||
G_CALLBACK (paginate_cb),
|
G_CALLBACK (paginate_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"draw-page",
|
"draw-page",
|
||||||
G_CALLBACK (draw_page_cb),
|
G_CALLBACK (draw_page_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"end-print",
|
"end-print",
|
||||||
G_CALLBACK (end_print_cb),
|
G_CALLBACK (end_print_cb),
|
||||||
job);
|
job);
|
||||||
g_signal_connect (priv->operation,
|
g_signal_connect (priv->operation,
|
||||||
"done",
|
"done",
|
||||||
G_CALLBACK (done_cb),
|
G_CALLBACK (done_cb),
|
||||||
job);
|
job);
|
||||||
|
|
||||||
return gtk_print_operation_run (priv->operation,
|
return gtk_print_operation_run (priv->operation,
|
||||||
action,
|
action,
|
||||||
parent,
|
parent,
|
||||||
error);
|
error);
|
||||||
|
@ -807,9 +782,11 @@ static void
|
||||||
xed_print_job_init (XedPrintJob *job)
|
xed_print_job_init (XedPrintJob *job)
|
||||||
{
|
{
|
||||||
job->priv = XED_PRINT_JOB_GET_PRIVATE (job);
|
job->priv = XED_PRINT_JOB_GET_PRIVATE (job);
|
||||||
|
|
||||||
|
job->priv->print_settings = g_settings_new ("org.x.editor.preferences.print");
|
||||||
|
|
||||||
job->priv->status = XED_PRINT_JOB_STATUS_INIT;
|
job->priv->status = XED_PRINT_JOB_STATUS_INIT;
|
||||||
|
|
||||||
job->priv->status_string = g_strdup (_("Preparing..."));
|
job->priv->status_string = g_strdup (_("Preparing..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,9 +794,9 @@ XedPrintJob *
|
||||||
xed_print_job_new (XedView *view)
|
xed_print_job_new (XedView *view)
|
||||||
{
|
{
|
||||||
XedPrintJob *job;
|
XedPrintJob *job;
|
||||||
|
|
||||||
g_return_val_if_fail (XED_IS_VIEW (view), NULL);
|
g_return_val_if_fail (XED_IS_VIEW (view), NULL);
|
||||||
|
|
||||||
job = XED_PRINT_JOB (g_object_new (XED_TYPE_PRINT_JOB,
|
job = XED_PRINT_JOB (g_object_new (XED_TYPE_PRINT_JOB,
|
||||||
"view", view,
|
"view", view,
|
||||||
NULL));
|
NULL));
|
||||||
|
@ -840,7 +817,7 @@ xed_print_job_get_status_string (XedPrintJob *job)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
|
g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
|
||||||
g_return_val_if_fail (job->priv->status_string != NULL, NULL);
|
g_return_val_if_fail (job->priv->status_string != NULL, NULL);
|
||||||
|
|
||||||
return job->priv->status_string;
|
return job->priv->status_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
|
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-metadata-manager.h"
|
#include "xed-metadata-manager.h"
|
||||||
#include "xed-window.h"
|
#include "xed-window.h"
|
||||||
#include "xed-app.h"
|
#include "xed-app.h"
|
||||||
|
|
|
@ -0,0 +1,750 @@
|
||||||
|
/*
|
||||||
|
* xed-settings.c
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002-2005 - Paolo Maggi
|
||||||
|
* 2009 - Ignacio Casal Quinteiro
|
||||||
|
*
|
||||||
|
* xed is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* xed is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with xed; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "xed-settings.h"
|
||||||
|
#include "xed-app.h"
|
||||||
|
#include "xed-debug.h"
|
||||||
|
#include "xed-view.h"
|
||||||
|
#include "xed-window.h"
|
||||||
|
#include "xed-notebook.h"
|
||||||
|
#include "xed-plugins-engine.h"
|
||||||
|
#include "xed-style-scheme-manager.h"
|
||||||
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-utils.h"
|
||||||
|
#include "xed-window-private.h"
|
||||||
|
|
||||||
|
#define XED_SETTINGS_SYSTEM_FONT "monospace-font-name"
|
||||||
|
|
||||||
|
#define XED_SETTINGS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), XED_TYPE_SETTINGS, XedSettingsPrivate))
|
||||||
|
|
||||||
|
struct _XedSettingsPrivate
|
||||||
|
{
|
||||||
|
GSettings *interface;
|
||||||
|
GSettings *editor;
|
||||||
|
GSettings *ui;
|
||||||
|
GSettings *plugins;
|
||||||
|
|
||||||
|
gchar *old_scheme;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (XedSettings, xed_settings, G_TYPE_SETTINGS)
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_settings_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
XedSettings *xs = XED_SETTINGS (object);
|
||||||
|
|
||||||
|
g_free (xs->priv->old_scheme);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_settings_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_settings_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedSettings *xs = XED_SETTINGS (object);
|
||||||
|
|
||||||
|
if (xs->priv->interface != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (xs->priv->interface);
|
||||||
|
xs->priv->interface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xs->priv->editor != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (xs->priv->editor);
|
||||||
|
xs->priv->editor = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xs->priv->ui != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (xs->priv->ui);
|
||||||
|
xs->priv->ui = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xs->priv->plugins != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (xs->priv->plugins);
|
||||||
|
xs->priv->plugins = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_settings_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_font (XedSettings *xs,
|
||||||
|
const gchar *font)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
guint ts;
|
||||||
|
|
||||||
|
ts = g_settings_get_uint (xs->priv->editor, XED_SETTINGS_TABS_SIZE);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
/* Note: we use def=FALSE to avoid XedView to query gconf */
|
||||||
|
xed_view_set_font (XED_VIEW (l->data), FALSE, font);
|
||||||
|
|
||||||
|
gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data), ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_system_font_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
|
||||||
|
gboolean use_default_font;
|
||||||
|
gchar *font;
|
||||||
|
|
||||||
|
use_default_font = g_settings_get_boolean (xs->priv->editor, XED_SETTINGS_USE_DEFAULT_FONT);
|
||||||
|
if (!use_default_font)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
font = g_settings_get_string (settings, key);
|
||||||
|
|
||||||
|
set_font (xs, font);
|
||||||
|
|
||||||
|
g_free (font);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_use_default_font_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
gboolean def;
|
||||||
|
gchar *font;
|
||||||
|
|
||||||
|
def = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
if (def)
|
||||||
|
{
|
||||||
|
font = g_settings_get_string (xs->priv->interface, XED_SETTINGS_SYSTEM_FONT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
font = g_settings_get_string (xs->priv->editor, XED_SETTINGS_EDITOR_FONT);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_font (xs, font);
|
||||||
|
|
||||||
|
g_free (font);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_editor_font_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
gboolean use_default_font;
|
||||||
|
gchar *font;
|
||||||
|
|
||||||
|
use_default_font = g_settings_get_boolean (xs->priv->editor, XED_SETTINGS_USE_DEFAULT_FONT);
|
||||||
|
if (use_default_font)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
font = g_settings_get_string (settings, key);
|
||||||
|
|
||||||
|
set_font (xs, font);
|
||||||
|
|
||||||
|
g_free (font);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_scheme_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GtkSourceStyleScheme *style;
|
||||||
|
gchar *scheme;
|
||||||
|
GList *docs;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
scheme = g_settings_get_string (settings, key);
|
||||||
|
|
||||||
|
if (xs->priv->old_scheme != NULL && (strcmp (scheme, xs->priv->old_scheme) == 0))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (xs->priv->old_scheme);
|
||||||
|
xs->priv->old_scheme = scheme;
|
||||||
|
|
||||||
|
style = gtk_source_style_scheme_manager_get_scheme (xed_get_style_scheme_manager (), scheme);
|
||||||
|
|
||||||
|
if (style == NULL)
|
||||||
|
{
|
||||||
|
g_warning ("Default style scheme '%s' not found, falling back to 'classic'", scheme);
|
||||||
|
|
||||||
|
style = gtk_source_style_scheme_manager_get_scheme (xed_get_style_scheme_manager (), "classic");
|
||||||
|
|
||||||
|
if (style == NULL)
|
||||||
|
{
|
||||||
|
g_warning ("Style scheme 'classic' cannot be found, check your GtkSourceView installation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_SOURCE_IS_BUFFER (l->data));
|
||||||
|
|
||||||
|
gtk_source_buffer_set_style_scheme (GTK_SOURCE_BUFFER (l->data), style);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_auto_save_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *docs, *l;
|
||||||
|
gboolean auto_save;
|
||||||
|
|
||||||
|
auto_save = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
XedTab *tab = xed_tab_get_from_document (XED_DOCUMENT (l->data));
|
||||||
|
|
||||||
|
xed_tab_set_auto_save_enabled (tab, auto_save);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_auto_save_interval_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *docs, *l;
|
||||||
|
gint auto_save_interval;
|
||||||
|
|
||||||
|
g_settings_get (settings, key, "u", &auto_save_interval);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
XedTab *tab = xed_tab_get_from_document (XED_DOCUMENT (l->data));
|
||||||
|
|
||||||
|
xed_tab_set_auto_save_interval (tab, auto_save_interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_undo_actions_limit_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *docs, *l;
|
||||||
|
gint ul;
|
||||||
|
|
||||||
|
g_settings_get (settings, key, "u", &ul);
|
||||||
|
|
||||||
|
ul = CLAMP (ul, -1, 250);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (l->data), ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_wrap_mode_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GtkWrapMode wrap_mode;
|
||||||
|
GList *views, *l;
|
||||||
|
|
||||||
|
wrap_mode = g_settings_get_enum (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (l->data), wrap_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_tabs_size_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
guint ts;
|
||||||
|
|
||||||
|
g_settings_get (settings, key, "u", &ts);
|
||||||
|
|
||||||
|
ts = CLAMP (ts, 1, 24);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data), ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: insert_spaces and line_numbers are mostly the same it just changes
|
||||||
|
the func called, maybe typedef the func and refactorize? */
|
||||||
|
static void
|
||||||
|
on_insert_spaces_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gboolean spaces;
|
||||||
|
|
||||||
|
spaces = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (l->data), spaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_auto_indent_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gboolean enable;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_auto_indent (GTK_SOURCE_VIEW (l->data), enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_display_line_numbers_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gboolean line_numbers;
|
||||||
|
|
||||||
|
line_numbers = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (l->data), line_numbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_hl_current_line_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gboolean hl;
|
||||||
|
|
||||||
|
hl = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (l->data), hl);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_bracket_matching_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *docs, *l;
|
||||||
|
gboolean enable;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (l->data), enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_display_right_margin_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gboolean display;
|
||||||
|
|
||||||
|
display = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (l->data), display);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_right_margin_position_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *views, *l;
|
||||||
|
gint pos;
|
||||||
|
|
||||||
|
g_settings_get (settings, key, "u", &pos);
|
||||||
|
|
||||||
|
pos = CLAMP (pos, 1, 160);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_right_margin_position (GTK_SOURCE_VIEW (l->data), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_smart_home_end_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GtkSourceSmartHomeEndType smart_he;
|
||||||
|
GList *views, *l;
|
||||||
|
|
||||||
|
smart_he = g_settings_get_enum (settings, key);
|
||||||
|
|
||||||
|
views = xed_app_get_views (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = views; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW (l->data), smart_he);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (views);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_syntax_highlighting_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
const GList *windows;
|
||||||
|
GList *docs, *l;
|
||||||
|
gboolean enable;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (l->data), enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
|
||||||
|
/* update the sensitivity of the Higlight Mode menu item */
|
||||||
|
windows = xed_app_get_windows (xed_app_get_default ());
|
||||||
|
while (windows != NULL)
|
||||||
|
{
|
||||||
|
GtkUIManager *ui;
|
||||||
|
GtkAction *a;
|
||||||
|
|
||||||
|
ui = xed_window_get_ui_manager (XED_WINDOW (windows->data));
|
||||||
|
|
||||||
|
a = gtk_ui_manager_get_action (ui, "/MenuBar/ViewMenu/ViewHighlightModeMenu");
|
||||||
|
|
||||||
|
gtk_action_set_sensitive (a, enable);
|
||||||
|
|
||||||
|
windows = g_list_next (windows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_search_highlighting_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
GList *docs, *l;
|
||||||
|
gboolean enable;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
docs = xed_app_get_documents (xed_app_get_default ());
|
||||||
|
|
||||||
|
for (l = docs; l != NULL; l = g_list_next (l))
|
||||||
|
{
|
||||||
|
xed_document_set_enable_search_highlighting (XED_DOCUMENT (l->data), enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (docs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_enable_tab_scrolling_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
const GList *windows;
|
||||||
|
gboolean enable;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
windows = xed_app_get_windows (xed_app_get_default ());
|
||||||
|
while (windows != NULL)
|
||||||
|
{
|
||||||
|
XedNotebook *notebook;
|
||||||
|
|
||||||
|
notebook = XED_NOTEBOOK (_xed_window_get_notebook (windows->data));
|
||||||
|
xed_notebook_set_tab_scrolling_enabled (notebook, enable);
|
||||||
|
|
||||||
|
windows = g_list_next (windows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_max_recents_changed (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
XedSettings *xs)
|
||||||
|
{
|
||||||
|
/* FIXME: we have no way at the moment to trigger the
|
||||||
|
* update of the inline recents in the File menu */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_settings_init (XedSettings *xs)
|
||||||
|
{
|
||||||
|
xs->priv = XED_SETTINGS_GET_PRIVATE (xs);
|
||||||
|
|
||||||
|
xs->priv->old_scheme = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize (XedSettings *xs)
|
||||||
|
{
|
||||||
|
GSettings *prefs;
|
||||||
|
|
||||||
|
prefs = g_settings_get_child (G_SETTINGS (xs), "preferences");
|
||||||
|
xs->priv->editor = g_settings_get_child (prefs, "editor");
|
||||||
|
xs->priv->ui = g_settings_get_child (prefs, "ui");
|
||||||
|
g_object_unref (prefs);
|
||||||
|
xs->priv->plugins = g_settings_get_child (G_SETTINGS (xs), "plugins");
|
||||||
|
|
||||||
|
/* Load settings */
|
||||||
|
xs->priv->interface = g_settings_new ("org.gnome.desktop.interface");
|
||||||
|
|
||||||
|
g_signal_connect (xs->priv->interface, "changed",
|
||||||
|
G_CALLBACK (on_system_font_changed), xs);
|
||||||
|
|
||||||
|
/* editor changes */
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::use-default-font",
|
||||||
|
G_CALLBACK (on_use_default_font_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::editor-font",
|
||||||
|
G_CALLBACK (on_editor_font_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::scheme",
|
||||||
|
G_CALLBACK (on_scheme_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::auto-save",
|
||||||
|
G_CALLBACK (on_auto_save_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::auto-save-interval",
|
||||||
|
G_CALLBACK (on_auto_save_interval_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::undo-actions-limit",
|
||||||
|
G_CALLBACK (on_undo_actions_limit_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::wrap-mode",
|
||||||
|
G_CALLBACK (on_wrap_mode_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::tabs-size",
|
||||||
|
G_CALLBACK (on_tabs_size_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::insert-spaces",
|
||||||
|
G_CALLBACK (on_insert_spaces_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::auto-indent",
|
||||||
|
G_CALLBACK (on_auto_indent_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::display-line-numbers",
|
||||||
|
G_CALLBACK (on_display_line_numbers_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::highlight-current-line",
|
||||||
|
G_CALLBACK (on_hl_current_line_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::bracket-matching",
|
||||||
|
G_CALLBACK (on_bracket_matching_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::display-right-margin",
|
||||||
|
G_CALLBACK (on_display_right_margin_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::right-margin-position",
|
||||||
|
G_CALLBACK (on_right_margin_position_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::smart-home-end",
|
||||||
|
G_CALLBACK (on_smart_home_end_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::syntax-highlighting",
|
||||||
|
G_CALLBACK (on_syntax_highlighting_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->editor, "changed::search-highlighting",
|
||||||
|
G_CALLBACK (on_search_highlighting_changed), xs);
|
||||||
|
g_signal_connect (xs->priv->ui, "changed::enable-tab-scrolling",
|
||||||
|
G_CALLBACK (on_enable_tab_scrolling_changed), xs);
|
||||||
|
|
||||||
|
/* ui changes */
|
||||||
|
g_signal_connect (xs->priv->ui, "changed::max-recents",
|
||||||
|
G_CALLBACK (on_max_recents_changed), xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_settings_class_init (XedSettingsClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = xed_settings_finalize;
|
||||||
|
object_class->dispose = xed_settings_dispose;
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (XedSettingsPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
GSettings *
|
||||||
|
xed_settings_new ()
|
||||||
|
{
|
||||||
|
XedSettings *settings;
|
||||||
|
|
||||||
|
settings = g_object_new (XED_TYPE_SETTINGS,
|
||||||
|
"schema", "org.x.editor",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
initialize (settings);
|
||||||
|
|
||||||
|
return G_SETTINGS (settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
xed_settings_get_system_font (XedSettings *xs)
|
||||||
|
{
|
||||||
|
gchar *system_font;
|
||||||
|
|
||||||
|
g_return_val_if_fail (XED_IS_SETTINGS (xs), NULL);
|
||||||
|
|
||||||
|
system_font = g_settings_get_string (xs->priv->interface, "monospace-font-name");
|
||||||
|
|
||||||
|
return system_font;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
xed_settings_get_list (GSettings *settings,
|
||||||
|
const gchar *key)
|
||||||
|
{
|
||||||
|
GSList *list = NULL;
|
||||||
|
gchar **values;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
|
||||||
|
g_return_val_if_fail (key != NULL, NULL);
|
||||||
|
|
||||||
|
values = g_settings_get_strv (settings, key);
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (values[i] != NULL)
|
||||||
|
{
|
||||||
|
list = g_slist_prepend (list, values[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (values);
|
||||||
|
|
||||||
|
return g_slist_reverse (list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xed_settings_set_list (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
const GSList *list)
|
||||||
|
{
|
||||||
|
gchar **values = NULL;
|
||||||
|
const GSList *l;
|
||||||
|
|
||||||
|
g_return_if_fail (G_IS_SETTINGS (settings));
|
||||||
|
g_return_if_fail (key != NULL);
|
||||||
|
|
||||||
|
if (list != NULL)
|
||||||
|
{
|
||||||
|
gint i, len;
|
||||||
|
|
||||||
|
len = g_slist_length ((GSList *)list);
|
||||||
|
values = g_new (gchar *, len + 1);
|
||||||
|
|
||||||
|
for (l = list, i = 0; l != NULL; l = g_slist_next (l), i++)
|
||||||
|
{
|
||||||
|
values[i] = l->data;
|
||||||
|
}
|
||||||
|
values [i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_settings_set_strv (settings, key, (const gchar * const *)values);
|
||||||
|
g_free (values);
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
* xed-settings.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 - Ignacio Casal Quinteiro
|
||||||
|
* 2002 - Paolo Maggi
|
||||||
|
*
|
||||||
|
* xed is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* xed is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with xed; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __XED_SETTINGS_H__
|
||||||
|
#define __XED_SETTINGS_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include "xed-app.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define XED_TYPE_SETTINGS (xed_settings_get_type ())
|
||||||
|
#define XED_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_SETTINGS, XedSettings))
|
||||||
|
#define XED_SETTINGS_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_SETTINGS, XedSettings const))
|
||||||
|
#define XED_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_SETTINGS, XedSettingsClass))
|
||||||
|
#define XED_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_SETTINGS))
|
||||||
|
#define XED_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SETTINGS))
|
||||||
|
#define XED_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_SETTINGS, XedSettingsClass))
|
||||||
|
|
||||||
|
typedef struct _XedSettings XedSettings;
|
||||||
|
typedef struct _XedSettingsClass XedSettingsClass;
|
||||||
|
typedef struct _XedSettingsPrivate XedSettingsPrivate;
|
||||||
|
|
||||||
|
struct _XedSettings
|
||||||
|
{
|
||||||
|
GSettings parent;
|
||||||
|
|
||||||
|
XedSettingsPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _XedSettingsClass
|
||||||
|
{
|
||||||
|
GSettingsClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
// typedef enum {
|
||||||
|
// XED_TOOLBAR_SYSTEM = 0,
|
||||||
|
// XED_TOOLBAR_ICONS,
|
||||||
|
// XED_TOOLBAR_ICONS_AND_TEXT,
|
||||||
|
// XED_TOOLBAR_ICONS_BOTH_HORIZ
|
||||||
|
// } XedToolbarSetting;
|
||||||
|
|
||||||
|
GType xed_settings_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GSettings *xed_settings_new (void);
|
||||||
|
|
||||||
|
// XedLockdownMask xed_settings_get_lockdown (XedSettings *xs);
|
||||||
|
|
||||||
|
gchar *xed_settings_get_system_font (XedSettings *xs);
|
||||||
|
|
||||||
|
/* Utility functions */
|
||||||
|
GSList *xed_settings_get_list (GSettings *settings,
|
||||||
|
const gchar *key);
|
||||||
|
|
||||||
|
void xed_settings_set_list (GSettings *settings,
|
||||||
|
const gchar *key,
|
||||||
|
const GSList *list);
|
||||||
|
|
||||||
|
/* key constants */
|
||||||
|
#define XED_SETTINGS_USE_DEFAULT_FONT "use-default-font"
|
||||||
|
#define XED_SETTINGS_EDITOR_FONT "editor-font"
|
||||||
|
#define XED_SETTINGS_SCHEME "scheme"
|
||||||
|
#define XED_SETTINGS_CREATE_BACKUP_COPY "create-backup-copy"
|
||||||
|
#define XED_SETTINGS_AUTO_SAVE "auto-save"
|
||||||
|
#define XED_SETTINGS_AUTO_SAVE_INTERVAL "auto-save-interval"
|
||||||
|
#define XED_SETTINGS_UNDO_ACTIONS_LIMIT "undo-actions-limit"
|
||||||
|
#define XED_SETTINGS_MAX_UNDO_ACTIONS "max-undo-actions"
|
||||||
|
#define XED_SETTINGS_WRAP_MODE "wrap-mode"
|
||||||
|
#define XED_SETTINGS_TABS_SIZE "tabs-size"
|
||||||
|
#define XED_SETTINGS_INSERT_SPACES "insert-spaces"
|
||||||
|
#define XED_SETTINGS_AUTO_INDENT "auto-indent"
|
||||||
|
#define XED_SETTINGS_DISPLAY_LINE_NUMBERS "display-line-numbers"
|
||||||
|
#define XED_SETTINGS_HIGHLIGHT_CURRENT_LINE "highlight-current-line"
|
||||||
|
#define XED_SETTINGS_BRACKET_MATCHING "bracket-matching"
|
||||||
|
#define XED_SETTINGS_DISPLAY_RIGHT_MARGIN "display-right-margin"
|
||||||
|
#define XED_SETTINGS_RIGHT_MARGIN_POSITION "right-margin-position"
|
||||||
|
#define XED_SETTINGS_SMART_HOME_END "smart-home-end"
|
||||||
|
#define XED_SETTINGS_WRITABLE_VFS_SCHEMES "writable-vfs-schemes"
|
||||||
|
#define XED_SETTINGS_RESTORE_CURSOR_POSITION "restore-cursor-position"
|
||||||
|
#define XED_SETTINGS_SYNTAX_HIGHLIGHTING "syntax-highlighting"
|
||||||
|
#define XED_SETTINGS_SEARCH_HIGHLIGHTING "search-highlighting"
|
||||||
|
#define XED_SETTINGS_ENABLE_TAB_SCROLLING "enable-tab-scrolling"
|
||||||
|
#define XED_SETTINGS_TOOLBAR_VISIBLE "toolbar-visible"
|
||||||
|
#define XED_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
|
||||||
|
#define XED_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
|
||||||
|
#define XED_SETTINGS_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
||||||
|
#define XED_SETTINGS_MAX_RECENTS "max-recents"
|
||||||
|
#define XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING "print-syntax-highlighting"
|
||||||
|
#define XED_SETTINGS_PRINT_HEADER "print-header"
|
||||||
|
#define XED_SETTINGS_PRINT_WRAP_MODE "print-wrap-mode"
|
||||||
|
#define XED_SETTINGS_PRINT_LINE_NUMBERS "print-line-numbers"
|
||||||
|
#define XED_SETTINGS_PRINT_FONT_BODY_PANGO "print-font-body-pango"
|
||||||
|
#define XED_SETTINGS_PRINT_FONT_HEADER_PANGO "print-font-header-pango"
|
||||||
|
#define XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO "print-font-numbers-pango"
|
||||||
|
#define XED_SETTINGS_ENCODING_AUTO_DETECTED "auto-detected"
|
||||||
|
#define XED_SETTINGS_ENCODING_SHOWN_IN_MENU "shown-in-menu"
|
||||||
|
#define XED_SETTINGS_ACTIVE_PLUGINS "active-plugins"
|
||||||
|
|
||||||
|
/* window state keys */
|
||||||
|
#define XED_SETTINGS_WINDOW_STATE "state"
|
||||||
|
#define XED_SETTINGS_WINDOW_SIZE "size"
|
||||||
|
#define XED_SETTINGS_SIDE_PANEL_SIZE "side-panel-size"
|
||||||
|
#define XED_SETTINGS_SIDE_PANEL_ACTIVE_PAGE "side-panel-active-page"
|
||||||
|
#define XED_SETTINGS_BOTTOM_PANEL_SIZE "bottom-panel-size"
|
||||||
|
#define XED_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE "bottom-panel-active-page"
|
||||||
|
#define XED_SETTINGS_ACTIVE_FILE_FILTER "filter-id"
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __XED_SETTINGS_H__ */
|
|
@ -42,7 +42,6 @@
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
#include "xed-style-scheme-manager.h"
|
#include "xed-style-scheme-manager.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
|
||||||
static GtkSourceStyleSchemeManager *style_scheme_manager = NULL;
|
static GtkSourceStyleSchemeManager *style_scheme_manager = NULL;
|
||||||
|
@ -62,7 +61,7 @@ get_xed_styles_path (void)
|
||||||
NULL);
|
NULL);
|
||||||
g_free (config_dir);
|
g_free (config_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ add_xed_styles_path (GtkSourceStyleSchemeManager *mgr)
|
||||||
{
|
{
|
||||||
gtk_source_style_scheme_manager_append_search_path (mgr, dir);
|
gtk_source_style_scheme_manager_append_search_path (mgr, dir);
|
||||||
g_free (dir);
|
g_free (dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkSourceStyleSchemeManager *
|
GtkSourceStyleSchemeManager *
|
||||||
|
@ -113,12 +112,12 @@ xed_style_scheme_manager_list_schemes_sorted (GtkSourceStyleSchemeManager *manag
|
||||||
g_return_val_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_MANAGER (manager), NULL);
|
g_return_val_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_MANAGER (manager), NULL);
|
||||||
|
|
||||||
scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
|
scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
|
||||||
|
|
||||||
while (*scheme_ids != NULL)
|
while (*scheme_ids != NULL)
|
||||||
{
|
{
|
||||||
GtkSourceStyleScheme *scheme;
|
GtkSourceStyleScheme *scheme;
|
||||||
|
|
||||||
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
|
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
|
||||||
*scheme_ids);
|
*scheme_ids);
|
||||||
|
|
||||||
schemes = g_slist_prepend (schemes, scheme);
|
schemes = g_slist_prepend (schemes, scheme);
|
||||||
|
@ -365,9 +364,9 @@ _xed_style_scheme_manager_uninstall_scheme (GtkSourceStyleSchemeManager *manager
|
||||||
|
|
||||||
if (g_unlink (filename) == -1)
|
if (g_unlink (filename) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Reload the available style schemes */
|
/* Reload the available style schemes */
|
||||||
gtk_source_style_scheme_manager_force_rescan (manager);
|
gtk_source_style_scheme_manager_force_rescan (manager);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@
|
||||||
#include "xed-print-preview.h"
|
#include "xed-print-preview.h"
|
||||||
#include "xed-progress-message-area.h"
|
#include "xed-progress-message-area.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define XED_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_TAB, XedTabPrivate))
|
#define XED_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_TAB, XedTabPrivate))
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@
|
||||||
|
|
||||||
struct _XedTabPrivate
|
struct _XedTabPrivate
|
||||||
{
|
{
|
||||||
|
GSettings *editor;
|
||||||
|
|
||||||
XedTabState state;
|
XedTabState state;
|
||||||
|
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
|
@ -73,7 +75,7 @@ struct _XedTabPrivate
|
||||||
|
|
||||||
XedDocumentSaveFlags save_flags;
|
XedDocumentSaveFlags save_flags;
|
||||||
|
|
||||||
gint auto_save_interval;
|
guint auto_save_interval;
|
||||||
guint auto_save_timeout;
|
guint auto_save_timeout;
|
||||||
|
|
||||||
gint not_editable : 1;
|
gint not_editable : 1;
|
||||||
|
@ -223,6 +225,8 @@ xed_tab_dispose (GObject *object)
|
||||||
tab->priv->tmp_save_location = NULL;
|
tab->priv->tmp_save_location = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&tab->priv->editor);
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_tab_parent_class)->dispose (object);
|
G_OBJECT_CLASS (xed_tab_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +376,9 @@ set_view_properties_according_to_state (XedTab *tab,
|
||||||
XedTabState state)
|
XedTabState state)
|
||||||
{
|
{
|
||||||
gboolean val;
|
gboolean val;
|
||||||
|
gboolean hl_current_line;
|
||||||
|
|
||||||
|
hl_current_line = g_settings_get_boolean (tab->priv->editor, XED_SETTINGS_HIGHLIGHT_CURRENT_LINE);
|
||||||
val = ((state == XED_TAB_STATE_NORMAL) && (tab->priv->print_preview == NULL) && !tab->priv->not_editable);
|
val = ((state == XED_TAB_STATE_NORMAL) && (tab->priv->print_preview == NULL) && !tab->priv->not_editable);
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (tab->priv->view), val);
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (tab->priv->view), val);
|
||||||
|
|
||||||
|
@ -381,7 +387,7 @@ set_view_properties_according_to_state (XedTab *tab,
|
||||||
|
|
||||||
val = ((state != XED_TAB_STATE_LOADING) &&
|
val = ((state != XED_TAB_STATE_LOADING) &&
|
||||||
(state != XED_TAB_STATE_CLOSING) &&
|
(state != XED_TAB_STATE_CLOSING) &&
|
||||||
(xed_prefs_manager_get_highlight_current_line ()));
|
(hl_current_line));
|
||||||
gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (tab->priv->view), val);
|
gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (tab->priv->view), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,15 +1424,15 @@ xed_tab_init (XedTab *tab)
|
||||||
{
|
{
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
|
gboolean auto_save;
|
||||||
|
guint auto_save_interval;
|
||||||
|
|
||||||
tab->priv = XED_TAB_GET_PRIVATE (tab);
|
tab->priv = XED_TAB_GET_PRIVATE (tab);
|
||||||
|
|
||||||
|
tab->priv->editor = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
tab->priv->state = XED_TAB_STATE_NORMAL;
|
tab->priv->state = XED_TAB_STATE_NORMAL;
|
||||||
|
|
||||||
tab->priv->not_editable = FALSE;
|
tab->priv->not_editable = FALSE;
|
||||||
|
|
||||||
tab->priv->save_flags = 0;
|
tab->priv->save_flags = 0;
|
||||||
|
|
||||||
tab->priv->ask_if_externally_modified = TRUE;
|
tab->priv->ask_if_externally_modified = TRUE;
|
||||||
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (tab), GTK_ORIENTATION_VERTICAL);
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (tab), GTK_ORIENTATION_VERTICAL);
|
||||||
|
@ -1438,14 +1444,17 @@ xed_tab_init (XedTab *tab)
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
|
||||||
/* Manage auto save data */
|
/* Manage auto save data */
|
||||||
tab->priv->auto_save = xed_prefs_manager_get_auto_save ();
|
auto_save = g_settings_get_boolean (tab->priv->editor, XED_SETTINGS_AUTO_SAVE);
|
||||||
|
auto_save_interval = g_settings_get_uint (tab->priv->editor, XED_SETTINGS_AUTO_SAVE_INTERVAL);
|
||||||
|
tab->priv->auto_save = auto_save;
|
||||||
tab->priv->auto_save = (tab->priv->auto_save != FALSE);
|
tab->priv->auto_save = (tab->priv->auto_save != FALSE);
|
||||||
|
|
||||||
tab->priv->auto_save_interval = xed_prefs_manager_get_auto_save_interval ();
|
tab->priv->auto_save_interval = auto_save_interval;
|
||||||
|
/*FIXME
|
||||||
if (tab->priv->auto_save_interval <= 0)
|
if (tab->priv->auto_save_interval <= 0)
|
||||||
{
|
{
|
||||||
tab->priv->auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL;
|
tab->priv->auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/* Create the view */
|
/* Create the view */
|
||||||
doc = xed_document_new ();
|
doc = xed_document_new ();
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
|
|
||||||
#include "xed-document.h"
|
#include "xed-document.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
|
|
||||||
/* For the workspace/viewport stuff */
|
/* For the workspace/viewport stuff */
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <atk/atk.h>
|
#include <atk/atk.h>
|
||||||
#include <xed/xed-encodings.h>
|
#include <xed/xed-encodings.h>
|
||||||
|
#include <gtksourceview/gtksourceview.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
1026
xed/xed-view.c
1026
xed/xed-view.c
File diff suppressed because it is too large
Load Diff
|
@ -34,8 +34,8 @@
|
||||||
#include <libpeas/peas-extension-set.h>
|
#include <libpeas/peas-extension-set.h>
|
||||||
|
|
||||||
#include "xed/xed-window.h"
|
#include "xed/xed-window.h"
|
||||||
#include "xed-prefs-manager.h"
|
|
||||||
#include "xed-message-bus.h"
|
#include "xed-message-bus.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -43,38 +43,42 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
struct _XedWindowPrivate
|
struct _XedWindowPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *notebook;
|
GSettings *editor_settings;
|
||||||
|
GSettings *ui_settings;
|
||||||
|
GSettings *window_settings;
|
||||||
|
|
||||||
GtkWidget *side_panel;
|
GtkWidget *notebook;
|
||||||
GtkWidget *bottom_panel;
|
|
||||||
|
|
||||||
GtkWidget *hpaned;
|
GtkWidget *side_panel;
|
||||||
GtkWidget *vpaned;
|
GtkWidget *bottom_panel;
|
||||||
|
|
||||||
GtkWidget *tab_width_combo;
|
GtkWidget *hpaned;
|
||||||
GtkWidget *language_combo;
|
GtkWidget *vpaned;
|
||||||
GtkWidget *show_side_pane_button;
|
|
||||||
GtkWidget *show_bottom_pane_button;
|
GtkWidget *tab_width_combo;
|
||||||
GtkWidget *bottom_pane_button_revealer;
|
GtkWidget *language_combo;
|
||||||
|
GtkWidget *show_side_pane_button;
|
||||||
|
GtkWidget *show_bottom_pane_button;
|
||||||
|
GtkWidget *bottom_pane_button_revealer;
|
||||||
|
|
||||||
XedMessageBus *message_bus;
|
XedMessageBus *message_bus;
|
||||||
PeasExtensionSet *extensions;
|
PeasExtensionSet *extensions;
|
||||||
|
|
||||||
/* Widgets for fullscreen mode */
|
/* Widgets for fullscreen mode */
|
||||||
GtkWidget *fullscreen_controls;
|
GtkWidget *fullscreen_controls;
|
||||||
GtkWidget *fullscreen_controls_container;
|
GtkWidget *fullscreen_controls_container;
|
||||||
guint fullscreen_animation_timeout_id;
|
guint fullscreen_animation_timeout_id;
|
||||||
gboolean fullscreen_animation_enter;
|
gboolean fullscreen_animation_enter;
|
||||||
|
|
||||||
/* statusbar and context ids for statusbar messages */
|
/* statusbar and context ids for statusbar messages */
|
||||||
GtkWidget *statusbar;
|
GtkWidget *statusbar;
|
||||||
GtkWidget *searchbar;
|
GtkWidget *searchbar;
|
||||||
guint generic_message_cid;
|
guint generic_message_cid;
|
||||||
guint tip_message_cid;
|
guint tip_message_cid;
|
||||||
guint tab_width_id;
|
guint tab_width_id;
|
||||||
guint spaces_instead_of_tabs_id;
|
guint spaces_instead_of_tabs_id;
|
||||||
guint language_changed_id;
|
guint language_changed_id;
|
||||||
guint use_word_wrap_id;
|
guint use_word_wrap_id;
|
||||||
|
|
||||||
/* Menus & Toolbars */
|
/* Menus & Toolbars */
|
||||||
GtkUIManager *manager;
|
GtkUIManager *manager;
|
||||||
|
@ -94,28 +98,28 @@ struct _XedWindowPrivate
|
||||||
guint recents_menu_ui_id;
|
guint recents_menu_ui_id;
|
||||||
gulong recents_handler_id;
|
gulong recents_handler_id;
|
||||||
|
|
||||||
XedTab *active_tab;
|
XedTab *active_tab;
|
||||||
gint num_tabs;
|
gint num_tabs;
|
||||||
|
|
||||||
gint num_tabs_with_error;
|
gint num_tabs_with_error;
|
||||||
|
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
GdkWindowState window_state;
|
GdkWindowState window_state;
|
||||||
|
|
||||||
gint side_panel_size;
|
gint side_panel_size;
|
||||||
gint bottom_panel_size;
|
gint bottom_panel_size;
|
||||||
|
|
||||||
XedWindowState state;
|
XedWindowState state;
|
||||||
|
|
||||||
gint bottom_panel_item_removed_handler_id;
|
gint bottom_panel_item_removed_handler_id;
|
||||||
|
|
||||||
GtkWindowGroup *window_group;
|
GtkWindowGroup *window_group;
|
||||||
|
|
||||||
GFile *default_location;
|
GFile *default_location;
|
||||||
|
|
||||||
gboolean removing_tabs : 1;
|
gboolean removing_tabs : 1;
|
||||||
gboolean dispose_has_run : 1;
|
gboolean dispose_has_run : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
176
xed/xed-window.c
176
xed/xed-window.c
|
@ -22,7 +22,6 @@
|
||||||
#include "xed-commands.h"
|
#include "xed-commands.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-language-manager.h"
|
#include "xed-language-manager.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-panel.h"
|
#include "xed-panel.h"
|
||||||
#include "xed-documents-panel.h"
|
#include "xed-documents-panel.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
#include "xed-status-combo-box.h"
|
#include "xed-status-combo-box.h"
|
||||||
|
#include "xed-settings.h"
|
||||||
|
|
||||||
#define LANGUAGE_NONE (const gchar *)"LangNone"
|
#define LANGUAGE_NONE (const gchar *)"LangNone"
|
||||||
#define XED_UIFILE "xed-ui.xml"
|
#define XED_UIFILE "xed-ui.xml"
|
||||||
|
@ -38,6 +38,9 @@
|
||||||
|
|
||||||
#define FULLSCREEN_ANIMATION_SPEED 4
|
#define FULLSCREEN_ANIMATION_SPEED 4
|
||||||
|
|
||||||
|
#define XED_WINDOW_DEFAULT_WIDTH 650
|
||||||
|
#define XED_WINDOW_DEFAULT_HEIGHT 500
|
||||||
|
|
||||||
#define XED_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_WINDOW, XedWindowPrivate))
|
#define XED_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_WINDOW, XedWindowPrivate))
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
|
@ -69,9 +72,9 @@ G_DEFINE_TYPE(XedWindow, xed_window, GTK_TYPE_WINDOW)
|
||||||
static void recent_manager_changed (GtkRecentManager *manager, XedWindow *window);
|
static void recent_manager_changed (GtkRecentManager *manager, XedWindow *window);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_window_get_property (GObject *object,
|
xed_window_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
XedWindow *window = XED_WINDOW(object);
|
XedWindow *window = XED_WINDOW(object);
|
||||||
|
@ -90,41 +93,33 @@ xed_window_get_property (GObject *object,
|
||||||
static void
|
static void
|
||||||
save_panes_state (XedWindow *window)
|
save_panes_state (XedWindow *window)
|
||||||
{
|
{
|
||||||
gint pane_page;
|
gint panel_page;
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
if (xed_prefs_manager_window_size_can_set ())
|
if (window->priv->side_panel_size > 0)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_window_size (window->priv->width, window->priv->height);
|
g_settings_set_int (window->priv->window_settings, XED_SETTINGS_SIDE_PANEL_SIZE, window->priv->side_panel_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xed_prefs_manager_window_state_can_set ())
|
panel_page = _xed_panel_get_active_item_id (XED_PANEL (window->priv->side_panel));
|
||||||
|
if (panel_page != 0)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_window_state (window->priv->window_state);
|
g_settings_set_int (window->priv->window_settings, XED_SETTINGS_SIDE_PANEL_ACTIVE_PAGE, panel_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((window->priv->side_panel_size > 0) && xed_prefs_manager_side_panel_size_can_set ())
|
if (window->priv->bottom_panel_size > 0)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_side_panel_size (window->priv->side_panel_size);
|
g_settings_set_int (window->priv->window_settings, XED_SETTINGS_BOTTOM_PANEL_SIZE, window->priv->bottom_panel_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pane_page = _xed_panel_get_active_item_id (XED_PANEL(window->priv->side_panel));
|
panel_page = _xed_panel_get_active_item_id (XED_PANEL(window->priv->bottom_panel));
|
||||||
if (pane_page != 0 && xed_prefs_manager_side_panel_active_page_can_set ())
|
if (panel_page != 0)
|
||||||
{
|
{
|
||||||
xed_prefs_manager_set_side_panel_active_page (pane_page);
|
g_settings_set_int (window->priv->window_settings, XED_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE, panel_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((window->priv->bottom_panel_size > 0) && xed_prefs_manager_bottom_panel_size_can_set ())
|
g_settings_apply (window->priv->window_settings);
|
||||||
{
|
|
||||||
xed_prefs_manager_set_bottom_panel_size (window->priv->bottom_panel_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
pane_page = _xed_panel_get_active_item_id (XED_PANEL(window->priv->bottom_panel));
|
|
||||||
if (pane_page != 0 && xed_prefs_manager_bottom_panel_active_page_can_set ())
|
|
||||||
{
|
|
||||||
xed_prefs_manager_set_bottom_panel_active_page (pane_page);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -141,6 +136,26 @@ on_key_pressed (GtkWidget *widget,
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_window_state (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
XedWindow *window = XED_WINDOW (widget);
|
||||||
|
|
||||||
|
if ((window->priv->window_state &
|
||||||
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
|
||||||
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
|
window->priv->width = allocation.width;
|
||||||
|
window->priv->height = allocation.height;
|
||||||
|
|
||||||
|
g_settings_set (window->priv->window_settings, XED_SETTINGS_WINDOW_SIZE,
|
||||||
|
"(ii)", window->priv->width, window->priv->height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_window_dispose (GObject *object)
|
xed_window_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -168,6 +183,7 @@ xed_window_dispose (GObject *object)
|
||||||
* for this window, but only once */
|
* for this window, but only once */
|
||||||
if (!window->priv->dispose_has_run)
|
if (!window->priv->dispose_has_run)
|
||||||
{
|
{
|
||||||
|
save_window_state (GTK_WIDGET (window));
|
||||||
save_panes_state (window);
|
save_panes_state (window);
|
||||||
|
|
||||||
/* Note that unreffing the extension will automatically remove
|
/* Note that unreffing the extension will automatically remove
|
||||||
|
@ -204,6 +220,11 @@ xed_window_dispose (GObject *object)
|
||||||
g_clear_object (&window->priv->window_group);
|
g_clear_object (&window->priv->window_group);
|
||||||
g_clear_object (&window->priv->default_location);
|
g_clear_object (&window->priv->default_location);
|
||||||
|
|
||||||
|
/* We must free the settings after saving the panels */
|
||||||
|
g_clear_object (&window->priv->editor_settings);
|
||||||
|
g_clear_object (&window->priv->ui_settings);
|
||||||
|
g_clear_object (&window->priv->window_settings);
|
||||||
|
|
||||||
/* Now that there have broken some reference loops, force collection again. */
|
/* Now that there have broken some reference loops, force collection again. */
|
||||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||||
|
|
||||||
|
@ -219,26 +240,29 @@ xed_window_finalize (GObject *object)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
xed_window_window_state_event (GtkWidget *widget,
|
xed_window_window_state_event (GtkWidget *widget,
|
||||||
GdkEventWindowState *event)
|
GdkEventWindowState *event)
|
||||||
{
|
{
|
||||||
XedWindow *window = XED_WINDOW(widget);
|
XedWindow *window = XED_WINDOW (widget);
|
||||||
|
|
||||||
window->priv->window_state = event->new_window_state;
|
window->priv->window_state = event->new_window_state;
|
||||||
if (event->changed_mask & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
|
g_settings_set_int (window->priv->window_settings, XED_SETTINGS_WINDOW_STATE, window->priv->state);
|
||||||
{
|
|
||||||
gboolean show;
|
|
||||||
show = !(event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
xed_window_configure_event (GtkWidget *widget,
|
xed_window_configure_event (GtkWidget *widget,
|
||||||
GdkEventConfigure *event)
|
GdkEventConfigure *event)
|
||||||
{
|
{
|
||||||
XedWindow *window = XED_WINDOW(widget);
|
XedWindow *window = XED_WINDOW (widget);
|
||||||
window->priv->width = event->width;
|
|
||||||
window->priv->height = event->height;
|
if (gtk_widget_get_realized (widget) &&
|
||||||
|
window->priv->state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN) == 0)
|
||||||
|
{
|
||||||
|
save_window_state (widget);
|
||||||
|
}
|
||||||
|
|
||||||
return GTK_WIDGET_CLASS (xed_window_parent_class)->configure_event (widget, event);
|
return GTK_WIDGET_CLASS (xed_window_parent_class)->configure_event (widget, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +422,7 @@ set_toolbar_style (XedWindow *window,
|
||||||
|
|
||||||
if (origin == NULL)
|
if (origin == NULL)
|
||||||
{
|
{
|
||||||
visible = xed_prefs_manager_get_toolbar_visible ();
|
visible = g_settings_get_boolean (window->priv->ui_settings, XED_SETTINGS_TOOLBAR_VISIBLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -417,9 +441,9 @@ set_toolbar_style (XedWindow *window,
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewToolbar");
|
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewToolbar");
|
||||||
|
|
||||||
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION(action)) != visible)
|
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
|
||||||
{
|
{
|
||||||
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), visible);
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
return visible;
|
return visible;
|
||||||
|
@ -524,7 +548,7 @@ set_paste_sensitivity_according_to_clipboard (XedWindow *window,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_sensitivity_according_to_tab (XedWindow *window,
|
set_sensitivity_according_to_tab (XedWindow *window,
|
||||||
XedTab *tab)
|
XedTab *tab)
|
||||||
{
|
{
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
XedView *view;
|
XedView *view;
|
||||||
|
@ -534,11 +558,14 @@ set_sensitivity_according_to_tab (XedWindow *window,
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
XedTabState state;
|
XedTabState state;
|
||||||
GtkClipboard *clipboard;
|
GtkClipboard *clipboard;
|
||||||
|
gboolean enable_syntax_hl;
|
||||||
|
|
||||||
g_return_if_fail(XED_TAB (tab));
|
g_return_if_fail (XED_TAB (tab));
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
|
enable_syntax_hl = g_settings_get_boolean (window->priv->editor_settings, XED_SETTINGS_SYNTAX_HIGHLIGHTING);
|
||||||
|
|
||||||
state = xed_tab_get_state (tab);
|
state = xed_tab_get_state (tab);
|
||||||
state_normal = (state == XED_TAB_STATE_NORMAL);
|
state_normal = (state == XED_TAB_STATE_NORMAL);
|
||||||
|
|
||||||
|
@ -631,8 +658,7 @@ set_sensitivity_according_to_tab (XedWindow *window,
|
||||||
gtk_action_set_sensitive (action, (state_normal || state == XED_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
|
gtk_action_set_sensitive (action, (state_normal || state == XED_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->action_group, "ViewHighlightMode");
|
action = gtk_action_group_get_action (window->priv->action_group, "ViewHighlightMode");
|
||||||
gtk_action_set_sensitive (action,
|
gtk_action_set_sensitive (action, (state != XED_TAB_STATE_CLOSING) && enable_syntax_hl);
|
||||||
(state != XED_TAB_STATE_CLOSING) && xed_prefs_manager_get_enable_syntax_highlighting ());
|
|
||||||
|
|
||||||
update_next_prev_doc_sensitivity (window, tab);
|
update_next_prev_doc_sensitivity (window, tab);
|
||||||
|
|
||||||
|
@ -960,11 +986,11 @@ update_recent_files_menu (XedWindow *window)
|
||||||
gint max_recents;
|
gint max_recents;
|
||||||
GList *actions, *l, *items;
|
GList *actions, *l, *items;
|
||||||
GList *filtered_items = NULL;
|
GList *filtered_items = NULL;
|
||||||
gint i;
|
guint i;
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
max_recents = xed_prefs_manager_get_max_recents ();
|
max_recents = g_settings_get_uint (window->priv->ui_settings, XED_SETTINGS_MAX_RECENTS);
|
||||||
|
|
||||||
g_return_if_fail(p->recents_action_group != NULL);
|
g_return_if_fail(p->recents_action_group != NULL);
|
||||||
|
|
||||||
|
@ -1080,10 +1106,7 @@ toolbar_visibility_changed (GtkWidget *toolbar,
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (toolbar);
|
visible = gtk_widget_get_visible (toolbar);
|
||||||
|
|
||||||
if (xed_prefs_manager_toolbar_visible_can_set ())
|
g_settings_set_boolean (window->priv->ui_settings, XED_SETTINGS_TOOLBAR_VISIBLE, visible);
|
||||||
{
|
|
||||||
xed_prefs_manager_set_toolbar_visible (visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewToolbar");
|
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewToolbar");
|
||||||
|
|
||||||
|
@ -1433,9 +1456,10 @@ set_statusbar_style (XedWindow *window,
|
||||||
{
|
{
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
|
|
||||||
if (origin == NULL)
|
if (origin == NULL)
|
||||||
{
|
{
|
||||||
visible = xed_prefs_manager_get_statusbar_visible ();
|
visible = g_settings_get_boolean (window->priv->ui_settings, XED_SETTINGS_STATUSBAR_VISIBLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1470,10 +1494,7 @@ statusbar_visibility_changed (GtkWidget *statusbar,
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (statusbar);
|
visible = gtk_widget_get_visible (statusbar);
|
||||||
|
|
||||||
if (xed_prefs_manager_statusbar_visible_can_set ())
|
g_settings_set_boolean (window->priv->ui_settings, XED_SETTINGS_STATUSBAR_VISIBLE, visible);
|
||||||
{
|
|
||||||
xed_prefs_manager_set_statusbar_visible (visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewStatusbar");
|
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "ViewStatusbar");
|
||||||
|
|
||||||
|
@ -1730,7 +1751,7 @@ clone_window (XedWindow *origin)
|
||||||
if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
|
if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
|
||||||
{
|
{
|
||||||
gint w, h;
|
gint w, h;
|
||||||
xed_prefs_manager_get_default_window_size (&w, &h);
|
_xed_window_get_default_size (&w, &h);
|
||||||
gtk_window_set_default_size (GTK_WINDOW(window), w, h);
|
gtk_window_set_default_size (GTK_WINDOW(window), w, h);
|
||||||
gtk_window_maximize (GTK_WINDOW(window));
|
gtk_window_maximize (GTK_WINDOW(window));
|
||||||
}
|
}
|
||||||
|
@ -3151,10 +3172,7 @@ side_panel_visibility_changed (GtkWidget *side_panel,
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (side_panel);
|
visible = gtk_widget_get_visible (side_panel);
|
||||||
|
|
||||||
if (xed_prefs_manager_side_pane_visible_can_set ())
|
g_settings_set_boolean (window->priv->ui_settings, XED_SETTINGS_SIDE_PANEL_VISIBLE, visible);
|
||||||
{
|
|
||||||
xed_prefs_manager_set_side_pane_visible (visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->panes_action_group, "ViewSidePane");
|
action = gtk_action_group_get_action (window->priv->panes_action_group, "ViewSidePane");
|
||||||
|
|
||||||
|
@ -3196,10 +3214,7 @@ bottom_panel_visibility_changed (XedPanel *bottom_panel,
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (GTK_WIDGET (bottom_panel));
|
visible = gtk_widget_get_visible (GTK_WIDGET (bottom_panel));
|
||||||
|
|
||||||
if (xed_prefs_manager_bottom_panel_visible_can_set ())
|
g_settings_set_boolean (window->priv->ui_settings, XED_SETTINGS_BOTTOM_PANEL_VISIBLE, visible);
|
||||||
{
|
|
||||||
xed_prefs_manager_set_bottom_panel_visible (visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
action = gtk_action_group_get_action (window->priv->panes_action_group, "ViewBottomPane");
|
action = gtk_action_group_get_action (window->priv->panes_action_group, "ViewBottomPane");
|
||||||
|
|
||||||
|
@ -3269,13 +3284,19 @@ static void
|
||||||
init_panels_visibility (XedWindow *window)
|
init_panels_visibility (XedWindow *window)
|
||||||
{
|
{
|
||||||
gint active_page;
|
gint active_page;
|
||||||
|
gboolean side_panel_visible;
|
||||||
|
gboolean bottom_panel_visible;
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
/* side pane */
|
/* side pane */
|
||||||
active_page = xed_prefs_manager_get_side_panel_active_page ();
|
active_page = g_settings_get_int (window->priv->window_settings, XED_SETTINGS_SIDE_PANEL_ACTIVE_PAGE);
|
||||||
_xed_panel_set_active_item_by_id (XED_PANEL (window->priv->side_panel), active_page);
|
_xed_panel_set_active_item_by_id (XED_PANEL (window->priv->side_panel), active_page);
|
||||||
|
|
||||||
if (xed_prefs_manager_get_side_pane_visible ())
|
side_panel_visible = g_settings_get_boolean (window->priv->ui_settings, XED_SETTINGS_SIDE_PANEL_VISIBLE);
|
||||||
|
bottom_panel_visible = g_settings_get_boolean (window->priv->ui_settings, XED_SETTINGS_BOTTOM_PANEL_VISIBLE);
|
||||||
|
|
||||||
|
if (side_panel_visible)
|
||||||
{
|
{
|
||||||
gtk_widget_show (window->priv->side_panel);
|
gtk_widget_show (window->priv->side_panel);
|
||||||
}
|
}
|
||||||
|
@ -3283,10 +3304,10 @@ init_panels_visibility (XedWindow *window)
|
||||||
/* bottom pane, it can be empty */
|
/* bottom pane, it can be empty */
|
||||||
if (xed_panel_get_n_items (XED_PANEL (window->priv->bottom_panel)) > 0)
|
if (xed_panel_get_n_items (XED_PANEL (window->priv->bottom_panel)) > 0)
|
||||||
{
|
{
|
||||||
active_page = xed_prefs_manager_get_bottom_panel_active_page ();
|
active_page = g_settings_get_int (window->priv->window_settings, XED_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE);
|
||||||
_xed_panel_set_active_item_by_id (XED_PANEL(window->priv->bottom_panel), active_page);
|
_xed_panel_set_active_item_by_id (XED_PANEL(window->priv->bottom_panel), active_page);
|
||||||
|
|
||||||
if (xed_prefs_manager_get_bottom_panel_visible ())
|
if (bottom_panel_visible)
|
||||||
{
|
{
|
||||||
gtk_widget_show (window->priv->bottom_panel);
|
gtk_widget_show (window->priv->bottom_panel);
|
||||||
}
|
}
|
||||||
|
@ -3375,7 +3396,7 @@ add_notebook (XedWindow *window,
|
||||||
gtk_paned_pack1 (GTK_PANED(window->priv->vpaned), notebook, TRUE, TRUE);
|
gtk_paned_pack1 (GTK_PANED(window->priv->vpaned), notebook, TRUE, TRUE);
|
||||||
gtk_widget_show (notebook);
|
gtk_widget_show (notebook);
|
||||||
|
|
||||||
xed_notebook_set_tab_scrolling_enabled (XED_NOTEBOOK (notebook), xed_prefs_manager_get_enable_tab_scrolling ());
|
// xed_notebook_set_tab_scrolling_enabled (XED_NOTEBOOK (notebook), xed_prefs_manager_get_enable_tab_scrolling ());
|
||||||
|
|
||||||
connect_notebook_signals (window, notebook);
|
connect_notebook_signals (window, notebook);
|
||||||
}
|
}
|
||||||
|
@ -3418,6 +3439,13 @@ xed_window_init (XedWindow *window)
|
||||||
window->priv->dispose_has_run = FALSE;
|
window->priv->dispose_has_run = FALSE;
|
||||||
window->priv->fullscreen_controls = NULL;
|
window->priv->fullscreen_controls = NULL;
|
||||||
window->priv->fullscreen_animation_timeout_id = 0;
|
window->priv->fullscreen_animation_timeout_id = 0;
|
||||||
|
window->priv->editor_settings = g_settings_new ("org.x.editor.preferences.editor");
|
||||||
|
window->priv->ui_settings = g_settings_new ("org.x.editor.preferences.ui");
|
||||||
|
|
||||||
|
/* Window settings are applied only once the window is closed. We do not want
|
||||||
|
to keep writing to disk when the window is dragged around */
|
||||||
|
window->priv->window_settings = g_settings_new ("org.x.editor.state.window");
|
||||||
|
g_settings_delay (window->priv->window_settings);
|
||||||
|
|
||||||
window->priv->message_bus = xed_message_bus_new ();
|
window->priv->message_bus = xed_message_bus_new ();
|
||||||
|
|
||||||
|
@ -3467,8 +3495,8 @@ xed_window_init (XedWindow *window)
|
||||||
|
|
||||||
/* panes' state must be restored after panels have been mapped,
|
/* panes' state must be restored after panels have been mapped,
|
||||||
* since the bottom pane position depends on the size of the vpaned. */
|
* since the bottom pane position depends on the size of the vpaned. */
|
||||||
window->priv->side_panel_size = xed_prefs_manager_get_side_panel_size ();
|
window->priv->side_panel_size = g_settings_get_int (window->priv->window_settings, XED_SETTINGS_SIDE_PANEL_SIZE);
|
||||||
window->priv->bottom_panel_size = xed_prefs_manager_get_bottom_panel_size ();
|
window->priv->bottom_panel_size = g_settings_get_int (window->priv->window_settings, XED_SETTINGS_BOTTOM_PANEL_SIZE);
|
||||||
|
|
||||||
g_signal_connect_after(window->priv->hpaned, "map", G_CALLBACK (hpaned_restore_position), window);
|
g_signal_connect_after(window->priv->hpaned, "map", G_CALLBACK (hpaned_restore_position), window);
|
||||||
g_signal_connect_after(window->priv->vpaned, "map", G_CALLBACK (vpaned_restore_position), window);
|
g_signal_connect_after(window->priv->vpaned, "map", G_CALLBACK (vpaned_restore_position), window);
|
||||||
|
@ -4211,3 +4239,13 @@ xed_window_get_message_bus (XedWindow *window)
|
||||||
g_return_val_if_fail(XED_IS_WINDOW (window), NULL);
|
g_return_val_if_fail(XED_IS_WINDOW (window), NULL);
|
||||||
return window->priv->message_bus;
|
return window->priv->message_bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_xed_window_get_default_size (gint *width,
|
||||||
|
gint *height)
|
||||||
|
{
|
||||||
|
g_return_if_fail (width != NULL && height != NULL);
|
||||||
|
|
||||||
|
*width = XED_WINDOW_DEFAULT_WIDTH;
|
||||||
|
*height = XED_WINDOW_DEFAULT_HEIGHT;
|
||||||
|
}
|
||||||
|
|
|
@ -106,6 +106,8 @@ gboolean _xed_window_is_fullscreen (XedWindow *window);
|
||||||
void _xed_recent_add (XedWindow *window, GFile *location, const gchar *mime);
|
void _xed_recent_add (XedWindow *window, GFile *location, const gchar *mime);
|
||||||
void _xed_recent_remove (XedWindow *window, GFile *location);
|
void _xed_recent_remove (XedWindow *window, GFile *location);
|
||||||
|
|
||||||
|
void _xed_window_get_default_size (gint *width, gint *height);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __XED_WINDOW_H__ */
|
#endif /* __XED_WINDOW_H__ */
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
#include "xed-encodings.h"
|
#include "xed-encodings.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
|
||||||
#include "xed-session.h"
|
#include "xed-session.h"
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-window.h"
|
#include "xed-window.h"
|
||||||
|
@ -597,10 +596,6 @@ main (int argc, char *argv[])
|
||||||
/* Set the associated .desktop file */
|
/* Set the associated .desktop file */
|
||||||
egg_set_desktop_file (DATADIR "/applications/xed.desktop");
|
egg_set_desktop_file (DATADIR "/applications/xed.desktop");
|
||||||
|
|
||||||
/* Load user preferences */
|
|
||||||
xed_debug_message (DEBUG_APP, "Init prefs manager");
|
|
||||||
xed_prefs_manager_app_init ();
|
|
||||||
|
|
||||||
/* Init plugins engine */
|
/* Init plugins engine */
|
||||||
xed_debug_message (DEBUG_APP, "Init plugins");
|
xed_debug_message (DEBUG_APP, "Init plugins");
|
||||||
engine = xed_plugins_engine_get_default ();
|
engine = xed_plugins_engine_get_default ();
|
||||||
|
@ -658,7 +653,6 @@ main (int argc, char *argv[])
|
||||||
* finalize it properly.
|
* finalize it properly.
|
||||||
*/
|
*/
|
||||||
g_object_unref (engine);
|
g_object_unref (engine);
|
||||||
xed_prefs_manager_app_shutdown ();
|
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
#ifndef ENABLE_GVFS_METADATA
|
||||||
xed_metadata_manager_shutdown ();
|
xed_metadata_manager_shutdown ();
|
||||||
|
|
Loading…
Reference in New Issue