mirror of
https://github.com/GNOME/gedit
synced 2024-07-05 01:49:06 +00:00
Revert "Merge branch 'master' into wip/next"
This reverts commit661db63099
, reversing changes made toa8cb2b57f9
. It is to basically come back to: commita8cb2b57f9
the previous version of gedit based on the Tepl library. The goal is to continue the gedit development (on master), but based on the Tepl library.
This commit is contained in:
parent
661db63099
commit
5164375a72
48
NEWS
48
NEWS
|
@ -1,52 +1,6 @@
|
||||||
News in 43.alpha, 2022-07-06
|
News in 40.alpha, 2021-xx-yy (not yet released)
|
||||||
----------------------------
|
|
||||||
* Update app description.
|
|
||||||
* Translation updates.
|
|
||||||
|
|
||||||
News in 42.1, 2022-05-27
|
|
||||||
------------------------
|
|
||||||
* Translation updates.
|
|
||||||
|
|
||||||
News in 42.0, 2022-04-01
|
|
||||||
----------------------------
|
|
||||||
* Rename display name back to gedit
|
|
||||||
* Build fix
|
|
||||||
* Translation updates
|
|
||||||
|
|
||||||
News in 41.0, 2022-02-14
|
|
||||||
----------------------------
|
|
||||||
* Fix some crashes, one when opening files, another when
|
|
||||||
deleting the open folder with the file browser plugin active
|
|
||||||
* Fix buttons in the color scheme selector dialog
|
|
||||||
* Build fixes
|
|
||||||
* Improve symbolic icon coloring
|
|
||||||
* Improve Save As behavior when saving error infobar is showing
|
|
||||||
* Translation updates
|
|
||||||
* Note that gnome-text-editor will be GNOME's recommended text
|
|
||||||
editor beginning with the GNOME 42 release next month
|
|
||||||
|
|
||||||
News in 41.alpha, 2021-07-17
|
|
||||||
----------------------------
|
|
||||||
* Replace use of Tepl and AMTK
|
|
||||||
* Use sourceview4 in the snap build
|
|
||||||
* Enable OpenLink plugin by default
|
|
||||||
* Warn when trying to open a big file and allow to cancel
|
|
||||||
* Port open-selector to GDateTime
|
|
||||||
* Allow disabling gspell and python options
|
|
||||||
* Fix parsing of font-family strgins when they contain whitespace
|
|
||||||
* Translation updates.
|
|
||||||
|
|
||||||
News in 40.1, 2021-04-17
|
|
||||||
------------------------
|
|
||||||
* Use document folder when opening new files
|
|
||||||
* Huge CPU consumption when a folder with content is deleted
|
|
||||||
* Updated translations
|
|
||||||
|
|
||||||
News in 40, 2021-03-19
|
|
||||||
----------------------------
|
----------------------------
|
||||||
* Remove all the deprecated API.
|
* Remove all the deprecated API.
|
||||||
* file-browser: drop use of confirm-trash
|
|
||||||
* Translation updates.
|
|
||||||
|
|
||||||
Tepl-ification:
|
Tepl-ification:
|
||||||
* Use tepl_pango_font_description_to_css().
|
* Use tepl_pango_font_description_to_css().
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
gedit - The GNOME text editor
|
gedit - The GNOME text editor
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
This is version 3.38.2 of gedit.
|
||||||
|
|
||||||
gedit is the text editor of the GNOME desktop environment.
|
gedit is the text editor of the GNOME desktop environment.
|
||||||
|
|
||||||
The first goal of gedit is to be easy to use, with a simple interface by
|
The first goal of gedit is to be easy to use, with a simple interface by
|
||||||
|
|
|
@ -59,12 +59,17 @@ modules:
|
||||||
url: https://download.gnome.org/sources/gspell/1.9/gspell-1.9.1.tar.xz
|
url: https://download.gnome.org/sources/gspell/1.9/gspell-1.9.1.tar.xz
|
||||||
sha256: dcbb769dfdde8e3c0a8ed3102ce7e661abbf7ddf85df08b29915e92cd723abdd
|
sha256: dcbb769dfdde8e3c0a8ed3102ce7e661abbf7ddf85df08b29915e92cd723abdd
|
||||||
|
|
||||||
- name: uchardet
|
- name: amtk
|
||||||
buildsystem: cmake-ninja
|
buildsystem: meson
|
||||||
sources:
|
sources:
|
||||||
- type: archive
|
- type: git
|
||||||
url: https://www.freedesktop.org/software/uchardet/releases/uchardet-0.0.6.tar.xz
|
url: https://gitlab.gnome.org/GNOME/amtk.git
|
||||||
sha256: 8351328cdfbcb2432e63938721dd781eb8c11ebc56e3a89d0f84576b96002c61
|
|
||||||
|
- name: tepl
|
||||||
|
buildsystem: meson
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://gitlab.gnome.org/GNOME/tepl.git
|
||||||
|
|
||||||
- name: gedit
|
- name: gedit
|
||||||
buildsystem: meson
|
buildsystem: meson
|
||||||
|
|
|
@ -41,10 +41,33 @@ apps:
|
||||||
GTK_USE_PORTAL: 1
|
GTK_USE_PORTAL: 1
|
||||||
|
|
||||||
parts:
|
parts:
|
||||||
|
amtk:
|
||||||
|
source: https://gitlab.gnome.org/GNOME/amtk.git
|
||||||
|
source-type: git
|
||||||
|
plugin: autotools
|
||||||
|
configflags:
|
||||||
|
- --prefix=/usr
|
||||||
|
- --enable-introspection=no
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
|
||||||
|
tepl:
|
||||||
|
after: [amtk, gtksourceview]
|
||||||
|
source: https://gitlab.gnome.org/GNOME/tepl.git
|
||||||
|
source-type: git
|
||||||
|
plugin: meson
|
||||||
|
meson-parameters:
|
||||||
|
- --prefix=/usr
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
build-packages:
|
||||||
|
- libuchardet-dev
|
||||||
|
stage-packages:
|
||||||
|
- libuchardet0
|
||||||
|
|
||||||
gtksourceview:
|
gtksourceview:
|
||||||
source: https://gitlab.gnome.org/GNOME/gtksourceview.git
|
source: https://gitlab.gnome.org/GNOME/gtksourceview.git
|
||||||
source-type: git
|
source-type: git
|
||||||
source-branch: gtksourceview-4-8
|
|
||||||
plugin: meson
|
plugin: meson
|
||||||
meson-parameters:
|
meson-parameters:
|
||||||
- --prefix=/usr
|
- --prefix=/usr
|
||||||
|
@ -71,7 +94,7 @@ parts:
|
||||||
cp $SNAPCRAFT_PART_INSTALL/usr/share/vala/vapi/gtksource* /usr/share/vala/vapi
|
cp $SNAPCRAFT_PART_INSTALL/usr/share/vala/vapi/gtksource* /usr/share/vala/vapi
|
||||||
|
|
||||||
gedit:
|
gedit:
|
||||||
after: [gtksourceview]
|
after: [gtksourceview, tepl]
|
||||||
source: .
|
source: .
|
||||||
source-type: git
|
source-type: git
|
||||||
parse-info: [usr/share/metainfo/org.gnome.gedit.appdata.xml]
|
parse-info: [usr/share/metainfo/org.gnome.gedit.appdata.xml]
|
||||||
|
@ -79,7 +102,6 @@ parts:
|
||||||
meson-parameters:
|
meson-parameters:
|
||||||
- --prefix=/usr
|
- --prefix=/usr
|
||||||
- -Dvala_args="--vapidir=$SNAPCRAFT_STAGE/usr/share/vala/vapi"
|
- -Dvala_args="--vapidir=$SNAPCRAFT_STAGE/usr/share/vala/vapi"
|
||||||
|
|
||||||
build-environment:
|
build-environment:
|
||||||
- C_INCLUDE_PATH: $SNAPCRAFT_STAGE/usr/include/gtksourceview-4
|
- C_INCLUDE_PATH: $SNAPCRAFT_STAGE/usr/include/gtksourceview-4
|
||||||
override-build: |
|
override-build: |
|
||||||
|
|
|
@ -76,11 +76,11 @@ like "ftp://ftp.gnome.org/robots.txt".
|
||||||
.B gedit will read from stdin
|
.B gedit will read from stdin
|
||||||
.TP
|
.TP
|
||||||
\fB+LINE\fR
|
\fB+LINE\fR
|
||||||
For all the files specified on command line, go to the line specified by LINE (do not insert a space between the "+" sign and the number).
|
For the first file, go to the line specified by LINE (do not insert a space between the "+" sign and the number).
|
||||||
If LINE is missing, go to the last line.
|
If LINE is missing, go to the last line.
|
||||||
.TP
|
.TP
|
||||||
\fBCOLUMN\fR
|
\fBCOLUMN\fR
|
||||||
For all the files specified on command line, go to the column specified by COLUMN.
|
For the first file, go to the column specified by COLUMN.
|
||||||
If COLUMN is missing, go to the first column.
|
If COLUMN is missing, go to the first column.
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
|
|
|
@ -4,6 +4,7 @@ install_man('gedit.1')
|
||||||
|
|
||||||
appdata = 'org.gnome.gedit.appdata.xml'
|
appdata = 'org.gnome.gedit.appdata.xml'
|
||||||
appdata_file = i18n.merge_file(
|
appdata_file = i18n.merge_file(
|
||||||
|
appdata,
|
||||||
input: appdata + '.in',
|
input: appdata + '.in',
|
||||||
output: appdata,
|
output: appdata,
|
||||||
po_dir: '../po/',
|
po_dir: '../po/',
|
||||||
|
@ -22,6 +23,7 @@ endif
|
||||||
|
|
||||||
desktop_file = 'org.gnome.gedit.desktop'
|
desktop_file = 'org.gnome.gedit.desktop'
|
||||||
desktop_output_file = i18n.merge_file(
|
desktop_output_file = i18n.merge_file(
|
||||||
|
desktop_file,
|
||||||
type: 'desktop',
|
type: 'desktop',
|
||||||
input: desktop_file + '.in',
|
input: desktop_file + '.in',
|
||||||
output: desktop_file,
|
output: desktop_file,
|
||||||
|
@ -43,7 +45,6 @@ active_plugins = [
|
||||||
'docinfo',
|
'docinfo',
|
||||||
'filebrowser',
|
'filebrowser',
|
||||||
'modelines',
|
'modelines',
|
||||||
'openlinks',
|
|
||||||
'sort',
|
'sort',
|
||||||
'spell',
|
'spell',
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<summary>Edit text files</summary>
|
<summary>Edit text files</summary>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
gedit is a popular text editor for the GNOME desktop environment.
|
gedit is the text editor of the GNOME desktop environment.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The first goal of gedit is to be easy to use, with a simple interface by
|
The first goal of gedit is to be easy to use, with a simple interface by
|
||||||
|
@ -28,21 +28,19 @@
|
||||||
</screenshots>
|
</screenshots>
|
||||||
<url type="homepage">https://wiki.gnome.org/Apps/Gedit</url>
|
<url type="homepage">https://wiki.gnome.org/Apps/Gedit</url>
|
||||||
<url type="bugtracker">https://gitlab.gnome.org/GNOME/gedit/issues</url>
|
<url type="bugtracker">https://gitlab.gnome.org/GNOME/gedit/issues</url>
|
||||||
<url type="donation">https://www.gnome.org/donate/</url>
|
<url type="donation">https://liberapay.com/gedit/</url>
|
||||||
<url type="help">https://help.gnome.org/users/gedit/stable/</url>
|
<url type="help">https://help.gnome.org/users/gedit/stable/</url>
|
||||||
<url type="translate">https://wiki.gnome.org/TranslationProject</url>
|
<url type="translate">https://wiki.gnome.org/TranslationProject</url>
|
||||||
<update_contact>jmas@softcatala.org</update_contact>
|
<update_contact>swilmet@gnome.org</update_contact>
|
||||||
<project_group>GNOME</project_group>
|
<project_group>GNOME</project_group>
|
||||||
<translation type="gettext">gedit</translation>
|
<translation type="gettext">gedit</translation>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="43.alpha" date="2022-07-06" />
|
|
||||||
<release version="42.1" date="2022-05-27" />
|
|
||||||
<release version="42.0" date="2022-04-01" />
|
|
||||||
<release version="41.0" date="2022-02-14" />
|
|
||||||
<release version="40.1" date="2021-04-17" />
|
|
||||||
<release version="40.0" date="2021-03-19" />
|
|
||||||
<release version="3.38.0" date="2020-09-11" />
|
<release version="3.38.0" date="2020-09-11" />
|
||||||
|
<release version="3.37.92" date="2020-09-04" />
|
||||||
|
<release version="3.37.3" date="2020-07-03" />
|
||||||
|
<release version="3.37.2" date="2020-05-29" />
|
||||||
|
<release version="3.37.1" date="2020-04-24" />
|
||||||
<release version="3.36.1" date="2020-03-20" />
|
<release version="3.36.1" date="2020-03-20" />
|
||||||
<release version="3.36.0" date="2020-03-06" />
|
<release version="3.36.0" date="2020-03-06" />
|
||||||
</releases>
|
</releases>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=gedit
|
Name=Text Editor
|
||||||
GenericName=Text Editor
|
|
||||||
Comment=Edit text files
|
Comment=Edit text files
|
||||||
Exec=gedit %U
|
Exec=gedit %U
|
||||||
Terminal=false
|
Terminal=false
|
||||||
|
@ -15,7 +14,7 @@ Actions=new-window;new-document;
|
||||||
# TRANSLATORS: Do NOT translate or localize the semicolons!
|
# TRANSLATORS: Do NOT translate or localize the semicolons!
|
||||||
# The list MUST also end with a semicolon!
|
# The list MUST also end with a semicolon!
|
||||||
# Search terms to find this application.
|
# Search terms to find this application.
|
||||||
Keywords=Text;Editor;Plaintext;Write;gedit;notepad;
|
Keywords=Text;Editor;Plaintext;Write;gedit;
|
||||||
DBusActivatable=true
|
DBusActivatable=true
|
||||||
|
|
||||||
[Desktop Action new-window]
|
[Desktop Action new-window]
|
||||||
|
|
|
@ -126,11 +126,6 @@
|
||||||
<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="display-overview-map" type="b">
|
|
||||||
<default>false</default>
|
|
||||||
<summary>Display Overview Map</summary>
|
|
||||||
<description>Whether gedit should display the overview map for the document.</description>
|
|
||||||
</key>
|
|
||||||
<key name="background-pattern" enum="org.gnome.gedit.BackgroundPatternType">
|
<key name="background-pattern" enum="org.gnome.gedit.BackgroundPatternType">
|
||||||
<default>'none'</default>
|
<default>'none'</default>
|
||||||
<summary>Document background pattern type</summary>
|
<summary>Document background pattern type</summary>
|
||||||
|
|
|
@ -31,9 +31,11 @@ editor. To learn that widget API, read the excellent
|
||||||
mostly valid). But GtkTextView is not enough for source code edition. gedit
|
mostly valid). But GtkTextView is not enough for source code edition. gedit
|
||||||
actually uses the
|
actually uses the
|
||||||
[GtkSourceView](https://wiki.gnome.org/Projects/GtkSourceView) library, which
|
[GtkSourceView](https://wiki.gnome.org/Projects/GtkSourceView) library, which
|
||||||
contains a subclass of GtkTextView with syntax highlighting, a completion
|
contains a subclass of GtkTextView with many features useful for a text editor
|
||||||
framework, the search and replace, and many other features useful for a text
|
or an IDE. But GtkSourceView is not enough to have a full-blown text editor,
|
||||||
editor or an IDE.
|
gedit is actually in the process of using more features from the
|
||||||
|
[Tepl](https://wiki.gnome.org/Projects/Tepl) library, and to further develop
|
||||||
|
Tepl alongside gedit.
|
||||||
|
|
||||||
For its plugin system, gedit uses the
|
For its plugin system, gedit uses the
|
||||||
[libpeas](https://wiki.gnome.org/Projects/Libpeas) library.
|
[libpeas](https://wiki.gnome.org/Projects/Libpeas) library.
|
||||||
|
|
|
@ -21,56 +21,6 @@
|
||||||
<link linkend="api-index-deprecated">index of deprecated symbols</link>.
|
<link linkend="api-index-deprecated">index of deprecated symbols</link>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>40 -> 41</title>
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>GeditProgressInfoBar</code> class has been restored
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<link linkend="GeditDocument">GeditDocument</link> is no longer a subclass
|
|
||||||
of <link linkend="TeplBuffer">TeplBuffer</link>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>GeditDocument::cursor-moved</code> signal has been restored.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>GeditDocument:shortname</code> property has been restored.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>gedit_document_is_untouched()</code> function has been
|
|
||||||
restored.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>gedit_view_set_font()</code> function has been restored.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<code>DEBUG_METADATA</code> has been restored.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The <code>GBOOLEAN_TO_POINTER()</code> and
|
|
||||||
<code>GPOINTER_TO_BOOLEAN()</code> macros have been restored to
|
|
||||||
<code>gedit-utils.h</code>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>3.38 -> 40</title>
|
<title>3.38 -> 40</title>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<xi:include href="xml/gedit-menu-extension.xml"/>
|
<xi:include href="xml/gedit-menu-extension.xml"/>
|
||||||
<xi:include href="xml/gedit-message-bus.xml"/>
|
<xi:include href="xml/gedit-message-bus.xml"/>
|
||||||
<xi:include href="xml/gedit-message.xml"/>
|
<xi:include href="xml/gedit-message.xml"/>
|
||||||
<xi:include href="xml/gedit-progress-info-bar.xml"/>
|
|
||||||
<xi:include href="xml/gedit-statusbar.xml"/>
|
<xi:include href="xml/gedit-statusbar.xml"/>
|
||||||
<xi:include href="xml/gedit-tab.xml"/>
|
<xi:include href="xml/gedit-tab.xml"/>
|
||||||
<xi:include href="xml/gedit-view.xml"/>
|
<xi:include href="xml/gedit-view.xml"/>
|
||||||
|
|
|
@ -54,10 +54,7 @@ gedit_document_new
|
||||||
gedit_document_get_file
|
gedit_document_get_file
|
||||||
gedit_document_get_short_name_for_display
|
gedit_document_get_short_name_for_display
|
||||||
gedit_document_get_mime_type
|
gedit_document_get_mime_type
|
||||||
gedit_document_is_untouched
|
|
||||||
gedit_document_is_untitled
|
gedit_document_is_untitled
|
||||||
gedit_document_goto_line
|
|
||||||
gedit_document_goto_line_offset
|
|
||||||
gedit_document_set_language
|
gedit_document_set_language
|
||||||
gedit_document_get_content_type
|
gedit_document_get_content_type
|
||||||
gedit_document_get_metadata
|
gedit_document_get_metadata
|
||||||
|
@ -151,26 +148,6 @@ GEDIT_MESSAGE_GET_CLASS
|
||||||
GeditMessagePrivate
|
GeditMessagePrivate
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
|
||||||
<FILE>gedit-progress-info-bar</FILE>
|
|
||||||
<TITLE>GeditProgressInfoBar</TITLE>
|
|
||||||
GeditProgressInfoBar
|
|
||||||
gedit_progress_info_bar_new
|
|
||||||
gedit_progress_info_bar_set_icon_name
|
|
||||||
gedit_progress_info_bar_set_markup
|
|
||||||
gedit_progress_info_bar_set_text
|
|
||||||
gedit_progress_info_bar_set_fraction
|
|
||||||
gedit_progress_info_bar_pulse
|
|
||||||
<SUBSECTION Standard>
|
|
||||||
GEDIT_PROGRESS_INFO_BAR
|
|
||||||
GEDIT_IS_PROGRESS_INFO_BAR
|
|
||||||
GEDIT_TYPE_PROGRESS_INFO_BAR
|
|
||||||
gedit_progress_info_bar_get_type
|
|
||||||
GEDIT_PROGRESS_INFO_BAR_CLASS
|
|
||||||
GEDIT_IS_PROGRESS_INFO_BAR_CLASS
|
|
||||||
GEDIT_PROGRESS_INFO_BAR_GET_CLASS
|
|
||||||
</SECTION>
|
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gedit-statusbar</FILE>
|
<FILE>gedit-statusbar</FILE>
|
||||||
<TITLE>GeditStatusbar</TITLE>
|
<TITLE>GeditStatusbar</TITLE>
|
||||||
|
@ -222,13 +199,6 @@ GeditViewPrivate
|
||||||
<TITLE>GeditView</TITLE>
|
<TITLE>GeditView</TITLE>
|
||||||
GeditView
|
GeditView
|
||||||
gedit_view_new
|
gedit_view_new
|
||||||
gedit_view_cut_clipboard
|
|
||||||
gedit_view_copy_clipboard
|
|
||||||
gedit_view_paste_clipboard
|
|
||||||
gedit_view_delete_selection
|
|
||||||
gedit_view_select_all
|
|
||||||
gedit_view_scroll_to_cursor
|
|
||||||
gedit_view_set_font
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GEDIT_VIEW
|
GEDIT_VIEW
|
||||||
GEDIT_IS_VIEW
|
GEDIT_IS_VIEW
|
||||||
|
@ -321,7 +291,6 @@ DEBUG_DOCUMENT
|
||||||
DEBUG_COMMANDS
|
DEBUG_COMMANDS
|
||||||
DEBUG_APP
|
DEBUG_APP
|
||||||
DEBUG_UTILS
|
DEBUG_UTILS
|
||||||
DEBUG_METADATA
|
|
||||||
gedit_debug_init
|
gedit_debug_init
|
||||||
gedit_debug
|
gedit_debug
|
||||||
gedit_debug_message
|
gedit_debug_message
|
||||||
|
@ -352,14 +321,9 @@ gedit_menu_extension_get_type
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gedit-utils</FILE>
|
<FILE>gedit-utils</FILE>
|
||||||
GBOOLEAN_TO_POINTER
|
|
||||||
GPOINTER_TO_BOOLEAN
|
|
||||||
gedit_utils_menu_position_under_tree_view
|
gedit_utils_menu_position_under_tree_view
|
||||||
gedit_utils_set_atk_name_description
|
gedit_utils_set_atk_name_description
|
||||||
gedit_warning
|
|
||||||
gedit_utils_replace_home_dir_with_tilde
|
|
||||||
gedit_utils_basename_for_display
|
gedit_utils_basename_for_display
|
||||||
gedit_utils_decode_uri
|
|
||||||
gedit_utils_drop_get_uris
|
gedit_utils_drop_get_uris
|
||||||
gedit_utils_get_compression_type_from_content_type
|
gedit_utils_get_compression_type_from_content_type
|
||||||
gedit_utils_is_valid_location
|
gedit_utils_is_valid_location
|
||||||
|
|
|
@ -6,12 +6,14 @@ gio_docpath = dependency('gio-2.0').get_pkgconfig_variable('prefix') / 'share/gt
|
||||||
gdk_docpath = dependency('gdk-3.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gdk3'
|
gdk_docpath = dependency('gdk-3.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gdk3'
|
||||||
gtk_docpath = dependency('gtk+-3.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gtk3'
|
gtk_docpath = dependency('gtk+-3.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gtk3'
|
||||||
gsv_docpath = dependency('gtksourceview-4').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gtksourceview-4.0'
|
gsv_docpath = dependency('gtksourceview-4').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/gtksourceview-4.0'
|
||||||
|
amtk_docpath = dependency('amtk-5').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/amtk-5'
|
||||||
|
tepl_docpath = dependency('tepl-6').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/tepl-6'
|
||||||
libpeas_docpath = dependency('libpeas-1.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/libpeas'
|
libpeas_docpath = dependency('libpeas-1.0').get_pkgconfig_variable('prefix') / 'share/gtk-doc/html/libpeas'
|
||||||
|
|
||||||
gedit_doc_dep = declare_dependency(
|
gedit_doc_dep = declare_dependency(
|
||||||
link_with: libgedit_shared_lib,
|
link_with: libgedit_shared_lib,
|
||||||
include_directories: root_include_dir,
|
include_directories: root_include_dir,
|
||||||
dependencies: deps_basic_list + [libxml_dep],
|
dependencies: deps_basic_list,
|
||||||
)
|
)
|
||||||
|
|
||||||
gnome.gtkdoc(
|
gnome.gtkdoc(
|
||||||
|
@ -28,6 +30,8 @@ gnome.gtkdoc(
|
||||||
'--extra-dir=@0@'.format(gdk_docpath),
|
'--extra-dir=@0@'.format(gdk_docpath),
|
||||||
'--extra-dir=@0@'.format(gtk_docpath),
|
'--extra-dir=@0@'.format(gtk_docpath),
|
||||||
'--extra-dir=@0@'.format(gsv_docpath),
|
'--extra-dir=@0@'.format(gsv_docpath),
|
||||||
|
'--extra-dir=@0@'.format(amtk_docpath),
|
||||||
|
'--extra-dir=@0@'.format(tepl_docpath),
|
||||||
'--extra-dir=@0@'.format(libpeas_docpath),
|
'--extra-dir=@0@'.format(libpeas_docpath),
|
||||||
],
|
],
|
||||||
content_files: [
|
content_files: [
|
||||||
|
|
56
docs/roadmap-done.md
Normal file
56
docs/roadmap-done.md
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
gedit roadmap - done tasks
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Tepl-ification of the gedit core
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
- gedit 3.36:
|
||||||
|
- Start to use the Tepl library.
|
||||||
|
- Use some Tepl utility functions.
|
||||||
|
- Use TeplFileMetadata, remove GeditMetadataManager.
|
||||||
|
- gedit 3.38:
|
||||||
|
- Move some utility functions to the Tepl library.
|
||||||
|
- Refactor and move some I/O error infobars to Tepl.
|
||||||
|
- GeditView now inherits from TeplView.
|
||||||
|
- Port to the new Tepl metadata API.
|
||||||
|
- Use TeplStyleSchemeChooserWidget in the preferences dialog.
|
||||||
|
- Create GeditFactory class, subclass of TeplAbstractFactory.
|
||||||
|
- gedit 40:
|
||||||
|
- Use `tepl_pango_font_description_to_css()`.
|
||||||
|
- Use TeplLanguageChooser's, for choosing a language for the syntax
|
||||||
|
highlighting. Remove GeditHighlightModeSelector and
|
||||||
|
GeditHighlightModeDialog.
|
||||||
|
- Use TeplProgressInfoBar. Remove GeditProgressInfoBar.
|
||||||
|
- GeditDocument now inherits from TeplBuffer, start to use the
|
||||||
|
TeplBuffer and TeplFile APIs.
|
||||||
|
|
||||||
|
Links:
|
||||||
|
- https://wiki.gnome.org/Projects/Tepl
|
||||||
|
|
||||||
|
Tepl-ification of the gedit plugins
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
- gedit 40:
|
||||||
|
- Draw Spaces plugin: new implementation based on TeplSpaceDrawerPrefs.
|
||||||
|
|
||||||
|
Other done tasks in gedit plugins
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
- gedit 40:
|
||||||
|
- Smart Spaces plugin: new implementation based on a GtkSourceView
|
||||||
|
feature.
|
||||||
|
|
||||||
|
New version of gedit on Windows
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
[gedit is now available on the Microsoft Store](https://www.microsoft.com/store/apps/9PL1J21XF0PT).
|
||||||
|
It was done during the GNOME 3.38 development cycle. The integration with
|
||||||
|
Windows is not perfect, but it works. It is planned to improve gedit for
|
||||||
|
Windows over time.
|
||||||
|
|
||||||
|
Documentation for contributors
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Write a guide to get started with gedit development.
|
||||||
|
|
||||||
|
Done during the GNOME 3.34 development cycle.
|
|
@ -4,10 +4,27 @@ gedit roadmap
|
||||||
This page contains the plans for major code changes we hope to get done in the
|
This page contains the plans for major code changes we hope to get done in the
|
||||||
future.
|
future.
|
||||||
|
|
||||||
See also the [GtkSourceView](https://wiki.gnome.org/Projects/GtkSourceView/RoadMap).
|
See the [roadmap-done.md](roadmap-done.md) file for done tasks.
|
||||||
|
|
||||||
See the [NEWS file](../NEWS) for a detailed history.
|
See the [NEWS file](../NEWS) for a detailed history.
|
||||||
|
|
||||||
|
See also the
|
||||||
|
[Tepl roadmap](https://gitlab.gnome.org/GNOME/tepl/blob/master/docs/roadmap.md).
|
||||||
|
|
||||||
|
Continue to make the gedit source code more re-usable
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
Status: **in progress** (this is an ongoing effort)
|
||||||
|
|
||||||
|
Next steps:
|
||||||
|
- Use more features from the Tepl library, and develop Tepl alongside gedit.
|
||||||
|
The goal is to reduce the amount of code in gedit, by having re-usable code
|
||||||
|
in Tepl instead.
|
||||||
|
|
||||||
|
Links:
|
||||||
|
- https://wiki.gnome.org/Apps/Gedit/ReusableCode
|
||||||
|
- https://wiki.gnome.org/Projects/Tepl
|
||||||
|
|
||||||
Improve gedit on Windows
|
Improve gedit on Windows
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
26
gedit.doap
26
gedit.doap
|
@ -7,7 +7,7 @@
|
||||||
<name xml:lang="en">gedit</name>
|
<name xml:lang="en">gedit</name>
|
||||||
<shortdesc xml:lang="en">GNOME Text Editor</shortdesc>
|
<shortdesc xml:lang="en">GNOME Text Editor</shortdesc>
|
||||||
<description>
|
<description>
|
||||||
gedit is a popular text editor for the GNOME desktop environment.
|
gedit is the text editor of the GNOME desktop environment.
|
||||||
|
|
||||||
The first goal of gedit is to be easy to use, with a simple interface by
|
The first goal of gedit is to be easy to use, with a simple interface by
|
||||||
default. More advanced features are available by enabling plugins.
|
default. More advanced features are available by enabling plugins.
|
||||||
|
@ -21,13 +21,6 @@ default. More advanced features are available by enabling plugins.
|
||||||
<programming-language>C</programming-language>
|
<programming-language>C</programming-language>
|
||||||
<programming-language>Python</programming-language>
|
<programming-language>Python</programming-language>
|
||||||
|
|
||||||
<maintainer>
|
|
||||||
<foaf:Person>
|
|
||||||
<foaf:name>Jeremy Bicha</foaf:name>
|
|
||||||
<foaf:mbox rdf:resource="mailto:jbicha@ubuntu.com" />
|
|
||||||
<gnome:userid>jbicha</gnome:userid>
|
|
||||||
</foaf:Person>
|
|
||||||
</maintainer>
|
|
||||||
<maintainer>
|
<maintainer>
|
||||||
<foaf:Person>
|
<foaf:Person>
|
||||||
<foaf:name>Sébastien Wilmet</foaf:name>
|
<foaf:name>Sébastien Wilmet</foaf:name>
|
||||||
|
@ -36,15 +29,7 @@ default. More advanced features are available by enabling plugins.
|
||||||
</foaf:Person>
|
</foaf:Person>
|
||||||
</maintainer>
|
</maintainer>
|
||||||
|
|
||||||
<!-- Old maintainers
|
<!-- Old maintainers
|
||||||
<maintainer>
|
|
||||||
<foaf:Person>
|
|
||||||
<foaf:name>Jordi Mas</foaf:name>
|
|
||||||
<foaf:mbox rdf:resource="mailto:jmas@softcatala.org" />
|
|
||||||
<gnome:userid>jmas</gnome:userid>
|
|
||||||
</foaf:Person>
|
|
||||||
</maintainer>
|
|
||||||
|
|
||||||
<maintainer>
|
<maintainer>
|
||||||
<foaf:Person>
|
<foaf:Person>
|
||||||
<foaf:name>Paolo Maggi</foaf:name>
|
<foaf:name>Paolo Maggi</foaf:name>
|
||||||
|
@ -73,5 +58,12 @@ default. More advanced features are available by enabling plugins.
|
||||||
<gnome:userid>icq</gnome:userid>
|
<gnome:userid>icq</gnome:userid>
|
||||||
</foaf:Person>
|
</foaf:Person>
|
||||||
</maintainer>
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Jeremy Bicha</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:jbicha@ubuntu.com" />
|
||||||
|
<gnome:userid>jbicha</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -6,7 +6,6 @@ EncodingsComboBox cheader_filename="gedit/gedit-encodings-combo-box.h"
|
||||||
MenuExtension cheader_filename="gedit/gedit-menu-extension.h"
|
MenuExtension cheader_filename="gedit/gedit-menu-extension.h"
|
||||||
Message cheader_filename="gedit/gedit-message.h"
|
Message cheader_filename="gedit/gedit-message.h"
|
||||||
MessageBus cheader_filename="gedit/gedit-message-bus.h"
|
MessageBus cheader_filename="gedit/gedit-message-bus.h"
|
||||||
ProgressInfoBar cheader_filename="gedit/gedit-progress-info-bar.h"
|
|
||||||
Statusbar cheader_filename="gedit/gedit-statusbar.h"
|
Statusbar cheader_filename="gedit/gedit-statusbar.h"
|
||||||
Tab cheader_filename="gedit/gedit-tab.h"
|
Tab cheader_filename="gedit/gedit-tab.h"
|
||||||
TabState cheader_filename="gedit/gedit-tab.h"
|
TabState cheader_filename="gedit/gedit-tab.h"
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-commands.h"
|
#include "gedit-commands.h"
|
||||||
#include "gedit-commands-private.h"
|
#include "gedit-commands-private.h"
|
||||||
#include "gedit-recent.h"
|
#include "gedit-recent-osx.h"
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
NSWindow *gdk_quartz_window_get_nswindow(GdkWindow *window);
|
NSWindow *gdk_quartz_window_get_nswindow(GdkWindow *window);
|
||||||
|
@ -286,7 +286,7 @@ gedit_app_osx_set_window_title_impl (GeditApp *app,
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
ismodified = !gedit_document_is_untouched (document);
|
ismodified = !tepl_buffer_is_untouched (TEPL_BUFFER (document));
|
||||||
[native setDocumentEdited:ismodified];
|
[native setDocumentEdited:ismodified];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define GEDIT_APP_PRIVATE_H
|
#define GEDIT_APP_PRIVATE_H
|
||||||
|
|
||||||
#include "gedit-app.h"
|
#include "gedit-app.h"
|
||||||
#include "gedit-metadata-manager.h"
|
|
||||||
#include "gedit-menu-extension.h"
|
#include "gedit-menu-extension.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -35,8 +34,6 @@ GtkPrintSettings *_gedit_app_get_default_print_settings (GeditApp *app);
|
||||||
void _gedit_app_set_default_print_settings (GeditApp *app,
|
void _gedit_app_set_default_print_settings (GeditApp *app,
|
||||||
GtkPrintSettings *settings);
|
GtkPrintSettings *settings);
|
||||||
|
|
||||||
GeditMetadataManager *_gedit_app_get_metadata_manager (GeditApp *app);
|
|
||||||
|
|
||||||
GMenuModel *_gedit_app_get_hamburger_menu (GeditApp *app);
|
GMenuModel *_gedit_app_get_hamburger_menu (GeditApp *app);
|
||||||
|
|
||||||
GMenuModel *_gedit_app_get_notebook_menu (GeditApp *app);
|
GMenuModel *_gedit_app_get_notebook_menu (GeditApp *app);
|
||||||
|
|
|
@ -28,9 +28,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
|
||||||
#include <libpeas/peas-extension-set.h>
|
#include <libpeas/peas-extension-set.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-commands-private.h"
|
#include "gedit-commands-private.h"
|
||||||
#include "gedit-notebook.h"
|
#include "gedit-notebook.h"
|
||||||
|
@ -45,10 +44,6 @@
|
||||||
#include "gedit-preferences-dialog.h"
|
#include "gedit-preferences-dialog.h"
|
||||||
#include "gedit-tab.h"
|
#include "gedit-tab.h"
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
#include "gedit-metadata-manager.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GEDIT_PAGE_SETUP_FILE "gedit-page-setup"
|
#define GEDIT_PAGE_SETUP_FILE "gedit-page-setup"
|
||||||
#define GEDIT_PRINT_SETTINGS_FILE "gedit-print-settings"
|
#define GEDIT_PRINT_SETTINGS_FILE "gedit-print-settings"
|
||||||
|
|
||||||
|
@ -56,10 +51,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
GeditPluginsEngine *engine;
|
GeditPluginsEngine *engine;
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
GeditMetadataManager *metadata_manager;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GtkCssProvider *theme_provider;
|
GtkCssProvider *theme_provider;
|
||||||
|
|
||||||
GtkPageSetup *page_setup;
|
GtkPageSetup *page_setup;
|
||||||
|
@ -154,10 +145,6 @@ gedit_app_dispose (GObject *object)
|
||||||
|
|
||||||
priv = gedit_app_get_instance_private (GEDIT_APP (object));
|
priv = gedit_app_get_instance_private (GEDIT_APP (object));
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
g_clear_object (&priv->metadata_manager);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_clear_object (&priv->ui_settings);
|
g_clear_object (&priv->ui_settings);
|
||||||
g_clear_object (&priv->window_settings);
|
g_clear_object (&priv->window_settings);
|
||||||
|
|
||||||
|
@ -656,10 +643,6 @@ gedit_app_startup (GApplication *application)
|
||||||
GeditAppPrivate *priv;
|
GeditAppPrivate *priv;
|
||||||
GtkCssProvider *css_provider;
|
GtkCssProvider *css_provider;
|
||||||
GtkSourceStyleSchemeManager *manager;
|
GtkSourceStyleSchemeManager *manager;
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
const gchar *cache_dir;
|
|
||||||
gchar *metadata_filename;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
priv = gedit_app_get_instance_private (GEDIT_APP (application));
|
priv = gedit_app_get_instance_private (GEDIT_APP (application));
|
||||||
|
|
||||||
|
@ -671,13 +654,6 @@ gedit_app_startup (GApplication *application)
|
||||||
|
|
||||||
setup_theme_extensions (GEDIT_APP (application));
|
setup_theme_extensions (GEDIT_APP (application));
|
||||||
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
cache_dir = gedit_dirs_get_user_cache_dir ();
|
|
||||||
metadata_filename = g_build_filename (cache_dir, "gedit-metadata.xml", NULL);
|
|
||||||
priv->metadata_manager = gedit_metadata_manager_new (metadata_filename);
|
|
||||||
g_free (metadata_filename);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Load/init settings */
|
/* Load/init settings */
|
||||||
_gedit_settings_get_singleton ();
|
_gedit_settings_get_singleton ();
|
||||||
priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
|
priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui");
|
||||||
|
@ -1138,10 +1114,6 @@ gedit_app_shutdown (GApplication *app)
|
||||||
save_page_setup (GEDIT_APP (app));
|
save_page_setup (GEDIT_APP (app));
|
||||||
save_print_settings (GEDIT_APP (app));
|
save_print_settings (GEDIT_APP (app));
|
||||||
|
|
||||||
/* GTK+ can still hold references to some gedit objects, for example
|
|
||||||
* GeditDocument for the clipboard. So the metadata-manager should be
|
|
||||||
* shutdown after.
|
|
||||||
*/
|
|
||||||
G_APPLICATION_CLASS (gedit_app_parent_class)->shutdown (app);
|
G_APPLICATION_CLASS (gedit_app_parent_class)->shutdown (app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,10 +1253,15 @@ load_print_settings (GeditApp *app)
|
||||||
static void
|
static void
|
||||||
gedit_app_init (GeditApp *app)
|
gedit_app_init (GeditApp *app)
|
||||||
{
|
{
|
||||||
|
TeplApplication *tepl_app;
|
||||||
|
|
||||||
g_set_application_name ("gedit");
|
g_set_application_name ("gedit");
|
||||||
gtk_window_set_default_icon_name ("org.gnome.gedit");
|
gtk_window_set_default_icon_name ("org.gnome.gedit");
|
||||||
|
|
||||||
g_application_add_main_option_entries (G_APPLICATION (app), options);
|
g_application_add_main_option_entries (G_APPLICATION (app), options);
|
||||||
|
|
||||||
|
tepl_app = tepl_application_get_from_gtk_application (GTK_APPLICATION (app));
|
||||||
|
tepl_application_handle_metadata (tepl_app);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1594,25 +1571,6 @@ _gedit_app_set_default_print_settings (GeditApp *app,
|
||||||
priv->print_settings = g_object_ref (settings);
|
priv->print_settings = g_object_ref (settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GeditMetadataManager *
|
|
||||||
_gedit_app_get_metadata_manager (GeditApp *app)
|
|
||||||
{
|
|
||||||
#ifndef ENABLE_GVFS_METADATA
|
|
||||||
GeditAppPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
|
|
||||||
|
|
||||||
priv = gedit_app_get_instance_private (app);
|
|
||||||
|
|
||||||
return priv->metadata_manager;
|
|
||||||
#else
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GMenuModel *
|
GMenuModel *
|
||||||
_gedit_app_get_hamburger_menu (GeditApp *app)
|
_gedit_app_get_hamburger_menu (GeditApp *app)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,13 +44,13 @@ _gedit_cmd_edit_undo (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
gtk_source_buffer_undo (active_document);
|
gtk_source_buffer_undo (active_document);
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (active_view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -67,13 +67,13 @@ _gedit_cmd_edit_redo (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
gtk_source_buffer_redo (active_document);
|
gtk_source_buffer_redo (active_document);
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (active_view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ _gedit_cmd_edit_cut (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
gedit_view_cut_clipboard (active_view);
|
tepl_view_cut_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,9 @@ _gedit_cmd_edit_copy (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
gedit_view_copy_clipboard (active_view);
|
tepl_view_copy_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,9 @@ _gedit_cmd_edit_paste (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
gedit_view_paste_clipboard (active_view);
|
tepl_view_paste_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ _gedit_cmd_edit_delete (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
gedit_view_delete_selection (active_view);
|
tepl_view_delete_selection (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,9 @@ _gedit_cmd_edit_select_all (GSimpleAction *action,
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
active_view = gedit_window_get_active_view (window);
|
||||||
g_return_if_fail (active_view);
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
gedit_view_select_all (active_view);
|
tepl_view_select_all (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "gedit-commands-private.h"
|
#include "gedit-commands-private.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-app.h"
|
#include "gedit-app.h"
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
|
@ -43,6 +44,10 @@
|
||||||
#include "gedit-file-chooser-open.h"
|
#include "gedit-file-chooser-open.h"
|
||||||
#include "gedit-close-confirmation-dialog.h"
|
#include "gedit-close-confirmation-dialog.h"
|
||||||
|
|
||||||
|
/* useful macro */
|
||||||
|
#define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))
|
||||||
|
#define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE))
|
||||||
|
|
||||||
#define GEDIT_IS_CLOSING_ALL "gedit-is-closing-all"
|
#define GEDIT_IS_CLOSING_ALL "gedit-is-closing-all"
|
||||||
#define GEDIT_NOTEBOOK_TO_CLOSE "gedit-notebook-to-close"
|
#define GEDIT_NOTEBOOK_TO_CLOSE "gedit-notebook-to-close"
|
||||||
#define GEDIT_IS_QUITTING "gedit-is-quitting"
|
#define GEDIT_IS_QUITTING "gedit-is-quitting"
|
||||||
|
@ -145,26 +150,24 @@ load_file_list (GeditWindow *window,
|
||||||
{
|
{
|
||||||
if (l == files)
|
if (l == files)
|
||||||
{
|
{
|
||||||
GeditDocument *doc;
|
TeplView *view;
|
||||||
|
|
||||||
gedit_window_set_active_tab (window, tab);
|
gedit_window_set_active_tab (window, tab);
|
||||||
jump_to = FALSE;
|
jump_to = FALSE;
|
||||||
doc = gedit_tab_get_document (tab);
|
view = TEPL_VIEW (gedit_tab_get_view (tab));
|
||||||
|
|
||||||
if (line_pos > 0)
|
if (line_pos > 0)
|
||||||
{
|
{
|
||||||
if (column_pos > 0)
|
if (column_pos > 0)
|
||||||
{
|
{
|
||||||
gedit_document_goto_line_offset (doc,
|
tepl_view_goto_line_offset (view,
|
||||||
line_pos - 1,
|
line_pos - 1,
|
||||||
column_pos - 1);
|
column_pos - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gedit_document_goto_line (doc, line_pos - 1);
|
tepl_view_goto_line (view, line_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (gedit_tab_get_view (tab));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +194,7 @@ load_file_list (GeditWindow *window,
|
||||||
|
|
||||||
doc = gedit_tab_get_document (tab);
|
doc = gedit_tab_get_document (tab);
|
||||||
|
|
||||||
if (gedit_document_is_untouched (doc) &&
|
if (tepl_buffer_is_untouched (TEPL_BUFFER (doc)) &&
|
||||||
gedit_tab_get_state (tab) == GEDIT_TAB_STATE_NORMAL)
|
gedit_tab_get_state (tab) == GEDIT_TAB_STATE_NORMAL)
|
||||||
{
|
{
|
||||||
_gedit_tab_load (tab,
|
_gedit_tab_load (tab,
|
||||||
|
@ -394,38 +397,6 @@ file_chooser_open_done_cb (GeditFileChooserOpen *file_chooser,
|
||||||
g_slist_free_full (files, g_object_unref);
|
g_slist_free_full (files, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar*
|
|
||||||
_get_currrent_doc_location (GeditWindow *window)
|
|
||||||
{
|
|
||||||
GFile *default_path = NULL;
|
|
||||||
const gchar *default_uri = NULL;
|
|
||||||
|
|
||||||
if (window != NULL)
|
|
||||||
{
|
|
||||||
GeditDocument *doc;
|
|
||||||
|
|
||||||
doc = gedit_window_get_active_document (window);
|
|
||||||
|
|
||||||
if (doc != NULL)
|
|
||||||
{
|
|
||||||
GtkSourceFile *file = gedit_document_get_file (doc);
|
|
||||||
GFile *location = gtk_source_file_get_location (file);
|
|
||||||
|
|
||||||
if (location != NULL)
|
|
||||||
{
|
|
||||||
default_path = g_file_get_parent (location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (default_path != NULL)
|
|
||||||
{
|
|
||||||
default_uri = g_file_get_uri(default_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return default_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_gedit_cmd_file_open (GSimpleAction *action,
|
_gedit_cmd_file_open (GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
|
@ -441,8 +412,6 @@ _gedit_cmd_file_open (GSimpleAction *action,
|
||||||
window = GEDIT_WINDOW (user_data);
|
window = GEDIT_WINDOW (user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar* default_uri = _get_currrent_doc_location (window);
|
|
||||||
|
|
||||||
file_chooser = _gedit_file_chooser_open_new ();
|
file_chooser = _gedit_file_chooser_open_new ();
|
||||||
|
|
||||||
if (window != NULL)
|
if (window != NULL)
|
||||||
|
@ -453,12 +422,6 @@ _gedit_cmd_file_open (GSimpleAction *action,
|
||||||
GTK_WINDOW (window));
|
GTK_WINDOW (window));
|
||||||
|
|
||||||
folder_uri = _gedit_window_get_file_chooser_folder_uri (window, GTK_FILE_CHOOSER_ACTION_OPEN);
|
folder_uri = _gedit_window_get_file_chooser_folder_uri (window, GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||||
|
|
||||||
if (default_uri != NULL)
|
|
||||||
{
|
|
||||||
folder_uri = default_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folder_uri != NULL)
|
if (folder_uri != NULL)
|
||||||
{
|
{
|
||||||
_gedit_file_chooser_set_current_folder_uri (GEDIT_FILE_CHOOSER (file_chooser),
|
_gedit_file_chooser_set_current_folder_uri (GEDIT_FILE_CHOOSER (file_chooser),
|
||||||
|
@ -510,7 +473,7 @@ replace_read_only_file (GtkWindow *parent,
|
||||||
* though the dialog uses wrapped text, if the name doesn't contain
|
* though the dialog uses wrapped text, if the name doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
name_for_display = gedit_utils_str_middle_truncate (parse_name, 50);
|
name_for_display = tepl_utils_str_middle_truncate (parse_name, 50);
|
||||||
g_free (parse_name);
|
g_free (parse_name);
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new (parent,
|
dialog = gtk_message_dialog_new (parent,
|
||||||
|
@ -562,7 +525,7 @@ change_compression (GtkWindow *parent,
|
||||||
* though the dialog uses wrapped text, if the name doesn't contain
|
* though the dialog uses wrapped text, if the name doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
name_for_display = gedit_utils_str_middle_truncate (parse_name, 50);
|
name_for_display = tepl_utils_str_middle_truncate (parse_name, 50);
|
||||||
g_free (parse_name);
|
g_free (parse_name);
|
||||||
|
|
||||||
if (compressed)
|
if (compressed)
|
||||||
|
@ -824,7 +787,6 @@ save_as_tab_async (GeditTab *tab,
|
||||||
/* Translators: "Save As" is the title of the file chooser window. */
|
/* Translators: "Save As" is the title of the file chooser window. */
|
||||||
save_dialog = gedit_file_chooser_dialog_create (C_("window title", "Save As"),
|
save_dialog = gedit_file_chooser_dialog_create (C_("window title", "Save As"),
|
||||||
GTK_WINDOW (window),
|
GTK_WINDOW (window),
|
||||||
GEDIT_FILE_CHOOSER_FLAG_SAVE,
|
|
||||||
_("_Save"),
|
_("_Save"),
|
||||||
_("_Cancel"));
|
_("_Cancel"));
|
||||||
|
|
||||||
|
|
|
@ -102,33 +102,21 @@ _gedit_cmd_help_about (GeditWindow *window)
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
GdkPixbuf *logo;
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_COMMANDS);
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
logo = gdk_pixbuf_new_from_resource ("/org/gnome/gedit/pixmaps/gedit-logo.png", &error);
|
|
||||||
if (error != NULL)
|
|
||||||
{
|
|
||||||
g_warning ("Error when loading the gedit logo: %s", error->message);
|
|
||||||
g_clear_error (&error);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_show_about_dialog (GTK_WINDOW (window),
|
gtk_show_about_dialog (GTK_WINDOW (window),
|
||||||
"program-name", "gedit",
|
"program-name", "gedit",
|
||||||
"authors", authors,
|
"authors", authors,
|
||||||
"comments", _("gedit is a small and lightweight text editor for the GNOME desktop"),
|
"comments", _("gedit is a small and lightweight text editor for the GNOME desktop"),
|
||||||
"copyright", "Copyright 1998-2021 – the gedit team",
|
"copyright", "Copyright 1998-2020 – the gedit team",
|
||||||
"license-type", GTK_LICENSE_GPL_2_0,
|
"license-type", GTK_LICENSE_GPL_2_0,
|
||||||
"logo", logo,
|
"logo-icon-name", "org.gnome.gedit",
|
||||||
"documenters", documenters,
|
"documenters", documenters,
|
||||||
"translator-credits", _("translator-credits"),
|
"translator-credits", _("translator-credits"),
|
||||||
"version", VERSION,
|
"version", VERSION,
|
||||||
"website", "http://www.gedit.org",
|
"website", "http://www.gedit.org",
|
||||||
"website-label", "www.gedit.org",
|
"website-label", "www.gedit.org",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_clear_object (&logo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-statusbar.h"
|
#include "gedit-statusbar.h"
|
||||||
|
@ -131,7 +132,7 @@ text_not_found (GeditWindow *window,
|
||||||
gchar *truncated_text;
|
gchar *truncated_text;
|
||||||
|
|
||||||
search_text = gedit_replace_dialog_get_search_text (replace_dialog);
|
search_text = gedit_replace_dialog_get_search_text (replace_dialog);
|
||||||
truncated_text = gedit_utils_str_end_truncate (search_text, MAX_MSG_LENGTH);
|
truncated_text = tepl_utils_str_end_truncate (search_text, MAX_MSG_LENGTH);
|
||||||
|
|
||||||
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
|
gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar),
|
||||||
window->priv->generic_message_cid,
|
window->priv->generic_message_cid,
|
||||||
|
@ -187,7 +188,7 @@ forward_search_finished (GtkSourceSearchContext *search_context,
|
||||||
&match_start,
|
&match_start,
|
||||||
&match_end);
|
&match_end);
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (view));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -293,7 +294,7 @@ backward_search_finished (GtkSourceSearchContext *search_context,
|
||||||
&match_start,
|
&match_start,
|
||||||
&match_end);
|
&match_end);
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (view));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,16 +21,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gedit-commands.h"
|
#include "gedit-commands.h"
|
||||||
#include "gedit-commands-private.h"
|
#include "gedit-commands-private.h"
|
||||||
|
#include <tepl/tepl.h>
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-window.h"
|
#include "gedit-window.h"
|
||||||
#include "gedit-highlight-mode-dialog.h"
|
|
||||||
#include "gedit-highlight-mode-selector.h"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_gedit_cmd_view_focus_active (GSimpleAction *action,
|
_gedit_cmd_view_focus_active (GSimpleAction *action,
|
||||||
|
@ -126,9 +121,9 @@ _gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
language_selected_cb (GeditHighlightModeSelector *selector,
|
language_activated_cb (TeplLanguageChooserDialog *dialog,
|
||||||
GtkSourceLanguage *language,
|
GtkSourceLanguage *language,
|
||||||
GeditWindow *window)
|
GeditWindow *window)
|
||||||
{
|
{
|
||||||
GeditDocument *active_document;
|
GeditDocument *active_document;
|
||||||
|
|
||||||
|
@ -137,6 +132,16 @@ language_selected_cb (GeditHighlightModeSelector *selector,
|
||||||
{
|
{
|
||||||
gedit_document_set_language (active_document, language);
|
gedit_document_set_language (active_document, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
language_chooser_dialog_response_after_cb (TeplLanguageChooserDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -145,12 +150,10 @@ _gedit_cmd_view_highlight_mode (GSimpleAction *action,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GeditWindow *window = GEDIT_WINDOW (user_data);
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
GeditHighlightModeDialog *dialog;
|
TeplLanguageChooserDialog *dialog;
|
||||||
GeditHighlightModeSelector *selector;
|
|
||||||
GeditDocument *active_document;
|
GeditDocument *active_document;
|
||||||
|
|
||||||
dialog = GEDIT_HIGHLIGHT_MODE_DIALOG (gedit_highlight_mode_dialog_new (GTK_WINDOW (window)));
|
dialog = tepl_language_chooser_dialog_new (GTK_WINDOW (window));
|
||||||
selector = gedit_highlight_mode_dialog_get_selector (dialog);
|
|
||||||
|
|
||||||
active_document = gedit_window_get_active_document (window);
|
active_document = gedit_window_get_active_document (window);
|
||||||
if (active_document != NULL)
|
if (active_document != NULL)
|
||||||
|
@ -158,15 +161,20 @@ _gedit_cmd_view_highlight_mode (GSimpleAction *action,
|
||||||
GtkSourceLanguage *language;
|
GtkSourceLanguage *language;
|
||||||
|
|
||||||
language = gedit_document_get_language (active_document);
|
language = gedit_document_get_language (active_document);
|
||||||
gedit_highlight_mode_selector_select_language (selector, language);
|
tepl_language_chooser_select_language (TEPL_LANGUAGE_CHOOSER (dialog), language);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect_object (selector,
|
g_signal_connect_object (dialog,
|
||||||
"language-selected",
|
"language-activated",
|
||||||
G_CALLBACK (language_selected_cb),
|
G_CALLBACK (language_activated_cb),
|
||||||
window,
|
window,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
g_signal_connect_after (dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (language_chooser_dialog_response_after_cb),
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_widget_show (GTK_WIDGET (dialog));
|
gtk_widget_show (GTK_WIDGET (dialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,6 @@ gedit_debug_init (void)
|
||||||
{
|
{
|
||||||
enabled_sections |= GEDIT_DEBUG_UTILS;
|
enabled_sections |= GEDIT_DEBUG_UTILS;
|
||||||
}
|
}
|
||||||
if (g_getenv ("GEDIT_DEBUG_METADATA") != NULL)
|
|
||||||
{
|
|
||||||
enabled_sections |= GEDIT_DEBUG_METADATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ typedef enum {
|
||||||
GEDIT_DEBUG_COMMANDS = 1 << 7,
|
GEDIT_DEBUG_COMMANDS = 1 << 7,
|
||||||
GEDIT_DEBUG_APP = 1 << 8,
|
GEDIT_DEBUG_APP = 1 << 8,
|
||||||
GEDIT_DEBUG_UTILS = 1 << 9,
|
GEDIT_DEBUG_UTILS = 1 << 9,
|
||||||
GEDIT_DEBUG_METADATA = 1 << 10,
|
|
||||||
} GeditDebugSection;
|
} GeditDebugSection;
|
||||||
|
|
||||||
#define DEBUG_VIEW GEDIT_DEBUG_VIEW, __FILE__, __LINE__, G_STRFUNC
|
#define DEBUG_VIEW GEDIT_DEBUG_VIEW, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
@ -61,7 +60,6 @@ typedef enum {
|
||||||
#define DEBUG_COMMANDS GEDIT_DEBUG_COMMANDS,__FILE__, __LINE__, G_STRFUNC
|
#define DEBUG_COMMANDS GEDIT_DEBUG_COMMANDS,__FILE__, __LINE__, G_STRFUNC
|
||||||
#define DEBUG_APP GEDIT_DEBUG_APP, __FILE__, __LINE__, G_STRFUNC
|
#define DEBUG_APP GEDIT_DEBUG_APP, __FILE__, __LINE__, G_STRFUNC
|
||||||
#define DEBUG_UTILS GEDIT_DEBUG_UTILS, __FILE__, __LINE__, G_STRFUNC
|
#define DEBUG_UTILS GEDIT_DEBUG_UTILS, __FILE__, __LINE__, G_STRFUNC
|
||||||
#define DEBUG_METADATA GEDIT_DEBUG_METADATA,__FILE__, __LINE__, G_STRFUNC
|
|
||||||
|
|
||||||
void gedit_debug_init (void);
|
void gedit_debug_init (void);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <gtkosxapplication.h>
|
#include <gtkosxapplication.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gchar *user_cache_dir = NULL;
|
|
||||||
static gchar *user_config_dir = NULL;
|
static gchar *user_config_dir = NULL;
|
||||||
static gchar *user_data_dir = NULL;
|
static gchar *user_data_dir = NULL;
|
||||||
static gchar *user_styles_dir = NULL;
|
static gchar *user_styles_dir = NULL;
|
||||||
|
@ -96,9 +95,6 @@ gedit_dirs_init ()
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
user_cache_dir = g_build_filename (g_get_user_cache_dir (),
|
|
||||||
"gedit",
|
|
||||||
NULL);
|
|
||||||
user_config_dir = g_build_filename (g_get_user_config_dir (),
|
user_config_dir = g_build_filename (g_get_user_config_dir (),
|
||||||
"gedit",
|
"gedit",
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -119,7 +115,6 @@ gedit_dirs_init ()
|
||||||
void
|
void
|
||||||
gedit_dirs_shutdown ()
|
gedit_dirs_shutdown ()
|
||||||
{
|
{
|
||||||
g_clear_pointer (&user_cache_dir, g_free);
|
|
||||||
g_clear_pointer (&user_config_dir, g_free);
|
g_clear_pointer (&user_config_dir, g_free);
|
||||||
g_clear_pointer (&user_data_dir, g_free);
|
g_clear_pointer (&user_data_dir, g_free);
|
||||||
g_clear_pointer (&user_styles_dir, g_free);
|
g_clear_pointer (&user_styles_dir, g_free);
|
||||||
|
@ -130,12 +125,6 @@ gedit_dirs_shutdown ()
|
||||||
g_clear_pointer (&gedit_plugins_data_dir, g_free);
|
g_clear_pointer (&gedit_plugins_data_dir, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
|
||||||
gedit_dirs_get_user_cache_dir (void)
|
|
||||||
{
|
|
||||||
return user_cache_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gedit_dirs_get_user_config_dir (void)
|
gedit_dirs_get_user_config_dir (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,8 +32,6 @@ void gedit_dirs_init (void);
|
||||||
void gedit_dirs_shutdown (void);
|
void gedit_dirs_shutdown (void);
|
||||||
|
|
||||||
|
|
||||||
const gchar *gedit_dirs_get_user_cache_dir (void);
|
|
||||||
|
|
||||||
const gchar *gedit_dirs_get_user_config_dir (void);
|
const gchar *gedit_dirs_get_user_config_dir (void);
|
||||||
|
|
||||||
const gchar *gedit_dirs_get_user_data_dir (void);
|
const gchar *gedit_dirs_get_user_data_dir (void);
|
||||||
|
|
|
@ -28,15 +28,9 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#define GEDIT_METADATA_ATTRIBUTE_POSITION "gedit-position"
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_POSITION "position"
|
#define GEDIT_METADATA_ATTRIBUTE_ENCODING "gedit-encoding"
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_ENCODING "encoding"
|
#define GEDIT_METADATA_ATTRIBUTE_LANGUAGE "gedit-language"
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_LANGUAGE "language"
|
|
||||||
#else
|
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_POSITION "metadata::gedit-position"
|
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_ENCODING "metadata::gedit-encoding"
|
|
||||||
#define GEDIT_METADATA_ATTRIBUTE_LANGUAGE "metadata::gedit-language"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
glong _gedit_document_get_seconds_since_last_save_or_load (GeditDocument *doc);
|
glong _gedit_document_get_seconds_since_last_save_or_load (GeditDocument *doc);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
* Copyright (C) 2002-2005 Paolo Maggi
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
* Copyright (C) 2014-2015 Sébastien Wilmet
|
* Copyright (C) 2014-2020 Sébastien Wilmet
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -22,21 +22,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gedit-document.h"
|
#include "gedit-document.h"
|
||||||
#include "gedit-document-private.h"
|
#include "gedit-document-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "gedit-app.h"
|
|
||||||
#include "gedit-app-private.h"
|
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-utils.h"
|
#include "gedit-utils.h"
|
||||||
#include "gedit-metadata-manager.h"
|
|
||||||
|
|
||||||
#define METADATA_QUERY "metadata::*"
|
|
||||||
|
|
||||||
#define NO_LANGUAGE_NAME "_NORMAL_"
|
#define NO_LANGUAGE_NAME "_NORMAL_"
|
||||||
|
|
||||||
|
@ -51,11 +43,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
GtkSourceFile *file;
|
GtkSourceFile *file;
|
||||||
|
|
||||||
GSettings *editor_settings;
|
TeplMetadata *metadata;
|
||||||
|
|
||||||
gint untitled_number;
|
|
||||||
|
|
||||||
GFileInfo *metadata_info;
|
|
||||||
|
|
||||||
gchar *content_type;
|
gchar *content_type;
|
||||||
|
|
||||||
|
@ -66,12 +54,7 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
GtkSourceSearchContext *search_context;
|
GtkSourceSearchContext *search_context;
|
||||||
|
|
||||||
GeditMetadataManager *metadata_manager;
|
|
||||||
|
|
||||||
guint user_action;
|
|
||||||
|
|
||||||
guint language_set_by_user : 1;
|
guint language_set_by_user : 1;
|
||||||
guint use_gvfs_metadata : 1;
|
|
||||||
|
|
||||||
/* The search is empty if there is no search context, or if the
|
/* The search is empty if there is no search context, or if the
|
||||||
* search text is empty. It is used for the sensitivity of some menu
|
* search text is empty. It is used for the sensitivity of some menu
|
||||||
|
@ -88,11 +71,9 @@ typedef struct
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_SHORTNAME,
|
|
||||||
PROP_CONTENT_TYPE,
|
PROP_CONTENT_TYPE,
|
||||||
PROP_MIME_TYPE,
|
PROP_MIME_TYPE,
|
||||||
PROP_EMPTY_SEARCH,
|
PROP_EMPTY_SEARCH,
|
||||||
PROP_USE_GVFS_METADATA,
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,7 +81,6 @@ static GParamSpec *properties[LAST_PROP];
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CURSOR_MOVED,
|
|
||||||
LOAD,
|
LOAD,
|
||||||
LOADED,
|
LOADED,
|
||||||
SAVE,
|
SAVE,
|
||||||
|
@ -110,41 +90,40 @@ enum
|
||||||
|
|
||||||
static guint document_signals[LAST_SIGNAL];
|
static guint document_signals[LAST_SIGNAL];
|
||||||
|
|
||||||
static GHashTable *allocated_untitled_numbers = NULL;
|
G_DEFINE_TYPE_WITH_PRIVATE (GeditDocument, gedit_document, TEPL_TYPE_BUFFER)
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GeditDocument, gedit_document, GTK_SOURCE_TYPE_BUFFER)
|
static void
|
||||||
|
load_metadata_from_metadata_manager (GeditDocument *doc)
|
||||||
static gint
|
|
||||||
get_untitled_number (void)
|
|
||||||
{
|
{
|
||||||
gint i = 1;
|
GeditDocumentPrivate *priv = gedit_document_get_instance_private (doc);
|
||||||
|
GFile *location;
|
||||||
|
|
||||||
if (allocated_untitled_numbers == NULL)
|
location = gtk_source_file_get_location (priv->file);
|
||||||
allocated_untitled_numbers = g_hash_table_new (NULL, NULL);
|
|
||||||
|
|
||||||
g_return_val_if_fail (allocated_untitled_numbers != NULL, -1);
|
if (location != NULL)
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
{
|
||||||
if (g_hash_table_lookup (allocated_untitled_numbers, GINT_TO_POINTER (i)) == NULL)
|
TeplMetadataManager *manager;
|
||||||
{
|
|
||||||
g_hash_table_insert (allocated_untitled_numbers,
|
|
||||||
GINT_TO_POINTER (i),
|
|
||||||
GINT_TO_POINTER (i));
|
|
||||||
|
|
||||||
return i;
|
manager = tepl_metadata_manager_get_singleton ();
|
||||||
}
|
tepl_metadata_manager_copy_from (manager, location, priv->metadata);
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_untitled_number (gint n)
|
save_metadata_into_metadata_manager (GeditDocument *doc)
|
||||||
{
|
{
|
||||||
g_return_if_fail (allocated_untitled_numbers != NULL);
|
GeditDocumentPrivate *priv = gedit_document_get_instance_private (doc);
|
||||||
|
GFile *location;
|
||||||
|
|
||||||
g_hash_table_remove (allocated_untitled_numbers, GINT_TO_POINTER (n));
|
location = gtk_source_file_get_location (priv->file);
|
||||||
|
|
||||||
|
if (location != NULL)
|
||||||
|
{
|
||||||
|
TeplMetadataManager *manager;
|
||||||
|
|
||||||
|
manager = tepl_metadata_manager_get_singleton ();
|
||||||
|
tepl_metadata_manager_merge_into (manager, location, priv->metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -216,17 +195,16 @@ gedit_document_dispose (GObject *object)
|
||||||
/* Metadata must be saved here and not in finalize because the language
|
/* Metadata must be saved here and not in finalize because the language
|
||||||
* is gone by the time finalize runs.
|
* is gone by the time finalize runs.
|
||||||
*/
|
*/
|
||||||
if (priv->file != NULL)
|
if (priv->metadata != NULL)
|
||||||
{
|
{
|
||||||
save_metadata (doc);
|
save_metadata (doc);
|
||||||
|
|
||||||
g_object_unref (priv->file);
|
g_object_unref (priv->metadata);
|
||||||
priv->file = NULL;
|
priv->metadata = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->metadata_info);
|
g_clear_object (&priv->file);
|
||||||
g_clear_object (&priv->search_context);
|
g_clear_object (&priv->search_context);
|
||||||
g_clear_object (&priv->metadata_manager);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_document_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gedit_document_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -234,17 +212,10 @@ gedit_document_dispose (GObject *object)
|
||||||
static void
|
static void
|
||||||
gedit_document_finalize (GObject *object)
|
gedit_document_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
GeditDocumentPrivate *priv = gedit_document_get_instance_private (GEDIT_DOCUMENT (object));
|
||||||
|
|
||||||
gedit_debug (DEBUG_DOCUMENT);
|
gedit_debug (DEBUG_DOCUMENT);
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (GEDIT_DOCUMENT (object));
|
|
||||||
|
|
||||||
if (priv->untitled_number > 0)
|
|
||||||
{
|
|
||||||
release_untitled_number (priv->untitled_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (priv->content_type);
|
g_free (priv->content_type);
|
||||||
|
|
||||||
if (priv->time_of_last_save_or_load != NULL)
|
if (priv->time_of_last_save_or_load != NULL)
|
||||||
|
@ -268,10 +239,6 @@ gedit_document_get_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_SHORTNAME:
|
|
||||||
g_value_take_string (value, gedit_document_get_short_name_for_display (doc));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_CONTENT_TYPE:
|
case PROP_CONTENT_TYPE:
|
||||||
g_value_take_string (value, gedit_document_get_content_type (doc));
|
g_value_take_string (value, gedit_document_get_content_type (doc));
|
||||||
break;
|
break;
|
||||||
|
@ -284,10 +251,6 @@ gedit_document_get_property (GObject *object,
|
||||||
g_value_set_boolean (value, priv->empty_search);
|
g_value_set_boolean (value, priv->empty_search);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_USE_GVFS_METADATA:
|
|
||||||
g_value_set_boolean (value, priv->use_gvfs_metadata);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -301,7 +264,6 @@ gedit_document_set_property (GObject *object,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GeditDocument *doc = GEDIT_DOCUMENT (object);
|
GeditDocument *doc = GEDIT_DOCUMENT (object);
|
||||||
GeditDocumentPrivate *priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
|
@ -309,97 +271,22 @@ gedit_document_set_property (GObject *object,
|
||||||
set_content_type (doc, g_value_get_string (value));
|
set_content_type (doc, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_USE_GVFS_METADATA:
|
|
||||||
priv->use_gvfs_metadata = g_value_get_boolean (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_document_begin_user_action (GtkTextBuffer *buffer)
|
|
||||||
{
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (GEDIT_DOCUMENT (buffer));
|
|
||||||
|
|
||||||
++priv->user_action;
|
|
||||||
|
|
||||||
if (GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->begin_user_action != NULL)
|
|
||||||
{
|
|
||||||
GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->begin_user_action (buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_document_end_user_action (GtkTextBuffer *buffer)
|
|
||||||
{
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (GEDIT_DOCUMENT (buffer));
|
|
||||||
|
|
||||||
--priv->user_action;
|
|
||||||
|
|
||||||
if (GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->end_user_action != NULL)
|
|
||||||
{
|
|
||||||
GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->end_user_action (buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_document_mark_set (GtkTextBuffer *buffer,
|
|
||||||
const GtkTextIter *iter,
|
|
||||||
GtkTextMark *mark)
|
|
||||||
{
|
|
||||||
GeditDocument *doc = GEDIT_DOCUMENT (buffer);
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
if (GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->mark_set != NULL)
|
|
||||||
{
|
|
||||||
GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->mark_set (buffer, iter, mark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mark == gtk_text_buffer_get_insert (buffer) && (priv->user_action == 0))
|
|
||||||
{
|
|
||||||
g_signal_emit (doc, document_signals[CURSOR_MOVED], 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_document_changed (GtkTextBuffer *buffer)
|
|
||||||
{
|
|
||||||
g_signal_emit (GEDIT_DOCUMENT (buffer), document_signals[CURSOR_MOVED], 0);
|
|
||||||
|
|
||||||
GTK_TEXT_BUFFER_CLASS (gedit_document_parent_class)->changed (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gedit_document_constructed (GObject *object)
|
gedit_document_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
GeditDocument *doc = GEDIT_DOCUMENT (object);
|
GeditDocument *doc = GEDIT_DOCUMENT (object);
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
GeditSettings *settings;
|
GeditSettings *settings;
|
||||||
GSettings *editor_settings;
|
GSettings *editor_settings;
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
settings = _gedit_settings_get_singleton ();
|
settings = _gedit_settings_get_singleton ();
|
||||||
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
|
|
||||||
if (!priv->use_gvfs_metadata)
|
|
||||||
{
|
|
||||||
GeditMetadataManager *metadata_manager;
|
|
||||||
|
|
||||||
metadata_manager = _gedit_app_get_metadata_manager (GEDIT_APP (g_application_get_default ()));
|
|
||||||
g_assert (GEDIT_IS_METADATA_MANAGER (metadata_manager));
|
|
||||||
priv->metadata_manager = g_object_ref (metadata_manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bind construct properties. */
|
/* Bind construct properties. */
|
||||||
g_settings_bind (editor_settings, GEDIT_SETTINGS_ENSURE_TRAILING_NEWLINE,
|
g_settings_bind (editor_settings, GEDIT_SETTINGS_ENSURE_TRAILING_NEWLINE,
|
||||||
doc, "implicit-trailing-newline",
|
doc, "implicit-trailing-newline",
|
||||||
|
@ -412,7 +299,6 @@ static void
|
||||||
gedit_document_class_init (GeditDocumentClass *klass)
|
gedit_document_class_init (GeditDocumentClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkTextBufferClass *buf_class = GTK_TEXT_BUFFER_CLASS (klass);
|
|
||||||
|
|
||||||
object_class->dispose = gedit_document_dispose;
|
object_class->dispose = gedit_document_dispose;
|
||||||
object_class->finalize = gedit_document_finalize;
|
object_class->finalize = gedit_document_finalize;
|
||||||
|
@ -420,26 +306,9 @@ gedit_document_class_init (GeditDocumentClass *klass)
|
||||||
object_class->set_property = gedit_document_set_property;
|
object_class->set_property = gedit_document_set_property;
|
||||||
object_class->constructed = gedit_document_constructed;
|
object_class->constructed = gedit_document_constructed;
|
||||||
|
|
||||||
buf_class->begin_user_action = gedit_document_begin_user_action;
|
|
||||||
buf_class->end_user_action = gedit_document_end_user_action;
|
|
||||||
buf_class->mark_set = gedit_document_mark_set;
|
|
||||||
buf_class->changed = gedit_document_changed;
|
|
||||||
|
|
||||||
klass->loaded = gedit_document_loaded_real;
|
klass->loaded = gedit_document_loaded_real;
|
||||||
klass->saved = gedit_document_saved_real;
|
klass->saved = gedit_document_saved_real;
|
||||||
|
|
||||||
/**
|
|
||||||
* GeditDocument:shortname:
|
|
||||||
*
|
|
||||||
* The document's short name.
|
|
||||||
*/
|
|
||||||
properties[PROP_SHORTNAME] =
|
|
||||||
g_param_spec_string ("shortname",
|
|
||||||
"Short Name",
|
|
||||||
"The document's short name",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GeditDocument:content-type:
|
* GeditDocument:content-type:
|
||||||
*
|
*
|
||||||
|
@ -479,44 +348,8 @@ gedit_document_class_init (GeditDocumentClass *klass)
|
||||||
TRUE,
|
TRUE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
|
||||||
* GeditDocument:use-gvfs-metadata:
|
|
||||||
*
|
|
||||||
* Whether to use GVFS metadata. If %FALSE, use the gedit metadata
|
|
||||||
* manager that stores the metadata in an XML file in the user cache
|
|
||||||
* directory.
|
|
||||||
*
|
|
||||||
* <warning>
|
|
||||||
* The property is used internally by gedit. It must not be used in a
|
|
||||||
* gedit plugin. The property can be modified or removed at any time.
|
|
||||||
* </warning>
|
|
||||||
*/
|
|
||||||
properties[PROP_USE_GVFS_METADATA] =
|
|
||||||
g_param_spec_boolean ("use-gvfs-metadata",
|
|
||||||
"Use GVFS metadata",
|
|
||||||
"",
|
|
||||||
TRUE,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
||||||
|
|
||||||
/* This signal is used to update the cursor position in the statusbar,
|
|
||||||
* it's emitted either when the insert mark is moved explicitely or
|
|
||||||
* when the buffer changes (insert/delete).
|
|
||||||
* FIXME When the replace_all was implemented in gedit, this signal was
|
|
||||||
* not emitted during the replace_all to improve performance. Now the
|
|
||||||
* replace_all is implemented in GtkSourceView, so the signal is
|
|
||||||
* emitted.
|
|
||||||
*/
|
|
||||||
document_signals[CURSOR_MOVED] =
|
|
||||||
g_signal_new ("cursor-moved",
|
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET (GeditDocumentClass, cursor_moved),
|
|
||||||
NULL, NULL, NULL,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GeditDocument::load:
|
* GeditDocument::load:
|
||||||
* @document: the #GeditDocument.
|
* @document: the #GeditDocument.
|
||||||
|
@ -799,79 +632,20 @@ on_location_changed (GtkSourceFile *file,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GeditDocument *doc)
|
GeditDocument *doc)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
GFile *location;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_DOCUMENT);
|
gedit_debug (DEBUG_DOCUMENT);
|
||||||
|
load_metadata_from_metadata_manager (doc);
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
location = gtk_source_file_get_location (file);
|
|
||||||
|
|
||||||
if (location != NULL && priv->untitled_number > 0)
|
|
||||||
{
|
|
||||||
release_untitled_number (priv->untitled_number);
|
|
||||||
priv->untitled_number = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (doc), properties[PROP_SHORTNAME]);
|
|
||||||
|
|
||||||
/* Load metadata for this location: we load sync since metadata is
|
|
||||||
* always local so it should be fast and we need the information
|
|
||||||
* right after the location was set.
|
|
||||||
* TODO: do async I/O for the metadata.
|
|
||||||
*/
|
|
||||||
if (priv->use_gvfs_metadata && location != NULL)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (priv->metadata_info != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (priv->metadata_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->metadata_info = g_file_query_info (location,
|
|
||||||
METADATA_QUERY,
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (error != NULL)
|
|
||||||
{
|
|
||||||
/* Do not complain about metadata if we are opening a
|
|
||||||
* non existing file.
|
|
||||||
*/
|
|
||||||
if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_ISDIR) &&
|
|
||||||
!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOTDIR) &&
|
|
||||||
!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
|
|
||||||
!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
|
||||||
{
|
|
||||||
g_warning ("%s", error->message);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->metadata_info == NULL)
|
|
||||||
{
|
|
||||||
priv->metadata_info = g_file_info_new ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gedit_document_init (GeditDocument *doc)
|
gedit_document_init (GeditDocument *doc)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv = gedit_document_get_instance_private (doc);
|
GeditDocumentPrivate *priv = gedit_document_get_instance_private (doc);
|
||||||
|
TeplFile *tepl_file;
|
||||||
GeditSettings *settings;
|
GeditSettings *settings;
|
||||||
GSettings *editor_settings;
|
GSettings *editor_settings;
|
||||||
|
|
||||||
gedit_debug (DEBUG_DOCUMENT);
|
gedit_debug (DEBUG_DOCUMENT);
|
||||||
|
|
||||||
settings = _gedit_settings_get_singleton ();
|
|
||||||
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
|
||||||
|
|
||||||
priv->untitled_number = get_untitled_number ();
|
|
||||||
priv->content_type = get_default_content_type ();
|
priv->content_type = get_default_content_type ();
|
||||||
priv->language_set_by_user = FALSE;
|
priv->language_set_by_user = FALSE;
|
||||||
priv->empty_search = TRUE;
|
priv->empty_search = TRUE;
|
||||||
|
@ -879,7 +653,13 @@ gedit_document_init (GeditDocument *doc)
|
||||||
update_time_of_last_save_or_load (doc);
|
update_time_of_last_save_or_load (doc);
|
||||||
|
|
||||||
priv->file = gtk_source_file_new ();
|
priv->file = gtk_source_file_new ();
|
||||||
priv->metadata_info = g_file_info_new ();
|
tepl_file = tepl_buffer_get_file (TEPL_BUFFER (doc));
|
||||||
|
|
||||||
|
g_object_bind_property (priv->file, "location",
|
||||||
|
tepl_file, "location",
|
||||||
|
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
|
priv->metadata = tepl_metadata_new ();
|
||||||
|
|
||||||
g_signal_connect_object (priv->file,
|
g_signal_connect_object (priv->file,
|
||||||
"notify::location",
|
"notify::location",
|
||||||
|
@ -887,6 +667,9 @@ gedit_document_init (GeditDocument *doc)
|
||||||
doc,
|
doc,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
|
|
||||||
g_settings_bind (editor_settings, GEDIT_SETTINGS_MAX_UNDO_ACTIONS,
|
g_settings_bind (editor_settings, GEDIT_SETTINGS_MAX_UNDO_ACTIONS,
|
||||||
doc, "max-undo-levels",
|
doc, "max-undo-levels",
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
|
||||||
|
@ -916,17 +699,7 @@ gedit_document_init (GeditDocument *doc)
|
||||||
GeditDocument *
|
GeditDocument *
|
||||||
gedit_document_new (void)
|
gedit_document_new (void)
|
||||||
{
|
{
|
||||||
gboolean use_gvfs_metadata;
|
return g_object_new (GEDIT_TYPE_DOCUMENT, NULL);
|
||||||
|
|
||||||
#ifdef ENABLE_GVFS_METADATA
|
|
||||||
use_gvfs_metadata = TRUE;
|
|
||||||
#else
|
|
||||||
use_gvfs_metadata = FALSE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return g_object_new (GEDIT_TYPE_DOCUMENT,
|
|
||||||
"use-gvfs-metadata", use_gvfs_metadata,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -1041,19 +814,17 @@ set_content_type (GeditDocument *doc,
|
||||||
gchar *
|
gchar *
|
||||||
_gedit_document_get_uri_for_display (GeditDocument *doc)
|
_gedit_document_get_uri_for_display (GeditDocument *doc)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
TeplFile *file;
|
||||||
GFile *location;
|
GFile *location;
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
|
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
file = tepl_buffer_get_file (TEPL_BUFFER (doc));
|
||||||
|
location = tepl_file_get_location (file);
|
||||||
location = gtk_source_file_get_location (priv->file);
|
|
||||||
|
|
||||||
if (location == NULL)
|
if (location == NULL)
|
||||||
{
|
{
|
||||||
return g_strdup_printf (_("Untitled Document %d"),
|
return tepl_file_get_short_name (file);
|
||||||
priv->untitled_number);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1070,24 +841,12 @@ _gedit_document_get_uri_for_display (GeditDocument *doc)
|
||||||
gchar *
|
gchar *
|
||||||
gedit_document_get_short_name_for_display (GeditDocument *doc)
|
gedit_document_get_short_name_for_display (GeditDocument *doc)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
TeplFile *file;
|
||||||
GFile *location;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
|
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
file = tepl_buffer_get_file (TEPL_BUFFER (doc));
|
||||||
|
return tepl_file_get_short_name (file);
|
||||||
location = gtk_source_file_get_location (priv->file);
|
|
||||||
|
|
||||||
if (location == NULL)
|
|
||||||
{
|
|
||||||
return g_strdup_printf (_("Untitled Document %d"),
|
|
||||||
priv->untitled_number);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return gedit_utils_basename_for_display (location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -1273,31 +1032,15 @@ gedit_document_saved_real (GeditDocument *doc)
|
||||||
doc);
|
doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
gedit_document_is_untouched (GeditDocument *doc)
|
|
||||||
{
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
GFile *location;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), TRUE);
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
location = gtk_source_file_get_location (priv->file);
|
|
||||||
|
|
||||||
return location == NULL && !gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc));
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gedit_document_is_untitled (GeditDocument *doc)
|
gedit_document_is_untitled (GeditDocument *doc)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
TeplFile *file;
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), TRUE);
|
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), TRUE);
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
file = tepl_buffer_get_file (TEPL_BUFFER (doc));
|
||||||
|
return tepl_file_get_location (file) == NULL;
|
||||||
return gtk_source_file_get_location (priv->file) == NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1329,51 +1072,6 @@ _gedit_document_needs_saving (GeditDocument *doc)
|
||||||
return (externally_modified || deleted) && !priv->create;
|
return (externally_modified || deleted) && !priv->create;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If @line is bigger than the lines of the document, the cursor is moved
|
|
||||||
* to the last line and FALSE is returned.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
gedit_document_goto_line (GeditDocument *doc,
|
|
||||||
gint line)
|
|
||||||
{
|
|
||||||
GtkTextIter iter;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_DOCUMENT);
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
|
|
||||||
g_return_val_if_fail (line >= -1, FALSE);
|
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (doc),
|
|
||||||
&iter,
|
|
||||||
line);
|
|
||||||
|
|
||||||
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter);
|
|
||||||
|
|
||||||
return gtk_text_iter_get_line (&iter) == line;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gedit_document_goto_line_offset (GeditDocument *doc,
|
|
||||||
gint line,
|
|
||||||
gint line_offset)
|
|
||||||
{
|
|
||||||
GtkTextIter iter;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
|
|
||||||
g_return_val_if_fail (line >= -1, FALSE);
|
|
||||||
g_return_val_if_fail (line_offset >= -1, FALSE);
|
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER (doc),
|
|
||||||
&iter,
|
|
||||||
line,
|
|
||||||
line_offset);
|
|
||||||
|
|
||||||
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter);
|
|
||||||
|
|
||||||
return (gtk_text_iter_get_line (&iter) == line &&
|
|
||||||
gtk_text_iter_get_line_offset (&iter) == line_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gedit_document_set_language:
|
* gedit_document_set_language:
|
||||||
* @doc:
|
* @doc:
|
||||||
|
@ -1432,64 +1130,6 @@ _gedit_document_get_seconds_since_last_save_or_load (GeditDocument *doc)
|
||||||
return n_microseconds / (1000 * 1000);
|
return n_microseconds / (1000 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
|
||||||
get_metadata_from_metadata_manager (GeditDocument *doc,
|
|
||||||
const gchar *key)
|
|
||||||
{
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
GFile *location;
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
location = gtk_source_file_get_location (priv->file);
|
|
||||||
|
|
||||||
if (location != NULL)
|
|
||||||
{
|
|
||||||
return gedit_metadata_manager_get (priv->metadata_manager, location, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
get_metadata_from_gvfs (GeditDocument *doc,
|
|
||||||
const gchar *key)
|
|
||||||
{
|
|
||||||
GeditDocumentPrivate *priv;
|
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
|
||||||
|
|
||||||
if (priv->metadata_info != NULL &&
|
|
||||||
g_file_info_has_attribute (priv->metadata_info, key) &&
|
|
||||||
g_file_info_get_attribute_type (priv->metadata_info, key) == G_FILE_ATTRIBUTE_TYPE_STRING)
|
|
||||||
{
|
|
||||||
return g_strdup (g_file_info_get_attribute_string (priv->metadata_info, key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_gvfs_metadata (GFileInfo *info,
|
|
||||||
const gchar *key,
|
|
||||||
const gchar *value)
|
|
||||||
{
|
|
||||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
|
||||||
|
|
||||||
if (value != NULL)
|
|
||||||
{
|
|
||||||
g_file_info_set_attribute_string (info, key, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Unset the key */
|
|
||||||
g_file_info_set_attribute (info,
|
|
||||||
key,
|
|
||||||
G_FILE_ATTRIBUTE_TYPE_INVALID,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gedit_document_get_metadata:
|
* gedit_document_get_metadata:
|
||||||
* @doc: a #GeditDocument
|
* @doc: a #GeditDocument
|
||||||
|
@ -1510,12 +1150,12 @@ gedit_document_get_metadata (GeditDocument *doc,
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
priv = gedit_document_get_instance_private (doc);
|
||||||
|
|
||||||
if (priv->use_gvfs_metadata)
|
if (priv->metadata == NULL)
|
||||||
{
|
{
|
||||||
return get_metadata_from_gvfs (doc, key);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_metadata_from_metadata_manager (doc, key);
|
return tepl_metadata_get (priv->metadata, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1533,84 +1173,30 @@ gedit_document_set_metadata (GeditDocument *doc,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
GeditDocumentPrivate *priv;
|
GeditDocumentPrivate *priv;
|
||||||
GFile *location;
|
|
||||||
const gchar *key;
|
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
GFileInfo *info = NULL;
|
const gchar *key;
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
|
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
|
||||||
g_return_if_fail (first_key != NULL);
|
g_return_if_fail (first_key != NULL);
|
||||||
|
|
||||||
priv = gedit_document_get_instance_private (doc);
|
priv = gedit_document_get_instance_private (doc);
|
||||||
|
|
||||||
location = gtk_source_file_get_location (priv->file);
|
if (priv->metadata == NULL)
|
||||||
|
|
||||||
/* With the metadata manager, can't set metadata for untitled documents.
|
|
||||||
* With GVFS metadata, if the location is NULL the metadata is stored in
|
|
||||||
* priv->metadata_info, so that it can be saved later if the document is
|
|
||||||
* saved.
|
|
||||||
*/
|
|
||||||
if (!priv->use_gvfs_metadata && location == NULL)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->use_gvfs_metadata)
|
|
||||||
{
|
|
||||||
info = g_file_info_new ();
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start (var_args, first_key);
|
va_start (var_args, first_key);
|
||||||
|
|
||||||
for (key = first_key; key; key = va_arg (var_args, const gchar *))
|
for (key = first_key; key != NULL; key = va_arg (var_args, const gchar *))
|
||||||
{
|
{
|
||||||
const gchar *value = va_arg (var_args, const gchar *);
|
const gchar *value = va_arg (var_args, const gchar *);
|
||||||
|
tepl_metadata_set (priv->metadata, key, value);
|
||||||
if (priv->use_gvfs_metadata)
|
|
||||||
{
|
|
||||||
set_gvfs_metadata (info, key, value);
|
|
||||||
set_gvfs_metadata (priv->metadata_info, key, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gedit_metadata_manager_set (priv->metadata_manager, location, key, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end (var_args);
|
va_end (var_args);
|
||||||
|
|
||||||
if (priv->use_gvfs_metadata && location != NULL)
|
save_metadata_into_metadata_manager (doc);
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
/* We save synchronously since metadata is always local so it
|
|
||||||
* should be fast. Moreover this function can be called on
|
|
||||||
* application shutdown, when the main loop has already exited,
|
|
||||||
* so an async operation would not terminate.
|
|
||||||
* https://bugzilla.gnome.org/show_bug.cgi?id=736591
|
|
||||||
*/
|
|
||||||
g_file_set_attributes_from_info (location,
|
|
||||||
info,
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (error != NULL)
|
|
||||||
{
|
|
||||||
/* Do not complain about metadata if we are closing a
|
|
||||||
* document for a non existing file.
|
|
||||||
*/
|
|
||||||
if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
|
|
||||||
!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
|
||||||
{
|
|
||||||
g_warning ("Set document metadata failed: %s", error->message);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
* Copyright (C) 2002-2005 Paolo Maggi
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
* Copyright (C) 2014 Sébastien Wilmet
|
* Copyright (C) 2014-2020 Sébastien Wilmet
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -24,20 +24,19 @@
|
||||||
#ifndef GEDIT_DOCUMENT_H
|
#ifndef GEDIT_DOCUMENT_H
|
||||||
#define GEDIT_DOCUMENT_H
|
#define GEDIT_DOCUMENT_H
|
||||||
|
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GEDIT_TYPE_DOCUMENT (gedit_document_get_type())
|
#define GEDIT_TYPE_DOCUMENT (gedit_document_get_type())
|
||||||
|
|
||||||
G_DECLARE_DERIVABLE_TYPE (GeditDocument, gedit_document, GEDIT, DOCUMENT, GtkSourceBuffer)
|
G_DECLARE_DERIVABLE_TYPE (GeditDocument, gedit_document, GEDIT, DOCUMENT, TeplBuffer)
|
||||||
|
|
||||||
struct _GeditDocumentClass
|
struct _GeditDocumentClass
|
||||||
{
|
{
|
||||||
GtkSourceBufferClass parent_class;
|
TeplBufferClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (* cursor_moved) (GeditDocument *document);
|
|
||||||
|
|
||||||
void (* load) (GeditDocument *document);
|
void (* load) (GeditDocument *document);
|
||||||
|
|
||||||
|
@ -58,17 +57,8 @@ gchar *gedit_document_get_content_type (GeditDocument *doc);
|
||||||
|
|
||||||
gchar *gedit_document_get_mime_type (GeditDocument *doc);
|
gchar *gedit_document_get_mime_type (GeditDocument *doc);
|
||||||
|
|
||||||
gboolean gedit_document_is_untouched (GeditDocument *doc);
|
|
||||||
|
|
||||||
gboolean gedit_document_is_untitled (GeditDocument *doc);
|
gboolean gedit_document_is_untitled (GeditDocument *doc);
|
||||||
|
|
||||||
gboolean gedit_document_goto_line (GeditDocument *doc,
|
|
||||||
gint line);
|
|
||||||
|
|
||||||
gboolean gedit_document_goto_line_offset (GeditDocument *doc,
|
|
||||||
gint line,
|
|
||||||
gint line_offset);
|
|
||||||
|
|
||||||
void gedit_document_set_language (GeditDocument *doc,
|
void gedit_document_set_language (GeditDocument *doc,
|
||||||
GtkSourceLanguage *lang);
|
GtkSourceLanguage *lang);
|
||||||
GtkSourceLanguage
|
GtkSourceLanguage
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "gedit-documents-panel.h"
|
#include "gedit-documents-panel.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-document.h"
|
#include "gedit-document.h"
|
||||||
|
@ -446,7 +447,7 @@ doc_get_name (GeditDocument *doc)
|
||||||
name = gedit_document_get_short_name_for_display (doc);
|
name = gedit_document_get_short_name_for_display (doc);
|
||||||
|
|
||||||
/* Truncate the name so it doesn't get insanely wide. */
|
/* Truncate the name so it doesn't get insanely wide. */
|
||||||
docname = gedit_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);
|
docname = tepl_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
|
50
gedit/gedit-factory.c
Normal file
50
gedit/gedit-factory.c
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-factory.h"
|
||||||
|
#include "gedit-dirs.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditFactory, gedit_factory, TEPL_TYPE_ABSTRACT_FACTORY)
|
||||||
|
|
||||||
|
static GFile *
|
||||||
|
gedit_factory_create_metadata_manager_file (TeplAbstractFactory *factory)
|
||||||
|
{
|
||||||
|
return g_file_new_build_filename (gedit_dirs_get_user_data_dir (),
|
||||||
|
"gedit-metadata.xml",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_factory_class_init (GeditFactoryClass *klass)
|
||||||
|
{
|
||||||
|
TeplAbstractFactoryClass *factory_class = TEPL_ABSTRACT_FACTORY_CLASS (klass);
|
||||||
|
|
||||||
|
factory_class->create_metadata_manager_file = gedit_factory_create_metadata_manager_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_factory_init (GeditFactory *factory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFactory *
|
||||||
|
gedit_factory_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_FACTORY, NULL);
|
||||||
|
}
|
53
gedit/gedit-factory.h
Normal file
53
gedit/gedit-factory.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FACTORY_H
|
||||||
|
#define GEDIT_FACTORY_H
|
||||||
|
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FACTORY (gedit_factory_get_type ())
|
||||||
|
#define GEDIT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FACTORY, GeditFactory))
|
||||||
|
#define GEDIT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FACTORY, GeditFactoryClass))
|
||||||
|
#define GEDIT_IS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FACTORY))
|
||||||
|
#define GEDIT_IS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FACTORY))
|
||||||
|
#define GEDIT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FACTORY, GeditFactoryClass))
|
||||||
|
|
||||||
|
typedef struct _GeditFactory GeditFactory;
|
||||||
|
typedef struct _GeditFactoryClass GeditFactoryClass;
|
||||||
|
|
||||||
|
struct _GeditFactory
|
||||||
|
{
|
||||||
|
TeplAbstractFactory parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFactoryClass
|
||||||
|
{
|
||||||
|
TeplAbstractFactoryClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gedit_factory_get_type (void);
|
||||||
|
|
||||||
|
GeditFactory * gedit_factory_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FACTORY_H */
|
|
@ -192,12 +192,6 @@ chooser_show (GeditFileChooserDialog *dialog)
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (dialog));
|
gtk_widget_grab_focus (GTK_WIDGET (dialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
chooser_hide (GeditFileChooserDialog *dialog)
|
|
||||||
{
|
|
||||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chooser_destroy (GeditFileChooserDialog *dialog)
|
chooser_destroy (GeditFileChooserDialog *dialog)
|
||||||
{
|
{
|
||||||
|
@ -217,26 +211,6 @@ chooser_get_window (GeditFileChooserDialog *dialog)
|
||||||
return GTK_WINDOW (dialog);
|
return GTK_WINDOW (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
chooser_add_pattern_filter (GeditFileChooserDialog *dialog,
|
|
||||||
const gchar *name,
|
|
||||||
const gchar *pattern)
|
|
||||||
{
|
|
||||||
GtkFileFilter *filter;
|
|
||||||
|
|
||||||
filter = gtk_file_filter_new ();
|
|
||||||
|
|
||||||
gtk_file_filter_set_name (filter, name);
|
|
||||||
gtk_file_filter_add_pattern (filter, pattern);
|
|
||||||
|
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
||||||
|
|
||||||
if (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == NULL)
|
|
||||||
{
|
|
||||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface,
|
gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface,
|
||||||
gpointer iface_data)
|
gpointer iface_data)
|
||||||
|
@ -255,11 +229,9 @@ gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface,
|
||||||
iface->get_file = chooser_get_file;
|
iface->get_file = chooser_get_file;
|
||||||
iface->set_do_overwrite_confirmation = chooser_set_do_overwrite_confirmation;
|
iface->set_do_overwrite_confirmation = chooser_set_do_overwrite_confirmation;
|
||||||
iface->show = chooser_show;
|
iface->show = chooser_show;
|
||||||
iface->hide = chooser_hide;
|
|
||||||
iface->destroy = chooser_destroy;
|
iface->destroy = chooser_destroy;
|
||||||
iface->set_modal = chooser_set_modal;
|
iface->set_modal = chooser_set_modal;
|
||||||
iface->get_window = chooser_get_window;
|
iface->get_window = chooser_get_window;
|
||||||
iface->add_pattern_filter = chooser_add_pattern_filter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -281,8 +253,7 @@ gedit_file_chooser_dialog_gtk_class_init (GeditFileChooserDialogGtkClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_option_menu (GeditFileChooserDialogGtk *dialog,
|
create_option_menu (GeditFileChooserDialogGtk *dialog)
|
||||||
GeditFileChooserFlags flags)
|
|
||||||
{
|
{
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
|
@ -291,7 +262,7 @@ create_option_menu (GeditFileChooserDialogGtk *dialog,
|
||||||
label = gtk_label_new_with_mnemonic (_("C_haracter Encoding:"));
|
label = gtk_label_new_with_mnemonic (_("C_haracter Encoding:"));
|
||||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||||
|
|
||||||
save_mode = (flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0;
|
save_mode = TRUE;
|
||||||
menu = gedit_encodings_combo_box_new (save_mode);
|
menu = gedit_encodings_combo_box_new (save_mode);
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
|
||||||
|
@ -403,18 +374,13 @@ create_newline_combo (GeditFileChooserDialogGtk *dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_extra_widget (GeditFileChooserDialogGtk *dialog,
|
create_extra_widget (GeditFileChooserDialogGtk *dialog)
|
||||||
GeditFileChooserFlags flags)
|
|
||||||
{
|
{
|
||||||
dialog->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
dialog->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_widget_show (dialog->extra_widget);
|
gtk_widget_show (dialog->extra_widget);
|
||||||
|
|
||||||
create_option_menu (dialog, flags);
|
create_option_menu (dialog);
|
||||||
|
create_newline_combo (dialog);
|
||||||
if ((flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0)
|
|
||||||
{
|
|
||||||
create_newline_combo (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), dialog->extra_widget);
|
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), dialog->extra_widget);
|
||||||
}
|
}
|
||||||
|
@ -455,35 +421,21 @@ gedit_file_chooser_dialog_gtk_init (GeditFileChooserDialogGtk *dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
GeditFileChooserDialog *
|
GeditFileChooserDialog *
|
||||||
gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GeditFileChooserFlags flags,
|
const gchar *accept_label,
|
||||||
const gchar *accept_label,
|
const gchar *cancel_label)
|
||||||
const gchar *cancel_label)
|
|
||||||
{
|
{
|
||||||
GeditFileChooserDialogGtk *result;
|
GeditFileChooserDialogGtk *result;
|
||||||
GtkFileChooserAction action;
|
|
||||||
gboolean select_multiple;
|
|
||||||
|
|
||||||
if ((flags & GEDIT_FILE_CHOOSER_FLAG_SAVE) != 0)
|
|
||||||
{
|
|
||||||
action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
|
||||||
select_multiple = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
|
||||||
select_multiple = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = g_object_new (GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK,
|
result = g_object_new (GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK,
|
||||||
"title", title,
|
"title", title,
|
||||||
"local-only", FALSE,
|
"local-only", FALSE,
|
||||||
"action", action,
|
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
"select-multiple", select_multiple,
|
"select-multiple", FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
create_extra_widget (result, flags);
|
create_extra_widget (result);
|
||||||
|
|
||||||
g_signal_connect (result,
|
g_signal_connect (result,
|
||||||
"notify::action",
|
"notify::action",
|
||||||
|
|
|
@ -33,11 +33,10 @@ G_DECLARE_FINAL_TYPE (GeditFileChooserDialogGtk, gedit_file_chooser_dialog_gtk,
|
||||||
GEDIT, FILE_CHOOSER_DIALOG_GTK,
|
GEDIT, FILE_CHOOSER_DIALOG_GTK,
|
||||||
GtkFileChooserDialog)
|
GtkFileChooserDialog)
|
||||||
|
|
||||||
GeditFileChooserDialog * gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
GeditFileChooserDialog * gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GeditFileChooserFlags flags,
|
const gchar *accept_label,
|
||||||
const gchar *accept_label,
|
const gchar *cancel_label);
|
||||||
const gchar *cancel_label);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -62,15 +62,13 @@ gedit_file_chooser_dialog_default_init (GeditFileChooserDialogInterface *iface)
|
||||||
}
|
}
|
||||||
|
|
||||||
GeditFileChooserDialog *
|
GeditFileChooserDialog *
|
||||||
gedit_file_chooser_dialog_create (const gchar *title,
|
gedit_file_chooser_dialog_create (const gchar *title,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GeditFileChooserFlags flags,
|
const gchar *accept_label,
|
||||||
const gchar *accept_label,
|
const gchar *cancel_label)
|
||||||
const gchar *cancel_label)
|
|
||||||
{
|
{
|
||||||
return gedit_file_chooser_dialog_gtk_create (title,
|
return gedit_file_chooser_dialog_gtk_create (title,
|
||||||
parent,
|
parent,
|
||||||
flags,
|
|
||||||
accept_label,
|
accept_label,
|
||||||
cancel_label);
|
cancel_label);
|
||||||
}
|
}
|
||||||
|
@ -213,19 +211,6 @@ gedit_file_chooser_dialog_show (GeditFileChooserDialog *dialog)
|
||||||
iface->show (dialog);
|
iface->show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gedit_file_chooser_dialog_hide (GeditFileChooserDialog *dialog)
|
|
||||||
{
|
|
||||||
GeditFileChooserDialogInterface *iface;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
|
||||||
|
|
||||||
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
|
||||||
g_return_if_fail (iface->hide != NULL);
|
|
||||||
|
|
||||||
iface->hide (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gedit_file_chooser_dialog_destroy (GeditFileChooserDialog *dialog)
|
gedit_file_chooser_dialog_destroy (GeditFileChooserDialog *dialog)
|
||||||
{
|
{
|
||||||
|
@ -270,21 +255,4 @@ gedit_file_chooser_dialog_get_window (GeditFileChooserDialog *dialog)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gedit_file_chooser_dialog_add_pattern_filter (GeditFileChooserDialog *dialog,
|
|
||||||
const gchar *name,
|
|
||||||
const gchar *pattern)
|
|
||||||
{
|
|
||||||
GeditFileChooserDialogInterface *iface;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
|
||||||
|
|
||||||
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
|
||||||
|
|
||||||
if (iface->add_pattern_filter)
|
|
||||||
{
|
|
||||||
iface->add_pattern_filter (dialog, name, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -64,7 +64,6 @@ struct _GeditFileChooserDialogInterface
|
||||||
gboolean overwrite_confirmation);
|
gboolean overwrite_confirmation);
|
||||||
|
|
||||||
void (*show) (GeditFileChooserDialog *dialog);
|
void (*show) (GeditFileChooserDialog *dialog);
|
||||||
void (*hide) (GeditFileChooserDialog *dialog);
|
|
||||||
|
|
||||||
void (*destroy) (GeditFileChooserDialog *dialog);
|
void (*destroy) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
@ -73,22 +72,11 @@ struct _GeditFileChooserDialogInterface
|
||||||
|
|
||||||
GtkWindow *
|
GtkWindow *
|
||||||
(*get_window) (GeditFileChooserDialog *dialog);
|
(*get_window) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
void (*add_pattern_filter) (GeditFileChooserDialog *dilaog,
|
|
||||||
const gchar *name,
|
|
||||||
const gchar *pattern);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GEDIT_FILE_CHOOSER_FLAG_SAVE = 1 << 0,
|
|
||||||
GEDIT_FILE_CHOOSER_FLAG_OPEN = 1 << 1
|
|
||||||
} GeditFileChooserFlags;
|
|
||||||
|
|
||||||
GeditFileChooserDialog *
|
GeditFileChooserDialog *
|
||||||
gedit_file_chooser_dialog_create (const gchar *title,
|
gedit_file_chooser_dialog_create (const gchar *title,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GeditFileChooserFlags flags,
|
|
||||||
const gchar *accept_label,
|
const gchar *accept_label,
|
||||||
const gchar *cancel_label);
|
const gchar *cancel_label);
|
||||||
|
|
||||||
|
@ -122,17 +110,12 @@ void gedit_file_chooser_dialog_set_do_overwrite_confirmation (
|
||||||
gboolean overwrite_confirmation);
|
gboolean overwrite_confirmation);
|
||||||
|
|
||||||
void gedit_file_chooser_dialog_show (GeditFileChooserDialog *dialog);
|
void gedit_file_chooser_dialog_show (GeditFileChooserDialog *dialog);
|
||||||
void gedit_file_chooser_dialog_hide (GeditFileChooserDialog *dialog);
|
|
||||||
|
|
||||||
void gedit_file_chooser_dialog_set_modal (GeditFileChooserDialog *dialog,
|
void gedit_file_chooser_dialog_set_modal (GeditFileChooserDialog *dialog,
|
||||||
gboolean is_modal);
|
gboolean is_modal);
|
||||||
|
|
||||||
GtkWindow *gedit_file_chooser_dialog_get_window (GeditFileChooserDialog *dialog);
|
GtkWindow *gedit_file_chooser_dialog_get_window (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
void gedit_file_chooser_dialog_add_pattern_filter (GeditFileChooserDialog *dialog,
|
|
||||||
const gchar *name,
|
|
||||||
const gchar *pattern);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GEDIT_FILE_CHOOSER_DIALOG_H */
|
#endif /* GEDIT_FILE_CHOOSER_DIALOG_H */
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-highlight-mode-dialog.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 - Ignacio Casal Quinteiro
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-highlight-mode-dialog.h"
|
|
||||||
|
|
||||||
struct _GeditHighlightModeDialog
|
|
||||||
{
|
|
||||||
GtkDialog parent_instance;
|
|
||||||
|
|
||||||
GeditHighlightModeSelector *selector;
|
|
||||||
gulong on_language_selected_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditHighlightModeDialog, gedit_highlight_mode_dialog, GTK_TYPE_DIALOG)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_dialog_response (GtkDialog *dialog,
|
|
||||||
gint response_id)
|
|
||||||
{
|
|
||||||
GeditHighlightModeDialog *dlg = GEDIT_HIGHLIGHT_MODE_DIALOG (dialog);
|
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
|
||||||
{
|
|
||||||
g_signal_handler_block (dlg->selector, dlg->on_language_selected_id);
|
|
||||||
gedit_highlight_mode_selector_activate_selected_language (dlg->selector);
|
|
||||||
g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_language_selected (GeditHighlightModeSelector *sel,
|
|
||||||
GtkSourceLanguage *language,
|
|
||||||
GeditHighlightModeDialog *dlg)
|
|
||||||
{
|
|
||||||
g_signal_handler_block (dlg->selector, dlg->on_language_selected_id);
|
|
||||||
gedit_highlight_mode_selector_activate_selected_language (dlg->selector);
|
|
||||||
g_signal_handler_unblock (dlg->selector, dlg->on_language_selected_id);
|
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (dlg));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_dialog_class_init (GeditHighlightModeDialogClass *klass)
|
|
||||||
{
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
|
||||||
|
|
||||||
dialog_class->response = gedit_highlight_mode_dialog_response;
|
|
||||||
|
|
||||||
/* Bind class to template */
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
|
||||||
"/org/gnome/gedit/ui/gedit-highlight-mode-dialog.ui");
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeDialog, selector);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_dialog_init (GeditHighlightModeDialog *dlg)
|
|
||||||
{
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (dlg));
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
|
|
||||||
|
|
||||||
dlg->on_language_selected_id = g_signal_connect (dlg->selector, "language-selected",
|
|
||||||
G_CALLBACK (on_language_selected), dlg);
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_highlight_mode_dialog_new (GtkWindow *parent)
|
|
||||||
{
|
|
||||||
return GTK_WIDGET (g_object_new (GEDIT_TYPE_HIGHLIGHT_MODE_DIALOG,
|
|
||||||
"transient-for", parent,
|
|
||||||
"use-header-bar", TRUE,
|
|
||||||
NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
GeditHighlightModeSelector *
|
|
||||||
gedit_highlight_mode_dialog_get_selector (GeditHighlightModeDialog *dlg)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GEDIT_IS_HIGHLIGHT_MODE_DIALOG (dlg), NULL);
|
|
||||||
|
|
||||||
return dlg->selector;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-highlight-mode-dialog.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 - Ignacio Casal Quinteiro
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GEDIT_HIGHLIGHT_MODE_DIALOG_H
|
|
||||||
#define GEDIT_HIGHLIGHT_MODE_DIALOG_H
|
|
||||||
|
|
||||||
#include "gedit-highlight-mode-selector.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_HIGHLIGHT_MODE_DIALOG (gedit_highlight_mode_dialog_get_type ())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditHighlightModeDialog, gedit_highlight_mode_dialog, GEDIT, HIGHLIGHT_MODE_DIALOG, GtkDialog)
|
|
||||||
|
|
||||||
GtkWidget *gedit_highlight_mode_dialog_new (GtkWindow *parent);
|
|
||||||
|
|
||||||
GeditHighlightModeSelector *gedit_highlight_mode_dialog_get_selector (GeditHighlightModeDialog *dlg);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_HIGHLIGHT_MODE_DIALOG_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,375 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-highlight-mode-selector.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 - Ignacio Casal Quinteiro
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-highlight-mode-selector.h"
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
COLUMN_NAME,
|
|
||||||
COLUMN_LANG,
|
|
||||||
N_COLUMNS
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeditHighlightModeSelector
|
|
||||||
{
|
|
||||||
GtkGrid parent_instance;
|
|
||||||
|
|
||||||
GtkWidget *treeview;
|
|
||||||
GtkWidget *entry;
|
|
||||||
GtkListStore *liststore;
|
|
||||||
GtkTreeModelFilter *treemodelfilter;
|
|
||||||
GtkTreeSelection *treeview_selection;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Signals */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
LANGUAGE_SELECTED,
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditHighlightModeSelector, gedit_highlight_mode_selector, GTK_TYPE_GRID)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_selector_language_selected (GeditHighlightModeSelector *widget,
|
|
||||||
GtkSourceLanguage *language)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_selector_class_init (GeditHighlightModeSelectorClass *klass)
|
|
||||||
{
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
signals[LANGUAGE_SELECTED] =
|
|
||||||
g_signal_new_class_handler ("language-selected",
|
|
||||||
G_TYPE_FROM_CLASS (klass),
|
|
||||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
||||||
G_CALLBACK (gedit_highlight_mode_selector_language_selected),
|
|
||||||
NULL, NULL, NULL,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
1,
|
|
||||||
GTK_SOURCE_TYPE_LANGUAGE);
|
|
||||||
|
|
||||||
/* Bind class to template */
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
|
||||||
"/org/gnome/gedit/ui/gedit-highlight-mode-selector.ui");
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeSelector, treeview);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeSelector, entry);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeSelector, liststore);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeSelector, treemodelfilter);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditHighlightModeSelector, treeview_selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
visible_func (GtkTreeModel *model,
|
|
||||||
GtkTreeIter *iter,
|
|
||||||
GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
const gchar *entry_text;
|
|
||||||
gchar *name;
|
|
||||||
gchar *name_normalized;
|
|
||||||
gchar *name_casefolded;
|
|
||||||
gchar *text_normalized;
|
|
||||||
gchar *text_casefolded;
|
|
||||||
gboolean visible = FALSE;
|
|
||||||
|
|
||||||
entry_text = gtk_entry_get_text (GTK_ENTRY (selector->entry));
|
|
||||||
|
|
||||||
if (*entry_text == '\0')
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter, COLUMN_NAME, &name, -1);
|
|
||||||
|
|
||||||
name_normalized = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
|
|
||||||
g_free (name);
|
|
||||||
|
|
||||||
name_casefolded = g_utf8_casefold (name_normalized, -1);
|
|
||||||
g_free (name_normalized);
|
|
||||||
|
|
||||||
text_normalized = g_utf8_normalize (entry_text, -1, G_NORMALIZE_ALL);
|
|
||||||
text_casefolded = g_utf8_casefold (text_normalized, -1);
|
|
||||||
g_free (text_normalized);
|
|
||||||
|
|
||||||
if (strstr (name_casefolded, text_casefolded) != NULL)
|
|
||||||
{
|
|
||||||
visible = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (name_casefolded);
|
|
||||||
g_free (text_casefolded);
|
|
||||||
|
|
||||||
return visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_entry_activate (GtkEntry *entry,
|
|
||||||
GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
gedit_highlight_mode_selector_activate_selected_language (selector);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_entry_changed (GtkEntry *entry,
|
|
||||||
GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter (selector->treemodelfilter);
|
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
|
|
||||||
{
|
|
||||||
gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
move_selection (GeditHighlightModeSelector *selector,
|
|
||||||
gint howmany)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
GtkTreePath *path;
|
|
||||||
gint *indices;
|
|
||||||
gint ret = FALSE;
|
|
||||||
|
|
||||||
if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter) &&
|
|
||||||
!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter);
|
|
||||||
indices = gtk_tree_path_get_indices (path);
|
|
||||||
|
|
||||||
if (indices)
|
|
||||||
{
|
|
||||||
gint num;
|
|
||||||
gint idx;
|
|
||||||
GtkTreePath *new_path;
|
|
||||||
|
|
||||||
idx = indices[0];
|
|
||||||
num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (selector->treemodelfilter), NULL);
|
|
||||||
|
|
||||||
if ((idx + howmany) < 0)
|
|
||||||
{
|
|
||||||
idx = 0;
|
|
||||||
}
|
|
||||||
else if ((idx + howmany) >= num)
|
|
||||||
{
|
|
||||||
idx = num - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idx = idx + howmany;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_path = gtk_tree_path_new_from_indices (idx, -1);
|
|
||||||
gtk_tree_selection_select_path (selector->treeview_selection, new_path);
|
|
||||||
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview),
|
|
||||||
new_path, NULL, TRUE, 0.5, 0);
|
|
||||||
gtk_tree_path_free (new_path);
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
on_entry_key_press_event (GtkWidget *entry,
|
|
||||||
GdkEventKey *event,
|
|
||||||
GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
if (event->keyval == GDK_KEY_Down)
|
|
||||||
{
|
|
||||||
return move_selection (selector, 1);
|
|
||||||
}
|
|
||||||
else if (event->keyval == GDK_KEY_Up)
|
|
||||||
{
|
|
||||||
return move_selection (selector, -1);
|
|
||||||
}
|
|
||||||
else if (event->keyval == GDK_KEY_Page_Down)
|
|
||||||
{
|
|
||||||
return move_selection (selector, 5);
|
|
||||||
}
|
|
||||||
else if (event->keyval == GDK_KEY_Page_Up)
|
|
||||||
{
|
|
||||||
return move_selection (selector, -5);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_row_activated (GtkTreeView *tree_view,
|
|
||||||
GtkTreePath *path,
|
|
||||||
GtkTreeViewColumn *column,
|
|
||||||
GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
gedit_highlight_mode_selector_activate_selected_language (selector);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_highlight_mode_selector_init (GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
GtkSourceLanguageManager *lm;
|
|
||||||
const gchar * const *ids;
|
|
||||||
gint i;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
selector = gedit_highlight_mode_selector_get_instance_private (selector);
|
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (selector));
|
|
||||||
|
|
||||||
gtk_tree_model_filter_set_visible_func (selector->treemodelfilter,
|
|
||||||
(GtkTreeModelFilterVisibleFunc)visible_func,
|
|
||||||
selector,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_signal_connect (selector->entry, "activate",
|
|
||||||
G_CALLBACK (on_entry_activate), selector);
|
|
||||||
g_signal_connect (selector->entry, "changed",
|
|
||||||
G_CALLBACK (on_entry_changed), selector);
|
|
||||||
g_signal_connect (selector->entry, "key-press-event",
|
|
||||||
G_CALLBACK (on_entry_key_press_event), selector);
|
|
||||||
|
|
||||||
g_signal_connect (selector->treeview, "row-activated",
|
|
||||||
G_CALLBACK (on_row_activated), selector);
|
|
||||||
|
|
||||||
/* Populate tree model */
|
|
||||||
gtk_list_store_append (selector->liststore, &iter);
|
|
||||||
gtk_list_store_set (selector->liststore, &iter,
|
|
||||||
COLUMN_NAME, _("Plain Text"),
|
|
||||||
COLUMN_LANG, NULL,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
lm = gtk_source_language_manager_get_default ();
|
|
||||||
ids = gtk_source_language_manager_get_language_ids (lm);
|
|
||||||
|
|
||||||
for (i = 0; ids[i] != NULL; i++)
|
|
||||||
{
|
|
||||||
GtkSourceLanguage *lang;
|
|
||||||
|
|
||||||
lang = gtk_source_language_manager_get_language (lm, ids[i]);
|
|
||||||
|
|
||||||
if (!gtk_source_language_get_hidden (lang))
|
|
||||||
{
|
|
||||||
gtk_list_store_append (selector->liststore, &iter);
|
|
||||||
gtk_list_store_set (selector->liststore, &iter,
|
|
||||||
COLUMN_NAME, gtk_source_language_get_name (lang),
|
|
||||||
COLUMN_LANG, lang,
|
|
||||||
-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* select first item */
|
|
||||||
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
|
|
||||||
{
|
|
||||||
gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GeditHighlightModeSelector *
|
|
||||||
gedit_highlight_mode_selector_new ()
|
|
||||||
{
|
|
||||||
return g_object_new (GEDIT_TYPE_HIGHLIGHT_MODE_SELECTOR, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_highlight_mode_selector_select_language (GeditHighlightModeSelector *selector,
|
|
||||||
GtkSourceLanguage *language)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_HIGHLIGHT_MODE_SELECTOR (selector));
|
|
||||||
|
|
||||||
if (language == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (selector->treemodelfilter), &iter))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
GtkSourceLanguage *lang;
|
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter),
|
|
||||||
&iter,
|
|
||||||
COLUMN_LANG, &lang,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
if (lang != NULL)
|
|
||||||
{
|
|
||||||
gboolean equal = (lang == language);
|
|
||||||
|
|
||||||
g_object_unref (lang);
|
|
||||||
|
|
||||||
if (equal)
|
|
||||||
{
|
|
||||||
GtkTreePath *path;
|
|
||||||
|
|
||||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (selector->treemodelfilter), &iter);
|
|
||||||
|
|
||||||
gtk_tree_selection_select_iter (selector->treeview_selection, &iter);
|
|
||||||
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (selector->treeview),
|
|
||||||
path, NULL, TRUE, 0.5, 0);
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (selector->treemodelfilter), &iter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_highlight_mode_selector_activate_selected_language (GeditHighlightModeSelector *selector)
|
|
||||||
{
|
|
||||||
GtkSourceLanguage *lang;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_HIGHLIGHT_MODE_SELECTOR (selector));
|
|
||||||
|
|
||||||
if (!gtk_tree_selection_get_selected (selector->treeview_selection, NULL, &iter))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (selector->treemodelfilter), &iter,
|
|
||||||
COLUMN_LANG, &lang,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (selector), signals[LANGUAGE_SELECTED], 0, lang);
|
|
||||||
|
|
||||||
if (lang != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-highlight-mode-selector.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 - Ignacio Casal Quinteiro
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_HIGHLIGHT_MODE_SELECTOR_H
|
|
||||||
#define GEDIT_HIGHLIGHT_MODE_SELECTOR_H
|
|
||||||
|
|
||||||
#include <gtksourceview/gtksource.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_HIGHLIGHT_MODE_SELECTOR (gedit_highlight_mode_selector_get_type ())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditHighlightModeSelector, gedit_highlight_mode_selector, GEDIT, HIGHLIGHT_MODE_SELECTOR, GtkGrid)
|
|
||||||
|
|
||||||
GeditHighlightModeSelector *gedit_highlight_mode_selector_new (void);
|
|
||||||
|
|
||||||
void gedit_highlight_mode_selector_select_language (GeditHighlightModeSelector *selector,
|
|
||||||
GtkSourceLanguage *language);
|
|
||||||
|
|
||||||
void gedit_highlight_mode_selector_activate_selected_language
|
|
||||||
(GeditHighlightModeSelector *selector);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_HIGHLIGHT_MODE_SELECTOR_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -23,16 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gedit-io-error-info-bar.h"
|
#include "gedit-io-error-info-bar.h"
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-encodings-combo-box.h"
|
#include "gedit-encodings-combo-box.h"
|
||||||
#include "gedit-settings.h"
|
|
||||||
#include "gedit-utils.h"
|
|
||||||
#include "gedit-document.h"
|
|
||||||
|
|
||||||
#define MAX_URI_IN_DIALOG_LENGTH 50
|
#define MAX_URI_IN_DIALOG_LENGTH 50
|
||||||
|
|
||||||
|
@ -227,7 +220,7 @@ parse_gio_error (gint code,
|
||||||
uri = g_file_get_uri (location);
|
uri = g_file_get_uri (location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri && gedit_utils_decode_uri (uri, NULL, NULL, &hn, NULL, NULL))
|
if (uri && tepl_utils_decode_uri (uri, NULL, NULL, &hn, NULL, NULL))
|
||||||
{
|
{
|
||||||
if (hn != NULL)
|
if (hn != NULL)
|
||||||
{
|
{
|
||||||
|
@ -330,8 +323,8 @@ gedit_unrecoverable_reverting_error_info_bar_new (GFile *location,
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
* though the dialog uses wrapped text, if the URI doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
temp_uri_for_display = tepl_utils_str_middle_truncate (full_formatted_uri,
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
MAX_URI_IN_DIALOG_LENGTH);
|
||||||
g_free (full_formatted_uri);
|
g_free (full_formatted_uri);
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
||||||
|
@ -402,67 +395,6 @@ create_combo_box (GtkWidget *info_bar,
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
create_primary_and_secondary_widgets_info_bar(GtkWidget *vbox, const gchar *primary_text,
|
|
||||||
const gchar *secondary_text)
|
|
||||||
{
|
|
||||||
gchar *primary_markup;
|
|
||||||
gchar *secondary_markup;
|
|
||||||
GtkWidget *primary_label;
|
|
||||||
GtkWidget *secondary_label;
|
|
||||||
|
|
||||||
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
|
|
||||||
primary_label = gtk_label_new (primary_markup);
|
|
||||||
g_free (primary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
|
|
||||||
gtk_widget_set_can_focus (primary_label, TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
|
||||||
|
|
||||||
if (secondary_text != NULL)
|
|
||||||
{
|
|
||||||
secondary_markup = g_strdup_printf ("<small>%s</small>",
|
|
||||||
secondary_text);
|
|
||||||
secondary_label = gtk_label_new (secondary_markup);
|
|
||||||
g_free (secondary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_set_can_focus (secondary_label, TRUE);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
create_file_too_big_error_info_bar (const gchar *primary_text,
|
|
||||||
const gchar *secondary_text)
|
|
||||||
{
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
GtkWidget *hbox_content;
|
|
||||||
GtkWidget *vbox;
|
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
|
||||||
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
|
|
||||||
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("_Continue loading"),
|
|
||||||
GTK_RESPONSE_ACCEPT);
|
|
||||||
|
|
||||||
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
|
||||||
|
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
create_primary_and_secondary_widgets_info_bar (vbox, primary_text, secondary_text);
|
|
||||||
gtk_widget_show_all (hbox_content);
|
|
||||||
set_contents (info_bar, hbox_content);
|
|
||||||
|
|
||||||
return info_bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_conversion_error_info_bar (const gchar *primary_text,
|
create_conversion_error_info_bar (const gchar *primary_text,
|
||||||
const gchar *secondary_text,
|
const gchar *secondary_text,
|
||||||
|
@ -471,6 +403,10 @@ create_conversion_error_info_bar (const gchar *primary_text,
|
||||||
GtkWidget *info_bar;
|
GtkWidget *info_bar;
|
||||||
GtkWidget *hbox_content;
|
GtkWidget *hbox_content;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
|
gchar *primary_markup;
|
||||||
|
gchar *secondary_markup;
|
||||||
|
GtkWidget *primary_label;
|
||||||
|
GtkWidget *secondary_label;
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
info_bar = gtk_info_bar_new ();
|
||||||
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
|
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
|
||||||
|
@ -500,7 +436,30 @@ create_conversion_error_info_bar (const gchar *primary_text,
|
||||||
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);
|
||||||
|
|
||||||
create_primary_and_secondary_widgets_info_bar (vbox, primary_text, secondary_text);
|
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
|
||||||
|
primary_label = gtk_label_new (primary_markup);
|
||||||
|
g_free (primary_markup);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
|
||||||
|
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
||||||
|
gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
|
||||||
|
gtk_widget_set_can_focus (primary_label, TRUE);
|
||||||
|
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
||||||
|
|
||||||
|
if (secondary_text != NULL)
|
||||||
|
{
|
||||||
|
secondary_markup = g_strdup_printf ("<small>%s</small>",
|
||||||
|
secondary_text);
|
||||||
|
secondary_label = gtk_label_new (secondary_markup);
|
||||||
|
g_free (secondary_markup);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_set_can_focus (secondary_label, TRUE);
|
||||||
|
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
||||||
|
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
||||||
|
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
|
||||||
|
}
|
||||||
|
|
||||||
create_combo_box (info_bar, vbox);
|
create_combo_box (info_bar, vbox);
|
||||||
gtk_widget_show_all (hbox_content);
|
gtk_widget_show_all (hbox_content);
|
||||||
set_contents (info_bar, hbox_content);
|
set_contents (info_bar, hbox_content);
|
||||||
|
@ -521,7 +480,6 @@ gedit_io_loading_error_info_bar_new (GFile *location,
|
||||||
GtkWidget *info_bar;
|
GtkWidget *info_bar;
|
||||||
gboolean edit_anyway = FALSE;
|
gboolean edit_anyway = FALSE;
|
||||||
gboolean convert_error = FALSE;
|
gboolean convert_error = FALSE;
|
||||||
gboolean file_too_big = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (error != NULL, NULL);
|
g_return_val_if_fail (error != NULL, NULL);
|
||||||
g_return_val_if_fail (error->domain == GTK_SOURCE_FILE_LOADER_ERROR ||
|
g_return_val_if_fail (error->domain == GTK_SOURCE_FILE_LOADER_ERROR ||
|
||||||
|
@ -541,8 +499,8 @@ gedit_io_loading_error_info_bar_new (GFile *location,
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
* though the dialog uses wrapped text, if the URI doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
temp_uri_for_display = tepl_utils_str_middle_truncate (full_formatted_uri,
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
MAX_URI_IN_DIALOG_LENGTH);
|
||||||
g_free (full_formatted_uri);
|
g_free (full_formatted_uri);
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
||||||
|
@ -591,16 +549,6 @@ gedit_io_loading_error_info_bar_new (GFile *location,
|
||||||
|
|
||||||
g_free (encoding_name);
|
g_free (encoding_name);
|
||||||
}
|
}
|
||||||
else if (error->domain == GTK_SOURCE_FILE_LOADER_ERROR &&
|
|
||||||
error->code == GTK_SOURCE_FILE_LOADER_ERROR_TOO_BIG)
|
|
||||||
{
|
|
||||||
error_message = g_strdup_printf (_("The file “%s” is very big."),
|
|
||||||
uri_for_display);
|
|
||||||
message_details = g_strconcat (_("Large files can make gedit slow or unresponsive. "
|
|
||||||
"You can continue loading this file at your own risk"),
|
|
||||||
NULL);
|
|
||||||
file_too_big = TRUE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parse_error (error, &error_message, &message_details, location, uri_for_display);
|
parse_error (error, &error_message, &message_details, location, uri_for_display);
|
||||||
|
@ -612,12 +560,7 @@ gedit_io_loading_error_info_bar_new (GFile *location,
|
||||||
uri_for_display);
|
uri_for_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_too_big)
|
if (convert_error)
|
||||||
{
|
|
||||||
info_bar = create_file_too_big_error_info_bar (error_message,
|
|
||||||
message_details);
|
|
||||||
}
|
|
||||||
else if (convert_error)
|
|
||||||
{
|
{
|
||||||
info_bar = create_conversion_error_info_bar (error_message,
|
info_bar = create_conversion_error_info_bar (error_message,
|
||||||
message_details,
|
message_details,
|
||||||
|
@ -662,8 +605,8 @@ gedit_conversion_error_while_saving_info_bar_new (GFile *locat
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
* though the dialog uses wrapped text, if the URI doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
temp_uri_for_display = tepl_utils_str_middle_truncate (full_formatted_uri,
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
MAX_URI_IN_DIALOG_LENGTH);
|
||||||
g_free (full_formatted_uri);
|
g_free (full_formatted_uri);
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
||||||
|
@ -707,88 +650,6 @@ gedit_conversion_error_info_bar_get_encoding (GtkWidget *info_bar)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_file_already_open_warning_info_bar_new (GFile *location)
|
|
||||||
{
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
GtkWidget *hbox_content;
|
|
||||||
GtkWidget *vbox;
|
|
||||||
gchar *primary_markup;
|
|
||||||
gchar *secondary_markup;
|
|
||||||
GtkWidget *primary_label;
|
|
||||||
GtkWidget *secondary_label;
|
|
||||||
gchar *primary_text;
|
|
||||||
const gchar *secondary_text;
|
|
||||||
gchar *full_formatted_uri;
|
|
||||||
gchar *uri_for_display;
|
|
||||||
gchar *temp_uri_for_display;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
|
||||||
|
|
||||||
full_formatted_uri = g_file_get_parse_name (location);
|
|
||||||
|
|
||||||
/* Truncate the URI so it doesn't get insanely wide. Note that even
|
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
|
||||||
*/
|
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
|
||||||
g_free (full_formatted_uri);
|
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
|
||||||
g_free (temp_uri_for_display);
|
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
/* Translators: the access key chosen for this string should be
|
|
||||||
different from other main menu access keys (Open, Edit, View...) */
|
|
||||||
_("Edit Any_way"),
|
|
||||||
GTK_RESPONSE_YES);
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
/* Translators: the access key chosen for this string should be
|
|
||||||
different from other main menu access keys (Open, Edit, View...) */
|
|
||||||
_("D_on’t Edit"),
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
|
|
||||||
GTK_MESSAGE_WARNING);
|
|
||||||
|
|
||||||
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
|
||||||
|
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
primary_text = g_strdup_printf (_("This file “%s” is already open in another window."), uri_for_display);
|
|
||||||
g_free (uri_for_display);
|
|
||||||
|
|
||||||
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
|
|
||||||
g_free (primary_text);
|
|
||||||
primary_label = gtk_label_new (primary_markup);
|
|
||||||
g_free (primary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
|
|
||||||
gtk_widget_set_can_focus (primary_label, TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
|
||||||
|
|
||||||
secondary_text = _("Do you want to edit it anyway?");
|
|
||||||
secondary_markup = g_strdup_printf ("<small>%s</small>",
|
|
||||||
secondary_text);
|
|
||||||
secondary_label = gtk_label_new (secondary_markup);
|
|
||||||
g_free (secondary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_set_can_focus (secondary_label, TRUE);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
|
|
||||||
|
|
||||||
gtk_widget_show_all (hbox_content);
|
|
||||||
set_contents (info_bar, hbox_content);
|
|
||||||
|
|
||||||
return info_bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
||||||
const GError *error)
|
const GError *error)
|
||||||
|
@ -817,8 +678,8 @@ gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
* though the dialog uses wrapped text, if the URI doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
temp_uri_for_display = tepl_utils_str_middle_truncate (full_formatted_uri,
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
MAX_URI_IN_DIALOG_LENGTH);
|
||||||
g_free (full_formatted_uri);
|
g_free (full_formatted_uri);
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
||||||
|
@ -877,110 +738,6 @@ gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
||||||
return info_bar;
|
return info_bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_no_backup_saving_error_info_bar_new (GFile *location,
|
|
||||||
const GError *error)
|
|
||||||
{
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
GtkWidget *hbox_content;
|
|
||||||
GtkWidget *vbox;
|
|
||||||
gchar *primary_markup;
|
|
||||||
gchar *secondary_markup;
|
|
||||||
GtkWidget *primary_label;
|
|
||||||
GtkWidget *secondary_label;
|
|
||||||
gchar *primary_text;
|
|
||||||
const gchar *secondary_text;
|
|
||||||
gchar *full_formatted_uri;
|
|
||||||
gchar *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 (error != NULL, NULL);
|
|
||||||
g_return_val_if_fail (error->domain == G_IO_ERROR &&
|
|
||||||
error->code == G_IO_ERROR_CANT_CREATE_BACKUP, NULL);
|
|
||||||
|
|
||||||
full_formatted_uri = g_file_get_parse_name (location);
|
|
||||||
|
|
||||||
/* Truncate the URI so it doesn't get insanely wide. Note that even
|
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
|
||||||
*/
|
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
|
||||||
g_free (full_formatted_uri);
|
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
|
||||||
g_free (temp_uri_for_display);
|
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
|
||||||
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("S_ave Anyway"),
|
|
||||||
GTK_RESPONSE_YES);
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("D_on’t Save"),
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
|
|
||||||
GTK_MESSAGE_WARNING);
|
|
||||||
|
|
||||||
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
|
||||||
|
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
editor_settings = g_settings_new ("org.gnome.gedit.preferences.editor");
|
|
||||||
|
|
||||||
create_backup_copy = g_settings_get_boolean (editor_settings,
|
|
||||||
GEDIT_SETTINGS_CREATE_BACKUP_COPY);
|
|
||||||
g_object_unref (editor_settings);
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
primary_text = g_strdup_printf (_("Could not create a temporary backup file while saving “%s”"),
|
|
||||||
uri_for_display);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (uri_for_display);
|
|
||||||
|
|
||||||
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
|
|
||||||
g_free (primary_text);
|
|
||||||
primary_label = gtk_label_new (primary_markup);
|
|
||||||
g_free (primary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
|
|
||||||
gtk_widget_set_can_focus (primary_label, TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
|
||||||
|
|
||||||
secondary_text = _("Could not back up the old copy of the file before saving the new one. "
|
|
||||||
"You can ignore this warning and save the file anyway, but if an error "
|
|
||||||
"occurs while saving, you could lose the old copy of the file. Save anyway?");
|
|
||||||
secondary_markup = g_strdup_printf ("<small>%s</small>",
|
|
||||||
secondary_text);
|
|
||||||
secondary_label = gtk_label_new (secondary_markup);
|
|
||||||
g_free (secondary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_set_can_focus (secondary_label, TRUE);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
|
|
||||||
|
|
||||||
gtk_widget_show_all (hbox_content);
|
|
||||||
set_contents (info_bar, hbox_content);
|
|
||||||
|
|
||||||
return info_bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
||||||
const GError *error)
|
const GError *error)
|
||||||
|
@ -1005,8 +762,8 @@ gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
* though the dialog uses wrapped text, if the URI doesn't contain
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
* white space then the text-wrapping code is too stupid to wrap it.
|
||||||
*/
|
*/
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
temp_uri_for_display = tepl_utils_str_middle_truncate (full_formatted_uri,
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
MAX_URI_IN_DIALOG_LENGTH);
|
||||||
g_free (full_formatted_uri);
|
g_free (full_formatted_uri);
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
||||||
|
@ -1110,149 +867,4 @@ gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
||||||
return info_bar;
|
return info_bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_externally_modified_info_bar_new (GFile *location,
|
|
||||||
gboolean document_modified)
|
|
||||||
{
|
|
||||||
gchar *full_formatted_uri;
|
|
||||||
gchar *uri_for_display;
|
|
||||||
gchar *temp_uri_for_display;
|
|
||||||
gchar *primary_text;
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
|
||||||
|
|
||||||
full_formatted_uri = g_file_get_parse_name (location);
|
|
||||||
|
|
||||||
/* Truncate the URI so it doesn't get insanely wide. Note that even
|
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
|
||||||
*/
|
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
|
||||||
g_free (full_formatted_uri);
|
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
|
||||||
g_free (temp_uri_for_display);
|
|
||||||
|
|
||||||
primary_text = g_strdup_printf (_("The file “%s” changed on disk."),
|
|
||||||
uri_for_display);
|
|
||||||
g_free (uri_for_display);
|
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
|
||||||
|
|
||||||
if (document_modified)
|
|
||||||
{
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *button;
|
|
||||||
button = gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("Drop Changes and _Reload"),
|
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
box = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
|
|
||||||
gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (box),
|
|
||||||
button,
|
|
||||||
TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("_Reload"),
|
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (info_bar), TRUE);
|
|
||||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
|
|
||||||
GTK_MESSAGE_WARNING);
|
|
||||||
|
|
||||||
set_info_bar_text (info_bar,
|
|
||||||
primary_text,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_free (primary_text);
|
|
||||||
|
|
||||||
return info_bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_invalid_character_info_bar_new (GFile *location)
|
|
||||||
{
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
GtkWidget *hbox_content;
|
|
||||||
GtkWidget *vbox;
|
|
||||||
GtkWidget *primary_label;
|
|
||||||
GtkWidget *secondary_label;
|
|
||||||
gchar *primary_markup;
|
|
||||||
gchar *secondary_markup;
|
|
||||||
gchar *primary_text;
|
|
||||||
gchar *full_formatted_uri;
|
|
||||||
gchar *uri_for_display;
|
|
||||||
gchar *temp_uri_for_display;
|
|
||||||
const gchar *secondary_text;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
|
||||||
|
|
||||||
full_formatted_uri = g_file_get_parse_name (location);
|
|
||||||
|
|
||||||
/* Truncate the URI so it doesn't get insanely wide. Note that even
|
|
||||||
* though the dialog uses wrapped text, if the URI doesn't contain
|
|
||||||
* white space then the text-wrapping code is too stupid to wrap it.
|
|
||||||
*/
|
|
||||||
temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri,
|
|
||||||
MAX_URI_IN_DIALOG_LENGTH);
|
|
||||||
g_free (full_formatted_uri);
|
|
||||||
|
|
||||||
uri_for_display = g_markup_escape_text (temp_uri_for_display, -1);
|
|
||||||
g_free (temp_uri_for_display);
|
|
||||||
|
|
||||||
info_bar = gtk_info_bar_new ();
|
|
||||||
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("S_ave Anyway"),
|
|
||||||
GTK_RESPONSE_YES);
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
|
|
||||||
_("D_on’t Save"),
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
|
|
||||||
GTK_MESSAGE_WARNING);
|
|
||||||
|
|
||||||
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
|
||||||
|
|
||||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
primary_text = g_strdup_printf (_("Some invalid chars have been detected while saving “%s”"),
|
|
||||||
uri_for_display);
|
|
||||||
|
|
||||||
g_free (uri_for_display);
|
|
||||||
|
|
||||||
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
|
|
||||||
g_free (primary_text);
|
|
||||||
primary_label = gtk_label_new (primary_markup);
|
|
||||||
g_free (primary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
|
|
||||||
gtk_widget_set_can_focus (primary_label, TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
|
||||||
|
|
||||||
secondary_text = _("If you continue saving this file you can corrupt the document. "
|
|
||||||
" Save anyway?");
|
|
||||||
secondary_markup = g_strdup_printf ("<small>%s</small>",
|
|
||||||
secondary_text);
|
|
||||||
secondary_label = gtk_label_new (secondary_markup);
|
|
||||||
g_free (secondary_markup);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_set_can_focus (secondary_label, TRUE);
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
|
||||||
gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
|
|
||||||
|
|
||||||
gtk_widget_show_all (hbox_content);
|
|
||||||
set_contents (info_bar, hbox_content);
|
|
||||||
|
|
||||||
return info_bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -39,22 +39,12 @@ GtkWidget *gedit_conversion_error_while_saving_info_bar_new (GFile
|
||||||
const GtkSourceEncoding
|
const GtkSourceEncoding
|
||||||
*gedit_conversion_error_info_bar_get_encoding (GtkWidget *info_bar);
|
*gedit_conversion_error_info_bar_get_encoding (GtkWidget *info_bar);
|
||||||
|
|
||||||
GtkWidget *gedit_file_already_open_warning_info_bar_new (GFile *location);
|
|
||||||
|
|
||||||
GtkWidget *gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
GtkWidget *gedit_externally_modified_saving_error_info_bar_new (GFile *location,
|
||||||
const GError *error);
|
const GError *error);
|
||||||
|
|
||||||
GtkWidget *gedit_no_backup_saving_error_info_bar_new (GFile *location,
|
|
||||||
const GError *error);
|
|
||||||
|
|
||||||
GtkWidget *gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
GtkWidget *gedit_unrecoverable_saving_error_info_bar_new (GFile *location,
|
||||||
const GError *error);
|
const GError *error);
|
||||||
|
|
||||||
GtkWidget *gedit_externally_modified_info_bar_new (GFile *location,
|
|
||||||
gboolean document_modified);
|
|
||||||
|
|
||||||
GtkWidget *gedit_invalid_character_info_bar_new (GFile *location);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GEDIT_IO_ERROR_INFO_BAR_H */
|
#endif /* GEDIT_IO_ERROR_INFO_BAR_H */
|
||||||
|
|
|
@ -1,650 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
||||||
/*
|
|
||||||
* gedit-metadata-manager.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2003-2007 Paolo Maggi
|
|
||||||
* Copyright (C) 2019 Canonical LTD
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-metadata-manager.h"
|
|
||||||
#include <libxml/xmlreader.h>
|
|
||||||
#include "gedit-debug.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define GEDIT_METADATA_VERBOSE_DEBUG 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MAX_ITEMS 50
|
|
||||||
|
|
||||||
typedef struct _Item Item;
|
|
||||||
|
|
||||||
struct _Item
|
|
||||||
{
|
|
||||||
/* Time of last access in seconds since January 1, 1970 UTC. */
|
|
||||||
gint64 atime;
|
|
||||||
|
|
||||||
GHashTable *values;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeditMetadataManager
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
/* It is true if the file has been read. */
|
|
||||||
gboolean values_loaded;
|
|
||||||
|
|
||||||
guint timeout_id;
|
|
||||||
|
|
||||||
GHashTable *items;
|
|
||||||
|
|
||||||
gchar *metadata_filename;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
PROP_METADATA_FILENAME,
|
|
||||||
LAST_PROP
|
|
||||||
};
|
|
||||||
|
|
||||||
static GParamSpec *properties[LAST_PROP];
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditMetadataManager, gedit_metadata_manager, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
static gboolean gedit_metadata_manager_save (GeditMetadataManager *self);
|
|
||||||
|
|
||||||
static void
|
|
||||||
item_free (gpointer data)
|
|
||||||
{
|
|
||||||
Item *item;
|
|
||||||
|
|
||||||
g_return_if_fail (data != NULL);
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
item = (Item *)data;
|
|
||||||
|
|
||||||
if (item->values != NULL)
|
|
||||||
g_hash_table_destroy (item->values);
|
|
||||||
|
|
||||||
g_free (item);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_arm_timeout (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
if (self->timeout_id == 0)
|
|
||||||
{
|
|
||||||
self->timeout_id =
|
|
||||||
g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE,
|
|
||||||
2,
|
|
||||||
(GSourceFunc)gedit_metadata_manager_save,
|
|
||||||
self,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_parse_item (GeditMetadataManager *self,
|
|
||||||
xmlDocPtr doc,
|
|
||||||
xmlNodePtr cur)
|
|
||||||
{
|
|
||||||
Item *item;
|
|
||||||
|
|
||||||
xmlChar *uri;
|
|
||||||
xmlChar *atime;
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (xmlStrcmp (cur->name, (const xmlChar *)"document") != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
uri = xmlGetProp (cur, (const xmlChar *)"uri");
|
|
||||||
if (uri == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
atime = xmlGetProp (cur, (const xmlChar *)"atime");
|
|
||||||
if (atime == NULL)
|
|
||||||
{
|
|
||||||
xmlFree (uri);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
item = g_new0 (Item, 1);
|
|
||||||
|
|
||||||
item->atime = g_ascii_strtoll ((char *)atime, NULL, 0);
|
|
||||||
|
|
||||||
item->values = g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
|
||||||
g_free,
|
|
||||||
g_free);
|
|
||||||
|
|
||||||
cur = cur->xmlChildrenNode;
|
|
||||||
|
|
||||||
while (cur != NULL)
|
|
||||||
{
|
|
||||||
if (xmlStrcmp (cur->name, (const xmlChar *)"entry") == 0)
|
|
||||||
{
|
|
||||||
xmlChar *key;
|
|
||||||
xmlChar *value;
|
|
||||||
|
|
||||||
key = xmlGetProp (cur, (const xmlChar *)"key");
|
|
||||||
value = xmlGetProp (cur, (const xmlChar *)"value");
|
|
||||||
|
|
||||||
if ((key != NULL) && (value != NULL))
|
|
||||||
{
|
|
||||||
g_hash_table_insert (item->values,
|
|
||||||
g_strdup ((gchar *)key),
|
|
||||||
g_strdup ((gchar *)value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key != NULL)
|
|
||||||
xmlFree (key);
|
|
||||||
if (value != NULL)
|
|
||||||
xmlFree (value);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_insert (self->items,
|
|
||||||
g_strdup ((gchar *)uri),
|
|
||||||
item);
|
|
||||||
|
|
||||||
xmlFree (uri);
|
|
||||||
xmlFree (atime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns FALSE in case of error. */
|
|
||||||
static gboolean
|
|
||||||
gedit_metadata_manager_load_values (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
xmlDocPtr doc;
|
|
||||||
xmlNodePtr cur;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
|
|
||||||
g_return_val_if_fail (self != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (self->values_loaded == FALSE, FALSE);
|
|
||||||
|
|
||||||
self->values_loaded = TRUE;
|
|
||||||
|
|
||||||
xmlKeepBlanksDefault (0);
|
|
||||||
|
|
||||||
if (self->metadata_filename == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: avoid races */
|
|
||||||
if (!g_file_test (self->metadata_filename, G_FILE_TEST_EXISTS))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
doc = xmlParseFile (self->metadata_filename);
|
|
||||||
|
|
||||||
if (doc == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur = xmlDocGetRootElement (doc);
|
|
||||||
if (cur == NULL)
|
|
||||||
{
|
|
||||||
g_message ("The metadata file '%s' is empty",
|
|
||||||
g_path_get_basename (self->metadata_filename));
|
|
||||||
xmlFreeDoc (doc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlStrcmp (cur->name, (const xmlChar *) "metadata"))
|
|
||||||
{
|
|
||||||
g_message ("File '%s' is of the wrong type",
|
|
||||||
g_path_get_basename (self->metadata_filename));
|
|
||||||
xmlFreeDoc (doc);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur = xmlDocGetRootElement (doc);
|
|
||||||
cur = cur->xmlChildrenNode;
|
|
||||||
|
|
||||||
while (cur != NULL)
|
|
||||||
{
|
|
||||||
gedit_metadata_manager_parse_item (self, doc, cur);
|
|
||||||
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlFreeDoc (doc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_metadata_manager_get:
|
|
||||||
* @self: a #GeditMetadataManager.
|
|
||||||
* @location: a #GFile.
|
|
||||||
* @key: a key.
|
|
||||||
*
|
|
||||||
* Gets the value associated with the specified @key for the file @location.
|
|
||||||
*/
|
|
||||||
gchar *
|
|
||||||
gedit_metadata_manager_get (GeditMetadataManager *self,
|
|
||||||
GFile *location,
|
|
||||||
const gchar *key)
|
|
||||||
{
|
|
||||||
Item *item;
|
|
||||||
gchar *value;
|
|
||||||
gchar *uri;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_METADATA_MANAGER (self), NULL);
|
|
||||||
g_return_val_if_fail (G_IS_FILE (location), NULL);
|
|
||||||
g_return_val_if_fail (key != NULL, NULL);
|
|
||||||
|
|
||||||
uri = g_file_get_uri (location);
|
|
||||||
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "URI: %s --- key: %s", uri, key );
|
|
||||||
|
|
||||||
if (!self->values_loaded)
|
|
||||||
{
|
|
||||||
gboolean res;
|
|
||||||
|
|
||||||
res = gedit_metadata_manager_load_values (self);
|
|
||||||
|
|
||||||
if (!res)
|
|
||||||
{
|
|
||||||
g_free (uri);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = (Item *)g_hash_table_lookup (self->items, uri);
|
|
||||||
|
|
||||||
g_free (uri);
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
item->atime = g_get_real_time () / 1000;
|
|
||||||
|
|
||||||
if (item->values == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
value = g_hash_table_lookup (item->values, key);
|
|
||||||
|
|
||||||
if (value == NULL)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return g_strdup (value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_metadata_manager_set:
|
|
||||||
* @self: a #GeditMetadataManager.
|
|
||||||
* @location: a #GFile.
|
|
||||||
* @key: a key.
|
|
||||||
* @value: the value associated with the @key.
|
|
||||||
*
|
|
||||||
* Sets the @key to contain the given @value for the file @location.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gedit_metadata_manager_set (GeditMetadataManager *self,
|
|
||||||
GFile *location,
|
|
||||||
const gchar *key,
|
|
||||||
const gchar *value)
|
|
||||||
{
|
|
||||||
Item *item;
|
|
||||||
gchar *uri;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_METADATA_MANAGER (self));
|
|
||||||
g_return_if_fail (G_IS_FILE (location));
|
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
|
|
||||||
uri = g_file_get_uri (location);
|
|
||||||
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "URI: %s --- key: %s --- value: %s", uri, key, value);
|
|
||||||
|
|
||||||
if (!self->values_loaded)
|
|
||||||
{
|
|
||||||
gboolean ok;
|
|
||||||
|
|
||||||
ok = gedit_metadata_manager_load_values (self);
|
|
||||||
|
|
||||||
if (!ok)
|
|
||||||
{
|
|
||||||
g_free (uri);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = (Item *)g_hash_table_lookup (self->items, uri);
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
{
|
|
||||||
item = g_new0 (Item, 1);
|
|
||||||
|
|
||||||
g_hash_table_insert (self->items,
|
|
||||||
g_strdup (uri),
|
|
||||||
item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item->values == NULL)
|
|
||||||
{
|
|
||||||
item->values = g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
|
||||||
g_free,
|
|
||||||
g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value != NULL)
|
|
||||||
{
|
|
||||||
g_hash_table_insert (item->values,
|
|
||||||
g_strdup (key),
|
|
||||||
g_strdup (value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_hash_table_remove (item->values,
|
|
||||||
key);
|
|
||||||
}
|
|
||||||
|
|
||||||
item->atime = g_get_real_time () / 1000;
|
|
||||||
|
|
||||||
g_free (uri);
|
|
||||||
|
|
||||||
gedit_metadata_manager_arm_timeout (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
save_values (const gchar *key, const gchar *value, xmlNodePtr parent)
|
|
||||||
{
|
|
||||||
xmlNodePtr xml_node;
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
|
|
||||||
if (value == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xml_node = xmlNewChild (parent,
|
|
||||||
NULL,
|
|
||||||
(const xmlChar *)"entry",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
xmlSetProp (xml_node,
|
|
||||||
(const xmlChar *)"key",
|
|
||||||
(const xmlChar *)key);
|
|
||||||
xmlSetProp (xml_node,
|
|
||||||
(const xmlChar *)"value",
|
|
||||||
(const xmlChar *)value);
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "entry: %s = %s", key, value);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
save_item (const gchar *key, const gpointer *data, xmlNodePtr parent)
|
|
||||||
{
|
|
||||||
xmlNodePtr xml_node;
|
|
||||||
const Item *item = (const Item *)data;
|
|
||||||
gchar *atime;
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
|
|
||||||
if (item == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xml_node = xmlNewChild (parent, NULL, (const xmlChar *)"document", NULL);
|
|
||||||
|
|
||||||
xmlSetProp (xml_node, (const xmlChar *)"uri", (const xmlChar *)key);
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "uri: %s", key);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
atime = g_strdup_printf ("%" G_GINT64_FORMAT, item->atime);
|
|
||||||
xmlSetProp (xml_node, (const xmlChar *)"atime", (const xmlChar *)atime);
|
|
||||||
|
|
||||||
#ifdef GEDIT_METADATA_VERBOSE_DEBUG
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "atime: %s", atime);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_free (atime);
|
|
||||||
|
|
||||||
g_hash_table_foreach (item->values,
|
|
||||||
(GHFunc)save_values,
|
|
||||||
xml_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const gchar *
|
|
||||||
gedit_metadata_manager_get_oldest (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer key, value, key_to_remove = NULL;
|
|
||||||
const Item *item_to_remove = NULL;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, self->items);
|
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
||||||
{
|
|
||||||
const Item *item = (const Item *) value;
|
|
||||||
|
|
||||||
if (key_to_remove == NULL)
|
|
||||||
{
|
|
||||||
key_to_remove = key;
|
|
||||||
item_to_remove = item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (item_to_remove != NULL, NULL);
|
|
||||||
|
|
||||||
if (item->atime < item_to_remove->atime)
|
|
||||||
key_to_remove = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return key_to_remove;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_resize_items (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
while (g_hash_table_size (self->items) > MAX_ITEMS)
|
|
||||||
{
|
|
||||||
const gchar *key_to_remove;
|
|
||||||
|
|
||||||
key_to_remove = gedit_metadata_manager_get_oldest (self);
|
|
||||||
g_return_if_fail (key_to_remove != NULL);
|
|
||||||
g_hash_table_remove (self->items,
|
|
||||||
key_to_remove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gedit_metadata_manager_save (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
xmlDocPtr doc;
|
|
||||||
xmlNodePtr root;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
|
|
||||||
self->timeout_id = 0;
|
|
||||||
|
|
||||||
gedit_metadata_manager_resize_items (self);
|
|
||||||
|
|
||||||
xmlIndentTreeOutput = TRUE;
|
|
||||||
|
|
||||||
doc = xmlNewDoc ((const xmlChar *)"1.0");
|
|
||||||
if (doc == NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* Create metadata root */
|
|
||||||
root = xmlNewDocNode (doc, NULL, (const xmlChar *)"metadata", NULL);
|
|
||||||
xmlDocSetRootElement (doc, root);
|
|
||||||
|
|
||||||
g_hash_table_foreach (self->items,
|
|
||||||
(GHFunc)save_item,
|
|
||||||
root);
|
|
||||||
|
|
||||||
/* FIXME: lock file - Paolo */
|
|
||||||
if (self->metadata_filename != NULL)
|
|
||||||
{
|
|
||||||
gchar *cache_dir;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
/* make sure the cache dir exists */
|
|
||||||
cache_dir = g_path_get_dirname (self->metadata_filename);
|
|
||||||
res = g_mkdir_with_parents (cache_dir, 0755);
|
|
||||||
if (res != -1)
|
|
||||||
{
|
|
||||||
xmlSaveFormatFile (self->metadata_filename,
|
|
||||||
doc,
|
|
||||||
1);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (cache_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlFreeDoc (doc);
|
|
||||||
|
|
||||||
gedit_debug_message (DEBUG_METADATA, "DONE");
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_get_property (GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeditMetadataManager *self = GEDIT_METADATA_MANAGER (object);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
|
||||||
case PROP_METADATA_FILENAME:
|
|
||||||
g_value_set_string (value, self->metadata_filename);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_set_property (GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeditMetadataManager *self = GEDIT_METADATA_MANAGER (object);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
|
||||||
case PROP_METADATA_FILENAME:
|
|
||||||
self->metadata_filename = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_init (GeditMetadataManager *self)
|
|
||||||
{
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
|
|
||||||
self->values_loaded = FALSE;
|
|
||||||
|
|
||||||
self->items =
|
|
||||||
g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
|
||||||
g_free,
|
|
||||||
item_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_dispose (GObject *object)
|
|
||||||
{
|
|
||||||
GeditMetadataManager *self = GEDIT_METADATA_MANAGER (object);
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
|
|
||||||
if (self->timeout_id)
|
|
||||||
{
|
|
||||||
g_source_remove (self->timeout_id);
|
|
||||||
self->timeout_id = 0;
|
|
||||||
gedit_metadata_manager_save (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->items != NULL)
|
|
||||||
g_hash_table_destroy (self->items);
|
|
||||||
|
|
||||||
g_free (self->metadata_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_metadata_manager_class_init (GeditMetadataManagerClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
|
|
||||||
object_class->dispose = gedit_metadata_manager_dispose;
|
|
||||||
object_class->get_property = gedit_metadata_manager_get_property;
|
|
||||||
object_class->set_property = gedit_metadata_manager_set_property;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GeditMetadataManager:metadata-filename:
|
|
||||||
*
|
|
||||||
* The filename where the metadata is stored.
|
|
||||||
*/
|
|
||||||
properties[PROP_METADATA_FILENAME] =
|
|
||||||
g_param_spec_string ("metadata-filename",
|
|
||||||
"Metadata filename",
|
|
||||||
"The filename where the metadata is stored",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
GeditMetadataManager *
|
|
||||||
gedit_metadata_manager_new (const gchar *metadata_filename)
|
|
||||||
{
|
|
||||||
gedit_debug (DEBUG_METADATA);
|
|
||||||
|
|
||||||
return g_object_new (GEDIT_TYPE_METADATA_MANAGER,
|
|
||||||
"metadata-filename", metadata_filename,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,49 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
||||||
/*
|
|
||||||
* gedit-metadata-manager.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2003 Paolo Maggi
|
|
||||||
* Copyright (C) 2019 Canonical LTD
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_METADATA_MANAGER_H
|
|
||||||
#define GEDIT_METADATA_MANAGER_H
|
|
||||||
|
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_METADATA_MANAGER (gedit_metadata_manager_get_type())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditMetadataManager, gedit_metadata_manager, GEDIT, METADATA_MANAGER, GObject)
|
|
||||||
|
|
||||||
GeditMetadataManager *gedit_metadata_manager_new (const gchar *metadata_filename);
|
|
||||||
|
|
||||||
gchar *gedit_metadata_manager_get (GeditMetadataManager *self,
|
|
||||||
GFile *location,
|
|
||||||
const gchar *key);
|
|
||||||
|
|
||||||
void gedit_metadata_manager_set (GeditMetadataManager *self,
|
|
||||||
GFile *location,
|
|
||||||
const gchar *key,
|
|
||||||
const gchar *value);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_METADATA_MANAGER_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-open-document-selector-helper.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-open-document-selector-helper.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_open_document_selector_debug_print_list (const gchar *title,
|
|
||||||
GList *fileitem_list)
|
|
||||||
{
|
|
||||||
FileItem *item;
|
|
||||||
GList *l;
|
|
||||||
char *accessed = NULL;
|
|
||||||
|
|
||||||
g_print ("%s\n", title);
|
|
||||||
|
|
||||||
for (l = fileitem_list; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
item = (FileItem *)l->data;
|
|
||||||
|
|
||||||
accessed = g_date_time_format_iso8601 (item->accessed);
|
|
||||||
|
|
||||||
g_print ("%s uri:%s (%s %s)\n",
|
|
||||||
accessed,
|
|
||||||
item->uri,
|
|
||||||
item->name,
|
|
||||||
item->path);
|
|
||||||
|
|
||||||
g_clear_pointer (&accessed, g_free);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileItem *
|
|
||||||
gedit_open_document_selector_create_fileitem_item (void)
|
|
||||||
{
|
|
||||||
FileItem *item;
|
|
||||||
|
|
||||||
item = g_slice_new0 (FileItem);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_open_document_selector_free_fileitem_item (FileItem *item)
|
|
||||||
{
|
|
||||||
g_free (item->uri);
|
|
||||||
g_free (item->name);
|
|
||||||
g_free (item->path);
|
|
||||||
g_clear_pointer (&item->accessed, g_date_time_unref);
|
|
||||||
|
|
||||||
g_slice_free (FileItem, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileItem *
|
|
||||||
gedit_open_document_selector_copy_fileitem_item (FileItem *item)
|
|
||||||
{
|
|
||||||
FileItem *new_item;
|
|
||||||
|
|
||||||
new_item = gedit_open_document_selector_create_fileitem_item ();
|
|
||||||
|
|
||||||
new_item->uri = g_strdup (item->uri);
|
|
||||||
new_item->name = g_strdup (item->name);
|
|
||||||
new_item->path = g_strdup (item->path);
|
|
||||||
new_item->accessed = g_date_time_ref (item->accessed);
|
|
||||||
|
|
||||||
return new_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline GList *
|
|
||||||
gedit_open_document_selector_copy_file_items_list (const GList *file_items_list)
|
|
||||||
{
|
|
||||||
GList *new_file_items_list;
|
|
||||||
|
|
||||||
new_file_items_list = g_list_copy_deep ((GList *)file_items_list,
|
|
||||||
(GCopyFunc)gedit_open_document_selector_copy_fileitem_item,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return new_file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
gedit_open_document_selector_free_file_items_list (GList *file_items_list)
|
|
||||||
{
|
|
||||||
g_list_free_full (file_items_list,
|
|
||||||
(GDestroyNotify)gedit_open_document_selector_free_fileitem_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-open-document-selector-helper.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_OPEN_DOCUMENT_SELECTOR_HELPER_H
|
|
||||||
#define GEDIT_OPEN_DOCUMENT_SELECTOR_HELPER_H
|
|
||||||
|
|
||||||
#include "gedit-open-document-selector.h"
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
gchar *uri;
|
|
||||||
gchar *name;
|
|
||||||
gchar *path;
|
|
||||||
GDateTime *accessed;
|
|
||||||
} FileItem;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_RECENT_FILES_LIST = 0,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_HOME_DIR_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_DESKTOP_DIR_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_LOCAL_BOOKMARKS_DIR_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_FILE_BROWSER_ROOT_DIR_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_ACTIVE_DOC_DIR_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_CURRENT_DOCS_LIST,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_LIST_TYPE_NUM_OF_LISTS
|
|
||||||
} ListType;
|
|
||||||
|
|
||||||
/* Use #if 1 and rebuild to activate selector debugging and timing */
|
|
||||||
#if 0
|
|
||||||
#define DEBUG_OPEN_DOCUMENT_SELECTOR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG_OPEN_DOCUMENT_SELECTOR
|
|
||||||
G_GNUC_UNUSED static const gchar *list_type_string[] =
|
|
||||||
{
|
|
||||||
"RECENT_FILES_LIST",
|
|
||||||
"HOME_DIR_LIST",
|
|
||||||
"DESKTOP_DIR_LIST",
|
|
||||||
"LOCAL_BOOKMARKS_DIR_LIST",
|
|
||||||
"FILE_BROWSER_ROOT_DIR_LIST",
|
|
||||||
"ACTIVE_DOC_DIR_LIST",
|
|
||||||
"CURRENT_DOCS_LIST"
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DEBUG_SELECTOR(x) do { x; } while (0)
|
|
||||||
#define DEBUG_SELECTOR_TIMER_DECL G_GNUC_UNUSED GTimer *debug_timer;
|
|
||||||
#define DEBUG_SELECTOR_TIMER_NEW debug_timer = g_timer_new ();
|
|
||||||
#define DEBUG_SELECTOR_TIMER_DESTROY g_timer_destroy (debug_timer);
|
|
||||||
#define DEBUG_SELECTOR_TIMER_GET g_timer_elapsed (debug_timer, NULL)
|
|
||||||
#else
|
|
||||||
#define DEBUG_SELECTOR(x)
|
|
||||||
#define DEBUG_SELECTOR_TIMER_DECL
|
|
||||||
#define DEBUG_SELECTOR_TIMER_NEW
|
|
||||||
#define DEBUG_SELECTOR_TIMER_DESTROY
|
|
||||||
#define DEBUG_SELECTOR_TIMER_GET
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GeditOpenDocumentSelector *selector;
|
|
||||||
ListType type;
|
|
||||||
} PushMessage;
|
|
||||||
|
|
||||||
void gedit_open_document_selector_debug_print_list (const gchar *title,
|
|
||||||
GList *fileitem_list);
|
|
||||||
|
|
||||||
GList *gedit_open_document_selector_copy_file_items_list (const GList *file_items_list);
|
|
||||||
|
|
||||||
void gedit_open_document_selector_free_file_items_list (GList *file_items_list);
|
|
||||||
|
|
||||||
FileItem *gedit_open_document_selector_create_fileitem_item (void);
|
|
||||||
|
|
||||||
void gedit_open_document_selector_free_fileitem_item (FileItem *item);
|
|
||||||
|
|
||||||
FileItem *gedit_open_document_selector_copy_fileitem_item (FileItem *item);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_OPEN_DOCUMENT_SELECTOR_HELPER_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,839 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-open-document-selector-store.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* You need to call gedit_open_document_selector_store_get_default()
|
|
||||||
* to get a singleton #GeditOpenDocumentSelectorStore object.
|
|
||||||
* #GeditOpenDocumentSelectorStore is responsible of managing
|
|
||||||
* the recent files list and computing others lists.
|
|
||||||
*
|
|
||||||
* The lists returned are lists of FileItem structs.
|
|
||||||
*
|
|
||||||
* #GeditOpenDocumentSelectorStore is destroyed automaticly at
|
|
||||||
* the end of your application.
|
|
||||||
*
|
|
||||||
* Call gedit_open_document_selector_store_update_list_async() with
|
|
||||||
* the corresponding ListType, then in your callback, call
|
|
||||||
* gedit_open_document_selector_store_update_list_finish() to get
|
|
||||||
* in return the list of FileItem structs.
|
|
||||||
*
|
|
||||||
* The recent files list can be filtered by calling
|
|
||||||
* gedit_open_document_selector_store_set_filter()
|
|
||||||
* and you can get the actual filter by calling
|
|
||||||
* gedit_open_document_selector_store_get_filter()
|
|
||||||
* ( this is in addition to the text mime type filter)
|
|
||||||
*
|
|
||||||
* The recent files list is not capped by Gedit settings like
|
|
||||||
* in gedit_recent_get_items() but you still can get the limit
|
|
||||||
* by calling gedit_open_document_selector_store_get_recent_limit().
|
|
||||||
*
|
|
||||||
* The original setting is stored in gsettings at :
|
|
||||||
* org.gnome.gedit.preferences.ui
|
|
||||||
* with the key : max-recents
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-open-document-selector-store.h"
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
#include "gedit-recent.h"
|
|
||||||
#include "gedit-utils.h"
|
|
||||||
#include "gedit-window.h"
|
|
||||||
#include "gedit-debug.h"
|
|
||||||
|
|
||||||
struct _GeditOpenDocumentSelectorStore
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GSource *recent_source;
|
|
||||||
|
|
||||||
GeditRecentConfiguration recent_config;
|
|
||||||
gchar *filter;
|
|
||||||
GList *recent_items;
|
|
||||||
gint recent_config_limit;
|
|
||||||
gboolean recent_items_need_update;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_LOCK_DEFINE_STATIC (recent_files_filter_lock);
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditOpenDocumentSelectorStore, gedit_open_document_selector_store, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
G_DEFINE_QUARK (gedit-open-document-selector-store-error-quark,
|
|
||||||
gedit_open_document_selector_store_error)
|
|
||||||
|
|
||||||
|
|
||||||
static GDateTime *
|
|
||||||
_get_date_time (GFileInfo *info)
|
|
||||||
{
|
|
||||||
guint32 time;
|
|
||||||
guint32 usecs;
|
|
||||||
GDateTime *dt = NULL, *dt2 = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
|
|
||||||
|
|
||||||
time = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
|
|
||||||
dt = g_date_time_new_from_unix_utc (time);
|
|
||||||
|
|
||||||
usecs = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
|
|
||||||
dt2 = g_date_time_add_seconds (dt, usecs / (gdouble) G_USEC_PER_SEC);
|
|
||||||
|
|
||||||
g_date_time_unref (dt);
|
|
||||||
|
|
||||||
return g_steal_pointer (&dt2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_current_docs_list (GeditOpenDocumentSelectorStore *selector_store G_GNUC_UNUSED,
|
|
||||||
GeditOpenDocumentSelector *selector)
|
|
||||||
{
|
|
||||||
GeditWindow *window;
|
|
||||||
GList *docs;
|
|
||||||
GList *l;
|
|
||||||
GFile *file;
|
|
||||||
GFileInfo *info;
|
|
||||||
FileItem *item;
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
|
|
||||||
window = gedit_open_document_selector_get_window (selector);
|
|
||||||
|
|
||||||
docs = gedit_window_get_documents (window);
|
|
||||||
for (l = docs; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
file = gtk_source_file_get_location (gedit_document_get_file (l->data));
|
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
/* In case of not saved docs */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
info = g_file_query_info (file,
|
|
||||||
"time::access,time::access-usec",
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (info == NULL)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
item = gedit_open_document_selector_create_fileitem_item ();
|
|
||||||
|
|
||||||
item->accessed = _get_date_time (info);
|
|
||||||
item->uri = g_file_get_uri (file);
|
|
||||||
|
|
||||||
file_items_list = g_list_prepend (file_items_list, item);
|
|
||||||
|
|
||||||
g_object_unref (info);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (docs);
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Notice that a content-type attribute must have been query to work */
|
|
||||||
static gboolean
|
|
||||||
check_mime_type (GFileInfo *info)
|
|
||||||
{
|
|
||||||
const gchar *content_type;
|
|
||||||
G_GNUC_UNUSED gchar *mime_type;
|
|
||||||
|
|
||||||
content_type = g_file_info_get_attribute_string (info, "standard::fast-content-type");
|
|
||||||
if (content_type == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
if (g_content_type_is_a (content_type, "text"))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
mime_type = g_content_type_get_mime_type (content_type);
|
|
||||||
if (mime_type == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_strcmp0 (mime_type, "text/plain") == 0)
|
|
||||||
{
|
|
||||||
g_free (mime_type);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (mime_type);
|
|
||||||
#else
|
|
||||||
if (g_content_type_is_a (content_type, "text/plain"))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_children_from_dir (GeditOpenDocumentSelectorStore *selector_store G_GNUC_UNUSED,
|
|
||||||
GFile *dir)
|
|
||||||
{
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
GFileEnumerator *file_enum;
|
|
||||||
GFileInfo *info;
|
|
||||||
GFileType filetype;
|
|
||||||
GFile *file;
|
|
||||||
FileItem *item;
|
|
||||||
gboolean is_text;
|
|
||||||
gboolean is_correct_type;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (dir), NULL);
|
|
||||||
|
|
||||||
file_enum = g_file_enumerate_children (dir,
|
|
||||||
"standard::name,"
|
|
||||||
"standard::type,"
|
|
||||||
"standard::fast-content-type,"
|
|
||||||
"time::access,time::access-usec",
|
|
||||||
G_FILE_QUERY_INFO_NONE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (file_enum == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((info = g_file_enumerator_next_file (file_enum, NULL, NULL)))
|
|
||||||
{
|
|
||||||
filetype = g_file_info_get_file_type (info);
|
|
||||||
is_text = check_mime_type (info);
|
|
||||||
is_correct_type = (filetype == G_FILE_TYPE_REGULAR ||
|
|
||||||
filetype == G_FILE_TYPE_SYMBOLIC_LINK ||
|
|
||||||
filetype == G_FILE_TYPE_SHORTCUT);
|
|
||||||
|
|
||||||
if (is_text &&
|
|
||||||
is_correct_type &&
|
|
||||||
(file = g_file_enumerator_get_child (file_enum, info)) != NULL)
|
|
||||||
{
|
|
||||||
item = gedit_open_document_selector_create_fileitem_item ();
|
|
||||||
item->uri = g_file_get_uri (file);
|
|
||||||
|
|
||||||
item->accessed = _get_date_time (info);
|
|
||||||
|
|
||||||
file_items_list = g_list_prepend (file_items_list, item);
|
|
||||||
g_object_unref (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (info);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_file_enumerator_close (file_enum, NULL, NULL);
|
|
||||||
g_object_unref (file_enum);
|
|
||||||
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_active_doc_dir_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector)
|
|
||||||
{
|
|
||||||
GeditWindow *window;
|
|
||||||
GeditDocument *active_doc;
|
|
||||||
GtkSourceFile *source_file;
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
|
|
||||||
window = gedit_open_document_selector_get_window (selector);
|
|
||||||
|
|
||||||
active_doc = gedit_window_get_active_document (window);
|
|
||||||
|
|
||||||
if (active_doc == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
source_file = gedit_document_get_file (active_doc);
|
|
||||||
if (gtk_source_file_is_local (source_file))
|
|
||||||
{
|
|
||||||
GFile *location;
|
|
||||||
GFile *parent_dir;
|
|
||||||
|
|
||||||
location = gtk_source_file_get_location (source_file);
|
|
||||||
parent_dir = g_file_get_parent (location);
|
|
||||||
|
|
||||||
if (parent_dir != NULL)
|
|
||||||
{
|
|
||||||
file_items_list = get_children_from_dir (selector_store, parent_dir);
|
|
||||||
g_object_unref (parent_dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GFile *
|
|
||||||
get_file_browser_root (GeditOpenDocumentSelectorStore *selector_store G_GNUC_UNUSED,
|
|
||||||
GeditOpenDocumentSelector *selector)
|
|
||||||
{
|
|
||||||
GeditWindow *window;
|
|
||||||
GeditMessageBus *bus;
|
|
||||||
GeditMessage *msg;
|
|
||||||
GFile *root = NULL;
|
|
||||||
|
|
||||||
window = gedit_open_document_selector_get_window (selector);
|
|
||||||
|
|
||||||
bus = gedit_window_get_message_bus (window);
|
|
||||||
if (gedit_message_bus_is_registered (bus, "/plugins/filebrowser", "get_root"))
|
|
||||||
{
|
|
||||||
msg = gedit_message_bus_send_sync (bus, "/plugins/filebrowser", "get_root", NULL, NULL);
|
|
||||||
g_object_get (msg, "location", &root, NULL);
|
|
||||||
g_object_unref (msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_file_browser_root_dir_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector)
|
|
||||||
{
|
|
||||||
GFile *root;
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
|
|
||||||
root = get_file_browser_root (selector_store, selector);
|
|
||||||
if (root != NULL && g_file_is_native (root))
|
|
||||||
{
|
|
||||||
file_items_list = get_children_from_dir (selector_store, root);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&root);
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Taken and adapted from gtk+ gtkbookmarksmanager.c */
|
|
||||||
static GList *
|
|
||||||
read_bookmarks_file (GFile *file)
|
|
||||||
{
|
|
||||||
gchar *contents;
|
|
||||||
gchar **lines, *space;
|
|
||||||
GList *uri_list = NULL;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (!g_file_load_contents (file, NULL, &contents, NULL, NULL, NULL))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
lines = g_strsplit (contents, "\n", -1);
|
|
||||||
|
|
||||||
for (i = 0; lines[i]; i++)
|
|
||||||
{
|
|
||||||
if (*lines[i] == '\0')
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_utf8_validate (lines[i], -1, NULL))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((space = strchr (lines[i], ' ')) != NULL)
|
|
||||||
{
|
|
||||||
space[0] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
uri_list = g_list_prepend (uri_list, g_strdup (lines[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev (lines);
|
|
||||||
g_free (contents);
|
|
||||||
|
|
||||||
return uri_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_local_bookmarks_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GList *bookmarks_uri_list = NULL;
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
GList *new_file_items_list = NULL;
|
|
||||||
GFile *bookmarks_file;
|
|
||||||
GFile *file;
|
|
||||||
gchar *filename;
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
filename = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "bookmarks", NULL);
|
|
||||||
bookmarks_file = g_file_new_for_path (filename);
|
|
||||||
g_free (filename);
|
|
||||||
|
|
||||||
bookmarks_uri_list = read_bookmarks_file (bookmarks_file);
|
|
||||||
g_object_unref (bookmarks_file);
|
|
||||||
|
|
||||||
for (l = bookmarks_uri_list; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
file = g_file_new_for_uri (l->data);
|
|
||||||
if (g_file_is_native (file))
|
|
||||||
{
|
|
||||||
new_file_items_list = get_children_from_dir (selector_store, file);
|
|
||||||
file_items_list = g_list_concat (file_items_list, new_file_items_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free_full (bookmarks_uri_list, g_free);
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Taken and adapted from gtk+ gtkplacessidebar.c */
|
|
||||||
static gboolean
|
|
||||||
path_is_home_dir (const gchar *path)
|
|
||||||
{
|
|
||||||
GFile *home_dir;
|
|
||||||
GFile *location;
|
|
||||||
const gchar *home_path;
|
|
||||||
gboolean res;
|
|
||||||
|
|
||||||
home_path = g_get_home_dir ();
|
|
||||||
if (home_path == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
home_dir = g_file_new_for_path (home_path);
|
|
||||||
location = g_file_new_for_path (path);
|
|
||||||
res = g_file_equal (home_dir, location);
|
|
||||||
|
|
||||||
g_object_unref (home_dir);
|
|
||||||
g_object_unref (location);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_desktop_dir_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
const gchar *desktop_dir_name;
|
|
||||||
gchar *desktop_uri;
|
|
||||||
GFile *desktop_file;
|
|
||||||
|
|
||||||
desktop_dir_name = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
|
||||||
|
|
||||||
/* "To disable a directory, point it to the homedir."
|
|
||||||
* See http://freedesktop.org/wiki/Software/xdg-user-dirs
|
|
||||||
*/
|
|
||||||
if (path_is_home_dir (desktop_dir_name))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
desktop_uri = g_strconcat ("file://", desktop_dir_name, NULL);
|
|
||||||
desktop_file = g_file_new_for_uri (desktop_uri);
|
|
||||||
file_items_list = get_children_from_dir (selector_store, desktop_file);
|
|
||||||
|
|
||||||
g_free (desktop_uri);
|
|
||||||
g_object_unref (desktop_file);
|
|
||||||
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_home_dir_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GList *file_items_list = NULL;
|
|
||||||
const gchar *home_name;
|
|
||||||
gchar *home_uri;
|
|
||||||
GFile *home_file;
|
|
||||||
|
|
||||||
home_name = g_get_home_dir ();
|
|
||||||
if (home_name == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
home_uri = g_strconcat ("file://", home_name, NULL);
|
|
||||||
home_file = g_file_new_for_uri (home_uri);
|
|
||||||
file_items_list = get_children_from_dir (selector_store, home_file);
|
|
||||||
|
|
||||||
g_free (home_uri);
|
|
||||||
g_object_unref (home_file);
|
|
||||||
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
convert_recent_item_list_to_fileitem_list (GList *uri_list)
|
|
||||||
{
|
|
||||||
GList *l;
|
|
||||||
GList *fileitem_list = NULL;
|
|
||||||
|
|
||||||
for (l = uri_list; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
gchar *uri;
|
|
||||||
FileItem *item;
|
|
||||||
|
|
||||||
uri = g_strdup (gtk_recent_info_get_uri (l->data));
|
|
||||||
|
|
||||||
item = gedit_open_document_selector_create_fileitem_item ();
|
|
||||||
item->uri = uri;
|
|
||||||
|
|
||||||
item->accessed = g_date_time_new_from_unix_local (gtk_recent_info_get_visited (l->data));
|
|
||||||
|
|
||||||
fileitem_list = g_list_prepend (fileitem_list, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileitem_list = g_list_reverse (fileitem_list);
|
|
||||||
return fileitem_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
get_recent_files_list (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GList *recent_items_list;
|
|
||||||
GList *file_items_list;
|
|
||||||
|
|
||||||
G_LOCK (recent_files_filter_lock);
|
|
||||||
recent_items_list = gedit_recent_get_items (&selector_store->recent_config);
|
|
||||||
G_UNLOCK (recent_files_filter_lock);
|
|
||||||
|
|
||||||
file_items_list = convert_recent_item_list_to_fileitem_list (recent_items_list);
|
|
||||||
g_list_free_full (recent_items_list, (GDestroyNotify)gtk_recent_info_unref);
|
|
||||||
|
|
||||||
return file_items_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
update_list_cb (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GAsyncResult *res,
|
|
||||||
gpointer user_data G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
GError *error;
|
|
||||||
PushMessage *message;
|
|
||||||
ListType type;
|
|
||||||
|
|
||||||
list = gedit_open_document_selector_store_update_list_finish (selector_store, res, &error);
|
|
||||||
|
|
||||||
message = g_task_get_task_data (G_TASK (res));
|
|
||||||
type = message->type;
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case GEDIT_OPEN_DOCUMENT_SELECTOR_RECENT_FILES_LIST:
|
|
||||||
gedit_open_document_selector_free_file_items_list (selector_store->recent_items);
|
|
||||||
selector_store->recent_items = list;
|
|
||||||
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): update_list_cb: type:%s, length:%i\n",
|
|
||||||
selector_store, list_type_string[type], g_list_length (list)););
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_recent_manager_changed (GtkRecentManager *manager G_GNUC_UNUSED,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GeditOpenDocumentSelectorStore *selector_store = GEDIT_OPEN_DOCUMENT_SELECTOR_STORE (user_data);
|
|
||||||
|
|
||||||
selector_store->recent_items_need_update = TRUE;
|
|
||||||
gedit_open_document_selector_store_update_list_async (selector_store,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(GAsyncReadyCallback)update_list_cb,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_RECENT_FILES_LIST,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_open_document_selector_store_dispose (GObject *object)
|
|
||||||
{
|
|
||||||
GeditOpenDocumentSelectorStore *selector_store = GEDIT_OPEN_DOCUMENT_SELECTOR_STORE (object);
|
|
||||||
|
|
||||||
gedit_recent_configuration_destroy (&selector_store->recent_config);
|
|
||||||
|
|
||||||
g_clear_pointer (&selector_store->recent_source, g_source_destroy);
|
|
||||||
g_clear_pointer (&selector_store->filter, g_free);
|
|
||||||
|
|
||||||
if (selector_store->recent_items)
|
|
||||||
{
|
|
||||||
gedit_open_document_selector_free_file_items_list (selector_store->recent_items);
|
|
||||||
selector_store->recent_items = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_open_document_selector_store_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_open_document_selector_store_class_init (GeditOpenDocumentSelectorStoreClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = gedit_open_document_selector_store_dispose;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The order of functions pointers must be the same as in
|
|
||||||
* ListType enum define in ./gedit-open-document-selector-helper.h
|
|
||||||
*/
|
|
||||||
static GList * (*list_func [])(GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector) =
|
|
||||||
{
|
|
||||||
get_recent_files_list,
|
|
||||||
get_home_dir_list,
|
|
||||||
get_desktop_dir_list,
|
|
||||||
get_local_bookmarks_list,
|
|
||||||
get_file_browser_root_dir_list,
|
|
||||||
get_active_doc_dir_list,
|
|
||||||
get_current_docs_list
|
|
||||||
};
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
update_recent_list (gpointer user_data)
|
|
||||||
{
|
|
||||||
GeditOpenDocumentSelectorStore *selector_store;
|
|
||||||
GeditOpenDocumentSelector *selector;
|
|
||||||
PushMessage *message;
|
|
||||||
/* The type variable is only used when debug code activated */
|
|
||||||
G_GNUC_UNUSED ListType type;
|
|
||||||
GList *file_items_list;
|
|
||||||
GTask *task = G_TASK(user_data);
|
|
||||||
|
|
||||||
selector_store = g_task_get_source_object (task);
|
|
||||||
message = g_task_get_task_data (task);
|
|
||||||
selector = message->selector;
|
|
||||||
type = message->type;
|
|
||||||
|
|
||||||
DEBUG_SELECTOR_TIMER_DECL
|
|
||||||
DEBUG_SELECTOR_TIMER_NEW
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: type:%s\n",
|
|
||||||
selector, list_type_string[type]););
|
|
||||||
|
|
||||||
/* Update the recent list only when it changes, copy otherwise but keep it the first time */
|
|
||||||
if (selector_store->recent_items != NULL && selector_store->recent_items_need_update == FALSE)
|
|
||||||
{
|
|
||||||
file_items_list = gedit_open_document_selector_copy_file_items_list (selector_store->recent_items);
|
|
||||||
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: recent list copy\n", selector););
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
selector_store->recent_items_need_update = FALSE;
|
|
||||||
file_items_list = get_recent_files_list (selector_store, selector);
|
|
||||||
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: recent list compute\n", selector););
|
|
||||||
|
|
||||||
if (selector_store->recent_items == NULL)
|
|
||||||
{
|
|
||||||
selector_store->recent_items = gedit_open_document_selector_copy_file_items_list (file_items_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_task_return_pointer (task,
|
|
||||||
file_items_list,
|
|
||||||
(GDestroyNotify)gedit_open_document_selector_free_file_items_list);
|
|
||||||
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: type:%s, time:%lf\n",
|
|
||||||
selector, list_type_string[type], DEBUG_SELECTOR_TIMER_GET););
|
|
||||||
DEBUG_SELECTOR_TIMER_DESTROY
|
|
||||||
|
|
||||||
selector_store->recent_source = NULL;
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
update_list_dispatcher (GTask *task,
|
|
||||||
gpointer source_object,
|
|
||||||
gpointer task_data,
|
|
||||||
GCancellable *cancellable G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
GeditOpenDocumentSelectorStore *selector_store = source_object;
|
|
||||||
GeditOpenDocumentSelector *selector;
|
|
||||||
PushMessage *message;
|
|
||||||
ListType type;
|
|
||||||
GList *file_items_list;
|
|
||||||
|
|
||||||
message = task_data;
|
|
||||||
selector = message->selector;
|
|
||||||
type = message->type;
|
|
||||||
|
|
||||||
DEBUG_SELECTOR_TIMER_DECL
|
|
||||||
DEBUG_SELECTOR_TIMER_NEW
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: Thread:%p, type:%s\n",
|
|
||||||
selector, g_thread_self (), list_type_string[type]););
|
|
||||||
|
|
||||||
if (type >= GEDIT_OPEN_DOCUMENT_SELECTOR_LIST_TYPE_NUM_OF_LISTS)
|
|
||||||
{
|
|
||||||
g_task_return_new_error (task,
|
|
||||||
GEDIT_OPEN_DOCUMENT_SELECTOR_STORE_ERROR, TYPE_OUT_OF_RANGE,
|
|
||||||
"List Type out of range");
|
|
||||||
g_object_unref (task);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Here we call the corresponding list creator function */
|
|
||||||
file_items_list = (*list_func[type]) (selector_store, selector);
|
|
||||||
|
|
||||||
DEBUG_SELECTOR (g_print ("\tStore(%p): store dispatcher: Thread:%p, type:%s, time:%lf\n",
|
|
||||||
selector, g_thread_self (), list_type_string[type], DEBUG_SELECTOR_TIMER_GET););
|
|
||||||
DEBUG_SELECTOR_TIMER_DESTROY
|
|
||||||
|
|
||||||
g_task_return_pointer (task,
|
|
||||||
file_items_list,
|
|
||||||
(GDestroyNotify)gedit_open_document_selector_free_file_items_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
GList *
|
|
||||||
gedit_open_document_selector_store_update_list_finish (GeditOpenDocumentSelectorStore *open_document_selector_store,
|
|
||||||
GAsyncResult *result,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (open_document_selector_store), NULL);
|
|
||||||
g_return_val_if_fail (g_task_is_valid (result, open_document_selector_store), NULL);
|
|
||||||
|
|
||||||
return g_task_propagate_pointer (G_TASK (result), error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_open_document_selector_store_update_list_async (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
GeditOpenDocumentSelector *selector,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GAsyncReadyCallback callback,
|
|
||||||
ListType type,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GTask *task;
|
|
||||||
PushMessage *message;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (selector_store));
|
|
||||||
g_return_if_fail (selector == NULL || GEDIT_IS_OPEN_DOCUMENT_SELECTOR (selector));
|
|
||||||
|
|
||||||
message = g_new (PushMessage, 1);
|
|
||||||
message->selector = selector;
|
|
||||||
message->type = type;
|
|
||||||
|
|
||||||
task = g_task_new (selector_store, cancellable, callback, user_data);
|
|
||||||
g_task_set_source_tag (task, gedit_open_document_selector_store_update_list_async);
|
|
||||||
g_task_set_priority (task, G_PRIORITY_DEFAULT);
|
|
||||||
g_task_set_task_data (task, message, (GDestroyNotify)g_free);
|
|
||||||
|
|
||||||
if (type == GEDIT_OPEN_DOCUMENT_SELECTOR_RECENT_FILES_LIST &&
|
|
||||||
selector_store->recent_source == NULL)
|
|
||||||
{
|
|
||||||
selector_store->recent_source = g_idle_source_new ();
|
|
||||||
g_task_attach_source (task, selector_store->recent_source, update_recent_list);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_task_run_in_thread (task, update_list_dispatcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (task);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_open_document_selector_store_init (GeditOpenDocumentSelectorStore *selector_store)
|
|
||||||
{
|
|
||||||
gedit_recent_configuration_init_default (&selector_store->recent_config);
|
|
||||||
|
|
||||||
/* We remove the recent files limit since we need the whole list but
|
|
||||||
* we back it up as gedit_open_document_selector_store_get_recent_limit
|
|
||||||
* use it
|
|
||||||
*/
|
|
||||||
selector_store->recent_config_limit = selector_store->recent_config.limit;
|
|
||||||
selector_store->recent_config.limit = -1;
|
|
||||||
|
|
||||||
g_signal_connect_object (selector_store->recent_config.manager,
|
|
||||||
"changed",
|
|
||||||
G_CALLBACK (on_recent_manager_changed),
|
|
||||||
selector_store,
|
|
||||||
0);
|
|
||||||
|
|
||||||
selector_store->recent_items_need_update = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gedit_open_document_selector_store_get_recent_limit (GeditOpenDocumentSelectorStore *selector_store)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (selector_store), -1);
|
|
||||||
|
|
||||||
return selector_store->recent_config_limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_open_document_selector_store_set_filter (GeditOpenDocumentSelectorStore *selector_store,
|
|
||||||
const gchar *filter)
|
|
||||||
{
|
|
||||||
gchar *old_filter;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (selector_store));
|
|
||||||
g_return_if_fail (filter != NULL);
|
|
||||||
|
|
||||||
G_LOCK (recent_files_filter_lock);
|
|
||||||
|
|
||||||
old_filter = selector_store->filter;
|
|
||||||
selector_store->filter = g_strdup (filter);
|
|
||||||
|
|
||||||
G_UNLOCK (recent_files_filter_lock);
|
|
||||||
g_free (old_filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gedit_open_document_selector_store_get_filter (GeditOpenDocumentSelectorStore *selector_store)
|
|
||||||
{
|
|
||||||
gchar *recent_filter;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_OPEN_DOCUMENT_SELECTOR_STORE (selector_store), NULL);
|
|
||||||
|
|
||||||
G_LOCK (recent_files_filter_lock);
|
|
||||||
recent_filter = g_strdup (selector_store->filter);
|
|
||||||
G_UNLOCK (recent_files_filter_lock);
|
|
||||||
|
|
||||||
return recent_filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gets a unique instance of #GeditOpenDocumentSelectorStore
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): A unique #GeditOpenDocumentSelectorStore.
|
|
||||||
* Do not ref or unref it, it will be destroyed at the end of the application.
|
|
||||||
*/
|
|
||||||
GeditOpenDocumentSelectorStore *
|
|
||||||
gedit_open_document_selector_store_get_default (void)
|
|
||||||
{
|
|
||||||
static GeditOpenDocumentSelectorStore *instance;
|
|
||||||
|
|
||||||
if (instance == NULL)
|
|
||||||
{
|
|
||||||
instance = g_object_new (GEDIT_TYPE_OPEN_DOCUMENT_SELECTOR_STORE, NULL);
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (instance), (gpointer) &instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-open-document-selector-store.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_OPEN_DOCUMENT_SELECTOR_STORE_H
|
|
||||||
#define GEDIT_OPEN_DOCUMENT_SELECTOR_STORE_H
|
|
||||||
|
|
||||||
#include "gedit-open-document-selector-helper.h"
|
|
||||||
#include "gedit-open-document-selector.h"
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_OPEN_DOCUMENT_SELECTOR_STORE (gedit_open_document_selector_store_get_type ())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditOpenDocumentSelectorStore, gedit_open_document_selector_store, GEDIT, OPEN_DOCUMENT_SELECTOR_STORE, GObject)
|
|
||||||
|
|
||||||
#define GEDIT_OPEN_DOCUMENT_SELECTOR_STORE_ERROR gedit_open_document_selector_store_error_quark ()
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
TYPE_OUT_OF_RANGE
|
|
||||||
} GeditOpenDocumentSelectorStoreError;
|
|
||||||
|
|
||||||
GQuark gedit_open_document_selector_store_error_quark (void);
|
|
||||||
|
|
||||||
gint gedit_open_document_selector_store_get_recent_limit (GeditOpenDocumentSelectorStore *store);
|
|
||||||
|
|
||||||
void gedit_open_document_selector_store_set_filter (GeditOpenDocumentSelectorStore *store,
|
|
||||||
const gchar *filter);
|
|
||||||
|
|
||||||
gchar *gedit_open_document_selector_store_get_filter (GeditOpenDocumentSelectorStore *store);
|
|
||||||
|
|
||||||
GList *gedit_open_document_selector_store_update_list_finish (GeditOpenDocumentSelectorStore *open_document_selector_store,
|
|
||||||
GAsyncResult *res,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
void gedit_open_document_selector_store_update_list_async (GeditOpenDocumentSelectorStore *open_document_selector_store,
|
|
||||||
GeditOpenDocumentSelector *open_document_selector,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GAsyncReadyCallback callback,
|
|
||||||
ListType type,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
GeditOpenDocumentSelectorStore *gedit_open_document_selector_store_get_default (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_OPEN_DOCUMENT_SELECTOR_STORE_H */
|
|
||||||
/* ex:set ts=8 noet: */
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-open-document-selector.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* gedit 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.
|
|
||||||
*
|
|
||||||
* gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_OPEN_DOCUMENT_SELECTOR_H
|
|
||||||
#define GEDIT_OPEN_DOCUMENT_SELECTOR_H
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include "gedit-window.h"
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_OPEN_DOCUMENT_SELECTOR (gedit_open_document_selector_get_type ())
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditOpenDocumentSelector, gedit_open_document_selector, GEDIT, OPEN_DOCUMENT_SELECTOR, GtkBox)
|
|
||||||
|
|
||||||
GeditOpenDocumentSelector *gedit_open_document_selector_new (GeditWindow *window);
|
|
||||||
|
|
||||||
GeditWindow *gedit_open_document_selector_get_window (GeditOpenDocumentSelector *selector);
|
|
||||||
|
|
||||||
GtkWidget *gedit_open_document_selector_get_search_entry (GeditOpenDocumentSelector *selector);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_OPEN_DOCUMENT_SELECTOR_H */
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,230 +0,0 @@
|
||||||
/* gedit-pango.c
|
|
||||||
*
|
|
||||||
* This file is a copy of pango_font_description_to_css from gtk gtkfontbutton.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Matthias Clasen <mclasen@redhat.com>
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define G_LOG_DOMAIN "gedit-pango"
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "gedit-pango.h"
|
|
||||||
|
|
||||||
#if PANGO_VERSION_CHECK (1, 44, 0)
|
|
||||||
static void
|
|
||||||
add_css_variations (GString *s,
|
|
||||||
const char *variations)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
const char *sep = "";
|
|
||||||
|
|
||||||
if (variations == NULL || variations[0] == '\0')
|
|
||||||
{
|
|
||||||
g_string_append (s, "normal");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = variations;
|
|
||||||
while (p && *p)
|
|
||||||
{
|
|
||||||
const char *start;
|
|
||||||
const char *end, *end2;
|
|
||||||
double value;
|
|
||||||
char name[5];
|
|
||||||
|
|
||||||
while (g_ascii_isspace (*p)) p++;
|
|
||||||
|
|
||||||
start = p;
|
|
||||||
end = strchr (p, ',');
|
|
||||||
if (end && (end - p < 6))
|
|
||||||
goto skip;
|
|
||||||
|
|
||||||
name[0] = p[0];
|
|
||||||
name[1] = p[1];
|
|
||||||
name[2] = p[2];
|
|
||||||
name[3] = p[3];
|
|
||||||
name[4] = '\0';
|
|
||||||
|
|
||||||
p += 4;
|
|
||||||
while (g_ascii_isspace (*p)) p++;
|
|
||||||
if (*p == '=') p++;
|
|
||||||
|
|
||||||
if (p - start < 5)
|
|
||||||
goto skip;
|
|
||||||
|
|
||||||
value = g_ascii_strtod (p, (char **) &end2);
|
|
||||||
|
|
||||||
while (end2 && g_ascii_isspace (*end2)) end2++;
|
|
||||||
|
|
||||||
if (end2 && (*end2 != ',' && *end2 != '\0'))
|
|
||||||
goto skip;
|
|
||||||
|
|
||||||
g_string_append_printf (s, "%s\"%s\" %g", sep, name, value);
|
|
||||||
sep = ", ";
|
|
||||||
|
|
||||||
skip:
|
|
||||||
p = end ? end + 1 : NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_pango_font_description_to_css:
|
|
||||||
*
|
|
||||||
* This function will generate CSS suitable for Gtk's CSS engine
|
|
||||||
* based on the properties of the #PangoFontDescription.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): A newly allocated string containing the
|
|
||||||
* CSS describing the font description.
|
|
||||||
*/
|
|
||||||
gchar *
|
|
||||||
gedit_pango_font_description_to_css (const PangoFontDescription *desc)
|
|
||||||
{
|
|
||||||
GString *s;
|
|
||||||
PangoFontMask set;
|
|
||||||
|
|
||||||
s = g_string_new ("");
|
|
||||||
|
|
||||||
set = pango_font_description_get_set_fields (desc);
|
|
||||||
if (set & PANGO_FONT_MASK_FAMILY)
|
|
||||||
{
|
|
||||||
g_string_append (s, "font-family: \"");
|
|
||||||
g_string_append (s, pango_font_description_get_family (desc));
|
|
||||||
g_string_append (s, "\"; ");
|
|
||||||
}
|
|
||||||
if (set & PANGO_FONT_MASK_STYLE)
|
|
||||||
{
|
|
||||||
switch (pango_font_description_get_style (desc))
|
|
||||||
{
|
|
||||||
case PANGO_STYLE_NORMAL:
|
|
||||||
g_string_append (s, "font-style: normal; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STYLE_OBLIQUE:
|
|
||||||
g_string_append (s, "font-style: oblique; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STYLE_ITALIC:
|
|
||||||
g_string_append (s, "font-style: italic; ");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (set & PANGO_FONT_MASK_VARIANT)
|
|
||||||
{
|
|
||||||
switch (pango_font_description_get_variant (desc))
|
|
||||||
{
|
|
||||||
case PANGO_VARIANT_NORMAL:
|
|
||||||
g_string_append (s, "font-variant: normal; ");
|
|
||||||
break;
|
|
||||||
case PANGO_VARIANT_SMALL_CAPS:
|
|
||||||
g_string_append (s, "font-variant: small-caps; ");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (set & PANGO_FONT_MASK_WEIGHT)
|
|
||||||
{
|
|
||||||
switch (pango_font_description_get_weight (desc))
|
|
||||||
{
|
|
||||||
case PANGO_WEIGHT_THIN:
|
|
||||||
g_string_append (s, "font-weight: 100; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_ULTRALIGHT:
|
|
||||||
g_string_append (s, "font-weight: 200; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_LIGHT:
|
|
||||||
case PANGO_WEIGHT_SEMILIGHT:
|
|
||||||
g_string_append (s, "font-weight: 300; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_BOOK:
|
|
||||||
case PANGO_WEIGHT_NORMAL:
|
|
||||||
g_string_append (s, "font-weight: 400; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_MEDIUM:
|
|
||||||
g_string_append (s, "font-weight: 500; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_SEMIBOLD:
|
|
||||||
g_string_append (s, "font-weight: 600; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_BOLD:
|
|
||||||
g_string_append (s, "font-weight: 700; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_ULTRABOLD:
|
|
||||||
g_string_append (s, "font-weight: 800; ");
|
|
||||||
break;
|
|
||||||
case PANGO_WEIGHT_HEAVY:
|
|
||||||
case PANGO_WEIGHT_ULTRAHEAVY:
|
|
||||||
g_string_append (s, "font-weight: 900; ");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (set & PANGO_FONT_MASK_STRETCH)
|
|
||||||
{
|
|
||||||
switch (pango_font_description_get_stretch (desc))
|
|
||||||
{
|
|
||||||
case PANGO_STRETCH_ULTRA_CONDENSED:
|
|
||||||
g_string_append (s, "font-stretch: ultra-condensed; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_EXTRA_CONDENSED:
|
|
||||||
g_string_append (s, "font-stretch: extra-condensed; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_CONDENSED:
|
|
||||||
g_string_append (s, "font-stretch: condensed; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_SEMI_CONDENSED:
|
|
||||||
g_string_append (s, "font-stretch: semi-condensed; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_NORMAL:
|
|
||||||
g_string_append (s, "font-stretch: normal; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_SEMI_EXPANDED:
|
|
||||||
g_string_append (s, "font-stretch: semi-expanded; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_EXPANDED:
|
|
||||||
g_string_append (s, "font-stretch: expanded; ");
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_EXTRA_EXPANDED:
|
|
||||||
break;
|
|
||||||
case PANGO_STRETCH_ULTRA_EXPANDED:
|
|
||||||
g_string_append (s, "font-stretch: ultra-expanded; ");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (set & PANGO_FONT_MASK_SIZE)
|
|
||||||
{
|
|
||||||
g_string_append_printf (s, "font-size: %dpt; ", pango_font_description_get_size (desc) / PANGO_SCALE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PANGO_VERSION_CHECK (1, 44, 0)
|
|
||||||
if (set & PANGO_FONT_MASK_VARIATIONS)
|
|
||||||
{
|
|
||||||
const char *variations;
|
|
||||||
|
|
||||||
g_string_append (s, "font-variation-settings: ");
|
|
||||||
variations = pango_font_description_get_variations (desc);
|
|
||||||
add_css_variations (s, variations);
|
|
||||||
g_string_append (s, "; ");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return g_string_free (s, FALSE);
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
/* gedit-pango.h
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_PANGO_H
|
|
||||||
#define GEDIT_PANGO_H
|
|
||||||
|
|
||||||
#include <pango/pango.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
gchar *gedit_pango_font_description_to_css (const PangoFontDescription *font_desc);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_PANGO_H */
|
|
|
@ -23,22 +23,14 @@
|
||||||
|
|
||||||
#include "gedit-preferences-dialog.h"
|
#include "gedit-preferences-dialog.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <tepl/tepl.h>
|
||||||
#include <libpeas-gtk/peas-gtk.h>
|
#include <libpeas-gtk/peas-gtk.h>
|
||||||
|
|
||||||
#include "gedit-utils.h"
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-document.h"
|
|
||||||
#include "gedit-dirs.h"
|
#include "gedit-dirs.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
#include "gedit-utils.h"
|
|
||||||
#include "gedit-file-chooser-dialog.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gedit-preferences dialog is a singleton since we don't
|
* gedit-preferences dialog is a singleton since we don't
|
||||||
|
@ -91,11 +83,9 @@ struct _GeditPreferencesDialog
|
||||||
GtkWidget *schemes_list;
|
GtkWidget *schemes_list;
|
||||||
GtkWidget *install_scheme_button;
|
GtkWidget *install_scheme_button;
|
||||||
GtkWidget *uninstall_scheme_button;
|
GtkWidget *uninstall_scheme_button;
|
||||||
GtkWidget *schemes_scrolled_window;
|
|
||||||
GtkWidget *schemes_toolbar;
|
GtkWidget *schemes_toolbar;
|
||||||
|
GtkFileChooserNative *
|
||||||
GeditFileChooserDialog *
|
install_scheme_file_chooser;
|
||||||
install_scheme_file_schooser;
|
|
||||||
|
|
||||||
/* Tabs */
|
/* Tabs */
|
||||||
GtkWidget *tabs_width_spinbutton;
|
GtkWidget *tabs_width_spinbutton;
|
||||||
|
@ -115,7 +105,6 @@ struct _GeditPreferencesDialog
|
||||||
|
|
||||||
GtkWidget *display_line_numbers_checkbutton;
|
GtkWidget *display_line_numbers_checkbutton;
|
||||||
GtkWidget *display_statusbar_checkbutton;
|
GtkWidget *display_statusbar_checkbutton;
|
||||||
GtkWidget *display_overview_map_checkbutton;
|
|
||||||
GtkWidget *display_grid_checkbutton;
|
GtkWidget *display_grid_checkbutton;
|
||||||
|
|
||||||
/* Right margin */
|
/* Right margin */
|
||||||
|
@ -181,7 +170,6 @@ gedit_preferences_dialog_class_init (GeditPreferencesDialogClass *klass)
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_line_numbers_checkbutton);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_line_numbers_checkbutton);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_statusbar_checkbutton);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_statusbar_checkbutton);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_grid_checkbutton);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_grid_checkbutton);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, display_overview_map_checkbutton);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_checkbutton);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_checkbutton);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_position_grid);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_position_grid);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_position_spinbutton);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, right_margin_position_spinbutton);
|
||||||
|
@ -199,7 +187,6 @@ gedit_preferences_dialog_class_init (GeditPreferencesDialogClass *klass)
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, font_button);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, font_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, font_grid);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, font_grid);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, schemes_list);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, schemes_list);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, schemes_scrolled_window);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, install_scheme_button);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, install_scheme_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, uninstall_scheme_button);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, uninstall_scheme_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, schemes_toolbar);
|
gtk_widget_class_bind_template_child (widget_class, GeditPreferencesDialog, schemes_toolbar);
|
||||||
|
@ -399,11 +386,6 @@ setup_view_page (GeditPreferencesDialog *dlg)
|
||||||
dlg->display_statusbar_checkbutton,
|
dlg->display_statusbar_checkbutton,
|
||||||
"active",
|
"active",
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
||||||
g_settings_bind (dlg->editor,
|
|
||||||
GEDIT_SETTINGS_DISPLAY_OVERVIEW_MAP,
|
|
||||||
dlg->display_overview_map_checkbutton,
|
|
||||||
"active",
|
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
|
|
||||||
g_settings_bind (dlg->editor,
|
g_settings_bind (dlg->editor,
|
||||||
GEDIT_SETTINGS_DISPLAY_RIGHT_MARGIN,
|
GEDIT_SETTINGS_DISPLAY_RIGHT_MARGIN,
|
||||||
dlg->right_margin_checkbutton,
|
dlg->right_margin_checkbutton,
|
||||||
|
@ -452,7 +434,7 @@ setup_font_colors_page_font_section (GeditPreferencesDialog *dlg)
|
||||||
|
|
||||||
/* Get values */
|
/* Get values */
|
||||||
settings = _gedit_settings_get_singleton ();
|
settings = _gedit_settings_get_singleton ();
|
||||||
system_font = gedit_settings_get_system_font (settings);
|
system_font = _gedit_settings_get_system_font (settings);
|
||||||
|
|
||||||
label = g_strdup_printf(_("_Use the system fixed width font (%s)"),
|
label = g_strdup_printf(_("_Use the system fixed width font (%s)"),
|
||||||
system_font);
|
system_font);
|
||||||
|
@ -480,255 +462,172 @@ setup_font_colors_page_font_section (GeditPreferencesDialog *dlg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_buttons_sensisitivity_according_to_scheme (GeditPreferencesDialog *dlg,
|
update_style_scheme_buttons_sensisitivity (GeditPreferencesDialog *dlg)
|
||||||
GtkSourceStyleScheme *scheme)
|
|
||||||
{
|
{
|
||||||
|
GtkSourceStyleScheme *selected_style_scheme;
|
||||||
gboolean editable = FALSE;
|
gboolean editable = FALSE;
|
||||||
|
|
||||||
if (scheme != NULL)
|
selected_style_scheme = gtk_source_style_scheme_chooser_get_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list));
|
||||||
|
|
||||||
|
if (selected_style_scheme != NULL)
|
||||||
{
|
{
|
||||||
const gchar *filename;
|
const gchar *filename;
|
||||||
|
|
||||||
filename = gtk_source_style_scheme_get_filename (scheme);
|
filename = gtk_source_style_scheme_get_filename (selected_style_scheme);
|
||||||
if (filename != NULL)
|
if (filename != NULL)
|
||||||
{
|
{
|
||||||
editable = g_str_has_prefix (filename, gedit_dirs_get_user_styles_dir ());
|
editable = g_str_has_prefix (filename, gedit_dirs_get_user_styles_dir ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dlg->uninstall_scheme_button,
|
gtk_widget_set_sensitive (dlg->uninstall_scheme_button, editable);
|
||||||
editable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
style_scheme_changed (GtkSourceStyleSchemeChooser *chooser,
|
style_scheme_notify_cb (GtkSourceStyleSchemeChooser *chooser,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GeditPreferencesDialog *dlg)
|
GeditPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
GtkSourceStyleScheme *scheme;
|
update_style_scheme_buttons_sensisitivity (dlg);
|
||||||
const gchar *id;
|
|
||||||
|
|
||||||
scheme = gtk_source_style_scheme_chooser_get_style_scheme (chooser);
|
|
||||||
id = gtk_source_style_scheme_get_id (scheme);
|
|
||||||
|
|
||||||
g_settings_set_string (dlg->editor, GEDIT_SETTINGS_SCHEME, id);
|
|
||||||
set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkSourceStyleScheme *
|
static GFile *
|
||||||
get_default_color_scheme (GeditPreferencesDialog *dlg)
|
get_user_style_scheme_destination_file (GFile *src_file)
|
||||||
{
|
{
|
||||||
GtkSourceStyleSchemeManager *manager;
|
gchar *basename;
|
||||||
GtkSourceStyleScheme *scheme = NULL;
|
|
||||||
gchar *pref_id;
|
|
||||||
|
|
||||||
manager = gtk_source_style_scheme_manager_get_default ();
|
|
||||||
|
|
||||||
pref_id = g_settings_get_string (dlg->editor,
|
|
||||||
GEDIT_SETTINGS_SCHEME);
|
|
||||||
|
|
||||||
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
|
|
||||||
pref_id);
|
|
||||||
g_free (pref_id);
|
|
||||||
|
|
||||||
if (scheme == NULL)
|
|
||||||
{
|
|
||||||
/* Fall-back to classic style scheme */
|
|
||||||
scheme = gtk_source_style_scheme_manager_get_scheme (manager,
|
|
||||||
"classic");
|
|
||||||
}
|
|
||||||
|
|
||||||
return scheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* file_copy:
|
|
||||||
* @name: a pointer to a %NULL-terminated string, that names
|
|
||||||
* the file to be copied, in the GLib file name encoding
|
|
||||||
* @dest_name: a pointer to a %NULL-terminated string, that is the
|
|
||||||
* name for the destination file, in the GLib file name encoding
|
|
||||||
* @error: return location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Copies file @name to @dest_name.
|
|
||||||
*
|
|
||||||
* If the call was successful, it returns %TRUE. If the call was not
|
|
||||||
* successful, it returns %FALSE and sets @error. The error domain
|
|
||||||
* is #G_FILE_ERROR. Possible error
|
|
||||||
* codes are those in the #GFileError enumeration.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE on success, %FALSE otherwise.
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
file_copy (const gchar *name,
|
|
||||||
const gchar *dest_name,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gchar *contents;
|
|
||||||
gsize length;
|
|
||||||
gchar *dest_dir;
|
|
||||||
|
|
||||||
/* FIXME - Paolo (Aug. 13, 2007):
|
|
||||||
* Since the style scheme files are relatively small, we can implement
|
|
||||||
* file copy getting all the content of the source file in a buffer and
|
|
||||||
* then write the content to the destination file. In this way we
|
|
||||||
* can use the g_file_get_contents and g_file_set_contents and avoid to
|
|
||||||
* write custom code to copy the file (with sane error management).
|
|
||||||
* If needed we can improve this code later. */
|
|
||||||
|
|
||||||
g_return_val_if_fail (name != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (dest_name != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
||||||
|
|
||||||
/* Note: we allow to copy a file to itself since this is not a problem
|
|
||||||
* in our use case */
|
|
||||||
|
|
||||||
/* Ensure the destination directory exists */
|
|
||||||
dest_dir = g_path_get_dirname (dest_name);
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
if (g_mkdir_with_parents (dest_dir, 0755) != 0)
|
|
||||||
{
|
|
||||||
gint save_errno = errno;
|
|
||||||
gchar *display_filename = g_filename_display_name (dest_dir);
|
|
||||||
|
|
||||||
g_set_error (error,
|
|
||||||
G_FILE_ERROR,
|
|
||||||
g_file_error_from_errno (save_errno),
|
|
||||||
_("Directory “%s” could not be created: g_mkdir_with_parents() failed: %s"),
|
|
||||||
display_filename,
|
|
||||||
g_strerror (save_errno));
|
|
||||||
|
|
||||||
g_free (dest_dir);
|
|
||||||
g_free (display_filename);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (dest_dir);
|
|
||||||
|
|
||||||
if (!g_file_get_contents (name, &contents, &length, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!g_file_set_contents (dest_name, contents, length, error))
|
|
||||||
{
|
|
||||||
g_free (contents);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (contents);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* install_style_scheme:
|
|
||||||
* @manager: a #GtkSourceStyleSchemeManager
|
|
||||||
* @fname: the file name of the style scheme to be installed
|
|
||||||
*
|
|
||||||
* Install a new user scheme.
|
|
||||||
* This function copies @fname in #GEDIT_STYLES_DIR and ask the style manager to
|
|
||||||
* recompute the list of available style schemes. It then checks if a style
|
|
||||||
* scheme with the right file name exists.
|
|
||||||
*
|
|
||||||
* If the call was succesful, it returns the id of the installed scheme
|
|
||||||
* otherwise %NULL.
|
|
||||||
*
|
|
||||||
* Return value: the id of the installed scheme, %NULL otherwise.
|
|
||||||
*/
|
|
||||||
static GtkSourceStyleScheme *
|
|
||||||
install_style_scheme (const gchar *fname)
|
|
||||||
{
|
|
||||||
GtkSourceStyleSchemeManager *manager;
|
|
||||||
gchar *new_file_name = NULL;
|
|
||||||
gchar *dirname;
|
|
||||||
const gchar *styles_dir;
|
const gchar *styles_dir;
|
||||||
GError *error = NULL;
|
GFile *dest_file;
|
||||||
gboolean copied = FALSE;
|
|
||||||
const gchar * const *ids;
|
|
||||||
|
|
||||||
g_return_val_if_fail (fname != NULL, NULL);
|
basename = g_file_get_basename (src_file);
|
||||||
|
g_return_val_if_fail (basename != NULL, NULL);
|
||||||
|
|
||||||
|
styles_dir = gedit_dirs_get_user_styles_dir ();
|
||||||
|
dest_file = g_file_new_build_filename (styles_dir, basename, NULL);
|
||||||
|
|
||||||
|
g_free (basename);
|
||||||
|
return dest_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns: whether @src_file has been correctly copied to @dest_file. */
|
||||||
|
static gboolean
|
||||||
|
copy_file (GFile *src_file,
|
||||||
|
GFile *dest_file,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_file_equal (src_file, dest_file))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tepl_utils_create_parent_directories (dest_file, NULL, error))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_file_copy (src_file,
|
||||||
|
dest_file,
|
||||||
|
G_FILE_COPY_OVERWRITE | G_FILE_COPY_TARGET_DEFAULT_PERMS,
|
||||||
|
NULL, /* cancellable */
|
||||||
|
NULL, NULL, /* progress callback */
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the style scheme ID of @user_style_scheme_file if it has been correctly
|
||||||
|
* installed and @user_style_scheme_file is a valid style scheme file.
|
||||||
|
*/
|
||||||
|
static const gchar *
|
||||||
|
get_style_scheme_id_after_installing_user_style_scheme (GFile *user_style_scheme_file)
|
||||||
|
{
|
||||||
|
GtkSourceStyleSchemeManager *manager;
|
||||||
|
const gchar * const *scheme_ids;
|
||||||
|
gint i;
|
||||||
|
|
||||||
manager = gtk_source_style_scheme_manager_get_default ();
|
manager = gtk_source_style_scheme_manager_get_default ();
|
||||||
|
|
||||||
dirname = g_path_get_dirname (fname);
|
|
||||||
styles_dir = gedit_dirs_get_user_styles_dir ();
|
|
||||||
|
|
||||||
if (strcmp (dirname, styles_dir) != 0)
|
|
||||||
{
|
|
||||||
gchar *basename;
|
|
||||||
|
|
||||||
basename = g_path_get_basename (fname);
|
|
||||||
new_file_name = g_build_filename (styles_dir, basename, NULL);
|
|
||||||
g_free (basename);
|
|
||||||
|
|
||||||
/* Copy the style scheme file into GEDIT_STYLES_DIR */
|
|
||||||
if (!file_copy (fname, new_file_name, &error))
|
|
||||||
{
|
|
||||||
g_free (new_file_name);
|
|
||||||
g_free (dirname);
|
|
||||||
|
|
||||||
g_message ("Cannot install style scheme:\n%s",
|
|
||||||
error->message);
|
|
||||||
|
|
||||||
g_error_free (error);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
copied = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
new_file_name = g_strdup (fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (dirname);
|
|
||||||
|
|
||||||
/* Reload the available style schemes */
|
|
||||||
gtk_source_style_scheme_manager_force_rescan (manager);
|
gtk_source_style_scheme_manager_force_rescan (manager);
|
||||||
|
|
||||||
/* Check the new style scheme has been actually installed */
|
scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
|
||||||
ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
|
|
||||||
|
|
||||||
while (*ids != NULL)
|
for (i = 0; scheme_ids != NULL && scheme_ids[i] != NULL; i++)
|
||||||
{
|
{
|
||||||
|
const gchar *cur_scheme_id = scheme_ids[i];
|
||||||
GtkSourceStyleScheme *scheme;
|
GtkSourceStyleScheme *scheme;
|
||||||
const gchar *filename;
|
const gchar *filename;
|
||||||
|
GFile *scheme_file;
|
||||||
|
|
||||||
scheme = gtk_source_style_scheme_manager_get_scheme (manager, *ids);
|
scheme = gtk_source_style_scheme_manager_get_scheme (manager, cur_scheme_id);
|
||||||
|
|
||||||
filename = gtk_source_style_scheme_get_filename (scheme);
|
filename = gtk_source_style_scheme_get_filename (scheme);
|
||||||
|
if (filename == NULL)
|
||||||
if (filename && (strcmp (filename, new_file_name) == 0))
|
|
||||||
{
|
{
|
||||||
/* The style scheme has been correctly installed */
|
continue;
|
||||||
g_free (new_file_name);
|
|
||||||
|
|
||||||
return scheme;
|
|
||||||
}
|
}
|
||||||
++ids;
|
|
||||||
|
scheme_file = g_file_new_for_path (filename);
|
||||||
|
if (g_file_equal (scheme_file, user_style_scheme_file))
|
||||||
|
{
|
||||||
|
g_object_unref (scheme_file);
|
||||||
|
return cur_scheme_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (scheme_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The style scheme has not been correctly installed */
|
|
||||||
if (copied)
|
|
||||||
g_unlink (new_file_name);
|
|
||||||
|
|
||||||
g_free (new_file_name);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* Returns: (nullable): the installed style scheme ID, or %NULL on failure. */
|
||||||
|
static const gchar *
|
||||||
|
install_style_scheme (GFile *src_file,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GFile *dest_file;
|
||||||
|
gboolean copied;
|
||||||
|
const gchar *installed_style_scheme_id = NULL;
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_FILE (src_file), NULL);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
|
dest_file = get_user_style_scheme_destination_file (src_file);
|
||||||
|
g_return_val_if_fail (dest_file != NULL, NULL);
|
||||||
|
|
||||||
|
copied = copy_file (src_file, dest_file, &my_error);
|
||||||
|
if (my_error != NULL)
|
||||||
|
{
|
||||||
|
g_propagate_error (error, my_error);
|
||||||
|
g_object_unref (dest_file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
installed_style_scheme_id = get_style_scheme_id_after_installing_user_style_scheme (dest_file);
|
||||||
|
|
||||||
|
if (installed_style_scheme_id == NULL && copied)
|
||||||
|
{
|
||||||
|
/* The style scheme has not been correctly installed. */
|
||||||
|
g_file_delete (dest_file, NULL, &my_error);
|
||||||
|
if (my_error != NULL)
|
||||||
|
{
|
||||||
|
gchar *dest_file_parse_name = g_file_get_parse_name (dest_file);
|
||||||
|
|
||||||
|
g_warning ("Failed to delete the file “%s”: %s",
|
||||||
|
dest_file_parse_name,
|
||||||
|
my_error->message);
|
||||||
|
|
||||||
|
g_free (dest_file_parse_name);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (dest_file);
|
||||||
|
return installed_style_scheme_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
* uninstall_style_scheme:
|
* uninstall_style_scheme:
|
||||||
* @manager: a #GtkSourceStyleSchemeManager
|
|
||||||
* @scheme: a #GtkSourceStyleScheme
|
* @scheme: a #GtkSourceStyleScheme
|
||||||
*
|
*
|
||||||
* Uninstall a user scheme.
|
* Uninstall a user scheme.
|
||||||
*
|
*
|
||||||
* If the call was succesful, it returns %TRUE
|
* Returns: %TRUE on success, %FALSE otherwise.
|
||||||
* otherwise %FALSE.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE on success, %FALSE otherwise.
|
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
uninstall_style_scheme (GtkSourceStyleScheme *scheme)
|
uninstall_style_scheme (GtkSourceStyleScheme *scheme)
|
||||||
|
@ -754,92 +653,94 @@ uninstall_style_scheme (GtkSourceStyleScheme *scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_scheme_chooser_response_cb (GeditFileChooserDialog *chooser,
|
add_scheme_chooser_response_cb (GtkFileChooserNative *chooser,
|
||||||
gint res_id,
|
gint response_id,
|
||||||
GeditPreferencesDialog *dlg)
|
GeditPreferencesDialog *dialog)
|
||||||
{
|
{
|
||||||
GFile *file;
|
GFile *file;
|
||||||
gchar *filename;
|
const gchar *scheme_id;
|
||||||
GtkSourceStyleScheme *scheme;
|
GeditSettings *settings;
|
||||||
|
GSettings *editor_settings;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (res_id != GTK_RESPONSE_ACCEPT)
|
if (response_id != GTK_RESPONSE_ACCEPT)
|
||||||
{
|
{
|
||||||
gedit_file_chooser_dialog_hide (chooser);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = gedit_file_chooser_dialog_get_file (chooser);
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (chooser));
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = g_file_get_path (file);
|
scheme_id = install_style_scheme (file, &error);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
if (filename == NULL)
|
if (scheme_id == NULL)
|
||||||
{
|
{
|
||||||
|
if (error != NULL)
|
||||||
|
{
|
||||||
|
tepl_utils_show_warning_dialog (GTK_WINDOW (dialog),
|
||||||
|
_("The selected color scheme cannot be installed: %s"),
|
||||||
|
error->message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tepl_utils_show_warning_dialog (GTK_WINDOW (dialog),
|
||||||
|
_("The selected color scheme cannot be installed."));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gedit_file_chooser_dialog_hide (chooser);
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
scheme = install_style_scheme (filename);
|
g_settings_set_string (editor_settings, GEDIT_SETTINGS_SCHEME, scheme_id);
|
||||||
g_free (filename);
|
|
||||||
|
|
||||||
if (scheme == NULL)
|
|
||||||
{
|
|
||||||
gedit_warning (GTK_WINDOW (dlg),
|
|
||||||
_("The selected color scheme cannot be installed."));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_settings_set_string (dlg->editor, GEDIT_SETTINGS_SCHEME,
|
|
||||||
gtk_source_style_scheme_get_id (scheme));
|
|
||||||
|
|
||||||
set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
install_scheme_clicked (GtkButton *button,
|
install_scheme_clicked (GtkButton *button,
|
||||||
GeditPreferencesDialog *dlg)
|
GeditPreferencesDialog *dialog)
|
||||||
{
|
{
|
||||||
GeditFileChooserDialog *chooser;
|
GtkFileChooserNative *chooser;
|
||||||
|
GtkFileFilter *scheme_filter;
|
||||||
|
GtkFileFilter *all_filter;
|
||||||
|
|
||||||
if (dlg->install_scheme_file_schooser != NULL)
|
if (dialog->install_scheme_file_chooser != NULL)
|
||||||
{
|
{
|
||||||
gedit_file_chooser_dialog_show (dlg->install_scheme_file_schooser);
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog->install_scheme_file_chooser));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chooser = gedit_file_chooser_dialog_create (_("Add Scheme"),
|
chooser = gtk_file_chooser_native_new (_("Add Color Scheme"),
|
||||||
GTK_WINDOW (dlg),
|
GTK_WINDOW (dialog),
|
||||||
GEDIT_FILE_CHOOSER_FLAG_OPEN,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
_("A_dd Scheme"),
|
_("_Add Scheme"),
|
||||||
_("_Cancel"));
|
_("_Cancel"));
|
||||||
|
|
||||||
/* Filters */
|
/* Filters */
|
||||||
gedit_file_chooser_dialog_add_pattern_filter (chooser,
|
scheme_filter = gtk_file_filter_new ();
|
||||||
_("Color Scheme Files"),
|
gtk_file_filter_set_name (scheme_filter, _("Color Scheme Files"));
|
||||||
"*.xml");
|
gtk_file_filter_add_pattern (scheme_filter, "*.xml");
|
||||||
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), scheme_filter);
|
||||||
|
|
||||||
gedit_file_chooser_dialog_add_pattern_filter (chooser,
|
all_filter = gtk_file_filter_new ();
|
||||||
_("All Files"),
|
gtk_file_filter_set_name (all_filter, _("All Files"));
|
||||||
"*");
|
gtk_file_filter_add_pattern (all_filter, "*");
|
||||||
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), all_filter);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), scheme_filter);
|
||||||
|
|
||||||
g_signal_connect (chooser,
|
g_signal_connect (chooser,
|
||||||
"response",
|
"response",
|
||||||
G_CALLBACK (add_scheme_chooser_response_cb),
|
G_CALLBACK (add_scheme_chooser_response_cb),
|
||||||
dlg);
|
dialog);
|
||||||
|
|
||||||
dlg->install_scheme_file_schooser = chooser;
|
g_set_weak_pointer (&dialog->install_scheme_file_chooser, chooser);
|
||||||
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (chooser),
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
|
||||||
(gpointer) &dlg->install_scheme_file_schooser);
|
|
||||||
|
|
||||||
gedit_file_chooser_dialog_show (chooser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -847,14 +748,33 @@ uninstall_scheme_clicked (GtkButton *button,
|
||||||
GeditPreferencesDialog *dlg)
|
GeditPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
GtkSourceStyleScheme *scheme;
|
GtkSourceStyleScheme *scheme;
|
||||||
|
GtkSourceStyleScheme *new_selected_scheme;
|
||||||
|
|
||||||
scheme = gtk_source_style_scheme_chooser_get_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list));
|
scheme = gtk_source_style_scheme_chooser_get_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list));
|
||||||
|
|
||||||
|
if (scheme == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!uninstall_style_scheme (scheme))
|
if (!uninstall_style_scheme (scheme))
|
||||||
{
|
{
|
||||||
gedit_warning (GTK_WINDOW (dlg),
|
tepl_utils_show_warning_dialog (GTK_WINDOW (dlg),
|
||||||
_("Could not remove color scheme “%s”."),
|
_("Could not remove color scheme “%s”."),
|
||||||
gtk_source_style_scheme_get_name (scheme));
|
gtk_source_style_scheme_get_name (scheme));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_selected_scheme = gtk_source_style_scheme_chooser_get_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list));
|
||||||
|
if (new_selected_scheme == NULL)
|
||||||
|
{
|
||||||
|
GeditSettings *settings;
|
||||||
|
GSettings *editor_settings;
|
||||||
|
|
||||||
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
|
|
||||||
|
g_settings_reset (editor_settings, GEDIT_SETTINGS_SCHEME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,14 +782,13 @@ static void
|
||||||
setup_font_colors_page_style_scheme_section (GeditPreferencesDialog *dlg)
|
setup_font_colors_page_style_scheme_section (GeditPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkSourceStyleScheme *scheme;
|
GeditSettings *settings;
|
||||||
|
GSettings *editor_settings;
|
||||||
|
|
||||||
gedit_debug (DEBUG_PREFS);
|
gedit_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
scheme = get_default_color_scheme (dlg);
|
/* junction between the schemes list and the toolbar */
|
||||||
|
context = gtk_widget_get_style_context (dlg->schemes_list);
|
||||||
/* junction between the scrolled window and the toolbar */
|
|
||||||
context = gtk_widget_get_style_context (dlg->schemes_scrolled_window);
|
|
||||||
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
|
||||||
context = gtk_widget_get_style_context (dlg->schemes_toolbar);
|
context = gtk_widget_get_style_context (dlg->schemes_toolbar);
|
||||||
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
|
||||||
|
@ -877,7 +796,7 @@ setup_font_colors_page_style_scheme_section (GeditPreferencesDialog *dlg)
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
g_signal_connect (dlg->schemes_list,
|
g_signal_connect (dlg->schemes_list,
|
||||||
"notify::style-scheme",
|
"notify::style-scheme",
|
||||||
G_CALLBACK (style_scheme_changed),
|
G_CALLBACK (style_scheme_notify_cb),
|
||||||
dlg);
|
dlg);
|
||||||
g_signal_connect (dlg->install_scheme_button,
|
g_signal_connect (dlg->install_scheme_button,
|
||||||
"clicked",
|
"clicked",
|
||||||
|
@ -888,11 +807,13 @@ setup_font_colors_page_style_scheme_section (GeditPreferencesDialog *dlg)
|
||||||
G_CALLBACK (uninstall_scheme_clicked),
|
G_CALLBACK (uninstall_scheme_clicked),
|
||||||
dlg);
|
dlg);
|
||||||
|
|
||||||
gtk_source_style_scheme_chooser_set_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list),
|
settings = _gedit_settings_get_singleton ();
|
||||||
scheme);
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
|
g_settings_bind (editor_settings, GEDIT_SETTINGS_SCHEME,
|
||||||
|
dlg->schemes_list, "tepl-style-scheme-id",
|
||||||
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
|
|
||||||
/* Set initial widget sensitivity */
|
update_style_scheme_buttons_sensisitivity (dlg);
|
||||||
set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "gedit-print-job.h"
|
#include "gedit-print-job.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-document-private.h"
|
#include "gedit-document-private.h"
|
||||||
|
@ -535,7 +535,7 @@ create_compositor (GeditPrintJob *job)
|
||||||
gchar *left;
|
gchar *left;
|
||||||
|
|
||||||
doc_name = _gedit_document_get_uri_for_display (GEDIT_DOCUMENT (buf));
|
doc_name = _gedit_document_get_uri_for_display (GEDIT_DOCUMENT (buf));
|
||||||
name_to_display = gedit_utils_str_middle_truncate (doc_name, 60);
|
name_to_display = tepl_utils_str_middle_truncate (doc_name, 60);
|
||||||
|
|
||||||
left = g_strdup_printf (_("File: %s"), name_to_display);
|
left = g_strdup_printf (_("File: %s"), name_to_display);
|
||||||
|
|
||||||
|
|
|
@ -1,177 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-progress-info-bar.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-progress-info-bar.h"
|
|
||||||
#include <glib/gi18n.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PROP_0,
|
|
||||||
PROP_HAS_CANCEL_BUTTON,
|
|
||||||
LAST_PROP
|
|
||||||
};
|
|
||||||
|
|
||||||
static GParamSpec *properties[LAST_PROP];
|
|
||||||
|
|
||||||
struct _GeditProgressInfoBar
|
|
||||||
{
|
|
||||||
GtkInfoBar parent_instance;
|
|
||||||
|
|
||||||
GtkWidget *image;
|
|
||||||
GtkWidget *label;
|
|
||||||
GtkWidget *progress;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditProgressInfoBar, gedit_progress_info_bar, GTK_TYPE_INFO_BAR)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_progress_info_bar_set_has_cancel_button (GeditProgressInfoBar *bar,
|
|
||||||
gboolean has_button)
|
|
||||||
{
|
|
||||||
if (has_button)
|
|
||||||
{
|
|
||||||
gtk_info_bar_add_button (GTK_INFO_BAR (bar), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_progress_info_bar_set_property (GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeditProgressInfoBar *bar;
|
|
||||||
|
|
||||||
bar = GEDIT_PROGRESS_INFO_BAR (object);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
|
||||||
case PROP_HAS_CANCEL_BUTTON:
|
|
||||||
gedit_progress_info_bar_set_has_cancel_button (bar,
|
|
||||||
g_value_get_boolean (value));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_progress_info_bar_class_init (GeditProgressInfoBarClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->set_property = gedit_progress_info_bar_set_property;
|
|
||||||
|
|
||||||
properties[PROP_HAS_CANCEL_BUTTON] =
|
|
||||||
g_param_spec_boolean ("has-cancel-button",
|
|
||||||
"Has Cancel Button",
|
|
||||||
"If the message bar has a cancel button",
|
|
||||||
TRUE,
|
|
||||||
G_PARAM_WRITABLE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
|
||||||
G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
g_object_class_install_properties (gobject_class, LAST_PROP, properties);
|
|
||||||
|
|
||||||
/* Bind class to template */
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
|
||||||
"/org/gnome/gedit/ui/gedit-progress-info-bar.ui");
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditProgressInfoBar, image);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditProgressInfoBar, label);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditProgressInfoBar, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_progress_info_bar_init (GeditProgressInfoBar *bar)
|
|
||||||
{
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (bar));
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gedit_progress_info_bar_new (const gchar *icon_name,
|
|
||||||
const gchar *markup,
|
|
||||||
gboolean has_cancel)
|
|
||||||
{
|
|
||||||
GeditProgressInfoBar *bar;
|
|
||||||
|
|
||||||
g_return_val_if_fail (icon_name != NULL, NULL);
|
|
||||||
g_return_val_if_fail (markup != NULL, NULL);
|
|
||||||
|
|
||||||
bar = GEDIT_PROGRESS_INFO_BAR (g_object_new (GEDIT_TYPE_PROGRESS_INFO_BAR,
|
|
||||||
"has-cancel-button", has_cancel,
|
|
||||||
NULL));
|
|
||||||
|
|
||||||
gedit_progress_info_bar_set_icon_name (bar, icon_name);
|
|
||||||
gedit_progress_info_bar_set_markup (bar, markup);
|
|
||||||
|
|
||||||
return GTK_WIDGET (bar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_progress_info_bar_set_icon_name (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *icon_name)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (bar));
|
|
||||||
g_return_if_fail (icon_name != NULL);
|
|
||||||
|
|
||||||
gtk_image_set_from_icon_name (GTK_IMAGE (bar->image),
|
|
||||||
icon_name,
|
|
||||||
GTK_ICON_SIZE_SMALL_TOOLBAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_progress_info_bar_set_markup (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *markup)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (bar));
|
|
||||||
g_return_if_fail (markup != NULL);
|
|
||||||
|
|
||||||
gtk_label_set_markup (GTK_LABEL (bar->label), markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_progress_info_bar_set_text (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *text)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (bar));
|
|
||||||
g_return_if_fail (text != NULL);
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (bar->label), text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_progress_info_bar_set_fraction (GeditProgressInfoBar *bar,
|
|
||||||
gdouble fraction)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (bar));
|
|
||||||
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar->progress), fraction);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_progress_info_bar_pulse (GeditProgressInfoBar *bar)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (bar));
|
|
||||||
|
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (bar->progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-progress-info-bar.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_PROGRESS_INFO_BAR_H
|
|
||||||
#define GEDIT_PROGRESS_INFO_BAR_H
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_PROGRESS_INFO_BAR (gedit_progress_info_bar_get_type ())
|
|
||||||
G_DECLARE_FINAL_TYPE (GeditProgressInfoBar, gedit_progress_info_bar, GEDIT, PROGRESS_INFO_BAR, GtkInfoBar)
|
|
||||||
|
|
||||||
GtkWidget *gedit_progress_info_bar_new (const gchar *icon_name,
|
|
||||||
const gchar *markup,
|
|
||||||
gboolean has_cancel);
|
|
||||||
|
|
||||||
void gedit_progress_info_bar_set_icon_name (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *icon_name);
|
|
||||||
|
|
||||||
void gedit_progress_info_bar_set_markup (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *markup);
|
|
||||||
|
|
||||||
void gedit_progress_info_bar_set_text (GeditProgressInfoBar *bar,
|
|
||||||
const gchar *text);
|
|
||||||
|
|
||||||
void gedit_progress_info_bar_set_fraction (GeditProgressInfoBar *bar,
|
|
||||||
gdouble fraction);
|
|
||||||
|
|
||||||
void gedit_progress_info_bar_pulse (GeditProgressInfoBar *bar);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_PROGRESS_INFO_BAR_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
249
gedit/gedit-recent-osx.c
Normal file
249
gedit/gedit-recent-osx.c
Normal file
|
@ -0,0 +1,249 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
|
* Copyright (C) 2014 - Paolo Borelli
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-recent-osx.h"
|
||||||
|
|
||||||
|
static gint
|
||||||
|
sort_recent_items_mru (GtkRecentInfo *a,
|
||||||
|
GtkRecentInfo *b,
|
||||||
|
gpointer unused)
|
||||||
|
{
|
||||||
|
g_assert (a != NULL && b != NULL);
|
||||||
|
return gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
populate_filter_info (GtkRecentInfo *info,
|
||||||
|
GtkRecentFilterInfo *filter_info,
|
||||||
|
GtkRecentFilterFlags needed)
|
||||||
|
{
|
||||||
|
filter_info->uri = gtk_recent_info_get_uri (info);
|
||||||
|
filter_info->mime_type = gtk_recent_info_get_mime_type (info);
|
||||||
|
|
||||||
|
filter_info->contains = GTK_RECENT_FILTER_URI | GTK_RECENT_FILTER_MIME_TYPE;
|
||||||
|
|
||||||
|
if (needed & GTK_RECENT_FILTER_DISPLAY_NAME)
|
||||||
|
{
|
||||||
|
filter_info->display_name = gtk_recent_info_get_display_name (info);
|
||||||
|
filter_info->contains |= GTK_RECENT_FILTER_DISPLAY_NAME;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_info->uri = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needed & GTK_RECENT_FILTER_APPLICATION)
|
||||||
|
{
|
||||||
|
filter_info->applications = (const gchar **) gtk_recent_info_get_applications (info, NULL);
|
||||||
|
filter_info->contains |= GTK_RECENT_FILTER_APPLICATION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_info->applications = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needed & GTK_RECENT_FILTER_GROUP)
|
||||||
|
{
|
||||||
|
filter_info->groups = (const gchar **) gtk_recent_info_get_groups (info, NULL);
|
||||||
|
filter_info->contains |= GTK_RECENT_FILTER_GROUP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_info->groups = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needed & GTK_RECENT_FILTER_AGE)
|
||||||
|
{
|
||||||
|
filter_info->age = gtk_recent_info_get_age (info);
|
||||||
|
filter_info->contains |= GTK_RECENT_FILTER_AGE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_info->age = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The GeditRecentConfiguration struct is allocated and owned by the caller */
|
||||||
|
void
|
||||||
|
gedit_recent_configuration_init_default (GeditRecentConfiguration *config)
|
||||||
|
{
|
||||||
|
config->manager = gtk_recent_manager_get_default ();
|
||||||
|
|
||||||
|
if (config->filter != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (config->filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
config->filter = gtk_recent_filter_new ();
|
||||||
|
gtk_recent_filter_add_application (config->filter, g_get_application_name ());
|
||||||
|
gtk_recent_filter_add_mime_type (config->filter, "text/plain");
|
||||||
|
g_object_ref_sink (config->filter);
|
||||||
|
|
||||||
|
config->limit = 5;
|
||||||
|
config->show_not_found = TRUE;
|
||||||
|
config->show_private = FALSE;
|
||||||
|
config->local_only = FALSE;
|
||||||
|
|
||||||
|
config->substring_filter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The GeditRecentConfiguration struct is owned and destroyed by the caller */
|
||||||
|
void
|
||||||
|
gedit_recent_configuration_destroy (GeditRecentConfiguration *config)
|
||||||
|
{
|
||||||
|
g_clear_object (&config->filter);
|
||||||
|
config->manager = NULL;
|
||||||
|
|
||||||
|
g_clear_pointer (&config->substring_filter, (GDestroyNotify)g_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
GList *
|
||||||
|
gedit_recent_get_items (GeditRecentConfiguration *config)
|
||||||
|
{
|
||||||
|
GtkRecentFilterFlags needed;
|
||||||
|
GList *items;
|
||||||
|
GList *retitems = NULL;
|
||||||
|
gint length;
|
||||||
|
char *substring_filter = NULL;
|
||||||
|
|
||||||
|
if (config->limit == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
items = gtk_recent_manager_get_items (config->manager);
|
||||||
|
|
||||||
|
if (!items)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
needed = gtk_recent_filter_get_needed (config->filter);
|
||||||
|
if (config->substring_filter && *config->substring_filter != '\0')
|
||||||
|
{
|
||||||
|
gchar *filter_normalized;
|
||||||
|
|
||||||
|
filter_normalized = g_utf8_normalize (config->substring_filter, -1, G_NORMALIZE_ALL);
|
||||||
|
substring_filter = g_utf8_casefold (filter_normalized, -1);
|
||||||
|
g_free (filter_normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (items)
|
||||||
|
{
|
||||||
|
GtkRecentInfo *info;
|
||||||
|
GtkRecentFilterInfo filter_info;
|
||||||
|
gboolean is_filtered;
|
||||||
|
|
||||||
|
info = items->data;
|
||||||
|
is_filtered = FALSE;
|
||||||
|
|
||||||
|
if (config->local_only && !gtk_recent_info_is_local (info))
|
||||||
|
{
|
||||||
|
is_filtered = TRUE;
|
||||||
|
}
|
||||||
|
else if (!config->show_private && gtk_recent_info_get_private_hint (info))
|
||||||
|
{
|
||||||
|
is_filtered = TRUE;
|
||||||
|
}
|
||||||
|
else if (!config->show_not_found && !gtk_recent_info_exists (info))
|
||||||
|
{
|
||||||
|
is_filtered = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (substring_filter)
|
||||||
|
{
|
||||||
|
gchar *uri_normalized;
|
||||||
|
gchar *uri_casefolded;
|
||||||
|
|
||||||
|
uri_normalized = g_utf8_normalize (gtk_recent_info_get_uri_display (info), -1, G_NORMALIZE_ALL);
|
||||||
|
uri_casefolded = g_utf8_casefold (uri_normalized, -1);
|
||||||
|
g_free (uri_normalized);
|
||||||
|
|
||||||
|
if (strstr (uri_casefolded, substring_filter) == NULL)
|
||||||
|
{
|
||||||
|
is_filtered = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (uri_casefolded);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_filtered)
|
||||||
|
{
|
||||||
|
populate_filter_info (info, &filter_info, needed);
|
||||||
|
is_filtered = !gtk_recent_filter_filter (config->filter, &filter_info);
|
||||||
|
|
||||||
|
/* these we own */
|
||||||
|
if (filter_info.applications)
|
||||||
|
{
|
||||||
|
g_strfreev ((gchar **) filter_info.applications);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter_info.groups)
|
||||||
|
{
|
||||||
|
g_strfreev ((gchar **) filter_info.groups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_filtered)
|
||||||
|
{
|
||||||
|
retitems = g_list_prepend (retitems, info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_recent_info_unref (info);
|
||||||
|
}
|
||||||
|
|
||||||
|
items = g_list_delete_link (items, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (substring_filter);
|
||||||
|
|
||||||
|
if (!retitems)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
retitems = g_list_sort_with_data (retitems, (GCompareDataFunc) sort_recent_items_mru, NULL);
|
||||||
|
length = g_list_length (retitems);
|
||||||
|
|
||||||
|
if ((config->limit != -1) && (length > config->limit))
|
||||||
|
{
|
||||||
|
GList *clamp, *l;
|
||||||
|
|
||||||
|
clamp = g_list_nth (retitems, config->limit - 1);
|
||||||
|
|
||||||
|
if (!clamp)
|
||||||
|
{
|
||||||
|
return retitems;
|
||||||
|
}
|
||||||
|
|
||||||
|
l = clamp->next;
|
||||||
|
clamp->next = NULL;
|
||||||
|
|
||||||
|
g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retitems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
54
gedit/gedit-recent-osx.h
Normal file
54
gedit/gedit-recent-osx.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
|
* Copyright (C) 2014 - Paolo Borelli
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* MERCHANWINDOWILITY 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_RECENT_OSX_H
|
||||||
|
#define GEDIT_RECENT_OSX_H
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* TODO: this code can be simplified, the struct can be made private, the dead
|
||||||
|
* code can be removed, etc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GtkRecentManager *manager;
|
||||||
|
GtkRecentFilter *filter;
|
||||||
|
|
||||||
|
gint limit;
|
||||||
|
gchar *substring_filter;
|
||||||
|
|
||||||
|
guint show_private : 1;
|
||||||
|
guint show_not_found : 1;
|
||||||
|
guint local_only : 1;
|
||||||
|
} GeditRecentConfiguration;
|
||||||
|
|
||||||
|
void gedit_recent_configuration_init_default (GeditRecentConfiguration *config);
|
||||||
|
void gedit_recent_configuration_destroy (GeditRecentConfiguration *config);
|
||||||
|
GList *gedit_recent_get_items (GeditRecentConfiguration *config);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_RECENT_OSX_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
|
@ -24,7 +24,7 @@
|
||||||
void
|
void
|
||||||
gedit_recent_add_document (GeditDocument *document)
|
gedit_recent_add_document (GeditDocument *document)
|
||||||
{
|
{
|
||||||
GtkSourceFile *file;
|
TeplFile *file;
|
||||||
GFile *location;
|
GFile *location;
|
||||||
GtkRecentManager *recent_manager;
|
GtkRecentManager *recent_manager;
|
||||||
GtkRecentData recent_data;
|
GtkRecentData recent_data;
|
||||||
|
@ -33,8 +33,8 @@ gedit_recent_add_document (GeditDocument *document)
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_DOCUMENT (document));
|
g_return_if_fail (GEDIT_IS_DOCUMENT (document));
|
||||||
|
|
||||||
file = gedit_document_get_file (document);
|
file = tepl_buffer_get_file (TEPL_BUFFER (document));
|
||||||
location = gtk_source_file_get_location (file);
|
location = tepl_file_get_location (file);
|
||||||
|
|
||||||
if (location == NULL)
|
if (location == NULL)
|
||||||
{
|
{
|
||||||
|
@ -89,229 +89,4 @@ gedit_recent_remove_if_local (GFile *location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
|
||||||
sort_recent_items_mru (GtkRecentInfo *a,
|
|
||||||
GtkRecentInfo *b,
|
|
||||||
gpointer unused)
|
|
||||||
{
|
|
||||||
g_assert (a != NULL && b != NULL);
|
|
||||||
return gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
populate_filter_info (GtkRecentInfo *info,
|
|
||||||
GtkRecentFilterInfo *filter_info,
|
|
||||||
GtkRecentFilterFlags needed)
|
|
||||||
{
|
|
||||||
filter_info->uri = gtk_recent_info_get_uri (info);
|
|
||||||
filter_info->mime_type = gtk_recent_info_get_mime_type (info);
|
|
||||||
|
|
||||||
filter_info->contains = GTK_RECENT_FILTER_URI | GTK_RECENT_FILTER_MIME_TYPE;
|
|
||||||
|
|
||||||
if (needed & GTK_RECENT_FILTER_DISPLAY_NAME)
|
|
||||||
{
|
|
||||||
filter_info->display_name = gtk_recent_info_get_display_name (info);
|
|
||||||
filter_info->contains |= GTK_RECENT_FILTER_DISPLAY_NAME;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter_info->uri = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needed & GTK_RECENT_FILTER_APPLICATION)
|
|
||||||
{
|
|
||||||
filter_info->applications = (const gchar **) gtk_recent_info_get_applications (info, NULL);
|
|
||||||
filter_info->contains |= GTK_RECENT_FILTER_APPLICATION;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter_info->applications = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needed & GTK_RECENT_FILTER_GROUP)
|
|
||||||
{
|
|
||||||
filter_info->groups = (const gchar **) gtk_recent_info_get_groups (info, NULL);
|
|
||||||
filter_info->contains |= GTK_RECENT_FILTER_GROUP;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter_info->groups = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needed & GTK_RECENT_FILTER_AGE)
|
|
||||||
{
|
|
||||||
filter_info->age = gtk_recent_info_get_age (info);
|
|
||||||
filter_info->contains |= GTK_RECENT_FILTER_AGE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter_info->age = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The GeditRecentConfiguration struct is allocated and owned by the caller */
|
|
||||||
void
|
|
||||||
gedit_recent_configuration_init_default (GeditRecentConfiguration *config)
|
|
||||||
{
|
|
||||||
config->manager = gtk_recent_manager_get_default ();
|
|
||||||
|
|
||||||
if (config->filter != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (config->filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
config->filter = gtk_recent_filter_new ();
|
|
||||||
gtk_recent_filter_add_application (config->filter, g_get_application_name ());
|
|
||||||
gtk_recent_filter_add_mime_type (config->filter, "text/plain");
|
|
||||||
g_object_ref_sink (config->filter);
|
|
||||||
|
|
||||||
config->limit = 5;
|
|
||||||
config->show_not_found = TRUE;
|
|
||||||
config->show_private = FALSE;
|
|
||||||
config->local_only = FALSE;
|
|
||||||
|
|
||||||
config->substring_filter = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The GeditRecentConfiguration struct is owned and destroyed by the caller */
|
|
||||||
void
|
|
||||||
gedit_recent_configuration_destroy (GeditRecentConfiguration *config)
|
|
||||||
{
|
|
||||||
g_clear_object (&config->filter);
|
|
||||||
config->manager = NULL;
|
|
||||||
|
|
||||||
g_clear_pointer (&config->substring_filter, (GDestroyNotify)g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
GList *
|
|
||||||
gedit_recent_get_items (GeditRecentConfiguration *config)
|
|
||||||
{
|
|
||||||
GtkRecentFilterFlags needed;
|
|
||||||
GList *items;
|
|
||||||
GList *retitems = NULL;
|
|
||||||
gint length;
|
|
||||||
char *substring_filter = NULL;
|
|
||||||
|
|
||||||
if (config->limit == 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
items = gtk_recent_manager_get_items (config->manager);
|
|
||||||
|
|
||||||
if (!items)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
needed = gtk_recent_filter_get_needed (config->filter);
|
|
||||||
if (config->substring_filter && *config->substring_filter != '\0')
|
|
||||||
{
|
|
||||||
gchar *filter_normalized;
|
|
||||||
|
|
||||||
filter_normalized = g_utf8_normalize (config->substring_filter, -1, G_NORMALIZE_ALL);
|
|
||||||
substring_filter = g_utf8_casefold (filter_normalized, -1);
|
|
||||||
g_free (filter_normalized);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (items)
|
|
||||||
{
|
|
||||||
GtkRecentInfo *info;
|
|
||||||
GtkRecentFilterInfo filter_info;
|
|
||||||
gboolean is_filtered;
|
|
||||||
|
|
||||||
info = items->data;
|
|
||||||
is_filtered = FALSE;
|
|
||||||
|
|
||||||
if (config->local_only && !gtk_recent_info_is_local (info))
|
|
||||||
{
|
|
||||||
is_filtered = TRUE;
|
|
||||||
}
|
|
||||||
else if (!config->show_private && gtk_recent_info_get_private_hint (info))
|
|
||||||
{
|
|
||||||
is_filtered = TRUE;
|
|
||||||
}
|
|
||||||
else if (!config->show_not_found && !gtk_recent_info_exists (info))
|
|
||||||
{
|
|
||||||
is_filtered = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (substring_filter)
|
|
||||||
{
|
|
||||||
gchar *uri_normalized;
|
|
||||||
gchar *uri_casefolded;
|
|
||||||
|
|
||||||
uri_normalized = g_utf8_normalize (gtk_recent_info_get_uri_display (info), -1, G_NORMALIZE_ALL);
|
|
||||||
uri_casefolded = g_utf8_casefold (uri_normalized, -1);
|
|
||||||
g_free (uri_normalized);
|
|
||||||
|
|
||||||
if (strstr (uri_casefolded, substring_filter) == NULL)
|
|
||||||
{
|
|
||||||
is_filtered = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (uri_casefolded);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_filtered)
|
|
||||||
{
|
|
||||||
populate_filter_info (info, &filter_info, needed);
|
|
||||||
is_filtered = !gtk_recent_filter_filter (config->filter, &filter_info);
|
|
||||||
|
|
||||||
/* these we own */
|
|
||||||
if (filter_info.applications)
|
|
||||||
{
|
|
||||||
g_strfreev ((gchar **) filter_info.applications);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filter_info.groups)
|
|
||||||
{
|
|
||||||
g_strfreev ((gchar **) filter_info.groups);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_filtered)
|
|
||||||
{
|
|
||||||
retitems = g_list_prepend (retitems, info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_recent_info_unref (info);
|
|
||||||
}
|
|
||||||
|
|
||||||
items = g_list_delete_link (items, items);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (substring_filter);
|
|
||||||
|
|
||||||
if (!retitems)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
retitems = g_list_sort_with_data (retitems, (GCompareDataFunc) sort_recent_items_mru, NULL);
|
|
||||||
length = g_list_length (retitems);
|
|
||||||
|
|
||||||
if ((config->limit != -1) && (length > config->limit))
|
|
||||||
{
|
|
||||||
GList *clamp, *l;
|
|
||||||
|
|
||||||
clamp = g_list_nth (retitems, config->limit - 1);
|
|
||||||
|
|
||||||
if (!clamp)
|
|
||||||
{
|
|
||||||
return retitems;
|
|
||||||
}
|
|
||||||
|
|
||||||
l = clamp->next;
|
|
||||||
clamp->next = NULL;
|
|
||||||
|
|
||||||
g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retitems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -27,29 +27,12 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct
|
void gedit_recent_add_document (GeditDocument *document);
|
||||||
{
|
|
||||||
GtkRecentManager *manager;
|
|
||||||
GtkRecentFilter *filter;
|
|
||||||
|
|
||||||
gint limit;
|
void gedit_recent_remove_if_local (GFile *location);
|
||||||
gchar *substring_filter;
|
|
||||||
|
|
||||||
guint show_private : 1;
|
|
||||||
guint show_not_found : 1;
|
|
||||||
guint local_only : 1;
|
|
||||||
} GeditRecentConfiguration;
|
|
||||||
|
|
||||||
void gedit_recent_add_document (GeditDocument *document);
|
|
||||||
|
|
||||||
void gedit_recent_remove_if_local (GFile *location);
|
|
||||||
|
|
||||||
void gedit_recent_configuration_init_default (GeditRecentConfiguration *config);
|
|
||||||
void gedit_recent_configuration_destroy (GeditRecentConfiguration *config);
|
|
||||||
GList *gedit_recent_get_items (GeditRecentConfiguration *config);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GEDIT_RECENT_H */
|
#endif /* GEDIT_RECENT_H */
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -37,7 +37,13 @@ struct _GeditSettings
|
||||||
GSettings *settings_file_chooser_state;
|
GSettings *settings_file_chooser_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* GeditSettings is a singleton. */
|
enum
|
||||||
|
{
|
||||||
|
SIGNAL_FONTS_CHANGED,
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[N_SIGNALS];
|
||||||
static GeditSettings *singleton = NULL;
|
static GeditSettings *singleton = NULL;
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditSettings, gedit_settings, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (GeditSettings, gedit_settings, G_TYPE_OBJECT)
|
||||||
|
@ -75,92 +81,46 @@ gedit_settings_class_init (GeditSettingsClass *klass)
|
||||||
|
|
||||||
object_class->dispose = gedit_settings_dispose;
|
object_class->dispose = gedit_settings_dispose;
|
||||||
object_class->finalize = gedit_settings_finalize;
|
object_class->finalize = gedit_settings_finalize;
|
||||||
|
|
||||||
|
/* This signal is emitted when the return value of
|
||||||
|
* _gedit_settings_get_selected_font() has potentially changed.
|
||||||
|
*/
|
||||||
|
signals[SIGNAL_FONTS_CHANGED] =
|
||||||
|
g_signal_new ("fonts-changed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
0,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_font (GeditSettings *self,
|
system_font_changed_cb (GSettings *settings,
|
||||||
const gchar *font)
|
|
||||||
{
|
|
||||||
guint tabs_size;
|
|
||||||
GList *views;
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
tabs_size = g_settings_get_uint (self->settings_editor, GEDIT_SETTINGS_TABS_SIZE);
|
|
||||||
|
|
||||||
views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
|
|
||||||
|
|
||||||
for (l = views; l != NULL; l = l->next)
|
|
||||||
{
|
|
||||||
/* Note: we use def=FALSE to avoid GeditView to query dconf. */
|
|
||||||
gedit_view_set_font (GEDIT_VIEW (l->data), FALSE, font);
|
|
||||||
|
|
||||||
/* FIXME: setting the tab width seems unrelated to set_font(). */
|
|
||||||
gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data), tabs_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (views);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_system_font_changed (GSettings *settings,
|
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
GeditSettings *self)
|
GeditSettings *self)
|
||||||
{
|
{
|
||||||
|
if (g_settings_get_boolean (self->settings_editor, GEDIT_SETTINGS_USE_DEFAULT_FONT))
|
||||||
gboolean use_default_font;
|
|
||||||
|
|
||||||
use_default_font = g_settings_get_boolean (self->settings_editor, GEDIT_SETTINGS_USE_DEFAULT_FONT);
|
|
||||||
|
|
||||||
if (use_default_font)
|
|
||||||
{
|
{
|
||||||
gchar *font;
|
g_signal_emit (self, signals[SIGNAL_FONTS_CHANGED], 0);
|
||||||
|
|
||||||
font = g_settings_get_string (settings, key);
|
|
||||||
set_font (self, font);
|
|
||||||
g_free (font);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_use_default_font_changed (GSettings *settings,
|
use_default_font_changed_cb (GSettings *settings,
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
GeditSettings *self)
|
GeditSettings *self)
|
||||||
{
|
{
|
||||||
gboolean use_default_font;
|
g_signal_emit (self, signals[SIGNAL_FONTS_CHANGED], 0);
|
||||||
gchar *font;
|
|
||||||
|
|
||||||
use_default_font = g_settings_get_boolean (settings, key);
|
|
||||||
|
|
||||||
if (use_default_font)
|
|
||||||
{
|
|
||||||
font = g_settings_get_string (self->settings_interface, GEDIT_SETTINGS_SYSTEM_FONT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
font = g_settings_get_string (self->settings_editor, GEDIT_SETTINGS_EDITOR_FONT);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_font (self, font);
|
|
||||||
|
|
||||||
g_free (font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_editor_font_changed (GSettings *settings,
|
editor_font_changed_cb (GSettings *settings,
|
||||||
const gchar *key,
|
const gchar *key,
|
||||||
GeditSettings *self)
|
GeditSettings *self)
|
||||||
{
|
{
|
||||||
gboolean use_default_font;
|
if (!g_settings_get_boolean (self->settings_editor, GEDIT_SETTINGS_USE_DEFAULT_FONT))
|
||||||
|
|
||||||
use_default_font = g_settings_get_boolean (self->settings_editor, GEDIT_SETTINGS_USE_DEFAULT_FONT);
|
|
||||||
|
|
||||||
if (!use_default_font)
|
|
||||||
{
|
{
|
||||||
gchar *font;
|
g_signal_emit (self, signals[SIGNAL_FONTS_CHANGED], 0);
|
||||||
|
|
||||||
font = g_settings_get_string (settings, key);
|
|
||||||
set_font (self, font);
|
|
||||||
g_free (font);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,43 +207,47 @@ on_syntax_highlighting_changed (GSettings *settings,
|
||||||
static void
|
static void
|
||||||
gedit_settings_init (GeditSettings *self)
|
gedit_settings_init (GeditSettings *self)
|
||||||
{
|
{
|
||||||
|
self->settings_interface = g_settings_new ("org.gnome.desktop.interface");
|
||||||
|
|
||||||
self->settings_editor = g_settings_new ("org.gnome.gedit.preferences.editor");
|
self->settings_editor = g_settings_new ("org.gnome.gedit.preferences.editor");
|
||||||
self->settings_ui = g_settings_new ("org.gnome.gedit.preferences.ui");
|
self->settings_ui = g_settings_new ("org.gnome.gedit.preferences.ui");
|
||||||
self->settings_file_chooser_state = g_settings_new ("org.gnome.gedit.state.file-chooser");
|
self->settings_file_chooser_state = g_settings_new ("org.gnome.gedit.state.file-chooser");
|
||||||
|
|
||||||
self->settings_interface = g_settings_new ("org.gnome.desktop.interface");
|
g_signal_connect_object (self->settings_interface,
|
||||||
|
"changed::" GEDIT_SETTINGS_SYSTEM_FONT,
|
||||||
|
G_CALLBACK (system_font_changed_cb),
|
||||||
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
g_signal_connect (self->settings_interface,
|
g_signal_connect_object (self->settings_editor,
|
||||||
"changed::monospace-font-name",
|
"changed::" GEDIT_SETTINGS_USE_DEFAULT_FONT,
|
||||||
G_CALLBACK (on_system_font_changed),
|
G_CALLBACK (use_default_font_changed_cb),
|
||||||
self);
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
/* editor changes */
|
g_signal_connect_object (self->settings_editor,
|
||||||
|
"changed::" GEDIT_SETTINGS_EDITOR_FONT,
|
||||||
|
G_CALLBACK (editor_font_changed_cb),
|
||||||
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
g_signal_connect (self->settings_editor,
|
g_signal_connect_object (self->settings_editor,
|
||||||
"changed::use-default-font",
|
"changed::auto-save",
|
||||||
G_CALLBACK (on_use_default_font_changed),
|
G_CALLBACK (on_auto_save_changed),
|
||||||
self);
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
g_signal_connect (self->settings_editor,
|
g_signal_connect_object (self->settings_editor,
|
||||||
"changed::editor-font",
|
"changed::auto-save-interval",
|
||||||
G_CALLBACK (on_editor_font_changed),
|
G_CALLBACK (on_auto_save_interval_changed),
|
||||||
self);
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
g_signal_connect (self->settings_editor,
|
g_signal_connect_object (self->settings_editor,
|
||||||
"changed::auto-save",
|
"changed::syntax-highlighting",
|
||||||
G_CALLBACK (on_auto_save_changed),
|
G_CALLBACK (on_syntax_highlighting_changed),
|
||||||
self);
|
self,
|
||||||
|
0);
|
||||||
g_signal_connect (self->settings_editor,
|
|
||||||
"changed::auto-save-interval",
|
|
||||||
G_CALLBACK (on_auto_save_interval_changed),
|
|
||||||
self);
|
|
||||||
|
|
||||||
g_signal_connect (self->settings_editor,
|
|
||||||
"changed::syntax-highlighting",
|
|
||||||
G_CALLBACK (on_syntax_highlighting_changed),
|
|
||||||
self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GeditSettings *
|
GeditSettings *
|
||||||
|
@ -328,11 +292,24 @@ _gedit_settings_peek_file_chooser_state_settings (GeditSettings *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
gedit_settings_get_system_font (GeditSettings *self)
|
_gedit_settings_get_system_font (GeditSettings *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GEDIT_IS_SETTINGS (self), NULL);
|
g_return_val_if_fail (GEDIT_IS_SETTINGS (self), NULL);
|
||||||
|
|
||||||
return g_settings_get_string (self->settings_interface, "monospace-font-name");
|
return g_settings_get_string (self->settings_interface, GEDIT_SETTINGS_SYSTEM_FONT);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
_gedit_settings_get_selected_font (GeditSettings *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_SETTINGS (self), NULL);
|
||||||
|
|
||||||
|
if (g_settings_get_boolean (self->settings_editor, GEDIT_SETTINGS_USE_DEFAULT_FONT))
|
||||||
|
{
|
||||||
|
return _gedit_settings_get_system_font (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_settings_get_string (self->settings_editor, GEDIT_SETTINGS_EDITOR_FONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -43,7 +43,11 @@ GSettings * _gedit_settings_peek_editor_settings (GeditSettings *self);
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GSettings * _gedit_settings_peek_file_chooser_state_settings (GeditSettings *self);
|
GSettings * _gedit_settings_peek_file_chooser_state_settings (GeditSettings *self);
|
||||||
|
|
||||||
gchar * gedit_settings_get_system_font (GeditSettings *self);
|
G_GNUC_INTERNAL
|
||||||
|
gchar * _gedit_settings_get_system_font (GeditSettings *self);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gchar * _gedit_settings_get_selected_font (GeditSettings *self);
|
||||||
|
|
||||||
GSList * gedit_settings_get_candidate_encodings (gboolean *default_candidates);
|
GSList * gedit_settings_get_candidate_encodings (gboolean *default_candidates);
|
||||||
|
|
||||||
|
@ -69,7 +73,6 @@ GSList * gedit_settings_get_candidate_encodings (gboolean *default_candidates)
|
||||||
#define GEDIT_SETTINGS_RESTORE_CURSOR_POSITION "restore-cursor-position"
|
#define GEDIT_SETTINGS_RESTORE_CURSOR_POSITION "restore-cursor-position"
|
||||||
#define GEDIT_SETTINGS_SYNTAX_HIGHLIGHTING "syntax-highlighting"
|
#define GEDIT_SETTINGS_SYNTAX_HIGHLIGHTING "syntax-highlighting"
|
||||||
#define GEDIT_SETTINGS_SEARCH_HIGHLIGHTING "search-highlighting"
|
#define GEDIT_SETTINGS_SEARCH_HIGHLIGHTING "search-highlighting"
|
||||||
#define GEDIT_SETTINGS_DISPLAY_OVERVIEW_MAP "display-overview-map"
|
|
||||||
#define GEDIT_SETTINGS_BACKGROUND_PATTERN "background-pattern"
|
#define GEDIT_SETTINGS_BACKGROUND_PATTERN "background-pattern"
|
||||||
#define GEDIT_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
|
#define GEDIT_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible"
|
||||||
#define GEDIT_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
|
#define GEDIT_SETTINGS_SIDE_PANEL_VISIBLE "side-panel-visible"
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-app.h"
|
#include "gedit-app.h"
|
||||||
#include "gedit-app-private.h"
|
#include "gedit-app-private.h"
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
#include "gedit-io-error-info-bar.h"
|
#include "gedit-io-error-info-bar.h"
|
||||||
#include "gedit-print-job.h"
|
#include "gedit-print-job.h"
|
||||||
#include "gedit-print-preview.h"
|
#include "gedit-print-preview.h"
|
||||||
#include "gedit-progress-info-bar.h"
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-document.h"
|
#include "gedit-document.h"
|
||||||
#include "gedit-document-private.h"
|
#include "gedit-document-private.h"
|
||||||
|
@ -143,9 +143,6 @@ static void launch_loader (GTask *loading_task,
|
||||||
|
|
||||||
static void launch_saver (GTask *saving_task);
|
static void launch_saver (GTask *saving_task);
|
||||||
|
|
||||||
static void continue_loading(GTask *loading_task);
|
|
||||||
|
|
||||||
|
|
||||||
static SaverData *
|
static SaverData *
|
||||||
saver_data_new (void)
|
saver_data_new (void)
|
||||||
{
|
{
|
||||||
|
@ -577,9 +574,9 @@ document_location_notify_handler (GtkSourceFile *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
document_shortname_notify_handler (GeditDocument *document,
|
document_shortname_notify_handler (TeplFile *file,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GeditTab *tab)
|
GeditTab *tab)
|
||||||
{
|
{
|
||||||
gedit_debug (DEBUG_TAB);
|
gedit_debug (DEBUG_TAB);
|
||||||
|
|
||||||
|
@ -691,14 +688,6 @@ io_loading_error_info_bar_response (GtkWidget *info_bar,
|
||||||
g_object_unref (loading_task);
|
g_object_unref (loading_task);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case GTK_RESPONSE_ACCEPT:
|
|
||||||
set_info_bar (data->tab, NULL, GTK_RESPONSE_NONE);
|
|
||||||
gedit_tab_set_state (data->tab, GEDIT_TAB_STATE_LOADING);
|
|
||||||
|
|
||||||
continue_loading (loading_task);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (location != NULL)
|
if (location != NULL)
|
||||||
{
|
{
|
||||||
|
@ -737,7 +726,7 @@ load_cancelled (GtkWidget *bar,
|
||||||
{
|
{
|
||||||
LoaderData *data = g_task_get_task_data (loading_task);
|
LoaderData *data = g_task_get_task_data (loading_task);
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (data->tab->info_bar));
|
g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (data->tab->info_bar));
|
||||||
|
|
||||||
g_cancellable_cancel (g_task_get_cancellable (loading_task));
|
g_cancellable_cancel (g_task_get_cancellable (loading_task));
|
||||||
remove_tab (data->tab);
|
remove_tab (data->tab);
|
||||||
|
@ -768,7 +757,7 @@ static void
|
||||||
show_loading_info_bar (GTask *loading_task)
|
show_loading_info_bar (GTask *loading_task)
|
||||||
{
|
{
|
||||||
LoaderData *data = g_task_get_task_data (loading_task);
|
LoaderData *data = g_task_get_task_data (loading_task);
|
||||||
GtkWidget *bar;
|
TeplProgressInfoBar *bar;
|
||||||
GeditDocument *doc;
|
GeditDocument *doc;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *dirname = NULL;
|
gchar *dirname = NULL;
|
||||||
|
@ -796,7 +785,7 @@ show_loading_info_bar (GTask *loading_task)
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
str = gedit_utils_str_middle_truncate (name, MAX_MSG_LENGTH);
|
str = tepl_utils_str_middle_truncate (name, MAX_MSG_LENGTH);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
name = str;
|
name = str;
|
||||||
}
|
}
|
||||||
|
@ -815,8 +804,8 @@ show_loading_info_bar (GTask *loading_task)
|
||||||
* we have a title long 99 + 20, but I think it's a rare enough
|
* we have a title long 99 + 20, but I think it's a rare enough
|
||||||
* case to be acceptable. It's justa darn title afterall :)
|
* case to be acceptable. It's justa darn title afterall :)
|
||||||
*/
|
*/
|
||||||
dirname = gedit_utils_str_middle_truncate (str,
|
dirname = tepl_utils_str_middle_truncate (str,
|
||||||
MAX (20, MAX_MSG_LENGTH - len));
|
MAX (20, MAX_MSG_LENGTH - len));
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -841,7 +830,7 @@ show_loading_info_bar (GTask *loading_task)
|
||||||
msg = g_strdup_printf (_("Reverting %s"), name_markup);
|
msg = g_strdup_printf (_("Reverting %s"), name_markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bar = gedit_progress_info_bar_new ("document-revert", msg, TRUE);
|
bar = tepl_progress_info_bar_new ("document-revert", msg, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -861,7 +850,7 @@ show_loading_info_bar (GTask *loading_task)
|
||||||
msg = g_strdup_printf (_("Loading %s"), name_markup);
|
msg = g_strdup_printf (_("Loading %s"), name_markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bar = gedit_progress_info_bar_new ("document-open", msg, TRUE);
|
bar = tepl_progress_info_bar_new ("document-open", msg, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect_object (bar,
|
g_signal_connect_object (bar,
|
||||||
|
@ -870,7 +859,7 @@ show_loading_info_bar (GTask *loading_task)
|
||||||
loading_task,
|
loading_task,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
set_info_bar (data->tab, bar, GTK_RESPONSE_NONE);
|
set_info_bar (data->tab, GTK_WIDGET (bar), GTK_RESPONSE_NONE);
|
||||||
|
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
@ -882,7 +871,7 @@ static void
|
||||||
show_saving_info_bar (GTask *saving_task)
|
show_saving_info_bar (GTask *saving_task)
|
||||||
{
|
{
|
||||||
GeditTab *tab = g_task_get_source_object (saving_task);
|
GeditTab *tab = g_task_get_source_object (saving_task);
|
||||||
GtkWidget *bar;
|
TeplProgressInfoBar *bar;
|
||||||
GeditDocument *doc;
|
GeditDocument *doc;
|
||||||
gchar *short_name;
|
gchar *short_name;
|
||||||
gchar *from;
|
gchar *from;
|
||||||
|
@ -910,7 +899,7 @@ show_saving_info_bar (GTask *saving_task)
|
||||||
*/
|
*/
|
||||||
if (len > MAX_MSG_LENGTH)
|
if (len > MAX_MSG_LENGTH)
|
||||||
{
|
{
|
||||||
from = gedit_utils_str_middle_truncate (short_name, MAX_MSG_LENGTH);
|
from = tepl_utils_str_middle_truncate (short_name, MAX_MSG_LENGTH);
|
||||||
g_free (short_name);
|
g_free (short_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -924,7 +913,7 @@ show_saving_info_bar (GTask *saving_task)
|
||||||
|
|
||||||
from = short_name;
|
from = short_name;
|
||||||
to = g_file_get_parse_name (location);
|
to = g_file_get_parse_name (location);
|
||||||
str = gedit_utils_str_middle_truncate (to, MAX (20, MAX_MSG_LENGTH - len));
|
str = tepl_utils_str_middle_truncate (to, MAX (20, MAX_MSG_LENGTH - len));
|
||||||
g_free (to);
|
g_free (to);
|
||||||
|
|
||||||
to = str;
|
to = str;
|
||||||
|
@ -946,9 +935,9 @@ show_saving_info_bar (GTask *saving_task)
|
||||||
msg = g_strdup_printf (_("Saving %s"), from_markup);
|
msg = g_strdup_printf (_("Saving %s"), from_markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bar = gedit_progress_info_bar_new ("document-save", msg, FALSE);
|
bar = tepl_progress_info_bar_new ("document-save", msg, FALSE);
|
||||||
|
|
||||||
set_info_bar (tab, bar, GTK_RESPONSE_NONE);
|
set_info_bar (tab, GTK_WIDGET (bar), GTK_RESPONSE_NONE);
|
||||||
|
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
g_free (to);
|
g_free (to);
|
||||||
|
@ -961,7 +950,7 @@ info_bar_set_progress (GeditTab *tab,
|
||||||
goffset size,
|
goffset size,
|
||||||
goffset total_size)
|
goffset total_size)
|
||||||
{
|
{
|
||||||
GeditProgressInfoBar *progress_info_bar;
|
TeplProgressInfoBar *progress_info_bar;
|
||||||
|
|
||||||
if (tab->info_bar == NULL)
|
if (tab->info_bar == NULL)
|
||||||
{
|
{
|
||||||
|
@ -970,23 +959,23 @@ info_bar_set_progress (GeditTab *tab,
|
||||||
|
|
||||||
gedit_debug_message (DEBUG_TAB, "%" G_GOFFSET_FORMAT "/%" G_GOFFSET_FORMAT, size, total_size);
|
gedit_debug_message (DEBUG_TAB, "%" G_GOFFSET_FORMAT "/%" G_GOFFSET_FORMAT, size, total_size);
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (tab->info_bar));
|
g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (tab->info_bar));
|
||||||
|
|
||||||
progress_info_bar = GEDIT_PROGRESS_INFO_BAR (tab->info_bar);
|
progress_info_bar = TEPL_PROGRESS_INFO_BAR (tab->info_bar);
|
||||||
|
|
||||||
if (total_size != 0)
|
if (total_size != 0)
|
||||||
{
|
{
|
||||||
gdouble frac = (gdouble)size / (gdouble)total_size;
|
gdouble frac = (gdouble)size / (gdouble)total_size;
|
||||||
|
|
||||||
gedit_progress_info_bar_set_fraction (progress_info_bar, frac);
|
tepl_progress_info_bar_set_fraction (progress_info_bar, frac);
|
||||||
}
|
}
|
||||||
else if (size != 0)
|
else if (size != 0)
|
||||||
{
|
{
|
||||||
gedit_progress_info_bar_pulse (progress_info_bar);
|
tepl_progress_info_bar_pulse (progress_info_bar);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gedit_progress_info_bar_set_fraction (progress_info_bar, 0);
|
tepl_progress_info_bar_set_fraction (progress_info_bar, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,7 +1034,7 @@ scroll_to_cursor (GeditTab *tab)
|
||||||
GeditView *view;
|
GeditView *view;
|
||||||
|
|
||||||
view = gedit_tab_get_view (tab);
|
view = gedit_tab_get_view (tab);
|
||||||
gedit_view_scroll_to_cursor (view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (view));
|
||||||
|
|
||||||
tab->idle_scroll = 0;
|
tab->idle_scroll = 0;
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
|
@ -1129,9 +1118,9 @@ invalid_character_info_bar_response (GtkWidget *info_bar,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
no_backup_error_info_bar_response (GtkWidget *info_bar,
|
cant_create_backup_error_info_bar_response (GtkWidget *info_bar,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
GTask *saving_task)
|
GTask *saving_task)
|
||||||
{
|
{
|
||||||
if (response_id == GTK_RESPONSE_YES)
|
if (response_id == GTK_RESPONSE_YES)
|
||||||
{
|
{
|
||||||
|
@ -1237,7 +1226,7 @@ externally_modified_notification_info_bar_response (GtkWidget *info_bar,
|
||||||
static void
|
static void
|
||||||
display_externally_modified_notification (GeditTab *tab)
|
display_externally_modified_notification (GeditTab *tab)
|
||||||
{
|
{
|
||||||
GtkWidget *info_bar;
|
TeplInfoBar *info_bar;
|
||||||
GeditDocument *doc;
|
GeditDocument *doc;
|
||||||
GtkSourceFile *file;
|
GtkSourceFile *file;
|
||||||
GFile *location;
|
GFile *location;
|
||||||
|
@ -1251,9 +1240,9 @@ display_externally_modified_notification (GeditTab *tab)
|
||||||
g_return_if_fail (location != NULL);
|
g_return_if_fail (location != NULL);
|
||||||
|
|
||||||
document_modified = gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc));
|
document_modified = gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc));
|
||||||
info_bar = gedit_externally_modified_info_bar_new (location, document_modified);
|
info_bar = tepl_io_error_info_bar_externally_modified (location, document_modified);
|
||||||
|
|
||||||
set_info_bar (tab, info_bar, GTK_RESPONSE_OK);
|
set_info_bar (tab, GTK_WIDGET (info_bar), GTK_RESPONSE_OK);
|
||||||
|
|
||||||
g_signal_connect (info_bar,
|
g_signal_connect (info_bar,
|
||||||
"response",
|
"response",
|
||||||
|
@ -1318,6 +1307,7 @@ gedit_tab_init (GeditTab *tab)
|
||||||
GeditDocument *doc;
|
GeditDocument *doc;
|
||||||
GeditView *view;
|
GeditView *view;
|
||||||
GtkSourceFile *file;
|
GtkSourceFile *file;
|
||||||
|
TeplFile *tepl_file;
|
||||||
|
|
||||||
tab->state = GEDIT_TAB_STATE_NORMAL;
|
tab->state = GEDIT_TAB_STATE_NORMAL;
|
||||||
|
|
||||||
|
@ -1348,6 +1338,7 @@ gedit_tab_init (GeditTab *tab)
|
||||||
g_object_set_data (G_OBJECT (doc), GEDIT_TAB_KEY, tab);
|
g_object_set_data (G_OBJECT (doc), GEDIT_TAB_KEY, tab);
|
||||||
|
|
||||||
file = gedit_document_get_file (doc);
|
file = gedit_document_get_file (doc);
|
||||||
|
tepl_file = tepl_buffer_get_file (TEPL_BUFFER (doc));
|
||||||
|
|
||||||
g_signal_connect_object (file,
|
g_signal_connect_object (file,
|
||||||
"notify::location",
|
"notify::location",
|
||||||
|
@ -1355,10 +1346,11 @@ gedit_tab_init (GeditTab *tab)
|
||||||
tab,
|
tab,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
g_signal_connect (doc,
|
g_signal_connect_object (tepl_file,
|
||||||
"notify::shortname",
|
"notify::short-name",
|
||||||
G_CALLBACK (document_shortname_notify_handler),
|
G_CALLBACK (document_shortname_notify_handler),
|
||||||
tab);
|
tab,
|
||||||
|
0);
|
||||||
|
|
||||||
g_signal_connect (doc,
|
g_signal_connect (doc,
|
||||||
"modified_changed",
|
"modified_changed",
|
||||||
|
@ -1442,7 +1434,7 @@ _gedit_tab_get_name (GeditTab *tab)
|
||||||
name = gedit_document_get_short_name_for_display (doc);
|
name = gedit_document_get_short_name_for_display (doc);
|
||||||
|
|
||||||
/* Truncate the name so it doesn't get insanely wide. */
|
/* Truncate the name so it doesn't get insanely wide. */
|
||||||
docname = gedit_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);
|
docname = tepl_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);
|
||||||
|
|
||||||
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
||||||
{
|
{
|
||||||
|
@ -1475,7 +1467,7 @@ _gedit_tab_get_tooltip (GeditTab *tab)
|
||||||
uri = _gedit_document_get_uri_for_display (doc);
|
uri = _gedit_document_get_uri_for_display (doc);
|
||||||
g_return_val_if_fail (uri != NULL, NULL);
|
g_return_val_if_fail (uri != NULL, NULL);
|
||||||
|
|
||||||
ruri = gedit_utils_replace_home_dir_with_tilde (uri);
|
ruri = tepl_utils_replace_home_dir_with_tilde (uri);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
ruri_markup = g_markup_printf_escaped ("<i>%s</i>", ruri);
|
ruri_markup = g_markup_printf_escaped ("<i>%s</i>", ruri);
|
||||||
|
@ -1584,8 +1576,6 @@ _gedit_tab_get_icon (GeditTab *tab)
|
||||||
{
|
{
|
||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
GtkIconTheme *theme;
|
GtkIconTheme *theme;
|
||||||
GtkIconInfo *info;
|
|
||||||
GtkStyleContext *context;
|
|
||||||
gint icon_size;
|
gint icon_size;
|
||||||
|
|
||||||
screen = gtk_widget_get_screen (GTK_WIDGET (tab));
|
screen = gtk_widget_get_screen (GTK_WIDGET (tab));
|
||||||
|
@ -1594,10 +1584,7 @@ _gedit_tab_get_icon (GeditTab *tab)
|
||||||
|
|
||||||
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &icon_size);
|
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &icon_size);
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (tab));
|
pixbuf = gtk_icon_theme_load_icon (theme, icon_name, icon_size, 0, NULL);
|
||||||
info = gtk_icon_theme_lookup_icon (theme, icon_name, icon_size, 0);
|
|
||||||
|
|
||||||
pixbuf = gtk_icon_info_load_symbolic_for_context (info, context, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
|
@ -1646,9 +1633,11 @@ goto_line (GTask *loading_task)
|
||||||
/* Move the cursor at the requested line if any. */
|
/* Move the cursor at the requested line if any. */
|
||||||
if (data->line_pos > 0)
|
if (data->line_pos > 0)
|
||||||
{
|
{
|
||||||
gedit_document_goto_line_offset (doc,
|
TeplView *view = TEPL_VIEW (gedit_tab_get_view (data->tab));
|
||||||
data->line_pos - 1,
|
|
||||||
MAX (0, data->column_pos - 1));
|
tepl_view_goto_line_offset (view,
|
||||||
|
data->line_pos - 1,
|
||||||
|
MAX (0, data->column_pos - 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1764,18 +1753,18 @@ successful_load (GTask *loading_task)
|
||||||
if (!gtk_source_file_is_readonly (file) &&
|
if (!gtk_source_file_is_readonly (file) &&
|
||||||
file_already_opened (doc, location))
|
file_already_opened (doc, location))
|
||||||
{
|
{
|
||||||
GtkWidget *info_bar;
|
TeplInfoBar *info_bar;
|
||||||
|
|
||||||
set_editable (data->tab, FALSE);
|
set_editable (data->tab, FALSE);
|
||||||
|
|
||||||
info_bar = gedit_file_already_open_warning_info_bar_new (location);
|
info_bar = tepl_io_error_info_bar_file_already_open (location);
|
||||||
|
|
||||||
g_signal_connect (info_bar,
|
g_signal_connect (info_bar,
|
||||||
"response",
|
"response",
|
||||||
G_CALLBACK (file_already_open_warning_info_bar_response),
|
G_CALLBACK (file_already_open_warning_info_bar_response),
|
||||||
data->tab);
|
data->tab);
|
||||||
|
|
||||||
set_info_bar (data->tab, info_bar, GTK_RESPONSE_CANCEL);
|
set_info_bar (data->tab, GTK_WIDGET (info_bar), GTK_RESPONSE_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When loading from stdin, the contents may not be saved, so set the
|
/* When loading from stdin, the contents may not be saved, so set the
|
||||||
|
@ -1989,48 +1978,6 @@ get_candidate_encodings (GeditTab *tab)
|
||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
continue_loading(GTask *loading_task)
|
|
||||||
{
|
|
||||||
LoaderData *data = g_task_get_task_data (loading_task);
|
|
||||||
// Pre loader
|
|
||||||
gtk_source_file_loader_load_async (data->loader,
|
|
||||||
G_PRIORITY_DEFAULT,
|
|
||||||
g_task_get_cancellable (loading_task),
|
|
||||||
(GFileProgressCallback) loader_progress_cb,
|
|
||||||
loading_task,
|
|
||||||
NULL,
|
|
||||||
(GAsyncReadyCallback) load_cb,
|
|
||||||
loading_task);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static
|
|
||||||
guint64 get_file_size (GFile *file)
|
|
||||||
{
|
|
||||||
GFileInfo *info;
|
|
||||||
GError *error = NULL;
|
|
||||||
guint64 res = 0;
|
|
||||||
|
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &error);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
g_error_free (error);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = g_file_info_get_size(info);
|
|
||||||
g_object_unref (info);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
launch_loader (GTask *loading_task,
|
launch_loader (GTask *loading_task,
|
||||||
const GtkSourceEncoding *encoding)
|
const GtkSourceEncoding *encoding)
|
||||||
|
@ -2038,8 +1985,6 @@ launch_loader (GTask *loading_task,
|
||||||
LoaderData *data = g_task_get_task_data (loading_task);
|
LoaderData *data = g_task_get_task_data (loading_task);
|
||||||
GSList *candidate_encodings = NULL;
|
GSList *candidate_encodings = NULL;
|
||||||
GeditDocument *doc;
|
GeditDocument *doc;
|
||||||
const int MB = 1024*1024;
|
|
||||||
const int FILE_TOO_LARGE = 100*MB;
|
|
||||||
|
|
||||||
if (encoding != NULL)
|
if (encoding != NULL)
|
||||||
{
|
{
|
||||||
|
@ -2065,47 +2010,6 @@ launch_loader (GTask *loading_task,
|
||||||
|
|
||||||
data->timer = g_timer_new ();
|
data->timer = g_timer_new ();
|
||||||
|
|
||||||
|
|
||||||
GFile * file = gtk_source_file_loader_get_location (data->loader);
|
|
||||||
guint64 size = get_file_size (file);
|
|
||||||
|
|
||||||
if (size > FILE_TOO_LARGE)
|
|
||||||
{
|
|
||||||
GtkWidget *info_bar;
|
|
||||||
GError *error = NULL;
|
|
||||||
GFile *location = gtk_source_file_loader_get_location (data->loader);
|
|
||||||
set_editable (data->tab, FALSE);
|
|
||||||
|
|
||||||
error = g_error_new_literal (GTK_SOURCE_FILE_LOADER_ERROR, 0, "");
|
|
||||||
error->code = GTK_SOURCE_FILE_LOADER_ERROR_TOO_BIG;
|
|
||||||
|
|
||||||
info_bar = gedit_io_loading_error_info_bar_new (location, NULL, error);
|
|
||||||
|
|
||||||
g_signal_connect (info_bar,
|
|
||||||
"response",
|
|
||||||
G_CALLBACK (io_loading_error_info_bar_response),
|
|
||||||
loading_task);
|
|
||||||
|
|
||||||
set_info_bar (data->tab, info_bar, GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
if (data->tab->state == GEDIT_TAB_STATE_LOADING)
|
|
||||||
{
|
|
||||||
gtk_widget_show (GTK_WIDGET (data->tab->frame));
|
|
||||||
gedit_tab_set_state (data->tab, GEDIT_TAB_STATE_LOADING_ERROR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gedit_tab_set_state (data->tab, GEDIT_TAB_STATE_REVERTING_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
successful_load (loading_task);
|
|
||||||
gedit_recent_add_document (doc);
|
|
||||||
|
|
||||||
g_error_free (error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pre loader
|
|
||||||
gtk_source_file_loader_load_async (data->loader,
|
gtk_source_file_loader_load_async (data->loader,
|
||||||
G_PRIORITY_DEFAULT,
|
G_PRIORITY_DEFAULT,
|
||||||
g_task_get_cancellable (loading_task),
|
g_task_get_cancellable (loading_task),
|
||||||
|
@ -2406,12 +2310,12 @@ save_cb (GtkSourceFileSaver *saver,
|
||||||
error->code == G_IO_ERROR_CANT_CREATE_BACKUP)
|
error->code == G_IO_ERROR_CANT_CREATE_BACKUP)
|
||||||
{
|
{
|
||||||
/* This error is recoverable */
|
/* This error is recoverable */
|
||||||
info_bar = gedit_no_backup_saving_error_info_bar_new (location, error);
|
info_bar = GTK_WIDGET (tepl_io_error_info_bar_cant_create_backup (location, error));
|
||||||
g_return_if_fail (info_bar != NULL);
|
g_return_if_fail (info_bar != NULL);
|
||||||
|
|
||||||
g_signal_connect (info_bar,
|
g_signal_connect (info_bar,
|
||||||
"response",
|
"response",
|
||||||
G_CALLBACK (no_backup_error_info_bar_response),
|
G_CALLBACK (cant_create_backup_error_info_bar_response),
|
||||||
saving_task);
|
saving_task);
|
||||||
}
|
}
|
||||||
else if (error->domain == GTK_SOURCE_FILE_SAVER_ERROR &&
|
else if (error->domain == GTK_SOURCE_FILE_SAVER_ERROR &&
|
||||||
|
@ -2420,7 +2324,7 @@ save_cb (GtkSourceFileSaver *saver,
|
||||||
/* If we have any invalid char in the document we must warn the user
|
/* If we have any invalid char in the document we must warn the user
|
||||||
* as it can make the document useless if it is saved.
|
* as it can make the document useless if it is saved.
|
||||||
*/
|
*/
|
||||||
info_bar = gedit_invalid_character_info_bar_new (location);
|
info_bar = GTK_WIDGET (tepl_io_error_info_bar_invalid_characters (location));
|
||||||
g_return_if_fail (info_bar != NULL);
|
g_return_if_fail (info_bar != NULL);
|
||||||
|
|
||||||
g_signal_connect (info_bar,
|
g_signal_connect (info_bar,
|
||||||
|
@ -2692,7 +2596,6 @@ _gedit_tab_save_as_async (GeditTab *tab,
|
||||||
g_return_if_fail (GEDIT_IS_TAB (tab));
|
g_return_if_fail (GEDIT_IS_TAB (tab));
|
||||||
g_return_if_fail (tab->state == GEDIT_TAB_STATE_NORMAL ||
|
g_return_if_fail (tab->state == GEDIT_TAB_STATE_NORMAL ||
|
||||||
tab->state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION ||
|
tab->state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION ||
|
||||||
tab->state == GEDIT_TAB_STATE_SAVING_ERROR ||
|
|
||||||
tab->state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW);
|
tab->state == GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW);
|
||||||
g_return_if_fail (G_IS_FILE (location));
|
g_return_if_fail (G_IS_FILE (location));
|
||||||
g_return_if_fail (encoding != NULL);
|
g_return_if_fail (encoding != NULL);
|
||||||
|
@ -2723,11 +2626,6 @@ _gedit_tab_save_as_async (GeditTab *tab,
|
||||||
set_info_bar (tab, NULL, GTK_RESPONSE_NONE);
|
set_info_bar (tab, NULL, GTK_RESPONSE_NONE);
|
||||||
save_flags |= GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME;
|
save_flags |= GTK_SOURCE_FILE_SAVER_FLAGS_IGNORE_MODIFICATION_TIME;
|
||||||
}
|
}
|
||||||
else if (tab->state == GEDIT_TAB_STATE_SAVING_ERROR)
|
|
||||||
{
|
|
||||||
set_info_bar (tab, NULL, GTK_RESPONSE_NONE);
|
|
||||||
gedit_tab_set_state (tab, GEDIT_TAB_STATE_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
file = gedit_document_get_file (doc);
|
file = gedit_document_get_file (doc);
|
||||||
|
|
||||||
|
@ -2808,15 +2706,15 @@ printing_cb (GeditPrintJob *job,
|
||||||
GeditPrintJobStatus status,
|
GeditPrintJobStatus status,
|
||||||
GeditTab *tab)
|
GeditTab *tab)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GEDIT_IS_PROGRESS_INFO_BAR (tab->info_bar));
|
g_return_if_fail (TEPL_IS_PROGRESS_INFO_BAR (tab->info_bar));
|
||||||
|
|
||||||
gtk_widget_show (tab->info_bar);
|
gtk_widget_show (tab->info_bar);
|
||||||
|
|
||||||
gedit_progress_info_bar_set_text (GEDIT_PROGRESS_INFO_BAR (tab->info_bar),
|
tepl_progress_info_bar_set_text (TEPL_PROGRESS_INFO_BAR (tab->info_bar),
|
||||||
gedit_print_job_get_status_string (job));
|
gedit_print_job_get_status_string (job));
|
||||||
|
|
||||||
gedit_progress_info_bar_set_fraction (GEDIT_PROGRESS_INFO_BAR (tab->info_bar),
|
tepl_progress_info_bar_set_fraction (TEPL_PROGRESS_INFO_BAR (tab->info_bar),
|
||||||
gedit_print_job_get_progress (job));
|
gedit_print_job_get_progress (job));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2926,21 +2824,19 @@ print_cancelled (GtkWidget *bar,
|
||||||
static void
|
static void
|
||||||
add_printing_info_bar (GeditTab *tab)
|
add_printing_info_bar (GeditTab *tab)
|
||||||
{
|
{
|
||||||
GtkWidget *bar;
|
TeplProgressInfoBar *bar;
|
||||||
|
|
||||||
bar = gedit_progress_info_bar_new ("document-print",
|
bar = tepl_progress_info_bar_new ("document-print", NULL, TRUE);
|
||||||
"",
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
g_signal_connect (bar,
|
g_signal_connect (bar,
|
||||||
"response",
|
"response",
|
||||||
G_CALLBACK (print_cancelled),
|
G_CALLBACK (print_cancelled),
|
||||||
tab);
|
tab);
|
||||||
|
|
||||||
set_info_bar (tab, bar, GTK_RESPONSE_NONE);
|
set_info_bar (tab, GTK_WIDGET (bar), GTK_RESPONSE_NONE);
|
||||||
|
|
||||||
/* hide until we start printing */
|
/* hide until we start printing */
|
||||||
gtk_widget_hide (bar);
|
gtk_widget_hide (GTK_WIDGET (bar));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "gedit-utils.h"
|
#include "gedit-utils.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -86,122 +87,6 @@ gedit_utils_set_atk_name_description (GtkWidget *widget,
|
||||||
atk_object_set_description (aobj, description);
|
atk_object_set_description (aobj, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gedit_warning (GtkWindow *parent, const gchar *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
gchar *str;
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkWindowGroup *wg = NULL;
|
|
||||||
|
|
||||||
g_return_if_fail (format != NULL);
|
|
||||||
|
|
||||||
if (parent != NULL)
|
|
||||||
wg = gtk_window_get_group (parent);
|
|
||||||
|
|
||||||
va_start (args, format);
|
|
||||||
str = g_strdup_vprintf (format, args);
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new_with_markup (
|
|
||||||
parent,
|
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_ERROR,
|
|
||||||
GTK_BUTTONS_OK,
|
|
||||||
"%s", str);
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
if (wg != NULL)
|
|
||||||
gtk_window_group_add_window (wg, GTK_WINDOW (dialog));
|
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog),
|
|
||||||
"response",
|
|
||||||
G_CALLBACK (gtk_widget_destroy),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the following functions are taken from eel */
|
|
||||||
|
|
||||||
static gchar *
|
|
||||||
gedit_utils_str_truncate (const gchar *string,
|
|
||||||
guint truncate_length,
|
|
||||||
gboolean middle)
|
|
||||||
{
|
|
||||||
GString *truncated;
|
|
||||||
guint length;
|
|
||||||
guint n_chars;
|
|
||||||
guint num_left_chars;
|
|
||||||
guint right_offset;
|
|
||||||
guint delimiter_length;
|
|
||||||
const gchar *delimiter = "\342\200\246";
|
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
|
||||||
|
|
||||||
length = strlen (string);
|
|
||||||
|
|
||||||
g_return_val_if_fail (g_utf8_validate (string, length, NULL), NULL);
|
|
||||||
|
|
||||||
/* It doesnt make sense to truncate strings to less than
|
|
||||||
* the size of the delimiter plus 2 characters (one on each
|
|
||||||
* side)
|
|
||||||
*/
|
|
||||||
delimiter_length = g_utf8_strlen (delimiter, -1);
|
|
||||||
if (truncate_length < (delimiter_length + 2))
|
|
||||||
{
|
|
||||||
return g_strdup (string);
|
|
||||||
}
|
|
||||||
|
|
||||||
n_chars = g_utf8_strlen (string, length);
|
|
||||||
|
|
||||||
/* Make sure the string is not already small enough. */
|
|
||||||
if (n_chars <= truncate_length)
|
|
||||||
{
|
|
||||||
return g_strdup (string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the 'middle' where the truncation will occur. */
|
|
||||||
if (middle)
|
|
||||||
{
|
|
||||||
num_left_chars = (truncate_length - delimiter_length) / 2;
|
|
||||||
right_offset = n_chars - truncate_length + num_left_chars + delimiter_length;
|
|
||||||
|
|
||||||
truncated = g_string_new_len (string,
|
|
||||||
g_utf8_offset_to_pointer (string, num_left_chars) - string);
|
|
||||||
g_string_append (truncated, delimiter);
|
|
||||||
g_string_append (truncated, g_utf8_offset_to_pointer (string, right_offset));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
num_left_chars = truncate_length - delimiter_length;
|
|
||||||
truncated = g_string_new_len (string,
|
|
||||||
g_utf8_offset_to_pointer (string, num_left_chars) - string);
|
|
||||||
g_string_append (truncated, delimiter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_string_free (truncated, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gedit_utils_str_middle_truncate (const gchar *string,
|
|
||||||
guint truncate_length)
|
|
||||||
{
|
|
||||||
return gedit_utils_str_truncate (string, truncate_length, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gedit_utils_str_end_truncate (const gchar *string,
|
|
||||||
guint truncate_length)
|
|
||||||
{
|
|
||||||
return gedit_utils_str_truncate (string, truncate_length, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
uri_get_dirname (const gchar *uri)
|
uri_get_dirname (const gchar *uri)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +106,7 @@ uri_get_dirname (const gchar *uri)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = gedit_utils_replace_home_dir_with_tilde (str);
|
res = tepl_utils_replace_home_dir_with_tilde (str);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
|
@ -264,10 +149,10 @@ gedit_utils_location_get_dirname_for_display (GFile *location)
|
||||||
g_object_unref (mount);
|
g_object_unref (mount);
|
||||||
|
|
||||||
/* obtain the "path" part of the uri */
|
/* obtain the "path" part of the uri */
|
||||||
gedit_utils_decode_uri (uri,
|
tepl_utils_decode_uri (uri,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&path);
|
&path);
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
{
|
{
|
||||||
|
@ -302,51 +187,6 @@ gedit_utils_location_get_dirname_for_display (GFile *location)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
|
||||||
gedit_utils_replace_home_dir_with_tilde (const gchar *uri)
|
|
||||||
{
|
|
||||||
gchar *tmp;
|
|
||||||
gchar *home;
|
|
||||||
|
|
||||||
g_return_val_if_fail (uri != NULL, NULL);
|
|
||||||
|
|
||||||
/* Note that g_get_home_dir returns a const string */
|
|
||||||
tmp = (gchar *)g_get_home_dir ();
|
|
||||||
|
|
||||||
if (tmp == NULL)
|
|
||||||
return g_strdup (uri);
|
|
||||||
|
|
||||||
home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
|
|
||||||
if (home == NULL)
|
|
||||||
return g_strdup (uri);
|
|
||||||
|
|
||||||
if (strcmp (uri, home) == 0)
|
|
||||||
{
|
|
||||||
g_free (home);
|
|
||||||
|
|
||||||
return g_strdup ("~/");
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = home;
|
|
||||||
home = g_strdup_printf ("%s/", tmp);
|
|
||||||
g_free (tmp);
|
|
||||||
|
|
||||||
if (g_str_has_prefix (uri, home))
|
|
||||||
{
|
|
||||||
gchar *res;
|
|
||||||
|
|
||||||
res = g_strdup_printf ("~/%s", uri + strlen (home));
|
|
||||||
|
|
||||||
g_free (home);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (home);
|
|
||||||
|
|
||||||
return g_strdup (uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_valid_scheme_character (gchar c)
|
is_valid_scheme_character (gchar c)
|
||||||
{
|
{
|
||||||
|
@ -513,7 +353,7 @@ gedit_utils_basename_for_display (GFile *location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_file_has_parent (location, NULL) ||
|
else if (g_file_has_parent (location, NULL) ||
|
||||||
!gedit_utils_decode_uri (uri, NULL, NULL, &hn, NULL, NULL))
|
!tepl_utils_decode_uri (uri, NULL, NULL, &hn, NULL, NULL))
|
||||||
{
|
{
|
||||||
/* For remote files with a parent (so not just http://foo.com)
|
/* For remote files with a parent (so not just http://foo.com)
|
||||||
or remote file for which the decoding of the host name fails,
|
or remote file for which the decoding of the host name fails,
|
||||||
|
@ -598,165 +438,6 @@ gedit_utils_drop_get_uris (GtkSelectionData *selection_data)
|
||||||
return uri_list;
|
return uri_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
null_ptr (gchar **ptr)
|
|
||||||
{
|
|
||||||
if (ptr)
|
|
||||||
*ptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_utils_decode_uri:
|
|
||||||
* @uri: the uri to decode
|
|
||||||
* @scheme: (out) (allow-none): return value pointer for the uri's
|
|
||||||
* scheme (e.g. http, sftp, ...), or %NULL
|
|
||||||
* @user: (out) (allow-none): return value pointer for the uri user info, or %NULL
|
|
||||||
* @port: (out) (allow-none): return value pointer for the uri port, or %NULL
|
|
||||||
* @host: (out) (allow-none): return value pointer for the uri host, or %NULL
|
|
||||||
* @path: (out) (allow-none): return value pointer for the uri path, or %NULL
|
|
||||||
*
|
|
||||||
* Parse and break an uri apart in its individual components like the uri
|
|
||||||
* scheme, user info, port, host and path. The return value pointer can be
|
|
||||||
* %NULL to ignore certain parts of the uri. If the function returns %TRUE, then
|
|
||||||
* all return value pointers should be freed using g_free
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the uri could be properly decoded, %FALSE otherwise.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
gedit_utils_decode_uri (const gchar *uri,
|
|
||||||
gchar **scheme,
|
|
||||||
gchar **user,
|
|
||||||
gchar **host,
|
|
||||||
gchar **port,
|
|
||||||
gchar **path)
|
|
||||||
{
|
|
||||||
/* Largely copied from glib/gio/gdummyfile.c:_g_decode_uri. This
|
|
||||||
* functionality should be in glib/gio, but for now we implement it
|
|
||||||
* ourselves (see bug #546182) */
|
|
||||||
|
|
||||||
const char *p, *in, *hier_part_start, *hier_part_end;
|
|
||||||
char *out;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
/* From RFC 3986 Decodes:
|
|
||||||
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
|
|
||||||
*/
|
|
||||||
|
|
||||||
p = uri;
|
|
||||||
|
|
||||||
null_ptr (scheme);
|
|
||||||
null_ptr (user);
|
|
||||||
null_ptr (port);
|
|
||||||
null_ptr (host);
|
|
||||||
null_ptr (path);
|
|
||||||
|
|
||||||
/* Decode scheme:
|
|
||||||
* scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!g_ascii_isalpha (*p))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
c = *p++;
|
|
||||||
|
|
||||||
if (c == ':')
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!(g_ascii_isalnum(c) ||
|
|
||||||
c == '+' ||
|
|
||||||
c == '-' ||
|
|
||||||
c == '.'))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scheme)
|
|
||||||
{
|
|
||||||
*scheme = g_malloc (p - uri);
|
|
||||||
out = *scheme;
|
|
||||||
|
|
||||||
for (in = uri; in < p - 1; in++)
|
|
||||||
{
|
|
||||||
*out++ = g_ascii_tolower (*in);
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
hier_part_start = p;
|
|
||||||
hier_part_end = p + strlen (p);
|
|
||||||
|
|
||||||
if (hier_part_start[0] == '/' && hier_part_start[1] == '/')
|
|
||||||
{
|
|
||||||
const char *authority_start, *authority_end;
|
|
||||||
const char *userinfo_start, *userinfo_end;
|
|
||||||
const char *host_start, *host_end;
|
|
||||||
const char *port_start;
|
|
||||||
|
|
||||||
authority_start = hier_part_start + 2;
|
|
||||||
/* authority is always followed by / or nothing */
|
|
||||||
authority_end = memchr (authority_start, '/', hier_part_end - authority_start);
|
|
||||||
|
|
||||||
if (authority_end == NULL)
|
|
||||||
authority_end = hier_part_end;
|
|
||||||
|
|
||||||
/* 3.2:
|
|
||||||
* authority = [ userinfo "@" ] host [ ":" port ]
|
|
||||||
*/
|
|
||||||
|
|
||||||
userinfo_end = memchr (authority_start, '@', authority_end - authority_start);
|
|
||||||
|
|
||||||
if (userinfo_end)
|
|
||||||
{
|
|
||||||
userinfo_start = authority_start;
|
|
||||||
|
|
||||||
if (user)
|
|
||||||
*user = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL);
|
|
||||||
|
|
||||||
if (user && *user == NULL)
|
|
||||||
{
|
|
||||||
if (scheme)
|
|
||||||
g_free (*scheme);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
host_start = userinfo_end + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
host_start = authority_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
port_start = memchr (host_start, ':', authority_end - host_start);
|
|
||||||
|
|
||||||
if (port_start)
|
|
||||||
{
|
|
||||||
host_end = port_start++;
|
|
||||||
|
|
||||||
if (port)
|
|
||||||
*port = g_strndup (port_start, authority_end - port_start);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
host_end = authority_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (host)
|
|
||||||
*host = g_strndup (host_start, host_end - host_start);
|
|
||||||
|
|
||||||
hier_part_start = authority_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path)
|
|
||||||
*path = g_uri_unescape_segment (hier_part_start, hier_part_end, "/");
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkSourceCompressionType
|
GtkSourceCompressionType
|
||||||
gedit_utils_get_compression_type_from_content_type (const gchar *content_type)
|
gedit_utils_get_compression_type_from_content_type (const gchar *content_type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,38 +27,19 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* useful macro */
|
|
||||||
#define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))
|
|
||||||
#define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE))
|
|
||||||
|
|
||||||
gboolean gedit_utils_menu_position_under_tree_view (GtkTreeView *tree_view,
|
gboolean gedit_utils_menu_position_under_tree_view (GtkTreeView *tree_view,
|
||||||
GdkRectangle *rect);
|
GdkRectangle *rect);
|
||||||
|
|
||||||
gchar *gedit_utils_str_middle_truncate (const gchar *string,
|
|
||||||
guint truncate_length);
|
|
||||||
gchar *gedit_utils_str_end_truncate (const gchar *string,
|
|
||||||
guint truncate_length);
|
|
||||||
void gedit_utils_set_atk_name_description (GtkWidget *widget,
|
void gedit_utils_set_atk_name_description (GtkWidget *widget,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *description);
|
const gchar *description);
|
||||||
void gedit_warning (GtkWindow *parent,
|
|
||||||
const gchar *format,
|
|
||||||
...) G_GNUC_PRINTF(2, 3);
|
|
||||||
|
|
||||||
gchar *gedit_utils_location_get_dirname_for_display (GFile *location);
|
gchar *gedit_utils_location_get_dirname_for_display (GFile *location);
|
||||||
gchar *gedit_utils_replace_home_dir_with_tilde (const gchar *uri);
|
|
||||||
|
|
||||||
gboolean gedit_utils_is_valid_location (GFile *location);
|
gboolean gedit_utils_is_valid_location (GFile *location);
|
||||||
|
|
||||||
gchar *gedit_utils_basename_for_display (GFile *location);
|
gchar *gedit_utils_basename_for_display (GFile *location);
|
||||||
|
|
||||||
gboolean gedit_utils_decode_uri (const gchar *uri,
|
|
||||||
gchar **scheme,
|
|
||||||
gchar **user,
|
|
||||||
gchar **host,
|
|
||||||
gchar **port,
|
|
||||||
gchar **path);
|
|
||||||
|
|
||||||
/* Turns data from a drop into a list of well formatted uris */
|
/* Turns data from a drop into a list of well formatted uris */
|
||||||
gchar **gedit_utils_drop_get_uris (GtkSelectionData *selection_data);
|
gchar **gedit_utils_drop_get_uris (GtkSelectionData *selection_data);
|
||||||
|
|
||||||
|
|
|
@ -1,495 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-view-centering.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 - Sébastien Lafargue
|
|
||||||
*
|
|
||||||
* Gedit is free software; you can redistribute this file and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Gedit 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* Based on Christian Hergert's prototype.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gedit-view-centering.h"
|
|
||||||
|
|
||||||
#include <gtksourceview/gtksource.h>
|
|
||||||
|
|
||||||
#include "gedit-view.h"
|
|
||||||
#include "gedit-debug.h"
|
|
||||||
|
|
||||||
struct _GeditViewCenteringPrivate
|
|
||||||
{
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *scrolled_window;
|
|
||||||
GtkWidget *sourceview;
|
|
||||||
GtkWidget *spacer;
|
|
||||||
|
|
||||||
GtkStyleContext *view_context;
|
|
||||||
GdkRGBA view_background;
|
|
||||||
GdkRGBA view_line_margin_fg;
|
|
||||||
GdkRGBA view_margin_background;
|
|
||||||
guint view_text_width;
|
|
||||||
|
|
||||||
guint centered : 1;
|
|
||||||
guint view_background_set : 1;
|
|
||||||
guint view_line_margin_fg_set : 1;
|
|
||||||
guint view_margin_background_set : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GeditViewCentering, gedit_view_centering, GTK_TYPE_BIN)
|
|
||||||
|
|
||||||
#define STYLE_TEXT "text"
|
|
||||||
#define STYLE_RIGHT_MARGIN "right-margin"
|
|
||||||
|
|
||||||
#define RIGHT_MARGIN_LINE_ALPHA 40
|
|
||||||
#define RIGHT_MARGIN_OVERLAY_ALPHA 15
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
get_style (GtkSourceStyleScheme *scheme,
|
|
||||||
const gchar *style_id,
|
|
||||||
const gchar *attribute,
|
|
||||||
GdkRGBA *color)
|
|
||||||
{
|
|
||||||
GtkSourceStyle *style;
|
|
||||||
gchar *style_string;
|
|
||||||
|
|
||||||
style = gtk_source_style_scheme_get_style (scheme, style_id);
|
|
||||||
if (!style)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_get (style, attribute, &style_string, NULL);
|
|
||||||
if (style_string)
|
|
||||||
{
|
|
||||||
gdk_rgba_parse (color, style_string);
|
|
||||||
g_free (style_string);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
get_spacer_colors (GeditViewCentering *container,
|
|
||||||
GtkSourceStyleScheme *scheme)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
|
|
||||||
if (scheme)
|
|
||||||
{
|
|
||||||
priv->view_background_set = get_style (scheme,
|
|
||||||
STYLE_TEXT, "background",
|
|
||||||
&priv->view_background);
|
|
||||||
|
|
||||||
priv->view_line_margin_fg_set = get_style (scheme,
|
|
||||||
STYLE_RIGHT_MARGIN, "foreground",
|
|
||||||
&priv->view_line_margin_fg);
|
|
||||||
priv->view_line_margin_fg.alpha = RIGHT_MARGIN_LINE_ALPHA / 255.0;
|
|
||||||
|
|
||||||
priv->view_margin_background_set = get_style (scheme,
|
|
||||||
STYLE_RIGHT_MARGIN, "background",
|
|
||||||
&priv->view_margin_background);
|
|
||||||
priv->view_margin_background.alpha = RIGHT_MARGIN_OVERLAY_ALPHA / 255.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: when GeditViewCentering will be transfered to GtkSourceView,
|
|
||||||
* this method will be replaced by a call to a new method called
|
|
||||||
* gtk_source_view_get_right_margin_pixel_position ()
|
|
||||||
*/
|
|
||||||
static guint
|
|
||||||
_gedit_view_centering_get_right_margin_pixel_position (GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
gchar *str;
|
|
||||||
PangoFontDescription *font_desc;
|
|
||||||
PangoLayout *layout;
|
|
||||||
guint right_margin_position;
|
|
||||||
gint width = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GEDIT_IS_VIEW_CENTERING (container), 0);
|
|
||||||
|
|
||||||
priv = container->priv;
|
|
||||||
|
|
||||||
right_margin_position = gtk_source_view_get_right_margin_position (GTK_SOURCE_VIEW (priv->sourceview));
|
|
||||||
|
|
||||||
gtk_style_context_save (priv->view_context);
|
|
||||||
gtk_style_context_set_state (priv->view_context, GTK_STATE_FLAG_NORMAL);
|
|
||||||
gtk_style_context_get (priv->view_context,
|
|
||||||
gtk_style_context_get_state (priv->view_context),
|
|
||||||
GTK_STYLE_PROPERTY_FONT, &font_desc,
|
|
||||||
NULL);
|
|
||||||
gtk_style_context_restore (priv->view_context);
|
|
||||||
|
|
||||||
str = g_strnfill (right_margin_position, '_');
|
|
||||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (priv->sourceview), str);
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
pango_layout_set_font_description (layout, font_desc);
|
|
||||||
pango_font_description_free (font_desc);
|
|
||||||
pango_layout_get_pixel_size (layout, &width, NULL);
|
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (layout));
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_view_right_margin_visibility_changed (GeditView *view,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
gboolean visibility;
|
|
||||||
|
|
||||||
visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
|
|
||||||
|
|
||||||
gtk_widget_set_visible (GTK_WIDGET (container->priv->spacer), visibility && priv->centered);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_view_right_margin_position_changed (GeditView *view,
|
|
||||||
GParamSpec *pspec,
|
|
||||||
GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
gboolean visibility;
|
|
||||||
|
|
||||||
priv->view_text_width = _gedit_view_centering_get_right_margin_pixel_position (container);
|
|
||||||
|
|
||||||
visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
|
|
||||||
|
|
||||||
if (visibility)
|
|
||||||
{
|
|
||||||
gtk_widget_queue_resize (priv->spacer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_view_context_changed (GtkStyleContext *stylecontext,
|
|
||||||
GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkSourceStyleScheme *scheme;
|
|
||||||
gboolean visibility;
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sourceview));
|
|
||||||
scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
|
|
||||||
get_spacer_colors (container, scheme);
|
|
||||||
|
|
||||||
priv->view_text_width = _gedit_view_centering_get_right_margin_pixel_position (container);
|
|
||||||
|
|
||||||
visibility = gtk_source_view_get_show_right_margin (GTK_SOURCE_VIEW (priv->sourceview));
|
|
||||||
|
|
||||||
if (visibility)
|
|
||||||
{
|
|
||||||
gtk_widget_queue_resize (priv->spacer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
on_spacer_draw (GeditViewCentering *container,
|
|
||||||
cairo_t *cr,
|
|
||||||
GtkDrawingArea *spacer)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
GtkStyleContext *context;
|
|
||||||
guint width, height;
|
|
||||||
|
|
||||||
if (!container->priv->sourceview)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (spacer));
|
|
||||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (spacer));
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (spacer));
|
|
||||||
gtk_style_context_save (context);
|
|
||||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
|
|
||||||
gtk_render_background (context, cr, 0, 0, width, height);
|
|
||||||
gtk_style_context_restore (context);
|
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
|
||||||
|
|
||||||
if (priv->view_background_set)
|
|
||||||
{
|
|
||||||
gdk_cairo_set_source_rgba (cr, &container->priv->view_background);
|
|
||||||
cairo_rectangle (cr, 0, 0, width, height);
|
|
||||||
cairo_fill (cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->view_margin_background_set)
|
|
||||||
{
|
|
||||||
gdk_cairo_set_source_rgba (cr, &container->priv->view_margin_background);
|
|
||||||
cairo_rectangle (cr, 0, 0, width, height);
|
|
||||||
cairo_fill (cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->view_line_margin_fg_set)
|
|
||||||
{
|
|
||||||
gdk_cairo_set_source_rgba (cr, &container->priv->view_line_margin_fg);
|
|
||||||
cairo_move_to (cr, width - 0.5, 0);
|
|
||||||
cairo_line_to (cr, width - 0.5, height);
|
|
||||||
cairo_stroke (cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_remove (GtkContainer *container,
|
|
||||||
GtkWidget *child)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
|
|
||||||
g_assert (GEDIT_IS_VIEW_CENTERING (container));
|
|
||||||
|
|
||||||
priv = GEDIT_VIEW_CENTERING (container)->priv;
|
|
||||||
|
|
||||||
if (priv->sourceview == child)
|
|
||||||
{
|
|
||||||
gtk_container_remove (GTK_CONTAINER (priv->scrolled_window), priv->sourceview);
|
|
||||||
g_object_remove_weak_pointer (G_OBJECT (priv->sourceview), (gpointer *)&priv->sourceview);
|
|
||||||
priv->sourceview = NULL;
|
|
||||||
priv->view_context = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GTK_CONTAINER_CLASS (gedit_view_centering_parent_class)->remove (container, child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_add (GtkContainer *container,
|
|
||||||
GtkWidget *child)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkSourceStyleScheme *scheme;
|
|
||||||
|
|
||||||
g_assert (GEDIT_IS_VIEW_CENTERING (container));
|
|
||||||
|
|
||||||
priv = GEDIT_VIEW_CENTERING (container)->priv;
|
|
||||||
|
|
||||||
if (GEDIT_IS_VIEW (child))
|
|
||||||
{
|
|
||||||
if (priv->sourceview)
|
|
||||||
{
|
|
||||||
gedit_view_centering_remove (container, priv->sourceview);
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->sourceview = child;
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (child), (gpointer *)&priv->sourceview);
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->scrolled_window), child);
|
|
||||||
|
|
||||||
priv->view_context = gtk_widget_get_style_context (child);
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sourceview));
|
|
||||||
scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (buffer));
|
|
||||||
get_spacer_colors (GEDIT_VIEW_CENTERING (container), scheme);
|
|
||||||
|
|
||||||
g_signal_connect (priv->sourceview,
|
|
||||||
"notify::right-margin-position",
|
|
||||||
G_CALLBACK (on_view_right_margin_position_changed),
|
|
||||||
container);
|
|
||||||
|
|
||||||
g_signal_connect (priv->sourceview,
|
|
||||||
"notify::show-right-margin",
|
|
||||||
G_CALLBACK (on_view_right_margin_visibility_changed),
|
|
||||||
container);
|
|
||||||
|
|
||||||
g_signal_connect (priv->view_context,
|
|
||||||
"changed",
|
|
||||||
G_CALLBACK (on_view_context_changed),
|
|
||||||
container);
|
|
||||||
|
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GTK_CONTAINER_CLASS (gedit_view_centering_parent_class)->add (container, child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
on_spacer_scroll_event (GtkWidget *widget,
|
|
||||||
GdkEvent *event,
|
|
||||||
GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GdkEventScroll *new_scroll_event;
|
|
||||||
|
|
||||||
new_scroll_event = (GdkEventScroll *)gdk_event_copy (event);
|
|
||||||
g_object_unref (new_scroll_event->window);
|
|
||||||
|
|
||||||
new_scroll_event->window = g_object_ref (gtk_widget_get_window (container->priv->sourceview));
|
|
||||||
new_scroll_event->send_event = TRUE;
|
|
||||||
|
|
||||||
new_scroll_event->x = 0;
|
|
||||||
new_scroll_event->y = 0;
|
|
||||||
new_scroll_event->x_root = 0;
|
|
||||||
new_scroll_event->y_root = 0;
|
|
||||||
|
|
||||||
gtk_main_do_event ((GdkEvent *)new_scroll_event);
|
|
||||||
gdk_event_free ((GdkEvent *)new_scroll_event);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_size_allocate (GtkWidget *widget,
|
|
||||||
GtkAllocation *alloc)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
GtkTextView *view;
|
|
||||||
gint container_width;
|
|
||||||
gint gutter_width;
|
|
||||||
gint text_width;
|
|
||||||
gint spacer_width;
|
|
||||||
gint current_spacer_width;
|
|
||||||
GdkWindow *gutter_window;
|
|
||||||
|
|
||||||
g_assert (GEDIT_IS_VIEW_CENTERING (widget));
|
|
||||||
|
|
||||||
priv = GEDIT_VIEW_CENTERING (widget)->priv;
|
|
||||||
|
|
||||||
view = GTK_TEXT_VIEW (priv->sourceview);
|
|
||||||
|
|
||||||
if (view)
|
|
||||||
{
|
|
||||||
container_width = alloc->width;
|
|
||||||
|
|
||||||
gutter_window = gtk_text_view_get_window (view, GTK_TEXT_WINDOW_LEFT);
|
|
||||||
gutter_width = (gutter_window) ? gdk_window_get_width (gutter_window) : 0;
|
|
||||||
|
|
||||||
text_width = priv->view_text_width;
|
|
||||||
spacer_width = MAX (0, container_width - text_width - gutter_width) / 2;
|
|
||||||
|
|
||||||
g_object_get(priv->spacer, "width-request", ¤t_spacer_width, NULL);
|
|
||||||
|
|
||||||
if (current_spacer_width != spacer_width)
|
|
||||||
{
|
|
||||||
g_object_set(priv->spacer, "width-request", spacer_width, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gedit_view_centering_parent_class)->size_allocate (widget, alloc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
GeditViewCentering *container = GEDIT_VIEW_CENTERING (object);
|
|
||||||
GeditViewCenteringPrivate *priv = container->priv;
|
|
||||||
|
|
||||||
if (priv->sourceview)
|
|
||||||
{
|
|
||||||
gedit_view_centering_remove (GTK_CONTAINER (container), priv->sourceview);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_view_centering_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_class_init (GeditViewCenteringClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
||||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->finalize = gedit_view_centering_finalize;
|
|
||||||
|
|
||||||
widget_class->size_allocate = gedit_view_centering_size_allocate;
|
|
||||||
|
|
||||||
container_class->add = gedit_view_centering_add;
|
|
||||||
container_class->remove = gedit_view_centering_remove;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_view_centering_init (GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
|
|
||||||
container->priv = gedit_view_centering_get_instance_private (container);
|
|
||||||
priv = container->priv;
|
|
||||||
priv->view_text_width = 0;
|
|
||||||
|
|
||||||
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
|
||||||
priv->spacer = gtk_drawing_area_new ();
|
|
||||||
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (container), priv->box);
|
|
||||||
gtk_box_pack_start (GTK_BOX (priv->box), priv->spacer, FALSE, FALSE, 0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (priv->box), priv->scrolled_window, TRUE, TRUE, 0);
|
|
||||||
|
|
||||||
gtk_widget_set_no_show_all (GTK_WIDGET (priv->spacer), TRUE);
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (priv->box));
|
|
||||||
|
|
||||||
g_signal_connect_swapped (priv->spacer, "draw",
|
|
||||||
G_CALLBACK (on_spacer_draw),
|
|
||||||
container);
|
|
||||||
|
|
||||||
gtk_widget_add_events(GTK_WIDGET(priv->spacer), GDK_SCROLL_MASK);
|
|
||||||
g_signal_connect (priv->spacer, "scroll-event",
|
|
||||||
G_CALLBACK (on_spacer_scroll_event),
|
|
||||||
container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_centering_set_centered:
|
|
||||||
* @container: a #GeditViewCentering.
|
|
||||||
* @centered: whether to center the sourceview child or not.
|
|
||||||
*
|
|
||||||
* If @centered is %TRUE, the sourceview child is centered
|
|
||||||
* horizontally on the #GeditViewCentering container.
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
gedit_view_centering_set_centered (GeditViewCentering *container,
|
|
||||||
gboolean centered)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW_CENTERING (container));
|
|
||||||
|
|
||||||
container->priv->centered = centered != FALSE;
|
|
||||||
|
|
||||||
on_view_right_margin_visibility_changed (GEDIT_VIEW (container->priv->sourceview), NULL, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_centering_get_centered:
|
|
||||||
* @container: a #GeditViewCentering.
|
|
||||||
*
|
|
||||||
* Return whether the #GtkSourceView child is centered or not.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the #GtkSourceView child is centered
|
|
||||||
* horizontally on the #GeditViewCentering container.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gedit_view_centering_get_centered (GeditViewCentering *container)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GEDIT_IS_VIEW_CENTERING (container), FALSE);
|
|
||||||
|
|
||||||
return container->priv->centered;
|
|
||||||
}
|
|
||||||
|
|
||||||
GeditViewCentering *
|
|
||||||
gedit_view_centering_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (GEDIT_TYPE_VIEW_CENTERING,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -1,67 +0,0 @@
|
||||||
/*
|
|
||||||
* gedit-view-centering.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 - Sébastien Lafargue
|
|
||||||
* Copyright (C) 2015 - Sébastien Wilmet
|
|
||||||
*
|
|
||||||
* Gedit is free software; you can redistribute this file and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Gedit 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GEDIT_VIEW_CENTERING_H
|
|
||||||
#define GEDIT_VIEW_CENTERING_H
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_VIEW_CENTERING (gedit_view_centering_get_type())
|
|
||||||
#define GEDIT_VIEW_CENTERING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_VIEW_CENTERING, GeditViewCentering))
|
|
||||||
#define GEDIT_VIEW_CENTERING_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_VIEW_CENTERING, GeditViewCentering const))
|
|
||||||
#define GEDIT_VIEW_CENTERING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_VIEW_CENTERING, GeditViewCenteringClass))
|
|
||||||
#define GEDIT_IS_VIEW_CENTERING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_VIEW_CENTERING))
|
|
||||||
#define GEDIT_IS_VIEW_CENTERING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_VIEW_CENTERING))
|
|
||||||
#define GEDIT_VIEW_CENTERING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_VIEW_CENTERING, GeditViewCenteringClass))
|
|
||||||
|
|
||||||
typedef struct _GeditViewCentering GeditViewCentering;
|
|
||||||
typedef struct _GeditViewCenteringClass GeditViewCenteringClass;
|
|
||||||
typedef struct _GeditViewCenteringPrivate GeditViewCenteringPrivate;
|
|
||||||
|
|
||||||
struct _GeditViewCentering
|
|
||||||
{
|
|
||||||
GtkBin parent;
|
|
||||||
|
|
||||||
GeditViewCenteringPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeditViewCenteringClass
|
|
||||||
{
|
|
||||||
GtkBinClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gedit_view_centering_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GeditViewCentering * gedit_view_centering_new (void);
|
|
||||||
|
|
||||||
void gedit_view_centering_set_centered (GeditViewCentering *container,
|
|
||||||
gboolean centered);
|
|
||||||
|
|
||||||
gboolean gedit_view_centering_get_centered (GeditViewCentering *container);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GEDIT_VIEW_CENTERING_H */
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
|
|
@ -3,7 +3,7 @@
|
||||||
* This file is part of gedit
|
* This file is part of gedit
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 - Ignacio Casal Quinteiro
|
* Copyright (C) 2010 - Ignacio Casal Quinteiro
|
||||||
* Copyright (C) 2013 - Sébastien Wilmet
|
* Copyright (C) 2013, 2019 - Sébastien Wilmet
|
||||||
*
|
*
|
||||||
* gedit is free software; you can redistribute it and/or modify
|
* gedit 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
|
||||||
|
@ -28,7 +28,6 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "gedit-view-centering.h"
|
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-utils.h"
|
#include "gedit-utils.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
|
@ -54,11 +53,7 @@ struct _GeditViewFrame
|
||||||
{
|
{
|
||||||
GtkOverlay parent_instance;
|
GtkOverlay parent_instance;
|
||||||
|
|
||||||
GSettings *editor_settings;
|
|
||||||
|
|
||||||
GeditView *view;
|
GeditView *view;
|
||||||
GeditViewCentering *view_centering;
|
|
||||||
GtkFrame *map_frame;
|
|
||||||
|
|
||||||
SearchMode search_mode;
|
SearchMode search_mode;
|
||||||
|
|
||||||
|
@ -164,7 +159,6 @@ gedit_view_frame_dispose (GObject *object)
|
||||||
gtk_source_file_set_mount_operation_factory (file, NULL, NULL, NULL);
|
gtk_source_file_set_mount_operation_factory (file, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&frame->editor_settings);
|
|
||||||
g_clear_object (&frame->entry_tag);
|
g_clear_object (&frame->entry_tag);
|
||||||
g_clear_object (&frame->search_settings);
|
g_clear_object (&frame->search_settings);
|
||||||
g_clear_object (&frame->old_search_settings);
|
g_clear_object (&frame->old_search_settings);
|
||||||
|
@ -219,7 +213,7 @@ hide_search_widget (GeditViewFrame *frame,
|
||||||
frame->start_mark);
|
frame->start_mark);
|
||||||
gtk_text_buffer_place_cursor (buffer, &iter);
|
gtk_text_buffer_place_cursor (buffer, &iter);
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (frame->view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (frame->view));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame->start_mark != NULL)
|
if (frame->start_mark != NULL)
|
||||||
|
@ -303,7 +297,7 @@ finish_search (GeditViewFrame *frame,
|
||||||
|
|
||||||
if (found || (entry_text[0] == '\0'))
|
if (found || (entry_text[0] == '\0'))
|
||||||
{
|
{
|
||||||
gedit_view_scroll_to_cursor (frame->view);
|
tepl_view_scroll_to_cursor (TEPL_VIEW (frame->view));
|
||||||
|
|
||||||
set_search_state (frame, SEARCH_STATE_NORMAL);
|
set_search_state (frame, SEARCH_STATE_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1061,6 @@ update_goto_line (GeditViewFrame *frame)
|
||||||
gchar **split_text = NULL;
|
gchar **split_text = NULL;
|
||||||
const gchar *text;
|
const gchar *text;
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
GeditDocument *doc;
|
|
||||||
|
|
||||||
entry_text = gtk_entry_get_text (GTK_ENTRY (frame->search_entry));
|
entry_text = gtk_entry_get_text (GTK_ENTRY (frame->search_entry));
|
||||||
|
|
||||||
|
@ -1123,11 +1116,8 @@ update_goto_line (GeditViewFrame *frame)
|
||||||
|
|
||||||
g_strfreev (split_text);
|
g_strfreev (split_text);
|
||||||
|
|
||||||
doc = get_document (frame);
|
moved = tepl_view_goto_line (TEPL_VIEW (frame->view), line);
|
||||||
moved = gedit_document_goto_line (doc, line);
|
moved_offset = tepl_view_goto_line_offset (TEPL_VIEW (frame->view), line, line_offset);
|
||||||
moved_offset = gedit_document_goto_line_offset (doc, line, line_offset);
|
|
||||||
|
|
||||||
gedit_view_scroll_to_cursor (frame->view);
|
|
||||||
|
|
||||||
if (!moved || !moved_offset)
|
if (!moved || !moved_offset)
|
||||||
{
|
{
|
||||||
|
@ -1438,8 +1428,6 @@ gedit_view_frame_class_init (GeditViewFrameClass *klass)
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
gtk_widget_class_set_template_from_resource (widget_class,
|
||||||
"/org/gnome/gedit/ui/gedit-view-frame.ui");
|
"/org/gnome/gedit/ui/gedit-view-frame.ui");
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, view);
|
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, view);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, view_centering);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, map_frame);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, revealer);
|
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, revealer);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, search_entry);
|
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, search_entry);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, go_up_button);
|
gtk_widget_class_bind_template_child (widget_class, GeditViewFrame, go_up_button);
|
||||||
|
@ -1466,13 +1454,6 @@ gedit_view_frame_init (GeditViewFrame *frame)
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (frame));
|
gtk_widget_init_template (GTK_WIDGET (frame));
|
||||||
|
|
||||||
frame->editor_settings = g_settings_new ("org.gnome.gedit.preferences.editor");
|
|
||||||
g_settings_bind (frame->editor_settings,
|
|
||||||
GEDIT_SETTINGS_DISPLAY_OVERVIEW_MAP,
|
|
||||||
frame->map_frame,
|
|
||||||
"visible",
|
|
||||||
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
|
|
||||||
|
|
||||||
doc = get_document (frame);
|
doc = get_document (frame);
|
||||||
file = gedit_document_get_file (doc);
|
file = gedit_document_get_file (doc);
|
||||||
|
|
||||||
|
@ -1570,14 +1551,6 @@ gedit_view_frame_new (void)
|
||||||
return g_object_new (GEDIT_TYPE_VIEW_FRAME, NULL);
|
return g_object_new (GEDIT_TYPE_VIEW_FRAME, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeditViewCentering *
|
|
||||||
gedit_view_frame_get_view_centering (GeditViewFrame *frame)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GEDIT_IS_VIEW_FRAME (frame), NULL);
|
|
||||||
|
|
||||||
return frame->view_centering;
|
|
||||||
}
|
|
||||||
|
|
||||||
GeditView *
|
GeditView *
|
||||||
gedit_view_frame_get_view (GeditViewFrame *frame)
|
gedit_view_frame_get_view (GeditViewFrame *frame)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gedit-document.h"
|
#include "gedit-document.h"
|
||||||
#include "gedit-view.h"
|
#include "gedit-view.h"
|
||||||
#include "gedit-view-centering.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -33,9 +32,6 @@ G_DECLARE_FINAL_TYPE (GeditViewFrame, gedit_view_frame, GEDIT, VIEW_FRAME, GtkOv
|
||||||
|
|
||||||
GeditViewFrame *gedit_view_frame_new (void);
|
GeditViewFrame *gedit_view_frame_new (void);
|
||||||
|
|
||||||
GeditViewCentering
|
|
||||||
*gedit_view_frame_get_view_centering (GeditViewFrame *frame);
|
|
||||||
|
|
||||||
GeditView *gedit_view_frame_get_view (GeditViewFrame *frame);
|
GeditView *gedit_view_frame_get_view (GeditViewFrame *frame);
|
||||||
|
|
||||||
void gedit_view_frame_popup_search (GeditViewFrame *frame);
|
void gedit_view_frame_popup_search (GeditViewFrame *frame);
|
||||||
|
|
|
@ -24,21 +24,16 @@
|
||||||
#include "gedit-view-activatable.h"
|
#include "gedit-view-activatable.h"
|
||||||
#include "gedit-plugins-engine.h"
|
#include "gedit-plugins-engine.h"
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
#include "gedit-pango.h"
|
|
||||||
#include "gedit-utils.h"
|
#include "gedit-utils.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
|
|
||||||
#define GEDIT_VIEW_SCROLL_MARGIN 0.02
|
|
||||||
|
|
||||||
struct _GeditViewPrivate
|
struct _GeditViewPrivate
|
||||||
{
|
{
|
||||||
GeditDocument *current_document;
|
|
||||||
PeasExtensionSet *extensions;
|
PeasExtensionSet *extensions;
|
||||||
|
|
||||||
gchar *direct_save_uri;
|
gchar *direct_save_uri;
|
||||||
|
|
||||||
GtkCssProvider *css_provider;
|
TeplSignalGroup *file_signal_group;
|
||||||
PangoFontDescription *font_desc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -55,7 +50,7 @@ enum
|
||||||
|
|
||||||
static guint signals[N_SIGNALS];
|
static guint signals[N_SIGNALS];
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GeditView, gedit_view, GTK_SOURCE_TYPE_VIEW)
|
G_DEFINE_TYPE_WITH_PRIVATE (GeditView, gedit_view, TEPL_TYPE_VIEW)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_editable (GeditView *view)
|
update_editable (GeditView *view)
|
||||||
|
@ -78,46 +73,23 @@ file_read_only_notify_cb (GtkSourceFile *file,
|
||||||
update_editable (view);
|
update_editable (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
current_document_removed (GeditView *view)
|
|
||||||
{
|
|
||||||
if (view->priv->current_document != NULL)
|
|
||||||
{
|
|
||||||
GtkSourceFile *file;
|
|
||||||
|
|
||||||
file = gedit_document_get_file (view->priv->current_document);
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (file,
|
|
||||||
file_read_only_notify_cb,
|
|
||||||
view);
|
|
||||||
|
|
||||||
g_object_unref (view->priv->current_document);
|
|
||||||
view->priv->current_document = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
buffer_changed (GeditView *view)
|
buffer_changed (GeditView *view)
|
||||||
{
|
{
|
||||||
|
GeditDocument *doc;
|
||||||
GtkSourceFile *file;
|
GtkSourceFile *file;
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
|
|
||||||
current_document_removed (view);
|
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
file = gedit_document_get_file (doc);
|
||||||
|
|
||||||
if (!GEDIT_IS_DOCUMENT (buffer))
|
tepl_signal_group_clear (&view->priv->file_signal_group);
|
||||||
{
|
view->priv->file_signal_group = tepl_signal_group_new (G_OBJECT (file));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
view->priv->current_document = g_object_ref (GEDIT_DOCUMENT (buffer));
|
tepl_signal_group_add (view->priv->file_signal_group,
|
||||||
|
g_signal_connect (file,
|
||||||
file = gedit_document_get_file (view->priv->current_document);
|
"notify::read-only",
|
||||||
g_signal_connect_object (file,
|
G_CALLBACK (file_read_only_notify_cb),
|
||||||
"notify::read-only",
|
view));
|
||||||
G_CALLBACK (file_read_only_notify_cb),
|
|
||||||
view,
|
|
||||||
0);
|
|
||||||
|
|
||||||
update_editable (view);
|
update_editable (view);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +106,7 @@ static void
|
||||||
gedit_view_init (GeditView *view)
|
gedit_view_init (GeditView *view)
|
||||||
{
|
{
|
||||||
GtkTargetList *target_list;
|
GtkTargetList *target_list;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *style_context;
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
gedit_debug (DEBUG_VIEW);
|
||||||
|
|
||||||
|
@ -168,13 +140,8 @@ gedit_view_init (GeditView *view)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* CSS stuff */
|
/* CSS stuff */
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (view));
|
style_context = gtk_widget_get_style_context (GTK_WIDGET (view));
|
||||||
gtk_style_context_add_class (context, "gedit-view");
|
gtk_style_context_add_class (style_context, "gedit-view");
|
||||||
|
|
||||||
view->priv->css_provider = gtk_css_provider_new ();
|
|
||||||
gtk_style_context_add_provider (context,
|
|
||||||
GTK_STYLE_PROVIDER (view->priv->css_provider),
|
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -183,8 +150,7 @@ gedit_view_dispose (GObject *object)
|
||||||
GeditView *view = GEDIT_VIEW (object);
|
GeditView *view = GEDIT_VIEW (object);
|
||||||
|
|
||||||
g_clear_object (&view->priv->extensions);
|
g_clear_object (&view->priv->extensions);
|
||||||
|
tepl_signal_group_clear (&view->priv->file_signal_group);
|
||||||
current_document_removed (view);
|
|
||||||
|
|
||||||
/* Disconnect notify buffer because the destroy of the textview will set
|
/* Disconnect notify buffer because the destroy of the textview will set
|
||||||
* the buffer to NULL, and we call get_buffer in the notify which would
|
* the buffer to NULL, and we call get_buffer in the notify which would
|
||||||
|
@ -194,39 +160,46 @@ gedit_view_dispose (GObject *object)
|
||||||
*/
|
*/
|
||||||
g_signal_handlers_disconnect_by_func (view, buffer_notify_cb, NULL);
|
g_signal_handlers_disconnect_by_func (view, buffer_notify_cb, NULL);
|
||||||
|
|
||||||
g_clear_object (&view->priv->css_provider);
|
|
||||||
g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_view_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gedit_view_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_font (GeditView *view)
|
||||||
|
{
|
||||||
|
GeditSettings *settings;
|
||||||
|
gchar *selected_font;
|
||||||
|
|
||||||
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
selected_font = _gedit_settings_get_selected_font (settings);
|
||||||
|
tepl_utils_override_font (GTK_WIDGET (view), selected_font);
|
||||||
|
g_free (selected_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fonts_changed_cb (GeditSettings *settings,
|
||||||
|
GeditView *view)
|
||||||
|
{
|
||||||
|
update_font (view);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gedit_view_constructed (GObject *object)
|
gedit_view_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
GeditView *view = GEDIT_VIEW (object);
|
GeditView *view = GEDIT_VIEW (object);
|
||||||
GeditSettings *settings;
|
GeditSettings *settings;
|
||||||
GSettings *editor_settings;
|
GSettings *editor_settings;
|
||||||
gboolean use_default_font;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_view_parent_class)->constructed (object);
|
G_OBJECT_CLASS (gedit_view_parent_class)->constructed (object);
|
||||||
|
|
||||||
settings = _gedit_settings_get_singleton ();
|
settings = _gedit_settings_get_singleton ();
|
||||||
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
editor_settings = _gedit_settings_peek_editor_settings (settings);
|
||||||
|
|
||||||
use_default_font = g_settings_get_boolean (editor_settings, GEDIT_SETTINGS_USE_DEFAULT_FONT);
|
update_font (view);
|
||||||
|
g_signal_connect_object (settings,
|
||||||
if (use_default_font)
|
"fonts-changed",
|
||||||
{
|
G_CALLBACK (fonts_changed_cb),
|
||||||
gedit_view_set_font (view, TRUE, NULL);
|
view,
|
||||||
}
|
0);
|
||||||
else
|
|
||||||
{
|
|
||||||
gchar *editor_font;
|
|
||||||
|
|
||||||
editor_font = g_settings_get_string (editor_settings, GEDIT_SETTINGS_EDITOR_FONT);
|
|
||||||
gedit_view_set_font (view, FALSE, editor_font);
|
|
||||||
g_free (editor_font);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_settings_bind (editor_settings, GEDIT_SETTINGS_DISPLAY_LINE_NUMBERS,
|
g_settings_bind (editor_settings, GEDIT_SETTINGS_DISPLAY_LINE_NUMBERS,
|
||||||
view, "show-line-numbers",
|
view, "show-line-numbers",
|
||||||
|
@ -747,217 +720,4 @@ gedit_view_new (GeditDocument *doc)
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gedit_view_cut_clipboard (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkClipboard *clipboard;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
|
|
||||||
GDK_SELECTION_CLIPBOARD);
|
|
||||||
|
|
||||||
gtk_text_buffer_cut_clipboard (buffer,
|
|
||||||
clipboard,
|
|
||||||
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
|
|
||||||
|
|
||||||
gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
|
|
||||||
gtk_text_buffer_get_insert (buffer),
|
|
||||||
GEDIT_VIEW_SCROLL_MARGIN,
|
|
||||||
FALSE,
|
|
||||||
0.0,
|
|
||||||
0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_view_copy_clipboard (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkClipboard *clipboard;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
|
|
||||||
GDK_SELECTION_CLIPBOARD);
|
|
||||||
|
|
||||||
gtk_text_buffer_copy_clipboard (buffer, clipboard);
|
|
||||||
|
|
||||||
/* on copy do not scroll, we are already on screen */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gedit_view_paste_clipboard (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkClipboard *clipboard;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
|
|
||||||
GDK_SELECTION_CLIPBOARD);
|
|
||||||
|
|
||||||
gtk_text_buffer_paste_clipboard (buffer,
|
|
||||||
clipboard,
|
|
||||||
NULL,
|
|
||||||
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
|
|
||||||
|
|
||||||
gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
|
|
||||||
gtk_text_buffer_get_insert (buffer),
|
|
||||||
GEDIT_VIEW_SCROLL_MARGIN,
|
|
||||||
FALSE,
|
|
||||||
0.0,
|
|
||||||
0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_delete_selection:
|
|
||||||
* @view: a #GeditView
|
|
||||||
*
|
|
||||||
* Deletes the text currently selected in the #GtkTextBuffer associated
|
|
||||||
* to the view and scroll to the cursor position.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gedit_view_delete_selection (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
gtk_text_buffer_delete_selection (buffer,
|
|
||||||
TRUE,
|
|
||||||
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
|
|
||||||
|
|
||||||
gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
|
|
||||||
gtk_text_buffer_get_insert (buffer),
|
|
||||||
GEDIT_VIEW_SCROLL_MARGIN,
|
|
||||||
FALSE,
|
|
||||||
0.0,
|
|
||||||
0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_select_all:
|
|
||||||
* @view: a #GeditView
|
|
||||||
*
|
|
||||||
* Selects all the text.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gedit_view_select_all (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
GtkTextIter start;
|
|
||||||
GtkTextIter end;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
|
||||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_scroll_to_cursor:
|
|
||||||
* @view: a #GeditView
|
|
||||||
*
|
|
||||||
* Scrolls the @view to the cursor position.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gedit_view_scroll_to_cursor (GeditView *view)
|
|
||||||
{
|
|
||||||
GtkTextBuffer *buffer;
|
|
||||||
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
||||||
|
|
||||||
gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
|
|
||||||
gtk_text_buffer_get_insert (buffer),
|
|
||||||
0.25,
|
|
||||||
FALSE,
|
|
||||||
0.0,
|
|
||||||
0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
update_css_provider (GeditView *view)
|
|
||||||
{
|
|
||||||
gchar *str;
|
|
||||||
gchar *css;
|
|
||||||
|
|
||||||
g_assert (GEDIT_IS_VIEW (view));
|
|
||||||
g_assert (view->priv->font_desc != NULL);
|
|
||||||
|
|
||||||
str = gedit_pango_font_description_to_css (view->priv->font_desc);
|
|
||||||
css = g_strdup_printf ("textview { %s }", str ? str : "");
|
|
||||||
gtk_css_provider_load_from_data (view->priv->css_provider, css, -1, NULL);
|
|
||||||
|
|
||||||
g_free (css);
|
|
||||||
g_free (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gedit_view_set_font:
|
|
||||||
* @view: a #GeditView
|
|
||||||
* @default_font: whether to reset to the default font
|
|
||||||
* @font_name: the name of the font to use
|
|
||||||
*
|
|
||||||
* If @default_font is #TRUE, resets the font of the @view to the default font.
|
|
||||||
* Otherwise sets it to @font_name.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gedit_view_set_font (GeditView *view,
|
|
||||||
gboolean default_font,
|
|
||||||
const gchar *font_name)
|
|
||||||
{
|
|
||||||
gedit_debug (DEBUG_VIEW);
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_IS_VIEW (view));
|
|
||||||
|
|
||||||
g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
|
|
||||||
|
|
||||||
if (default_font)
|
|
||||||
{
|
|
||||||
GeditSettings *settings;
|
|
||||||
gchar *font;
|
|
||||||
|
|
||||||
settings = _gedit_settings_get_singleton ();
|
|
||||||
font = gedit_settings_get_system_font (settings);
|
|
||||||
|
|
||||||
view->priv->font_desc = pango_font_description_from_string (font);
|
|
||||||
g_free (font);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_return_if_fail (font_name != NULL);
|
|
||||||
|
|
||||||
view->priv->font_desc = pango_font_description_from_string (font_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_return_if_fail (view->priv->font_desc != NULL);
|
|
||||||
|
|
||||||
update_css_provider (view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ex:set ts=8 noet: */
|
/* ex:set ts=8 noet: */
|
||||||
|
|
|
@ -22,10 +22,8 @@
|
||||||
#ifndef GEDIT_VIEW_H
|
#ifndef GEDIT_VIEW_H
|
||||||
#define GEDIT_VIEW_H
|
#define GEDIT_VIEW_H
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include <gedit/gedit-document.h>
|
#include <gedit/gedit-document.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -42,7 +40,7 @@ typedef struct _GeditViewPrivate GeditViewPrivate;
|
||||||
|
|
||||||
struct _GeditView
|
struct _GeditView
|
||||||
{
|
{
|
||||||
GtkSourceView view;
|
TeplView view;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GeditViewPrivate *priv;
|
GeditViewPrivate *priv;
|
||||||
|
@ -50,7 +48,7 @@ struct _GeditView
|
||||||
|
|
||||||
struct _GeditViewClass
|
struct _GeditViewClass
|
||||||
{
|
{
|
||||||
GtkSourceViewClass parent_class;
|
TeplViewClass parent_class;
|
||||||
|
|
||||||
void (*drop_uris) (GeditView *view,
|
void (*drop_uris) (GeditView *view,
|
||||||
gchar **uri_list);
|
gchar **uri_list);
|
||||||
|
@ -62,22 +60,6 @@ GType gedit_view_get_type (void);
|
||||||
|
|
||||||
GtkWidget * gedit_view_new (GeditDocument *doc);
|
GtkWidget * gedit_view_new (GeditDocument *doc);
|
||||||
|
|
||||||
void gedit_view_cut_clipboard (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_copy_clipboard (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_paste_clipboard (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_delete_selection (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_select_all (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_scroll_to_cursor (GeditView *view);
|
|
||||||
|
|
||||||
void gedit_view_set_font (GeditView *view,
|
|
||||||
gboolean default_font,
|
|
||||||
const gchar *font_name);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GEDIT_VIEW_H */
|
#endif /* GEDIT_VIEW_H */
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "gedit-message-bus.h"
|
#include "gedit-message-bus.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
#include "gedit-multi-notebook.h"
|
#include "gedit-multi-notebook.h"
|
||||||
#include "gedit-open-document-selector.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -54,15 +53,12 @@ struct _GeditWindowPrivate
|
||||||
PeasExtensionSet *extensions;
|
PeasExtensionSet *extensions;
|
||||||
|
|
||||||
/* Widgets for fullscreen mode */
|
/* Widgets for fullscreen mode */
|
||||||
GtkWidget *fullscreen_controls;
|
|
||||||
GtkWidget *fullscreen_eventbox;
|
GtkWidget *fullscreen_eventbox;
|
||||||
|
GtkRevealer *fullscreen_revealer;
|
||||||
GtkWidget *fullscreen_headerbar;
|
GtkWidget *fullscreen_headerbar;
|
||||||
|
GtkWidget *fullscreen_new_button;
|
||||||
GtkMenuButton *fullscreen_gear_button;
|
GtkMenuButton *fullscreen_gear_button;
|
||||||
|
GtkMenuButton *fullscreen_open_recent_button;
|
||||||
GtkWidget *fullscreen_new_button;
|
|
||||||
GtkWidget *fullscreen_open_button;
|
|
||||||
GtkWidget *fullscreen_open_document_popover;
|
|
||||||
GeditOpenDocumentSelector *fullscreen_open_document_selector;
|
|
||||||
|
|
||||||
/* statusbar and context ids for statusbar messages */
|
/* statusbar and context ids for statusbar messages */
|
||||||
GtkWidget *statusbar;
|
GtkWidget *statusbar;
|
||||||
|
@ -83,10 +79,7 @@ struct _GeditWindowPrivate
|
||||||
GtkWidget *side_headerbar;
|
GtkWidget *side_headerbar;
|
||||||
GtkWidget *headerbar;
|
GtkWidget *headerbar;
|
||||||
|
|
||||||
GtkWidget *open_document_popover;
|
GtkWidget *new_button;
|
||||||
GtkWidget *new_button;
|
|
||||||
GtkWidget *open_button;
|
|
||||||
GeditOpenDocumentSelector *open_document_selector;
|
|
||||||
|
|
||||||
GtkMenuButton *gear_button;
|
GtkMenuButton *gear_button;
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <libpeas/peas-extension-set.h>
|
#include <libpeas/peas-extension-set.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-window-private.h"
|
#include "gedit-window-private.h"
|
||||||
#include "gedit-app.h"
|
#include "gedit-app.h"
|
||||||
#include "gedit-app-private.h"
|
#include "gedit-app-private.h"
|
||||||
#include "gedit-recent.h"
|
|
||||||
#include "gedit-notebook.h"
|
#include "gedit-notebook.h"
|
||||||
#include "gedit-notebook-popup-menu.h"
|
#include "gedit-notebook-popup-menu.h"
|
||||||
#include "gedit-multi-notebook.h"
|
#include "gedit-multi-notebook.h"
|
||||||
|
@ -40,7 +40,6 @@
|
||||||
#include "gedit-tab.h"
|
#include "gedit-tab.h"
|
||||||
#include "gedit-tab-private.h"
|
#include "gedit-tab-private.h"
|
||||||
#include "gedit-view-frame.h"
|
#include "gedit-view-frame.h"
|
||||||
#include "gedit-view-centering.h"
|
|
||||||
#include "gedit-utils.h"
|
#include "gedit-utils.h"
|
||||||
#include "gedit-commands.h"
|
#include "gedit-commands.h"
|
||||||
#include "gedit-commands-private.h"
|
#include "gedit-commands-private.h"
|
||||||
|
@ -55,11 +54,6 @@
|
||||||
#include "gedit-status-menu-button.h"
|
#include "gedit-status-menu-button.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
#include "gedit-menu-stack-switcher.h"
|
#include "gedit-menu-stack-switcher.h"
|
||||||
#include "gedit-highlight-mode-selector.h"
|
|
||||||
#include "gedit-open-document-selector.h"
|
|
||||||
|
|
||||||
#define TAB_WIDTH_DATA "GeditWindowTabWidthData"
|
|
||||||
#define FULLSCREEN_ANIMATION_SPEED 500
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -164,9 +158,9 @@ save_window_state (GtkWidget *widget)
|
||||||
GeditWindow *window = GEDIT_WINDOW (widget);
|
GeditWindow *window = GEDIT_WINDOW (widget);
|
||||||
|
|
||||||
if ((window->priv->window_state &
|
if ((window->priv->window_state &
|
||||||
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
|
||||||
{
|
{
|
||||||
gtk_window_get_size (GTK_WINDOW (widget), &window->priv->width, &window->priv->height);
|
gtk_window_get_size (GTK_WINDOW (widget), &window->priv->width, &window->priv->height);
|
||||||
|
|
||||||
g_settings_set (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_SIZE,
|
g_settings_set (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_SIZE,
|
||||||
"(ii)", window->priv->width, window->priv->height);
|
"(ii)", window->priv->width, window->priv->height);
|
||||||
|
@ -237,6 +231,8 @@ gedit_window_dispose (GObject *object)
|
||||||
*/
|
*/
|
||||||
remove_actions (window);
|
remove_actions (window);
|
||||||
|
|
||||||
|
window->priv->fullscreen_open_recent_button = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_window_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gedit_window_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,22 +247,6 @@ gedit_window_finalize (GObject *object)
|
||||||
G_OBJECT_CLASS (gedit_window_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gedit_window_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Center the view when the window is in fullscreen mode. */
|
|
||||||
static void
|
|
||||||
update_view_centering (GeditTab *tab,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GeditViewFrame *view_frame;
|
|
||||||
GeditViewCentering *view_centering;
|
|
||||||
gboolean is_fullscreen;
|
|
||||||
|
|
||||||
view_frame = _gedit_tab_get_view_frame (tab);
|
|
||||||
view_centering = gedit_view_frame_get_view_centering (view_frame);
|
|
||||||
|
|
||||||
is_fullscreen = GPOINTER_TO_BOOLEAN (user_data);
|
|
||||||
gedit_view_centering_set_centered (view_centering, is_fullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_fullscreen (GeditWindow *window,
|
update_fullscreen (GeditWindow *window,
|
||||||
gboolean is_fullscreen)
|
gboolean is_fullscreen)
|
||||||
|
@ -287,10 +267,6 @@ update_fullscreen (GeditWindow *window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gedit_multi_notebook_foreach_tab (window->priv->multi_notebook,
|
|
||||||
(GtkCallback)update_view_centering,
|
|
||||||
GBOOLEAN_TO_POINTER (is_fullscreen));
|
|
||||||
|
|
||||||
#ifndef OS_OSX
|
#ifndef OS_OSX
|
||||||
if (is_fullscreen)
|
if (is_fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -336,7 +312,7 @@ gedit_window_configure_event (GtkWidget *widget,
|
||||||
|
|
||||||
if (gtk_widget_get_realized (widget) &&
|
if (gtk_widget_get_realized (widget) &&
|
||||||
(window->priv->window_state &
|
(window->priv->window_state &
|
||||||
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
|
||||||
{
|
{
|
||||||
save_window_state (widget);
|
save_window_state (widget);
|
||||||
}
|
}
|
||||||
|
@ -478,7 +454,6 @@ gedit_window_class_init (GeditWindowClass *klass)
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, side_headerbar);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, side_headerbar);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, headerbar);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, headerbar);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, new_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, new_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, open_button);
|
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, gear_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, gear_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, hpaned);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, hpaned);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, side_panel);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, side_panel);
|
||||||
|
@ -491,11 +466,10 @@ gedit_window_class_init (GeditWindowClass *klass)
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, language_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, language_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, tab_width_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, tab_width_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, line_col_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, line_col_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_controls);
|
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_eventbox);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_eventbox);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_revealer);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_headerbar);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_headerbar);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_new_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_new_button);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_open_button);
|
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_gear_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, fullscreen_gear_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,48 +765,8 @@ update_actions_sensitivity (GeditWindow *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_recent_chooser_item_activated (GeditOpenDocumentSelector *open_document_selector,
|
language_chooser_show_cb (TeplLanguageChooser *language_chooser,
|
||||||
gchar *uri,
|
GeditWindow *window)
|
||||||
GeditWindow *window)
|
|
||||||
{
|
|
||||||
GFile *location;
|
|
||||||
GeditView *active_view;
|
|
||||||
|
|
||||||
g_return_if_fail (GEDIT_WINDOW (window));
|
|
||||||
g_return_if_fail (GEDIT_OPEN_DOCUMENT_SELECTOR (open_document_selector));
|
|
||||||
|
|
||||||
/* TODO: get_current_file when exists */
|
|
||||||
location = g_file_new_for_uri (uri);
|
|
||||||
|
|
||||||
if (location)
|
|
||||||
{
|
|
||||||
GSList *locations = NULL;
|
|
||||||
GSList *loaded = NULL;
|
|
||||||
|
|
||||||
locations = g_slist_prepend (locations, (gpointer) location);
|
|
||||||
loaded = gedit_commands_load_locations (window, locations, NULL, 0, 0);
|
|
||||||
|
|
||||||
/* if it doesn't contain just 1 element */
|
|
||||||
if (!loaded || loaded->next)
|
|
||||||
{
|
|
||||||
gedit_recent_remove_if_local (location);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free (locations);
|
|
||||||
g_slist_free (loaded);
|
|
||||||
|
|
||||||
g_object_unref (location);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Needed to close the popover when activating the same
|
|
||||||
* document as the current one */
|
|
||||||
active_view = gedit_window_get_active_view (window);
|
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
language_selector_show_cb (GeditHighlightModeSelector *selector,
|
|
||||||
GeditWindow *window)
|
|
||||||
{
|
{
|
||||||
GeditDocument *active_document;
|
GeditDocument *active_document;
|
||||||
|
|
||||||
|
@ -842,14 +776,14 @@ language_selector_show_cb (GeditHighlightModeSelector *selector,
|
||||||
GtkSourceLanguage *language;
|
GtkSourceLanguage *language;
|
||||||
|
|
||||||
language = gedit_document_get_language (active_document);
|
language = gedit_document_get_language (active_document);
|
||||||
gedit_highlight_mode_selector_select_language (selector, language);
|
tepl_language_chooser_select_language (language_chooser, language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
language_selected_cb (GeditHighlightModeSelector *selector,
|
language_activated_cb (TeplLanguageChooser *language_chooser,
|
||||||
GtkSourceLanguage *language,
|
GtkSourceLanguage *language,
|
||||||
GeditWindow *window)
|
GeditWindow *window)
|
||||||
{
|
{
|
||||||
GeditDocument *active_document;
|
GeditDocument *active_document;
|
||||||
|
|
||||||
|
@ -859,13 +793,13 @@ language_selected_cb (GeditHighlightModeSelector *selector,
|
||||||
gedit_document_set_language (active_document, language);
|
gedit_document_set_language (active_document, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_hide (GTK_WIDGET (window->priv->language_popover));
|
gtk_widget_hide (window->priv->language_popover);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_statusbar (GeditWindow *window)
|
setup_statusbar (GeditWindow *window)
|
||||||
{
|
{
|
||||||
GeditHighlightModeSelector *selector;
|
TeplLanguageChooserWidget *language_chooser;
|
||||||
|
|
||||||
gedit_debug (DEBUG_WINDOW);
|
gedit_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
|
@ -895,20 +829,20 @@ setup_statusbar (GeditWindow *window)
|
||||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->priv->language_button),
|
gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->priv->language_button),
|
||||||
window->priv->language_popover);
|
window->priv->language_popover);
|
||||||
|
|
||||||
selector = gedit_highlight_mode_selector_new ();
|
language_chooser = tepl_language_chooser_widget_new ();
|
||||||
|
|
||||||
g_signal_connect (selector,
|
g_signal_connect (language_chooser,
|
||||||
"show",
|
"show",
|
||||||
G_CALLBACK (language_selector_show_cb),
|
G_CALLBACK (language_chooser_show_cb),
|
||||||
window);
|
window);
|
||||||
|
|
||||||
g_signal_connect (selector,
|
g_signal_connect (language_chooser,
|
||||||
"language-selected",
|
"language-activated",
|
||||||
G_CALLBACK (language_selected_cb),
|
G_CALLBACK (language_activated_cb),
|
||||||
window);
|
window);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (window->priv->language_popover), GTK_WIDGET (selector));
|
gtk_container_add (GTK_CONTAINER (window->priv->language_popover), GTK_WIDGET (language_chooser));
|
||||||
gtk_widget_show (GTK_WIDGET (selector));
|
gtk_widget_show (GTK_WIDGET (language_chooser));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GeditWindow *
|
static GeditWindow *
|
||||||
|
@ -1110,8 +1044,8 @@ set_title (GeditWindow *window)
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
|
||||||
tmp = gedit_utils_str_middle_truncate (name,
|
tmp = tepl_utils_str_middle_truncate (name,
|
||||||
MAX_TITLE_LENGTH);
|
MAX_TITLE_LENGTH);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
name = tmp;
|
name = tmp;
|
||||||
}
|
}
|
||||||
|
@ -1129,8 +1063,8 @@ set_title (GeditWindow *window)
|
||||||
* we have a title long 99 + 20, but I think it's a rare enough
|
* we have a title long 99 + 20, but I think it's a rare enough
|
||||||
* case to be acceptable. It's justa darn title afterall :)
|
* case to be acceptable. It's justa darn title afterall :)
|
||||||
*/
|
*/
|
||||||
dirname = gedit_utils_str_middle_truncate (str,
|
dirname = tepl_utils_str_middle_truncate (str,
|
||||||
MAX (20, MAX_TITLE_LENGTH - len));
|
MAX (20, MAX_TITLE_LENGTH - len));
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1756,84 +1690,88 @@ drop_uris_cb (GtkWidget *widget,
|
||||||
load_uris_from_drop (window, uri_list);
|
load_uris_from_drop (window, uri_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_fullscreen_revealer_state (GeditWindow *window)
|
||||||
|
{
|
||||||
|
gboolean open_recent_menu_is_active;
|
||||||
|
gboolean hamburger_menu_is_active;
|
||||||
|
|
||||||
|
open_recent_menu_is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (window->priv->fullscreen_open_recent_button));
|
||||||
|
hamburger_menu_is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (window->priv->fullscreen_gear_button));
|
||||||
|
|
||||||
|
gtk_revealer_set_reveal_child (window->priv->fullscreen_revealer,
|
||||||
|
(window->priv->in_fullscreen_eventbox ||
|
||||||
|
open_recent_menu_is_active ||
|
||||||
|
hamburger_menu_is_active));
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_fullscreen_controls_enter_notify_event (GtkWidget *widget,
|
on_fullscreen_eventbox_enter_notify_event (GtkWidget *fullscreen_eventbox,
|
||||||
GdkEventCrossing *event,
|
GdkEventCrossing *event,
|
||||||
GeditWindow *window)
|
GeditWindow *window)
|
||||||
{
|
{
|
||||||
window->priv->in_fullscreen_eventbox = TRUE;
|
window->priv->in_fullscreen_eventbox = TRUE;
|
||||||
|
update_fullscreen_revealer_state (window);
|
||||||
|
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER (window->priv->fullscreen_controls), TRUE);
|
return GDK_EVENT_PROPAGATE;
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
real_fullscreen_controls_leave_notify_event (gpointer data)
|
on_fullscreen_eventbox_leave_notify_event (GtkWidget *fullscreen_eventbox,
|
||||||
|
GdkEventCrossing *event,
|
||||||
|
GeditWindow *window)
|
||||||
{
|
{
|
||||||
GeditWindow *window = GEDIT_WINDOW (data);
|
if (-1.0 <= event->y && event->y <= 0.0)
|
||||||
gboolean hamburger_menu_state;
|
|
||||||
gboolean fullscreen_open_button_state;
|
|
||||||
|
|
||||||
hamburger_menu_state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (window->priv->fullscreen_gear_button));
|
|
||||||
fullscreen_open_button_state =
|
|
||||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (window->priv->fullscreen_open_button));
|
|
||||||
|
|
||||||
window->priv->in_fullscreen_eventbox = FALSE;
|
|
||||||
|
|
||||||
if (!hamburger_menu_state && !fullscreen_open_button_state)
|
|
||||||
{
|
{
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER (window->priv->fullscreen_controls), FALSE);
|
/* Ignore the event.
|
||||||
|
*
|
||||||
|
* Leave notify events are received with -1 <= y <= 0
|
||||||
|
* coordinates, although the GeditWindow is in fullscreen mode
|
||||||
|
* and when there are no screens above (it's maybe a bug in an
|
||||||
|
* underlying library).
|
||||||
|
* If we hide the headerbar when those events happen, then it
|
||||||
|
* makes the headerbar to be shown/hidden a lot of time in a
|
||||||
|
* short period of time, i.e. a "stuttering". In other words
|
||||||
|
* lots of leave/enter events are received when moving the mouse
|
||||||
|
* upwards on the screen when the mouse is already at the top.
|
||||||
|
* The expected leave event has a positive event->y value being
|
||||||
|
* >= to the height of the headerbar (approximately
|
||||||
|
* 40 <= y <= 50). So clearly when we receive a leave event with
|
||||||
|
* event->y <= 0, it means that the mouse has left the eventbox
|
||||||
|
* on the wrong side.
|
||||||
|
* The -1.0 <= event->y is there (instead of just <= 0.0) in the
|
||||||
|
* case that there is another screen *above*, even if this
|
||||||
|
* heuristic/workaround is not perfect in that case. But that
|
||||||
|
* case is quite rare, so it's probably a good enough solution.
|
||||||
|
*
|
||||||
|
* Note that apparently the "stuttering" occurs only on an Xorg
|
||||||
|
* session, not on Wayland (tested with GNOME).
|
||||||
|
*
|
||||||
|
* If you see a better solution...
|
||||||
|
*/
|
||||||
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
window->priv->in_fullscreen_eventbox = FALSE;
|
||||||
}
|
update_fullscreen_revealer_state (window);
|
||||||
|
|
||||||
/* this idle is needed because the toggled signal from gear button is received
|
|
||||||
* after the leave event from the event box ( which is automatically triggered when user
|
|
||||||
* bring up the gear menu */
|
|
||||||
static gboolean
|
|
||||||
on_fullscreen_controls_leave_notify_event (GtkWidget *widget,
|
|
||||||
GdkEventCrossing *event,
|
|
||||||
GeditWindow *window)
|
|
||||||
{
|
|
||||||
g_idle_add (real_fullscreen_controls_leave_notify_event, window);
|
|
||||||
|
|
||||||
return GDK_EVENT_PROPAGATE;
|
return GDK_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fullscreen_controls_setup (GeditWindow *window)
|
setup_fullscreen_eventbox (GeditWindow *window)
|
||||||
{
|
{
|
||||||
GeditWindowPrivate *priv = window->priv;
|
gtk_widget_set_size_request (window->priv->fullscreen_eventbox, -1, 1);
|
||||||
|
|
||||||
g_signal_connect (priv->fullscreen_eventbox,
|
|
||||||
"enter-notify-event",
|
|
||||||
G_CALLBACK (on_fullscreen_controls_enter_notify_event),
|
|
||||||
window);
|
|
||||||
|
|
||||||
g_signal_connect (priv->fullscreen_eventbox,
|
|
||||||
"leave-notify-event",
|
|
||||||
G_CALLBACK (on_fullscreen_controls_leave_notify_event),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (window->priv->fullscreen_eventbox), -1, 1);
|
|
||||||
gtk_widget_hide (window->priv->fullscreen_eventbox);
|
gtk_widget_hide (window->priv->fullscreen_eventbox);
|
||||||
|
|
||||||
priv->fullscreen_open_document_popover = gtk_popover_new (priv->fullscreen_open_button);
|
g_signal_connect (window->priv->fullscreen_eventbox,
|
||||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (priv->fullscreen_open_button),
|
"enter-notify-event",
|
||||||
priv->fullscreen_open_document_popover);
|
G_CALLBACK (on_fullscreen_eventbox_enter_notify_event),
|
||||||
|
window);
|
||||||
|
|
||||||
window->priv->fullscreen_open_document_selector = gedit_open_document_selector_new (window);
|
g_signal_connect (window->priv->fullscreen_eventbox,
|
||||||
|
"leave-notify-event",
|
||||||
gtk_container_add (GTK_CONTAINER (priv->fullscreen_open_document_popover),
|
G_CALLBACK (on_fullscreen_eventbox_leave_notify_event),
|
||||||
GTK_WIDGET (priv->fullscreen_open_document_selector));
|
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (priv->fullscreen_open_document_selector));
|
|
||||||
|
|
||||||
g_signal_connect (window->priv->fullscreen_open_document_selector,
|
|
||||||
"file-activated",
|
|
||||||
G_CALLBACK (on_recent_chooser_item_activated),
|
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1947,7 +1885,7 @@ on_tab_added (GeditMultiNotebook *multi,
|
||||||
G_CALLBACK (bracket_matched_cb),
|
G_CALLBACK (bracket_matched_cb),
|
||||||
window);
|
window);
|
||||||
g_signal_connect (doc,
|
g_signal_connect (doc,
|
||||||
"cursor-moved",
|
"tepl-cursor-moved",
|
||||||
G_CALLBACK (update_cursor_position_statusbar),
|
G_CALLBACK (update_cursor_position_statusbar),
|
||||||
window);
|
window);
|
||||||
g_signal_connect (doc,
|
g_signal_connect (doc,
|
||||||
|
@ -2206,23 +2144,10 @@ on_notebook_removed (GeditMultiNotebook *mnb,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_fullscreen_gear_button_toggled (GtkToggleButton *fullscreen_gear_button,
|
on_fullscreen_toggle_button_toggled (GtkToggleButton *fullscreen_toggle_button,
|
||||||
GeditWindow *window)
|
GeditWindow *window)
|
||||||
{
|
{
|
||||||
gboolean button_active = gtk_toggle_button_get_active (fullscreen_gear_button);
|
update_fullscreen_revealer_state (window);
|
||||||
|
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER (window->priv->fullscreen_controls),
|
|
||||||
button_active || window->priv->in_fullscreen_eventbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_fullscreen_file_menu_button_toggled (GtkMenuButton *fullscreen_open_button,
|
|
||||||
GeditWindow *window)
|
|
||||||
{
|
|
||||||
gboolean button_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fullscreen_open_button));
|
|
||||||
|
|
||||||
gtk_revealer_set_reveal_child (GTK_REVEALER (window->priv->fullscreen_controls),
|
|
||||||
button_active || window->priv->in_fullscreen_eventbox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2612,18 +2537,6 @@ window_unrealized (GtkWidget *window,
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
check_window_is_active (GeditWindow *window,
|
|
||||||
GParamSpec *property,
|
|
||||||
gpointer useless)
|
|
||||||
{
|
|
||||||
if (window->priv->window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
|
||||||
{
|
|
||||||
gtk_widget_set_visible (window->priv->fullscreen_eventbox,
|
|
||||||
gtk_window_is_active (GTK_WINDOW (window)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
extension_added (PeasExtensionSet *extensions,
|
extension_added (PeasExtensionSet *extensions,
|
||||||
PeasPluginInfo *info,
|
PeasPluginInfo *info,
|
||||||
|
@ -2695,6 +2608,76 @@ sync_fullscreen_actions (GeditWindow *window,
|
||||||
g_object_unref (action);
|
g_object_unref (action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_amtk_application_window (GeditWindow *gedit_window)
|
||||||
|
{
|
||||||
|
AmtkApplicationWindow *amtk_window;
|
||||||
|
|
||||||
|
amtk_window = amtk_application_window_get_from_gtk_application_window (GTK_APPLICATION_WINDOW (gedit_window));
|
||||||
|
amtk_application_window_set_statusbar (amtk_window, GTK_STATUSBAR (gedit_window->priv->statusbar));
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_open_buttons (GeditWindow *window,
|
||||||
|
GtkMenuButton **open_recent_button)
|
||||||
|
{
|
||||||
|
GtkWidget *hbox;
|
||||||
|
GtkStyleContext *style_context;
|
||||||
|
GtkWidget *open_dialog_button;
|
||||||
|
GtkWidget *my_open_recent_button;
|
||||||
|
AmtkApplicationWindow *amtk_window;
|
||||||
|
GtkWidget *recent_menu;
|
||||||
|
|
||||||
|
/* It currently needs to be a GtkBox, not a GtkGrid, because GtkGrid and
|
||||||
|
* GTK_STYLE_CLASS_LINKED doesn't work as expected in a RTL locale.
|
||||||
|
* Probably a GtkGrid bug.
|
||||||
|
*/
|
||||||
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
style_context = gtk_widget_get_style_context (hbox);
|
||||||
|
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
|
||||||
|
|
||||||
|
open_dialog_button = gtk_button_new_with_mnemonic (_("_Open"));
|
||||||
|
gtk_widget_set_tooltip_text (open_dialog_button, _("Open a file"));
|
||||||
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (open_dialog_button), "win.open");
|
||||||
|
|
||||||
|
my_open_recent_button = gtk_menu_button_new ();
|
||||||
|
gtk_widget_set_tooltip_text (my_open_recent_button, _("Open a recently used file"));
|
||||||
|
|
||||||
|
amtk_window = amtk_application_window_get_from_gtk_application_window (GTK_APPLICATION_WINDOW (window));
|
||||||
|
recent_menu = amtk_application_window_create_open_recent_menu (amtk_window);
|
||||||
|
gtk_menu_button_set_popup (GTK_MENU_BUTTON (my_open_recent_button), recent_menu);
|
||||||
|
|
||||||
|
gtk_container_add (GTK_CONTAINER (hbox), open_dialog_button);
|
||||||
|
gtk_container_add (GTK_CONTAINER (hbox), my_open_recent_button);
|
||||||
|
gtk_widget_show_all (hbox);
|
||||||
|
|
||||||
|
if (open_recent_button != NULL)
|
||||||
|
{
|
||||||
|
*open_recent_button = GTK_MENU_BUTTON (my_open_recent_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_open_buttons (GeditWindow *window)
|
||||||
|
{
|
||||||
|
gtk_container_add_with_properties (GTK_CONTAINER (window->priv->headerbar),
|
||||||
|
create_open_buttons (window, NULL),
|
||||||
|
"position", 0, /* The first on the left. */
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_container_add_with_properties (GTK_CONTAINER (window->priv->fullscreen_headerbar),
|
||||||
|
create_open_buttons (window, &(window->priv->fullscreen_open_recent_button)),
|
||||||
|
"position", 0, /* The first on the left. */
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect (GTK_TOGGLE_BUTTON (window->priv->fullscreen_open_recent_button),
|
||||||
|
"toggled",
|
||||||
|
G_CALLBACK (on_fullscreen_toggle_button_toggled),
|
||||||
|
window);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gedit_window_init (GeditWindow *window)
|
gedit_window_init (GeditWindow *window)
|
||||||
{
|
{
|
||||||
|
@ -2709,7 +2692,6 @@ gedit_window_init (GeditWindow *window)
|
||||||
window->priv->state = GEDIT_WINDOW_STATE_NORMAL;
|
window->priv->state = GEDIT_WINDOW_STATE_NORMAL;
|
||||||
window->priv->inhibition_cookie = 0;
|
window->priv->inhibition_cookie = 0;
|
||||||
window->priv->dispose_has_run = FALSE;
|
window->priv->dispose_has_run = FALSE;
|
||||||
window->priv->fullscreen_controls = NULL;
|
|
||||||
window->priv->direct_save_uri = NULL;
|
window->priv->direct_save_uri = NULL;
|
||||||
window->priv->closed_docs_stack = NULL;
|
window->priv->closed_docs_stack = NULL;
|
||||||
window->priv->editor_settings = g_settings_new ("org.gnome.gedit.preferences.editor");
|
window->priv->editor_settings = g_settings_new ("org.gnome.gedit.preferences.editor");
|
||||||
|
@ -2723,6 +2705,8 @@ gedit_window_init (GeditWindow *window)
|
||||||
window->priv->message_bus = gedit_message_bus_new ();
|
window->priv->message_bus = gedit_message_bus_new ();
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (window));
|
gtk_widget_init_template (GTK_WIDGET (window));
|
||||||
|
init_amtk_application_window (window);
|
||||||
|
init_open_buttons (window);
|
||||||
|
|
||||||
g_action_map_add_action_entries (G_ACTION_MAP (window),
|
g_action_map_add_action_entries (G_ACTION_MAP (window),
|
||||||
win_entries,
|
win_entries,
|
||||||
|
@ -2732,32 +2716,9 @@ gedit_window_init (GeditWindow *window)
|
||||||
window->priv->window_group = gtk_window_group_new ();
|
window->priv->window_group = gtk_window_group_new ();
|
||||||
gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
|
gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
|
||||||
|
|
||||||
/* Setup file popover and file dialog */
|
setup_fullscreen_eventbox (window);
|
||||||
window->priv->open_document_popover = gtk_popover_new (window->priv->open_button);
|
|
||||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->priv->open_button),
|
|
||||||
window->priv->open_document_popover);
|
|
||||||
|
|
||||||
window->priv->open_document_selector = gedit_open_document_selector_new (window);
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (window->priv->open_document_popover),
|
|
||||||
GTK_WIDGET (window->priv->open_document_selector));
|
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (window->priv->open_document_selector));
|
|
||||||
|
|
||||||
g_signal_connect (window->priv->open_document_selector,
|
|
||||||
"file-activated",
|
|
||||||
G_CALLBACK (on_recent_chooser_item_activated),
|
|
||||||
window);
|
|
||||||
|
|
||||||
fullscreen_controls_setup (window);
|
|
||||||
sync_fullscreen_actions (window, FALSE);
|
sync_fullscreen_actions (window, FALSE);
|
||||||
|
|
||||||
g_object_bind_property (gedit_open_document_selector_get_search_entry (window->priv->open_document_selector),
|
|
||||||
"text",
|
|
||||||
gedit_open_document_selector_get_search_entry (window->priv->fullscreen_open_document_selector),
|
|
||||||
"text",
|
|
||||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
||||||
|
|
||||||
hamburger_menu = _gedit_app_get_hamburger_menu (GEDIT_APP (g_application_get_default ()));
|
hamburger_menu = _gedit_app_get_hamburger_menu (GEDIT_APP (g_application_get_default ()));
|
||||||
if (hamburger_menu)
|
if (hamburger_menu)
|
||||||
{
|
{
|
||||||
|
@ -2772,14 +2733,9 @@ gedit_window_init (GeditWindow *window)
|
||||||
gtk_widget_set_no_show_all (GTK_WIDGET (window->priv->fullscreen_gear_button), TRUE);
|
gtk_widget_set_no_show_all (GTK_WIDGET (window->priv->fullscreen_gear_button), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect (GTK_TOGGLE_BUTTON (window->priv->fullscreen_open_button),
|
|
||||||
"toggled",
|
|
||||||
G_CALLBACK (on_fullscreen_file_menu_button_toggled),
|
|
||||||
window);
|
|
||||||
|
|
||||||
g_signal_connect (GTK_TOGGLE_BUTTON (window->priv->fullscreen_gear_button),
|
g_signal_connect (GTK_TOGGLE_BUTTON (window->priv->fullscreen_gear_button),
|
||||||
"toggled",
|
"toggled",
|
||||||
G_CALLBACK (on_fullscreen_gear_button_toggled),
|
G_CALLBACK (on_fullscreen_toggle_button_toggled),
|
||||||
window);
|
window);
|
||||||
|
|
||||||
/* Setup status bar */
|
/* Setup status bar */
|
||||||
|
@ -2893,12 +2849,6 @@ gedit_window_init (GeditWindow *window)
|
||||||
G_CALLBACK (window_unrealized),
|
G_CALLBACK (window_unrealized),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Check if the window is active for fullscreen */
|
|
||||||
g_signal_connect (window,
|
|
||||||
"notify::is-active",
|
|
||||||
G_CALLBACK (check_window_is_active),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gedit_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
gedit_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
||||||
|
|
||||||
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
|
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
|
||||||
|
|
|
@ -28,12 +28,13 @@
|
||||||
# include "gedit-app-win32.h"
|
# include "gedit-app-win32.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
#include "gedit-dirs.h"
|
#include "gedit-dirs.h"
|
||||||
#include "gedit-debug.h"
|
#include "gedit-debug.h"
|
||||||
|
#include "gedit-factory.h"
|
||||||
#include "gedit-settings.h"
|
#include "gedit-settings.h"
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
@ -116,6 +117,7 @@ int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GType type;
|
GType type;
|
||||||
|
GeditFactory *factory;
|
||||||
GeditApp *app;
|
GeditApp *app;
|
||||||
gint status;
|
gint status;
|
||||||
|
|
||||||
|
@ -138,6 +140,9 @@ main (int argc, char *argv[])
|
||||||
gedit_dirs_init ();
|
gedit_dirs_init ();
|
||||||
|
|
||||||
setup_i18n ();
|
setup_i18n ();
|
||||||
|
tepl_init ();
|
||||||
|
factory = gedit_factory_new ();
|
||||||
|
tepl_abstract_factory_set_singleton (TEPL_ABSTRACT_FACTORY (factory));
|
||||||
|
|
||||||
app = g_object_new (type,
|
app = g_object_new (type,
|
||||||
"application-id", "org.gnome.gedit",
|
"application-id", "org.gnome.gedit",
|
||||||
|
@ -162,6 +167,7 @@ main (int argc, char *argv[])
|
||||||
G_OBJECT (app)->ref_count);
|
G_OBJECT (app)->ref_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tepl_finalize ();
|
||||||
gedit_dirs_shutdown ();
|
gedit_dirs_shutdown ();
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
|
|
@ -8,7 +8,6 @@ libgedit_public_headers = [
|
||||||
'gedit-menu-extension.h',
|
'gedit-menu-extension.h',
|
||||||
'gedit-message-bus.h',
|
'gedit-message-bus.h',
|
||||||
'gedit-message.h',
|
'gedit-message.h',
|
||||||
'gedit-progress-info-bar.h',
|
|
||||||
'gedit-statusbar.h',
|
'gedit-statusbar.h',
|
||||||
'gedit-tab.h',
|
'gedit-tab.h',
|
||||||
'gedit-utils.h',
|
'gedit-utils.h',
|
||||||
|
@ -28,13 +27,11 @@ libgedit_public_sources = [
|
||||||
'gedit-menu-extension.c',
|
'gedit-menu-extension.c',
|
||||||
'gedit-message-bus.c',
|
'gedit-message-bus.c',
|
||||||
'gedit-message.c',
|
'gedit-message.c',
|
||||||
'gedit-progress-info-bar.c',
|
|
||||||
'gedit-statusbar.c',
|
'gedit-statusbar.c',
|
||||||
'gedit-tab.c',
|
'gedit-tab.c',
|
||||||
'gedit-utils.c',
|
'gedit-utils.c',
|
||||||
'gedit-view-activatable.c',
|
'gedit-view-activatable.c',
|
||||||
'gedit-view.c',
|
'gedit-view.c',
|
||||||
'gedit-view-centering.c',
|
|
||||||
'gedit-window-activatable.c',
|
'gedit-window-activatable.c',
|
||||||
'gedit-window.c',
|
'gedit-window.c',
|
||||||
]
|
]
|
||||||
|
@ -48,37 +45,30 @@ libgedit_private_headers = [
|
||||||
'gedit-documents-panel.h',
|
'gedit-documents-panel.h',
|
||||||
'gedit-encoding-items.h',
|
'gedit-encoding-items.h',
|
||||||
'gedit-encodings-dialog.h',
|
'gedit-encodings-dialog.h',
|
||||||
|
'gedit-factory.h',
|
||||||
'gedit-file-chooser-dialog-gtk.h',
|
'gedit-file-chooser-dialog-gtk.h',
|
||||||
'gedit-file-chooser-dialog.h',
|
'gedit-file-chooser-dialog.h',
|
||||||
'gedit-file-chooser.h',
|
'gedit-file-chooser.h',
|
||||||
'gedit-file-chooser-open-dialog.h',
|
'gedit-file-chooser-open-dialog.h',
|
||||||
'gedit-file-chooser-open.h',
|
'gedit-file-chooser-open.h',
|
||||||
'gedit-file-chooser-open-native.h',
|
'gedit-file-chooser-open-native.h',
|
||||||
'gedit-highlight-mode-dialog.h',
|
|
||||||
'gedit-highlight-mode-selector.h',
|
|
||||||
'gedit-history-entry.h',
|
'gedit-history-entry.h',
|
||||||
'gedit-io-error-info-bar.h',
|
'gedit-io-error-info-bar.h',
|
||||||
'gedit-menu-stack-switcher.h',
|
'gedit-menu-stack-switcher.h',
|
||||||
'gedit-metadata-manager.h',
|
|
||||||
'gedit-multi-notebook.h',
|
'gedit-multi-notebook.h',
|
||||||
'gedit-notebook.h',
|
'gedit-notebook.h',
|
||||||
'gedit-notebook-popup-menu.h',
|
'gedit-notebook-popup-menu.h',
|
||||||
'gedit-notebook-stack-switcher.h',
|
'gedit-notebook-stack-switcher.h',
|
||||||
'gedit-open-document-selector.h',
|
|
||||||
'gedit-open-document-selector-helper.h',
|
|
||||||
'gedit-open-document-selector-store.h',
|
|
||||||
'gedit-pango.h',
|
|
||||||
'gedit-plugins-engine.h',
|
'gedit-plugins-engine.h',
|
||||||
'gedit-preferences-dialog.h',
|
'gedit-preferences-dialog.h',
|
||||||
'gedit-print-job.h',
|
'gedit-print-job.h',
|
||||||
'gedit-print-preview.h',
|
'gedit-print-preview.h',
|
||||||
'gedit-recent.h',
|
'gedit-recent.h',
|
||||||
|
'gedit-recent-osx.h',
|
||||||
'gedit-replace-dialog.h',
|
'gedit-replace-dialog.h',
|
||||||
'gedit-settings.h',
|
'gedit-settings.h',
|
||||||
'gedit-status-menu-button.h',
|
'gedit-status-menu-button.h',
|
||||||
'gedit-tab-label.h',
|
'gedit-tab-label.h',
|
||||||
'gedit-tab-private.h',
|
|
||||||
'gedit-view-centering.h',
|
|
||||||
'gedit-view-frame.h',
|
'gedit-view-frame.h',
|
||||||
'gedit-window-private.h',
|
'gedit-window-private.h',
|
||||||
]
|
]
|
||||||
|
@ -95,26 +85,20 @@ libgedit_private_sources = [
|
||||||
'gedit-documents-panel.c',
|
'gedit-documents-panel.c',
|
||||||
'gedit-encoding-items.c',
|
'gedit-encoding-items.c',
|
||||||
'gedit-encodings-dialog.c',
|
'gedit-encodings-dialog.c',
|
||||||
|
'gedit-factory.c',
|
||||||
'gedit-file-chooser.c',
|
'gedit-file-chooser.c',
|
||||||
'gedit-file-chooser-dialog.c',
|
'gedit-file-chooser-dialog.c',
|
||||||
'gedit-file-chooser-dialog-gtk.c',
|
'gedit-file-chooser-dialog-gtk.c',
|
||||||
'gedit-file-chooser-open.c',
|
'gedit-file-chooser-open.c',
|
||||||
'gedit-file-chooser-open-dialog.c',
|
'gedit-file-chooser-open-dialog.c',
|
||||||
'gedit-file-chooser-open-native.c',
|
'gedit-file-chooser-open-native.c',
|
||||||
'gedit-highlight-mode-dialog.c',
|
|
||||||
'gedit-highlight-mode-selector.c',
|
|
||||||
'gedit-history-entry.c',
|
'gedit-history-entry.c',
|
||||||
'gedit-io-error-info-bar.c',
|
'gedit-io-error-info-bar.c',
|
||||||
'gedit-menu-stack-switcher.c',
|
'gedit-menu-stack-switcher.c',
|
||||||
'gedit-metadata-manager.c',
|
|
||||||
'gedit-multi-notebook.c',
|
'gedit-multi-notebook.c',
|
||||||
'gedit-notebook.c',
|
'gedit-notebook.c',
|
||||||
'gedit-notebook-popup-menu.c',
|
'gedit-notebook-popup-menu.c',
|
||||||
'gedit-notebook-stack-switcher.c',
|
'gedit-notebook-stack-switcher.c',
|
||||||
'gedit-open-document-selector.c',
|
|
||||||
'gedit-open-document-selector-helper.c',
|
|
||||||
'gedit-open-document-selector-store.c',
|
|
||||||
'gedit-pango.c',
|
|
||||||
'gedit-plugins-engine.c',
|
'gedit-plugins-engine.c',
|
||||||
'gedit-preferences-dialog.c',
|
'gedit-preferences-dialog.c',
|
||||||
'gedit-print-job.c',
|
'gedit-print-job.c',
|
||||||
|
@ -133,12 +117,12 @@ libgedit_link_args = []
|
||||||
libgedit_deps = [
|
libgedit_deps = [
|
||||||
deps_basic_list,
|
deps_basic_list,
|
||||||
libgd_dep,
|
libgd_dep,
|
||||||
libxml_dep,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
if host_machine.system() == 'darwin'
|
||||||
libgedit_private_sources += [
|
libgedit_private_sources += [
|
||||||
'gedit-app-osx.m',
|
'gedit-app-osx.m',
|
||||||
|
'gedit-recent-osx.c',
|
||||||
]
|
]
|
||||||
libgedit_c_args += [
|
libgedit_c_args += [
|
||||||
'-DOS_OSX=1',
|
'-DOS_OSX=1',
|
||||||
|
@ -213,12 +197,10 @@ libgedit_gir = gnome.generate_gir(
|
||||||
install_dir_typelib: get_option('libdir') / 'gedit/girepository-1.0',
|
install_dir_typelib: get_option('libdir') / 'gedit/girepository-1.0',
|
||||||
)
|
)
|
||||||
|
|
||||||
if get_option('python')
|
python3.install_sources(
|
||||||
python3.install_sources(
|
'Gedit.py',
|
||||||
'Gedit.py',
|
subdir: 'gi/overrides',
|
||||||
subdir: 'gi/overrides',
|
)
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Vala API
|
# Vala API
|
||||||
libgedit_vapi = gnome.generate_vapi(
|
libgedit_vapi = gnome.generate_vapi(
|
||||||
|
|
|
@ -14,18 +14,6 @@
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gedit-map-frame:dir(ltr) border {
|
|
||||||
border-width: 0 0 0 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gedit-map-frame:dir(rtl) border {
|
|
||||||
border-width: 0 1px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.open-document-selector-treeview {
|
|
||||||
padding: 3px 6px 3px 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
statusbar frame {
|
statusbar frame {
|
||||||
border: none;
|
border: none;
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
|
|
|
@ -1,28 +1,3 @@
|
||||||
.open-document-selector-treeview:hover {
|
|
||||||
background-color: alpha(@theme_fg_color, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.open-document-selector-treeview:selected:hover {
|
|
||||||
background-color: @theme_selected_bg_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only normal state is handle */
|
|
||||||
.open-document-selector-name-label {
|
|
||||||
color: @theme_fg_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only normal state is handle */
|
|
||||||
.open-document-selector-path-label {
|
|
||||||
color: @theme_unfocused_fg_color;
|
|
||||||
font-size: smaller;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only normal state is handle */
|
|
||||||
.open-document-selector-match {
|
|
||||||
color: shade (@theme_fg_color, 0.6);
|
|
||||||
background-color: alpha(@warning_color, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gedit-document-panel {
|
.gedit-document-panel {
|
||||||
background-color: @sidebar_bg;
|
background-color: @sidebar_bg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,15 @@
|
||||||
<gresource prefix="/org/gnome/gedit">
|
<gresource prefix="/org/gnome/gedit">
|
||||||
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
|
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
|
||||||
<file preprocess="xml-stripblanks">gtk/menus-common.ui</file>
|
<file preprocess="xml-stripblanks">gtk/menus-common.ui</file>
|
||||||
<file preprocess="to-pixdata">pixmaps/gedit-logo.png</file>
|
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-encodings-dialog.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-encodings-dialog.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-preferences-dialog.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-preferences-dialog.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-replace-dialog.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-replace-dialog.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-print-preview.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-print-preview.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-print-preferences.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-print-preferences.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-progress-info-bar.ui</file>
|
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-status-menu-button.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-status-menu-button.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-tab-label.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-tab-label.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-view-frame.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-view-frame.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-highlight-mode-dialog.ui</file>
|
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-highlight-mode-selector.ui</file>
|
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-window.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-window.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-open-document-selector.ui</file>
|
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-shortcuts.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-shortcuts.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/gedit-statusbar.ui</file>
|
<file preprocess="xml-stripblanks">ui/gedit-statusbar.ui</file>
|
||||||
<file>css/gedit-style.css</file>
|
<file>css/gedit-style.css</file>
|
||||||
|
|
|
@ -391,7 +391,7 @@
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_About gedit</attribute>
|
<attribute name="label" translatable="yes">_About Text Editor</attribute>
|
||||||
<attribute name="hidden-when">macos-menubar</attribute>
|
<attribute name="hidden-when">macos-menubar</attribute>
|
||||||
<attribute name="action">app.about</attribute>
|
<attribute name="action">app.about</attribute>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
<attribute name="action">app.help</attribute>
|
<attribute name="action">app.help</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_About gedit</attribute>
|
<attribute name="label" translatable="yes">_About Text Editor</attribute>
|
||||||
<attribute name="action">app.about</attribute>
|
<attribute name="action">app.about</attribute>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
<attribute name="action">app.help</attribute>
|
<attribute name="action">app.help</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_About gedit</attribute>
|
<attribute name="label" translatable="yes">_About Text Editor</attribute>
|
||||||
<attribute name="action">app.about</attribute>
|
<attribute name="action">app.about</attribute>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
@ -1,87 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<!-- interface-requires gtk+ 3.8 -->
|
|
||||||
<template class="GeditHighlightModeDialog" parent="GtkDialog">
|
|
||||||
<property name="width_request">300</property>
|
|
||||||
<property name="height_request">400</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="border_width">5</property>
|
|
||||||
<property name="title" translatable="yes">Highlight Mode</property>
|
|
||||||
<property name="type_hint">dialog</property>
|
|
||||||
<property name="modal">True</property>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox" id="dialog-vbox1">
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="layout_style">end</property>
|
|
||||||
<property name="border_width">5</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="cancel_button">
|
|
||||||
<property name="label" translatable="yes">_Cancel</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="ok_button">
|
|
||||||
<property name="label" translatable="yes">_Select</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="can_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GeditHighlightModeSelector" id="selector">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<action-widgets>
|
|
||||||
<action-widget response="-6">cancel_button</action-widget>
|
|
||||||
<action-widget response="-5">ok_button</action-widget>
|
|
||||||
</action-widgets>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
|
@ -1,83 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<!-- interface-requires gtk+ 3.8 -->
|
|
||||||
<object class="GtkListStore" id="liststore">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name name -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
<!-- column-name lang -->
|
|
||||||
<column type="GtkSourceLanguage"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
<object class="GtkTreeModelFilter" id="treemodelfilter">
|
|
||||||
<property name="child_model">liststore</property>
|
|
||||||
</object>
|
|
||||||
<template class="GeditHighlightModeSelector" parent="GtkGrid">
|
|
||||||
<property name="width_request">300</property>
|
|
||||||
<property name="height_request">400</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="row_spacing">3</property>
|
|
||||||
<property name="border_width">6</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSearchEntry" id="entry">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">True</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="activates_default">True</property>
|
|
||||||
<property name="placeholder_text" translatable="yes">Search highlight mode…</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeView" id="treeview">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<property name="model">treemodelfilter</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="headers_clickable">False</property>
|
|
||||||
<property name="enable_search">False</property>
|
|
||||||
<child internal-child="selection">
|
|
||||||
<object class="GtkTreeSelection" id="treeview_selection"/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeViewColumn" id="treeviewcolumn">
|
|
||||||
<child>
|
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext"/>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="text">0</attribute>
|
|
||||||
</attributes>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="width">1</property>
|
|
||||||
<property name="height">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
|
@ -1,115 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<requires lib="gtk+" version="3.10"/>
|
|
||||||
<template class="GeditOpenDocumentSelector" parent="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="border_width">9</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSearchEntry" id="search_entry">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="primary_icon_name">edit-find-symbolic</property>
|
|
||||||
<property name="primary_icon_activatable">False</property>
|
|
||||||
<property name="primary_icon_sensitive">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkFrame" id="placeholder_box">
|
|
||||||
<property name="visible">False</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="placeholder_inner_box">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="halign">center</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="placeholder_image">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon_name">edit-find-symbolic</property>
|
|
||||||
<property name="pixel_size">64</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="placeholder_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">No results</property>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow" id="scrolled_window">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="hscrollbar_policy">never</property>
|
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTreeView" id="treeview">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="headers_visible">False</property>
|
|
||||||
<property name="fixed_height_mode">True</property>
|
|
||||||
<property name="enable_grid_lines">horizontal</property>
|
|
||||||
<property name="enable_search">False</property>
|
|
||||||
<property name="activate_on_single_click">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="open_button">
|
|
||||||
<property name="label" translatable="yes">Other _Documents…</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Open another file</property>
|
|
||||||
<property name="margin-top">6</property>
|
|
||||||
<property name="action_name">win.open</property>
|
|
||||||
<style>
|
|
||||||
<class name="text-button"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
|
@ -105,21 +105,6 @@
|
||||||
<property name="width">2</property>
|
<property name="width">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="display_overview_map_checkbutton">
|
|
||||||
<property name="label" translatable="yes">Display _overview map</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="width">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="display_grid_checkbutton">
|
<object class="GtkCheckButton" id="display_grid_checkbutton">
|
||||||
<property name="label" translatable="yes">Display _grid pattern</property>
|
<property name="label" translatable="yes">Display _grid pattern</property>
|
||||||
|
@ -131,7 +116,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="width">2</property>
|
<property name="width">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -645,19 +630,8 @@
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="schemes_scrolled_window">
|
<object class="TeplStyleSchemeChooserWidget" id="schemes_list">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<property name="shadow_type">etched-in</property>
|
|
||||||
<property name="min_content_height">200</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSourceStyleSchemeChooserWidget" id="schemes_list">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<!-- interface-requires gtk+ 3.6 -->
|
|
||||||
<template class="GeditProgressInfoBar" parent="GtkInfoBar">
|
|
||||||
<property name="app_paintable">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="message_type">other</property>
|
|
||||||
<child internal-child="content_area">
|
|
||||||
<object class="GtkBox" id="infobar-content_area1">
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="box1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="spacing">4</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="image">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="icon-size">2</property>
|
|
||||||
<property name="icon_name">image-missing</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="padding">4</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="label">label</property>
|
|
||||||
<property name="use_markup">True</property>
|
|
||||||
<property name="ellipsize">end</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkProgressBar" id="progress">
|
|
||||||
<property name="height_request">15</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox" id="infobar-action_area1">
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
|
@ -7,33 +7,15 @@
|
||||||
<property name="has_focus">False</property>
|
<property name="has_focus">False</property>
|
||||||
<property name="is_focus">False</property>
|
<property name="is_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="overlay_scrolling">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GeditViewCentering" id="view_centering">
|
<object class="GeditView" id="view">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="vexpand">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GeditView" id="view">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkFrame" id="map_frame">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<style>
|
|
||||||
<class name="gedit-map-frame"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSourceMap" id="map">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="view">view</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -27,50 +27,6 @@
|
||||||
<object class="GtkHeaderBar" id="headerbar">
|
<object class="GtkHeaderBar" id="headerbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="show_close_button">True</property>
|
<property name="show_close_button">True</property>
|
||||||
<child>
|
|
||||||
<object class="GtkMenuButton" id="open_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Open a file</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="use_popover">True</property>
|
|
||||||
<style>
|
|
||||||
<class name="text-button"/>
|
|
||||||
<class name="image-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="open_button_box">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="open_button_name">
|
|
||||||
<property name="label" translatable="yes">_Open</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="valign">baseline</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="open_button_arrow">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="valign">baseline</property>
|
|
||||||
<property name="icon_name">pan-down-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child internal-child="accessible">
|
|
||||||
<object class="AtkObject" id="open_button_a11y">
|
|
||||||
<property name="accessible-name" translatable="yes">Open</property>
|
|
||||||
<property name="accessible-description" translatable="yes">Open a file</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">start</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="new_button">
|
<object class="GtkButton" id="new_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -354,7 +310,7 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkRevealer" id="fullscreen_controls">
|
<object class="GtkRevealer" id="fullscreen_revealer">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="reveal_child">False</property>
|
<property name="reveal_child">False</property>
|
||||||
|
@ -362,47 +318,6 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHeaderBar" id="fullscreen_headerbar">
|
<object class="GtkHeaderBar" id="fullscreen_headerbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
|
||||||
<object class="GtkMenuButton" id="fullscreen_open_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Open a file dialog</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="use_popover">True</property>
|
|
||||||
<style>
|
|
||||||
<class name="text-button"/>
|
|
||||||
<class name="image-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox" id="fullscreen_open_button_box">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="has_focus">False</property>
|
|
||||||
<property name="is_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="fullscreen_open_button_name">
|
|
||||||
<property name="label" translatable="yes">Open</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="fullscreen_open_button_arrow">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon_name">pan-down-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child internal-child="accessible">
|
|
||||||
<object class="AtkObject" id="fullscreen_open_button_a11y">
|
|
||||||
<property name="accessible-name" translatable="yes">Open</property>
|
|
||||||
<property name="accessible-description" translatable="yes">Open a file</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">start</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="fullscreen_new_button">
|
<object class="GtkButton" id="fullscreen_new_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
BIN
help/C/figures/gedit-icon.png
Normal file
BIN
help/C/figures/gedit-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 815 B |
|
@ -1,376 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
viewBox="0 0 128 128"
|
|
||||||
style="display:inline;enable-background:new"
|
|
||||||
version="1.0"
|
|
||||||
id="svg11300"
|
|
||||||
height="128"
|
|
||||||
width="128">
|
|
||||||
<title
|
|
||||||
id="title4162">Adwaita Icon Template</title>
|
|
||||||
<defs
|
|
||||||
id="defs3">
|
|
||||||
<linearGradient
|
|
||||||
id="linearGradient1038">
|
|
||||||
<stop
|
|
||||||
style="stop-color:#c0bfbc;stop-opacity:1"
|
|
||||||
offset="0"
|
|
||||||
id="stop1026" />
|
|
||||||
<stop
|
|
||||||
id="stop1028"
|
|
||||||
offset="0.04545454"
|
|
||||||
style="stop-color:#ffffff;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
id="stop1030"
|
|
||||||
offset="0.09090909"
|
|
||||||
style="stop-color:#deddda;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
id="stop1032"
|
|
||||||
offset="0.90909088"
|
|
||||||
style="stop-color:#deddda;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
style="stop-color:#ffffff;stop-opacity:1"
|
|
||||||
offset="0.95454544"
|
|
||||||
id="stop1034" />
|
|
||||||
<stop
|
|
||||||
style="stop-color:#c0bfbc;stop-opacity:1"
|
|
||||||
offset="1"
|
|
||||||
id="stop1036" />
|
|
||||||
</linearGradient>
|
|
||||||
<clipPath
|
|
||||||
id="clipPath2213"
|
|
||||||
clipPathUnits="userSpaceOnUse">
|
|
||||||
<rect
|
|
||||||
ry="8"
|
|
||||||
rx="8"
|
|
||||||
y="-188"
|
|
||||||
x="160"
|
|
||||||
height="56"
|
|
||||||
width="16"
|
|
||||||
id="rect2215"
|
|
||||||
style="display:inline;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
</clipPath>
|
|
||||||
<linearGradient
|
|
||||||
id="linearGradient1005">
|
|
||||||
<stop
|
|
||||||
style="stop-color:#d0bb8e;stop-opacity:1"
|
|
||||||
offset="0"
|
|
||||||
id="stop1001" />
|
|
||||||
<stop
|
|
||||||
style="stop-color:#ffffff;stop-opacity:1"
|
|
||||||
offset="1"
|
|
||||||
id="stop1003" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
id="linearGradient1351-3">
|
|
||||||
<stop
|
|
||||||
id="stop1347"
|
|
||||||
offset="0"
|
|
||||||
style="stop-color:#d5d3cf;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
id="stop1349-6"
|
|
||||||
offset="1"
|
|
||||||
style="stop-color:#ffffff;stop-opacity:1" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
gradientTransform="translate(-135.99999)"
|
|
||||||
gradientUnits="userSpaceOnUse"
|
|
||||||
y2="-276"
|
|
||||||
x2="115.99999"
|
|
||||||
y1="-276"
|
|
||||||
x1="27.99999"
|
|
||||||
id="linearGradient1159"
|
|
||||||
xlink:href="#linearGradient1038" />
|
|
||||||
<linearGradient
|
|
||||||
gradientTransform="matrix(0.07621224,-0.44419723,0.44419725,-0.07621223,77.725794,331.83807)"
|
|
||||||
y2="-127.39915"
|
|
||||||
x2="158.51802"
|
|
||||||
y1="-97.698288"
|
|
||||||
x1="128.81717"
|
|
||||||
gradientUnits="userSpaceOnUse"
|
|
||||||
id="linearGradient1103"
|
|
||||||
xlink:href="#linearGradient1005" />
|
|
||||||
<clipPath
|
|
||||||
id="clipPath1609-7"
|
|
||||||
clipPathUnits="userSpaceOnUse">
|
|
||||||
<path
|
|
||||||
style="fill:#e74747;stroke:none;stroke-width:0.25px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
d="m 252,116 28,-28 v -8 h -36 v 36 z"
|
|
||||||
id="path1611-5" />
|
|
||||||
</clipPath>
|
|
||||||
<linearGradient
|
|
||||||
y2="72"
|
|
||||||
x2="340"
|
|
||||||
y1="76"
|
|
||||||
x1="344"
|
|
||||||
gradientTransform="matrix(0.25,0,0,0.25,180,83)"
|
|
||||||
gradientUnits="userSpaceOnUse"
|
|
||||||
id="linearGradient1130"
|
|
||||||
xlink:href="#linearGradient1351-3" />
|
|
||||||
<clipPath
|
|
||||||
id="clipPath1062"
|
|
||||||
clipPathUnits="userSpaceOnUse">
|
|
||||||
<rect
|
|
||||||
transform="scale(-1)"
|
|
||||||
style="opacity:1;vector-effect:none;fill:#f6f5f4;fill-opacity:1;stroke:none;stroke-width:13.71876526;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
|
||||||
id="rect1064"
|
|
||||||
width="88"
|
|
||||||
height="108"
|
|
||||||
x="-108"
|
|
||||||
y="-116"
|
|
||||||
rx="8"
|
|
||||||
ry="8"
|
|
||||||
clip-path="none" />
|
|
||||||
</clipPath>
|
|
||||||
</defs>
|
|
||||||
<metadata
|
|
||||||
id="metadata4">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:creator>
|
|
||||||
<cc:Agent>
|
|
||||||
<dc:title>GNOME Design Team</dc:title>
|
|
||||||
</cc:Agent>
|
|
||||||
</dc:creator>
|
|
||||||
<dc:source />
|
|
||||||
<cc:license
|
|
||||||
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
|
||||||
<dc:title>Adwaita Icon Template</dc:title>
|
|
||||||
<dc:subject>
|
|
||||||
<rdf:Bag />
|
|
||||||
</dc:subject>
|
|
||||||
<dc:date />
|
|
||||||
<dc:rights>
|
|
||||||
<cc:Agent>
|
|
||||||
<dc:title />
|
|
||||||
</cc:Agent>
|
|
||||||
</dc:rights>
|
|
||||||
<dc:publisher>
|
|
||||||
<cc:Agent>
|
|
||||||
<dc:title />
|
|
||||||
</cc:Agent>
|
|
||||||
</dc:publisher>
|
|
||||||
<dc:identifier />
|
|
||||||
<dc:relation />
|
|
||||||
<dc:language />
|
|
||||||
<dc:coverage />
|
|
||||||
<dc:description />
|
|
||||||
<dc:contributor>
|
|
||||||
<cc:Agent>
|
|
||||||
<dc:title />
|
|
||||||
</cc:Agent>
|
|
||||||
</dc:contributor>
|
|
||||||
</cc:Work>
|
|
||||||
<cc:License
|
|
||||||
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
|
||||||
<cc:requires
|
|
||||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
|
||||||
<cc:requires
|
|
||||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
|
||||||
<cc:permits
|
|
||||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
|
||||||
<cc:requires
|
|
||||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
|
||||||
</cc:License>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
transform="translate(0,-172)"
|
|
||||||
style="display:inline"
|
|
||||||
id="layer1">
|
|
||||||
<g
|
|
||||||
style="display:none"
|
|
||||||
id="layer2">
|
|
||||||
<g
|
|
||||||
id="g9211"
|
|
||||||
style="display:inline;enable-background:new">
|
|
||||||
<rect
|
|
||||||
style="display:inline;overflow:visible;visibility:visible;fill:#f0f0f0;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;enable-background:accumulate"
|
|
||||||
id="rect13805"
|
|
||||||
width="128"
|
|
||||||
height="128"
|
|
||||||
x="9.2651362e-08"
|
|
||||||
y="172" />
|
|
||||||
<circle
|
|
||||||
cx="64.000031"
|
|
||||||
cy="236"
|
|
||||||
r="59.504131"
|
|
||||||
id="circle2892"
|
|
||||||
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
<rect
|
|
||||||
ry="7.9292889"
|
|
||||||
rx="8.701004"
|
|
||||||
y="180.49496"
|
|
||||||
x="20.495007"
|
|
||||||
height="111.01005"
|
|
||||||
width="87.009987"
|
|
||||||
id="rect2894"
|
|
||||||
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
<rect
|
|
||||||
ry="7.9238095"
|
|
||||||
rx="7.9238095"
|
|
||||||
y="184.49524"
|
|
||||||
x="12.495266"
|
|
||||||
height="103.00952"
|
|
||||||
width="103.00952"
|
|
||||||
id="rect2896"
|
|
||||||
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
<rect
|
|
||||||
ry="8.701005"
|
|
||||||
rx="7.9292889"
|
|
||||||
y="200.49496"
|
|
||||||
x="8.4950066"
|
|
||||||
height="87.010048"
|
|
||||||
width="111.01004"
|
|
||||||
id="rect2898"
|
|
||||||
style="display:inline;opacity:0.1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.99000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.99000001, 0.99000001;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
<path
|
|
||||||
id="path2900"
|
|
||||||
d="M 2.6203015e-5,288.99999 H 128.00003"
|
|
||||||
style="display:inline;fill:none;stroke:#62a0ea;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
style="display:inline"
|
|
||||||
id="layer9">
|
|
||||||
<rect
|
|
||||||
clip-path="none"
|
|
||||||
ry="8"
|
|
||||||
rx="8"
|
|
||||||
y="-294"
|
|
||||||
x="-108"
|
|
||||||
height="30.25"
|
|
||||||
width="88"
|
|
||||||
id="rect1167"
|
|
||||||
style="opacity:1;vector-effect:none;fill:#1a5fb4;fill-opacity:1;stroke:none;stroke-width:13.71876526;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
|
||||||
transform="scale(-1)" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-374,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8005"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-424,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8015"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-414,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8025"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-404,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8035"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-394,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8045"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<g
|
|
||||||
transform="matrix(0.25,0,0,0.25,-384,202.04808)"
|
|
||||||
clip-path="url(#clipPath2213)"
|
|
||||||
id="g8055"
|
|
||||||
style="display:inline;enable-background:new" />
|
|
||||||
<rect
|
|
||||||
transform="scale(-1)"
|
|
||||||
style="opacity:1;vector-effect:none;fill:url(#linearGradient1159);fill-opacity:1;stroke:none;stroke-width:13.71876526;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
|
||||||
id="rect1151"
|
|
||||||
width="88"
|
|
||||||
height="40"
|
|
||||||
x="-108"
|
|
||||||
y="-292"
|
|
||||||
rx="8"
|
|
||||||
ry="8"
|
|
||||||
clip-path="none" />
|
|
||||||
<rect
|
|
||||||
clip-path="none"
|
|
||||||
ry="8"
|
|
||||||
rx="8"
|
|
||||||
y="-288"
|
|
||||||
x="-108"
|
|
||||||
height="108"
|
|
||||||
width="88"
|
|
||||||
id="rect1161"
|
|
||||||
style="opacity:1;vector-effect:none;fill:#f6f5f4;fill-opacity:1;stroke:none;stroke-width:13.71876526;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
|
||||||
transform="scale(-1)" />
|
|
||||||
<g
|
|
||||||
transform="translate(-4,2)"
|
|
||||||
id="g1153">
|
|
||||||
<path
|
|
||||||
style="display:inline;opacity:1;fill:#d5d3cf;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new"
|
|
||||||
d="m 32,188 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z m 8,0 c -1.10457,0 -2,0.89543 -2,2 0,1.10457 0.89543,2 2,2 1.10457,0 2,-0.89543 2,-2 0,-1.10457 -0.89543,-2 -2,-2 z"
|
|
||||||
id="path950-3-7" />
|
|
||||||
<circle
|
|
||||||
r="2"
|
|
||||||
cy="190"
|
|
||||||
cx="-104"
|
|
||||||
id="path1148"
|
|
||||||
style="opacity:1;vector-effect:none;fill:#d5d3cf;fill-opacity:1;stroke:none;stroke-width:16;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
|
||||||
transform="scale(-1,1)" />
|
|
||||||
<path
|
|
||||||
d="m 112,192 a 2,2 0 0 1 -1.73205,-1 2,2 0 0 1 0,-2 A 2,2 0 0 1 112,188"
|
|
||||||
style="opacity:1;vector-effect:none;fill:#d5d3cf;fill-opacity:1;stroke:none;stroke-width:16;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
|
||||||
id="circle16770" />
|
|
||||||
<path
|
|
||||||
transform="scale(-1,1)"
|
|
||||||
d="m -24,192 a 2,2 0 0 1 -1.732051,-1 2,2 0 0 1 0,-2 A 2,2 0 0 1 -24,188"
|
|
||||||
style="display:inline;opacity:1;vector-effect:none;fill:#d5d3cf;fill-opacity:1;stroke:none;stroke-width:16;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new"
|
|
||||||
id="circle16770-3" />
|
|
||||||
</g>
|
|
||||||
<rect
|
|
||||||
style="display:inline;opacity:1;fill:url(#linearGradient1130);fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
|
|
||||||
id="rect1056-3"
|
|
||||||
width="36"
|
|
||||||
height="36"
|
|
||||||
x="252"
|
|
||||||
y="88"
|
|
||||||
rx="11.2"
|
|
||||||
ry="11.2"
|
|
||||||
transform="matrix(0,0.71428571,0.71428571,0,25.142858,88.000008)"
|
|
||||||
clip-path="url(#clipPath1609-7)" />
|
|
||||||
<path
|
|
||||||
clip-path="url(#clipPath1062)"
|
|
||||||
id="path1047"
|
|
||||||
transform="translate(0,172)"
|
|
||||||
d="M 100,16 32,84 v 20 h 22 l 68,-68 -7.86719,-5.761719 -0.0742,-0.07227 -8.22461,-8.22461 z"
|
|
||||||
style="opacity:0.2;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:12.48982716;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal" />
|
|
||||||
<path
|
|
||||||
style="opacity:1;vector-effect:none;fill:url(#linearGradient1103);fill-opacity:1;stroke:none;stroke-width:12.48982716;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
|
||||||
d="m 32,276 v -20 l 20,20 z"
|
|
||||||
id="path1038" />
|
|
||||||
<path
|
|
||||||
id="path1042"
|
|
||||||
d="m 31.999996,276 4e-6,-8 8,8 z"
|
|
||||||
style="display:inline;opacity:1;vector-effect:none;fill:#424048;fill-opacity:1;stroke:none;stroke-width:12.48982716;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
|
||||||
<path
|
|
||||||
id="path1044"
|
|
||||||
d="m 50,274 -16,-16 67.94696,-67.94695 16,16 z"
|
|
||||||
style="display:inline;fill:#f6d32d;fill-opacity:1;stroke:none;stroke-width:0.50643784px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new" />
|
|
||||||
<path
|
|
||||||
id="path1046"
|
|
||||||
d="M 37.887772,261.88776 32,256 l 68.00001,-67.99999 5.83472,5.9408 z"
|
|
||||||
style="display:inline;opacity:1;fill:#f9f06b;fill-opacity:1;stroke:none;stroke-width:0.3581056px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new" />
|
|
||||||
<path
|
|
||||||
id="path1048"
|
|
||||||
d="M 46.112246,270.11223 52,276 l 68,-68 -5.9408,-5.83472 z"
|
|
||||||
style="display:inline;opacity:1;fill:#e5a50a;fill-opacity:1;stroke:none;stroke-width:0.3581056px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 17 KiB |
|
@ -1,74 +0,0 @@
|
||||||
<page xmlns="http://projectmallard.org/1.0/"
|
|
||||||
xmlns:its="http://www.w3.org/2005/11/its"
|
|
||||||
type="topic" style="task"
|
|
||||||
id="gedit-character-encodings">
|
|
||||||
|
|
||||||
<info>
|
|
||||||
<link type="guide" xref="index#gedit-working-with-files" group="last"/>
|
|
||||||
<link type="seealso" xref="gedit-open-files"/>
|
|
||||||
<desc>When text and characters do not look as expected.</desc>
|
|
||||||
<revision pkgversion="3.38" date="2020-11-16" status="draft"/>
|
|
||||||
<credit type="author">
|
|
||||||
<name>Andre Klapper</name>
|
|
||||||
<email its:translate="no">ak-47@gmx.net</email>
|
|
||||||
<year>2020</year>
|
|
||||||
</credit>
|
|
||||||
<credit type="author">
|
|
||||||
<name>Shaun McCance</name>
|
|
||||||
<email its:translate="no">shaunm@gnome.org</email>
|
|
||||||
<year>2009</year>
|
|
||||||
</credit>
|
|
||||||
<include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
|
|
||||||
</info>
|
|
||||||
|
|
||||||
<title>Dealing with character encoding problems</title>
|
|
||||||
|
|
||||||
<section id="basics">
|
|
||||||
<title>Character encodings</title>
|
|
||||||
<p>A character encoding is a specific way of recording characters internally
|
|
||||||
in a computer. There are many character encodings.</p>
|
|
||||||
<p>By default, <app>gedit</app> uses UTF-8, a modern character encoding
|
|
||||||
that can handle text from most of the world's languages. Another common
|
|
||||||
encoding for English and some other Western languages is ISO-8859-1.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="problems">
|
|
||||||
<title>Problems</title>
|
|
||||||
<p>If you open a file in a different character encoding than the encoding
|
|
||||||
in which the file was written, then some or all characters might be displayed
|
|
||||||
incorrectly.</p>
|
|
||||||
|
|
||||||
<p>This can happen if the file was created on another operating system
|
|
||||||
or if the file uses a different script.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="solutions">
|
|
||||||
<title>Solutions</title>
|
|
||||||
|
|
||||||
<p>If the content of a text file does not look as expected,
|
|
||||||
<link xref="gedit-open-files">open the file</link> again by choosing a different
|
|
||||||
<gui>Character Encoding</gui> at the bottom of the file chooser dialog.</p>
|
|
||||||
|
|
||||||
<p>If you have an idea which language is used in the document or in the area
|
|
||||||
of the original author of the document:</p>
|
|
||||||
<steps>
|
|
||||||
<item>
|
|
||||||
<p>Select <gui style="menuitem">Add or remove…</gui> from the <gui>Character Encoding</gui> dropdown at the bottom of the file chooser dialog.</p>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<p>Select one or more languages and their encodings under <gui>Available Encodings</gui> on the left.</p>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<p>Press <gui style="button">+</gui> to add the selected encodings to the <gui>Character Encoding</gui> dropdown.</p>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<p>Close the dialog by pressing <gui style="button">Apply</gui>.</p>
|
|
||||||
</item>
|
|
||||||
</steps>
|
|
||||||
|
|
||||||
<note style="tip"><p>If none of these solutions solve the problem, then you
|
|
||||||
could try to edit the file anyway. It is recommended to first create a backup
|
|
||||||
copy of your file.</p></note>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
</page>
|
|
|
@ -7,7 +7,6 @@
|
||||||
<desc>Set the pages to print in a certain order.</desc>
|
<desc>Set the pages to print in a certain order.</desc>
|
||||||
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
||||||
<revision pkgversion="3.8" date="2013-03-21" status="review"/>
|
<revision pkgversion="3.8" date="2013-03-21" status="review"/>
|
||||||
<revision pkgversion="40.1" date="2021-08-20" status="review"/>
|
|
||||||
<credit type="author">
|
<credit type="author">
|
||||||
<name>Phil Bull</name>
|
<name>Phil Bull</name>
|
||||||
<email>philbull@gmail.com</email>
|
<email>philbull@gmail.com</email>
|
||||||
|
@ -30,8 +29,8 @@
|
||||||
|
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Select <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print</gui></guiseq>.</p>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>In the <gui style="tab">General</gui> tab of the Print dialog under
|
<p>In the <gui style="tab">General</gui> tab of the Print dialog under
|
||||||
|
@ -54,8 +53,8 @@
|
||||||
<p>To Collate:</p>
|
<p>To Collate:</p>
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Click <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print</gui></guiseq>.</p>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>In the <gui style="tab">General</gui> tab of the Print dialog under
|
<p>In the <gui style="tab">General</gui> tab of the Print dialog under
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
<link type="guide" xref="gedit-printing#printing-order-select"/>
|
<link type="guide" xref="gedit-printing#printing-order-select"/>
|
||||||
<desc>Choose the pages that you want to print.</desc>
|
<desc>Choose the pages that you want to print.</desc>
|
||||||
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
||||||
<revision pkgversion="40.1" date="2021-08-20" status="review"/>
|
|
||||||
<credit type="author">
|
<credit type="author">
|
||||||
<name>Phil Bull</name>
|
<name>Phil Bull</name>
|
||||||
<email>philbull@gmail.com</email>
|
<email>philbull@gmail.com</email>
|
||||||
|
@ -26,8 +25,8 @@
|
||||||
|
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Select <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print…</gui></guiseq>.</p>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>In the <gui style="tab">General</gui> tab in the Print dialog choose
|
<p>In the <gui style="tab">General</gui> tab in the Print dialog choose
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
<link type="guide" xref="index#gedit-printing-guide"/>
|
<link type="guide" xref="index#gedit-printing-guide"/>
|
||||||
<desc>Print the files that you create with gedit.</desc>
|
<desc>Print the files that you create with gedit.</desc>
|
||||||
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
<revision pkgversion="3.8" date="2013-02-24" status="review"/>
|
||||||
<revision pkgversion="40.1" date="2021-08-20" status="review"/>
|
|
||||||
<credit type="author">
|
<credit type="author">
|
||||||
<name>Jim Campbell</name>
|
<name>Jim Campbell</name>
|
||||||
<email>jcampbell@gnome.org</email>
|
<email>jcampbell@gnome.org</email>
|
||||||
|
@ -36,11 +35,10 @@
|
||||||
|
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Select <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print Preview</gui></guiseq>. Alternatively, you
|
||||||
</item>
|
can press <keyseq><key>Shift</key><key>Ctrl</key>
|
||||||
<item>
|
<key>P</key></keyseq>.</p>
|
||||||
<p>Press <gui style="button">Preview</gui>.</p>
|
|
||||||
</item>
|
</item>
|
||||||
</steps>
|
</steps>
|
||||||
|
|
||||||
|
@ -59,15 +57,17 @@
|
||||||
|
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Select <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print</gui>
|
||||||
|
<gui style="tab">General</gui></guiseq>.</p>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>In the <gui style="tab">General</gui> tab, select the desired printer
|
<p>Select the desired printer from the list of printers available.</p>
|
||||||
from the list of printers available.</p>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>Press <gui style="button">Print</gui>.</p>
|
<p>You can preview the file using <gui style="button">Print Preview</gui>
|
||||||
|
and once you are satisfied with the settings, click
|
||||||
|
<gui style="button">Print</gui> to send the file to printer.</p>
|
||||||
</item>
|
</item>
|
||||||
</steps>
|
</steps>
|
||||||
|
|
||||||
|
@ -92,19 +92,17 @@
|
||||||
<title>Printing To File</title>
|
<title>Printing To File</title>
|
||||||
|
|
||||||
<p>You can also use <app>gedit</app> to print to a file. To print your
|
<p>You can also use <app>gedit</app> to print to a file. To print your
|
||||||
document to a file of a different format:</p>
|
document to file of a different format:</p>
|
||||||
|
|
||||||
<steps>
|
<steps>
|
||||||
<item>
|
<item>
|
||||||
<p>Press the menu button in the top-right corner of the window and select
|
<p>Select <guiseq><gui style="menu">File</gui>
|
||||||
the Print button.</p>
|
<gui style="menuitem">Print</gui>
|
||||||
|
<gui style="menuitem">Print to File</gui></guiseq>.</p>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>In the <gui style="tab">General</gui> tab, select <gui>Print to File</gui>
|
<p>Printing is enabled for the following file formats, you may select
|
||||||
from the list of printers available.</p>
|
from:</p>
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<p>Select an output format:</p>
|
|
||||||
<list>
|
<list>
|
||||||
<item>
|
<item>
|
||||||
<p>Portable Document Format (.pdf)</p>
|
<p>Portable Document Format (.pdf)</p>
|
||||||
|
@ -118,7 +116,8 @@
|
||||||
</list>
|
</list>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<p>Press <gui style="button">Print</gui>.</p>
|
<p>To print the document to file, click
|
||||||
|
<gui style="button">Print</gui>.</p>
|
||||||
</item>
|
</item>
|
||||||
</steps>
|
</steps>
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user