[gnome-latex] View: move some code to the liblatexila
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex] View: move some code to the liblatexila
- Date: Tue, 28 Apr 2020 03:12:18 +0000 (UTC)
commit 656d12a8975572eed80eb434c7b5c4481a01da05
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Apr 28 04:41:36 2020 +0200
View: move some code to the liblatexila
For the indent_width it was already the default value.
docs/reference/gnome-latex-sections.txt | 2 +-
src/app_settings.vala | 33 -----------------
src/document_view.vala | 18 +---------
src/liblatexila/latexila-view.c | 63 ++++++++++++++++++++++++++-------
src/liblatexila/latexila-view.h | 6 ++--
5 files changed, 56 insertions(+), 66 deletions(-)
---
diff --git a/docs/reference/gnome-latex-sections.txt b/docs/reference/gnome-latex-sections.txt
index c61558f..7944490 100644
--- a/docs/reference/gnome-latex-sections.txt
+++ b/docs/reference/gnome-latex-sections.txt
@@ -312,6 +312,6 @@ latexila_utils_migrate_latexila_to_gnome_latex
<SECTION>
<FILE>view</FILE>
-latexila_view_configure_space_drawer
+latexila_view_setup
latexila_view_get_indentation_style
</SECTION>
diff --git a/src/app_settings.vala b/src/app_settings.vala
index 19249c1..3aacee2 100644
--- a/src/app_settings.vala
+++ b/src/app_settings.vala
@@ -68,39 +68,6 @@ public class AppSettings : GLib.Settings
set_font (setting.get_string (key));
});
- editor.changed["tabs-size"].connect ((setting, key) =>
- {
- uint val;
- setting.get (key, "u", out val);
-
- foreach (DocumentView view in GlatexApp.get_instance ().get_views ())
- view.tab_width = val;
- });
-
- editor.changed["insert-spaces"].connect ((setting, key) =>
- {
- bool val = setting.get_boolean (key);
-
- foreach (DocumentView view in GlatexApp.get_instance ().get_views ())
- view.insert_spaces_instead_of_tabs = val;
- });
-
- editor.changed["display-line-numbers"].connect ((setting, key) =>
- {
- bool val = setting.get_boolean (key);
-
- foreach (DocumentView view in GlatexApp.get_instance ().get_views ())
- view.show_line_numbers = val;
- });
-
- editor.changed["highlight-current-line"].connect ((setting, key) =>
- {
- bool val = setting.get_boolean (key);
-
- foreach (DocumentView view in GlatexApp.get_instance ().get_views ())
- view.highlight_current_line = val;
- });
-
editor.changed["bracket-matching"].connect ((setting, key) =>
{
bool val = setting.get_boolean (key);
diff --git a/src/document_view.vala b/src/document_view.vala
index c48337c..4c874aa 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -40,31 +40,15 @@ public class DocumentView : Tepl.View
this.editable = !((Document) d).readonly;
});
- wrap_mode = WrapMode.WORD;
- auto_indent = true;
- indent_width = -1;
-
- Latexila.view_configure_space_drawer (this);
+ Latexila.view_setup (this);
/* settings */
_editor_settings = new GLib.Settings ("org.gnome.gnome-latex.preferences.editor");
- _editor_settings.bind ("forget-no-tabs", this, "smart-backspace",
- SettingsBindFlags.GET);
-
set_font_from_settings ();
- // tab width
- uint tmp;
- _editor_settings.get ("tabs-size", "u", out tmp);
- tab_width = tmp;
-
- insert_spaces_instead_of_tabs = _editor_settings.get_boolean ("insert-spaces");
- show_line_numbers = _editor_settings.get_boolean ("display-line-numbers");
- highlight_current_line = _editor_settings.get_boolean ("highlight-current-line");
doc.highlight_matching_brackets =
_editor_settings.get_boolean ("bracket-matching");
- set_smart_home_end (SourceSmartHomeEndType.AFTER);
// completion
try
diff --git a/src/liblatexila/latexila-view.c b/src/liblatexila/latexila-view.c
index 7af4a17..46fed91 100644
--- a/src/liblatexila/latexila-view.c
+++ b/src/liblatexila/latexila-view.c
@@ -1,7 +1,7 @@
/*
* This file is part of GNOME LaTeX.
*
- * Copyright (C) 2017 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2017-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
@@ -26,21 +26,13 @@
*/
#include "latexila-view.h"
+#include "latexila-settings.h"
-/**
- * latexila_view_configure_space_drawer:
- * @view: a #GtkSourceView.
- *
- * Configures the #GtkSourceSpaceDrawer of @view, to draw non-breaking spaces at
- * all locations.
- */
-void
-latexila_view_configure_space_drawer (GtkSourceView *view)
+static void
+configure_space_drawer (GtkSourceView *view)
{
GtkSourceSpaceDrawer *space_drawer;
- g_return_if_fail (GTK_SOURCE_IS_VIEW (view));
-
space_drawer = gtk_source_view_get_space_drawer (view);
/* Rationale for always drawing non-breaking spaces:
@@ -59,6 +51,53 @@ latexila_view_configure_space_drawer (GtkSourceView *view)
gtk_source_space_drawer_set_enable_matrix (space_drawer, TRUE);
}
+/**
+ * latexila_view_setup:
+ * @view: a #GtkSourceView widget.
+ *
+ * Setups a #GtkSourceView widget for GNOME LaTeX.
+ */
+void
+latexila_view_setup (GtkSourceView *view)
+{
+ GtkTextView *text_view;
+ LatexilaSettings *settings;
+ GSettings *editor_settings;
+
+ g_return_if_fail (GTK_SOURCE_IS_VIEW (view));
+
+ text_view = GTK_TEXT_VIEW (view);
+
+ configure_space_drawer (view);
+
+ gtk_text_view_set_wrap_mode (text_view, GTK_WRAP_WORD);
+ gtk_source_view_set_auto_indent (view, TRUE);
+ gtk_source_view_set_smart_home_end (view, GTK_SOURCE_SMART_HOME_END_AFTER);
+
+ settings = latexila_settings_get_singleton ();
+ editor_settings = latexila_settings_peek_editor_settings (settings);
+
+ g_settings_bind (editor_settings, "forget-no-tabs",
+ view, "smart-backspace",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (editor_settings, "tabs-size",
+ view, "tab-width",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (editor_settings, "insert-spaces",
+ view, "insert-spaces-instead-of-tabs",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (editor_settings, "display-line-numbers",
+ view, "show-line-numbers",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
+
+ g_settings_bind (editor_settings, "highlight-current-line",
+ view, "highlight-current-line",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
+}
+
/**
* latexila_view_get_indentation_style:
* @view: a #GtkSourceView.
diff --git a/src/liblatexila/latexila-view.h b/src/liblatexila/latexila-view.h
index 74b3d33..2b77569 100644
--- a/src/liblatexila/latexila-view.h
+++ b/src/liblatexila/latexila-view.h
@@ -1,7 +1,7 @@
/*
* This file is part of GNOME LaTeX.
*
- * Copyright (C) 2017 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2017-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
@@ -24,9 +24,9 @@
G_BEGIN_DECLS
-void latexila_view_configure_space_drawer (GtkSourceView *view);
+void latexila_view_setup (GtkSourceView *view);
-gchar * latexila_view_get_indentation_style (GtkSourceView *view);
+gchar * latexila_view_get_indentation_style (GtkSourceView *view);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]