[gnome-latex] Document/Buffer: move some code to the liblatexila
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex] Document/Buffer: move some code to the liblatexila
- Date: Tue, 28 Apr 2020 03:45:25 +0000 (UTC)
commit 8b4051f56bc262a4f18bb98190a63d33f3c0771b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Apr 28 05:29:37 2020 +0200
Document/Buffer: move some code to the liblatexila
docs/reference/gnome-latex-docs.xml | 1 +
docs/reference/gnome-latex-sections.txt | 5 +++
po/POTFILES.in | 1 +
src/app_settings.vala | 8 -----
src/document.vala | 5 +--
src/document_view.vala | 3 --
src/liblatexila/Makefile.am | 2 ++
src/liblatexila/latexila-buffer.c | 55 +++++++++++++++++++++++++++++++++
src/liblatexila/latexila-buffer.h | 31 +++++++++++++++++++
src/liblatexila/latexila.h | 1 +
10 files changed, 97 insertions(+), 15 deletions(-)
---
diff --git a/docs/reference/gnome-latex-docs.xml b/docs/reference/gnome-latex-docs.xml
index efd4303..35edfac 100644
--- a/docs/reference/gnome-latex-docs.xml
+++ b/docs/reference/gnome-latex-docs.xml
@@ -16,6 +16,7 @@
<title>Main Classes</title>
<xi:include href="xml/factory.xml"/>
<xi:include href="xml/settings.xml"/>
+ <xi:include href="xml/buffer.xml"/>
<xi:include href="xml/view.xml"/>
</chapter>
diff --git a/docs/reference/gnome-latex-sections.txt b/docs/reference/gnome-latex-sections.txt
index 7944490..9467f04 100644
--- a/docs/reference/gnome-latex-sections.txt
+++ b/docs/reference/gnome-latex-sections.txt
@@ -1,5 +1,10 @@
<INCLUDE>latexila.h</INCLUDE>
+<SECTION>
+<FILE>buffer</FILE>
+latexila_buffer_setup
+</SECTION>
+
<SECTION>
<FILE>build-tools</FILE>
LatexilaBuildTools
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ba1ab40..3926dbe 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,6 +23,7 @@ src/file_browser.vala
src/glatex_app.vala
src/latex_menu.vala
src/liblatexila/dh-dconf-migration.c
+src/liblatexila/latexila-buffer.c
src/liblatexila/latexila-build-job.c
src/liblatexila/latexila-build-tool.c
src/liblatexila/latexila-build-tools.c
diff --git a/src/app_settings.vala b/src/app_settings.vala
index 3aacee2..f3f6ea3 100644
--- a/src/app_settings.vala
+++ b/src/app_settings.vala
@@ -68,14 +68,6 @@ public class AppSettings : GLib.Settings
set_font (setting.get_string (key));
});
- editor.changed["bracket-matching"].connect ((setting, key) =>
- {
- bool val = setting.get_boolean (key);
-
- foreach (Document doc in GlatexApp.get_instance ().get_documents ())
- doc.highlight_matching_brackets = val;
- });
-
editor.changed["auto-save"].connect ((setting, key) =>
{
bool val = setting.get_boolean (key);
diff --git a/src/document.vala b/src/document.vala
index a198f55..520945d 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -48,10 +48,7 @@ public class Document : Tepl.Buffer
new_file = false;
});
- Latexila.Settings settings = Latexila.Settings.get_singleton ();
- GLib.Settings editor_settings = settings.peek_editor_settings ();
- editor_settings.bind ("scheme", this, "tepl-style-scheme-id",
- SettingsBindFlags.GET);
+ Latexila.buffer_setup (this);
// Longer-term it would be better of course to get rid of the
// Document:location property.
diff --git a/src/document_view.vala b/src/document_view.vala
index 4c874aa..a8130d9 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -47,9 +47,6 @@ public class DocumentView : Tepl.View
set_font_from_settings ();
- doc.highlight_matching_brackets =
- _editor_settings.get_boolean ("bracket-matching");
-
// completion
try
{
diff --git a/src/liblatexila/Makefile.am b/src/liblatexila/Makefile.am
index 9d737ee..e8c445d 100644
--- a/src/liblatexila/Makefile.am
+++ b/src/liblatexila/Makefile.am
@@ -25,6 +25,7 @@ liblatexila_la_LIBADD = \
liblatexila_public_headers = \
latexila.h \
+ latexila-buffer.h \
latexila-build-job.h \
latexila-build-tool.h \
latexila-build-tools.h \
@@ -49,6 +50,7 @@ liblatexila_public_headers = \
$(NULL)
liblatexila_public_c_files = \
+ latexila-buffer.c \
latexila-build-job.c \
latexila-build-tool.c \
latexila-build-tools.c \
diff --git a/src/liblatexila/latexila-buffer.c b/src/liblatexila/latexila-buffer.c
new file mode 100644
index 0000000..9c98f77
--- /dev/null
+++ b/src/liblatexila/latexila-buffer.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of GNOME LaTeX.
+ *
+ * Copyright (C) 2020 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * GNOME LaTeX 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNOME LaTeX 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 GNOME LaTeX. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * SECTION:buffer
+ * @title: LatexilaBuffer
+ * @short_description: Additional #TeplBuffer functions
+ *
+ * Additional #TeplBuffer functions.
+ */
+
+#include "latexila-buffer.h"
+#include "latexila-settings.h"
+
+/**
+ * latexila_buffer_setup:
+ * @buffer: a #TeplBuffer.
+ *
+ * Setups a #TeplBuffer for GNOME LaTeX.
+ */
+void
+latexila_buffer_setup (TeplBuffer *buffer)
+{
+ LatexilaSettings *settings;
+ GSettings *editor_settings;
+
+ g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
+
+ settings = latexila_settings_get_singleton ();
+ editor_settings = latexila_settings_peek_editor_settings (settings);
+
+ g_settings_bind (editor_settings, "scheme",
+ buffer, "tepl-style-scheme-id",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "bracket-matching",
+ buffer, "highlight-matching-brackets",
+ G_SETTINGS_BIND_GET);
+}
diff --git a/src/liblatexila/latexila-buffer.h b/src/liblatexila/latexila-buffer.h
new file mode 100644
index 0000000..b31a4b9
--- /dev/null
+++ b/src/liblatexila/latexila-buffer.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of GNOME LaTeX.
+ *
+ * Copyright (C) 2020 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * GNOME LaTeX 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNOME LaTeX 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 GNOME LaTeX. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LATEXILA_BUFFER_H
+#define LATEXILA_BUFFER_H
+
+#include <tepl/tepl.h>
+
+G_BEGIN_DECLS
+
+void latexila_buffer_setup (TeplBuffer *buffer);
+
+G_END_DECLS
+
+#endif /* LATEXILA_BUFFER_H */
diff --git a/src/liblatexila/latexila.h b/src/liblatexila/latexila.h
index b89f1ba..0c531d2 100644
--- a/src/liblatexila/latexila.h
+++ b/src/liblatexila/latexila.h
@@ -27,6 +27,7 @@
#include "latexila-types.h"
#include "latexila-enum-types.h"
+#include "latexila-buffer.h"
#include "latexila-build-job.h"
#include "latexila-build-tool.h"
#include "latexila-build-tools.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]