Skip to content

Commit

Permalink
Upgrade Sourceview to version 4
Browse files Browse the repository at this point in the history
  • Loading branch information
ondratu committed Nov 14, 2024
1 parent 2834e96 commit 49a8cff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
7 changes: 4 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
root = true

# elementary defaults
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = tab
indent_style = space
insert_final_newline = false
max_line_length = 79
max_line_length = 80
tab_width = 4

# Markup files
[{*.ui,*.xml}]
tab_width = 2
tab_width = 2
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Version 1.5.0
* right margin settings (issue 36)
* dark theme renderer support (issue #18)
* tab_width from ini config file fix (issue #28)
* upgrade SourceView to version 4

Version 1.4.3

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ gtksource or webkit2 could have another version name.
.. code:: sh
# python3.5, gtk3, librsvg etc are in dependencies
apt install python3-pip python3-gi python3-docutils gir1.2-gtksource-3.0 \
gir1.2-webkit2-4.1 gir1.2-gtkspell3-3.0
apt install python3-pip python3-gi python3-docutils gir1.2-gtksource-4 \
gir1.2-webkit2-4.1 gir1.2-gtkspell3-3.0 python3-mr2
pip3 install formiko
# optionaly
Expand All @@ -130,7 +130,7 @@ pkgsrc, you must fix ``VIM_PATH`` variable in ``formiko/vim.py`` file.
.. code:: sh
# python3.6 is in dependecies as like gtk3
pkgin install py36-pip py36-gobject3 py36-docutils gtksourceview3 \
pkgin install py36-pip py36-gobject3 py36-docutils gtksourceview4 \
librsvg webkit-gtk py36-pygments
pip3.6 install formiko
Expand All @@ -149,7 +149,7 @@ On FreeBSD you must install all these packages:
.. code:: sh
pkg install py37-gobject3 py37-docutils py37-pygments py37-pip \
gtksourceview3 webkit2-gtk3 gtkspell3 gobject-introspection \
gtksourceview4 webkit2-gtk3 gtkspell3 gobject-introspection \
librsvg2 adwaita-icon-theme
**Optionaly**
Expand Down
2 changes: 1 addition & 1 deletion formiko/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

require_version("Gdk", "3.0")
require_version("Gtk", "3.0")
require_version("GtkSource", "3.0")
require_version("GtkSource", "4")
require_version("Pango", "1.0")
require_version("GtkSpell", "3.0")

Expand Down
15 changes: 6 additions & 9 deletions formiko/sourceview.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sys import stderr
from traceback import format_exc

from gi.repository import GObject, Gtk
from gi.repository import GObject, Gtk, GtkSource
from gi.repository.GLib import (
UserDirectory,
Variant,
Expand All @@ -14,7 +14,6 @@
)
from gi.repository.GtkSource import (
Buffer,
DrawSpacesFlags,
SearchContext,
SearchSettings,
View,
Expand All @@ -32,7 +31,6 @@

PERIOD_SAVE_TIME = 300 # 5min


class SourceView(Gtk.ScrolledWindow, ActionHelper):
__file_name = ""
__last_changes = 0
Expand All @@ -48,6 +46,7 @@ class SourceView(Gtk.ScrolledWindow, ActionHelper):
action_target = GObject.property(type=GObject.TYPE_VARIANT)

def __init__(self, win, preferences, action_name=None):
GtkSource.init()
super().__init__()
if action_name:
self.action_name = action_name
Expand Down Expand Up @@ -174,10 +173,8 @@ def set_text_wrapping(self, text_wrapping):
self.source_view.set_wrap_mode(Gtk.WrapMode.NONE)

def set_white_chars(self, white_chars):
if white_chars:
self.source_view.set_draw_spaces(DrawSpacesFlags.ALL)
else:
self.source_view.set_draw_spaces(0)
space_drawer = self.source_view.get_space_drawer()
space_drawer.set_enable_matrix(white_chars)

def check_in_thread(self):
"""Check source file time.
Expand Down Expand Up @@ -304,7 +301,7 @@ def do_next_match(self, text):
else:
return False

found, search_iter, end = self.search_context.forward(search_iter)
found, search_iter, end, _ = self.search_context.forward(search_iter)

if not found:
self.search_mark = None
Expand All @@ -323,7 +320,7 @@ def do_previous_match(self, text):
else:
return False

found, start, search_iter = self.search_context.backward(search_iter)
found, start, search_iter, _ = self.search_context.backward(search_iter)
if not found:
self.search_mark = None
return False
Expand Down

0 comments on commit 49a8cff

Please sign in to comment.