Skip to content

Commit

Permalink
Use now GtkSourceview 4
Browse files Browse the repository at this point in the history
Removed ngc.lang as it is in the old specification format version 1.0.
Use now gcode.lang - this one is also suitable for gedit like mentioned in ngc.lang.
  • Loading branch information
hansu committed Aug 24, 2024
1 parent f7cbbcc commit 8857ee1
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 120 deletions.
2 changes: 1 addition & 1 deletion debian/linuxcnc.install.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ usr/share/axis
usr/share/glade
usr/share/gmoccapy
usr/share/gscreen
usr/share/gtksourceview-2.0
usr/share/gtksourceview-4

usr/share/applications/linuxcnc.desktop
usr/share/applications/linuxcnc-latency.desktop
Expand Down
2 changes: 1 addition & 1 deletion docs/src/gui/gladevcp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,7 @@ image::images/offsetpage.png[align="center"]
=== HAL_sourceview widget

This is for displaying and simple editing of G-code.
It looks for `.ngc` highlighting specs in `~/share/gtksourceview-2.0/language-specs/`.
It looks for `.ngc` highlighting specs in `~/share/gtksourceview-4/language-specs/`.
The current running line will be highlighted.

With external Python glue code it can:
Expand Down
2 changes: 1 addition & 1 deletion lib/python/gladevcp/gtksourceview.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<glade-catalog name="gtksourceview" library="gtksourceview-2.0" depends="gtk+">
<glade-catalog name="gtksourceview" library="gtksourceview-4" depends="gtk+">
<glade-widget-classes>
<glade-widget-class name="GtkSourceView" title="GtkSourceView" generic-name="gtksourceview">
<properties>
Expand Down
8 changes: 4 additions & 4 deletions lib/python/gladevcp/hal_sourceview.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import gi
gi.require_version("Gtk","3.0")
gi.require_version("Gdk","3.0")
gi.require_version("GtkSource","3.0")
gi.require_version("GtkSource","4")
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
Expand Down Expand Up @@ -62,10 +62,10 @@ def __init__(self, *a, **kw):
self.lm = GtkSource.LanguageManager()
self.sm = GtkSource.StyleSchemeManager()
if 'EMC2_HOME' in os.environ:
path = os.path.join(os.environ['EMC2_HOME'], 'share/gtksourceview-2.0/language-specs/')
path = os.path.join(os.environ['EMC2_HOME'], 'share/gtksourceview-4/language-specs/')
self.lm.set_search_path(self.lm.get_search_path() + [path])

self.buf.set_language(self.lm.get_language('.ngc'))
self.buf.set_language(self.lm.get_language('gcode'))
self.set_show_line_numbers(True)
self.set_show_line_marks(True)
self.set_highlight_current_line(True)
Expand Down Expand Up @@ -116,7 +116,7 @@ def set_language(self, lang, path = None):
# lang = the lang file to set
if path == None:
if 'EMC2_HOME' in os.environ:
path = os.path.join(os.environ['EMC2_HOME'], 'share/gtksourceview-2.0/language-specs/')
path = os.path.join(os.environ['EMC2_HOME'], 'share/gtksourceview-4/language-specs/')
if path:
self.lm.set_search_path(path)
self.buf.set_language(self.lm.get_language(lang))
Expand Down
110 changes: 0 additions & 110 deletions share/gtksourceview-2.0/language-specs/ngc.lang

This file was deleted.

4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ install-dirs:
$(DESTDIR)$(datadir)/gmoccapy/icons \
$(DESTDIR)$(datadir)/glade/catalogs \
$(DESTDIR)$(datadir)/glade/pixmaps/hicolor/22x22/actions \
$(DESTDIR)$(datadir)/gtksourceview-2.0/language-specs \
$(DESTDIR)$(datadir)/gtksourceview-4/language-specs \
$(DESTDIR)$(datadir)/linuxcnc/stepconf \
$(DESTDIR)$(datadir)/linuxcnc/pncconf \
$(DESTDIR)$(datadir)/linuxcnc/pncconf/pncconf-help \
Expand Down Expand Up @@ -763,7 +763,7 @@ install-kernel-indep: install-dirs
$(FILE) ../lib/python/gladevcp/hal_python.xml $(DESTDIR)$(datadir)/glade/catalogs/
$(FILE) ../share/glade/pixmaps/hicolor/22x22/actions/widget*.png $(DESTDIR)$(datadir)/glade/pixmaps/hicolor/22x22/actions/

$(FILE) ../share/gtksourceview-2.0/language-specs/*.lang $(DESTDIR)$(datadir)/gtksourceview-2.0/language-specs/
$(FILE) ../share/gtksourceview-4/language-specs/*.lang $(DESTDIR)$(datadir)/gtksourceview-4/language-specs/

$(FILE) ../src/hal/drivers/mesa-hostmot2/modbus/*.tmpl $(DESTDIR)$(prefix)/share/linuxcnc/

Expand Down
2 changes: 1 addition & 1 deletion src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def __init__(self, argv):
# check the highlighting type
# the following would load the python language
# self.widgets.gcode_view.set_language("python")
LANGDIR = os.path.join(BASE, "share", "Gtksourceview-2.0", "language-specs")
LANGDIR = os.path.join(BASE, "share", "Gtksourceview-4", "language-specs")
file_path = os.path.join(LANGDIR, "gcode.lang")
if os.path.isfile(file_path):
LOG.info("Gcode.lang found")
Expand Down

0 comments on commit 8857ee1

Please sign in to comment.