From 234beb84f92ccfa904bab203cf53e77de4ee6fa5 Mon Sep 17 00:00:00 2001 From: Shaolu Date: Fri, 10 Apr 2015 23:05:13 -0700 Subject: [PATCH 1/3] Update plugin.py Scripting accommodations for a "ctags append" feature that allows appending the ctags command in the parser with options. I originally made this so I could easily configure ctags with options like "--langmap=javascript:.itz.js.node" For this system, I have modified three key files: configure_dialog.ui plugin.py org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml --- sourcecodebrowser/plugin.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/sourcecodebrowser/plugin.py b/sourcecodebrowser/plugin.py index 19123fc..584d03a 100644 --- a/sourcecodebrowser/plugin.py +++ b/sourcecodebrowser/plugin.py @@ -2,13 +2,13 @@ import sys import logging import tempfile -import ctags +from . import ctags from gi.repository import GObject, GdkPixbuf, Gedit, Gtk, PeasGtk, Gio logging.basicConfig() LOG_LEVEL = logging.WARN SETTINGS_SCHEMA = "org.gnome.gedit.plugins.sourcecodebrowser" -DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') +DATA_DIR = "/usr/share/gedit/plugins/sourcecodebrowser" ICON_DIR = os.path.join(DATA_DIR, 'icons', '16x16') class SourceTree(Gtk.VBox): @@ -33,6 +33,7 @@ def __init__(self): # preferences (should be set by plugin) self.show_line_numbers = True self.ctags_executable = 'ctags' + self.ctags_append = '' self.expand_rows = True self.sort_list = True self.create_ui() @@ -74,7 +75,7 @@ def clear(self): self._store.clear() def create_ui(self): - """ Craete the main user interface and pack into box. """ + """ Create the main user interface and pack into box. """ self._store = Gtk.TreeStore(GdkPixbuf.Pixbuf, # icon GObject.TYPE_STRING, # name GObject.TYPE_STRING, # kind @@ -218,7 +219,7 @@ def parse_file(self, path, uri): filename to pass to ctags, and the uri is the actual URI as known by Gedit. They would be different for remote files. """ - command = "ctags -nu --fields=fiKlmnsSzt -f - '%s'" % path + command = "ctags " + self.ctags_append + "-nu --fields=fiKlmnsSzt -f - '%s'" % path #self._log.debug(command) try: parser = ctags.Parser() @@ -275,6 +276,9 @@ def get_widget(self, has_schema): builder.get_object("ctags_executable").set_text( self._settings.get_string('ctags-executable') ) + builder.get_object("ctags_append").set_text( + self._settings.get_string('ctags-append') + ) builder.connect_signals(self) return widget @@ -293,6 +297,9 @@ def on_sort_list_toggled(self, button, data=None): def on_ctags_executable_changed(self, editable, data=None): self._settings.set_string('ctags-executable', editable.get_text()) + def on_ctags_append_changed(self, editable, data=None): + self._settings.set_string('ctags-append', editable.get_text()) + class SourceCodeBrowserPlugin(GObject.Object, Gedit.WindowActivatable, PeasGtk.Configurable): """ @@ -326,6 +333,7 @@ def do_activate(self): self._version_check() self._sourcetree = SourceTree() self._sourcetree.ctags_executable = self.ctags_executable + self._sourcetree.ctags_append = self.ctags_append self._sourcetree.show_line_numbers = self.show_line_numbers self._sourcetree.expand_rows = self.expand_rows self._sourcetree.sort_list = self.sort_list @@ -372,11 +380,13 @@ def _init_settings(self): self.expand_rows = settings.get_boolean("expand-rows") self.sort_list = settings.get_boolean("sort-list") self.ctags_executable = settings.get_string("ctags-executable") + self.ctags_append = settings.get_string("ctags-append") settings.connect("changed::load-remote-files", self.on_setting_changed) settings.connect("changed::show-line-numbers", self.on_setting_changed) settings.connect("changed::expand-rows", self.on_setting_changed) settings.connect("changed::sort-list", self.on_setting_changed) settings.connect("changed::ctags-executable", self.on_setting_changed) + settings.connect("changed::ctags-append", self.on_setting_changed) self._settings = settings else: self._log.warn("Settings schema not installed. Plugin will not be configurable.") @@ -386,6 +396,7 @@ def _init_settings(self): self.expand_rows = True self.sort_list = True self.ctags_executable = 'ctags' + self.ctags_append = '' def _load_active_document_symbols(self): """ Load the symbols for the given URI. """ @@ -431,6 +442,7 @@ def on_setting_changed(self, settings, key, data=None): self.show_line_numbers = False self.expand_rows = True self.ctags_executable = 'ctags' + self.ctags_append = '' """ if key == 'load-remote-files': self.load_remote_files = self._settings.get_boolean(key) @@ -442,9 +454,12 @@ def on_setting_changed(self, settings, key, data=None): self.sort_list = self._settings.get_boolean(key) elif key == 'ctags-executable': self.ctags_executable = self._settings.get_string(key) + elif key == 'ctags-append': + self.ctags_append = self._settings.get_string(key) if self._sourcetree is not None: self._sourcetree.ctags_executable = self.ctags_executable + self._sourcetree.ctags_append = self.ctags_append self._sourcetree.show_line_numbers = self.show_line_numbers self._sourcetree.expand_rows = self.expand_rows self._sourcetree.sort_list = self.sort_list From 8d4ef898842e941aced97c65ae5939fa555cb074 Mon Sep 17 00:00:00 2001 From: Shaolu Date: Fri, 10 Apr 2015 23:08:12 -0700 Subject: [PATCH 2/3] Update configure_dialog.ui Scripting accommodations for a "ctags append" feature that allows appending the ctags command in the parser with options. I originally made this so I could easily configure ctags with options like "--langmap=javascript:.itz.js.node" For this system, I have modified three key files: configure_dialog.ui plugin.py org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml --- sourcecodebrowser/data/configure_dialog.ui | 53 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/sourcecodebrowser/data/configure_dialog.ui b/sourcecodebrowser/data/configure_dialog.ui index a1f46e3..514f612 100644 --- a/sourcecodebrowser/data/configure_dialog.ui +++ b/sourcecodebrowser/data/configure_dialog.ui @@ -1,6 +1,7 @@ + - + False 5 @@ -20,10 +21,10 @@ gtk-close + False True True True - False True @@ -48,10 +49,10 @@ Show _line numbers in tree + False True True False - False True 0 True @@ -67,10 +68,10 @@ Load symbols from _remote files + False True True False - False True 0 True @@ -86,10 +87,10 @@ Start with rows _expanded + False True True False - False True 0 True @@ -105,10 +106,10 @@ _Sort list alphabetically + False True True False - False True 0 True @@ -144,7 +145,6 @@ True ctags - True @@ -162,6 +162,45 @@ 4 + + + True + False + + + True + False + 0 + ctags append str + + + False + True + 0 + + + + + True + True + + + + + False + True + 6 + 1 + + + + + False + True + 6 + 5 + + False From aa581e80ef081e6ca965bb6fa299c20aef556e67 Mon Sep 17 00:00:00 2001 From: Shaolu Date: Fri, 10 Apr 2015 23:11:25 -0700 Subject: [PATCH 3/3] Update org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml Scripting accommodations for a "ctags append" feature that allows appending the ctags command in the parser with options. I originally made this so I could easily configure ctags with options like "--langmap=javascript:.itz.js.node" For this system, I have modified three key files: configure_dialog.ui plugin.py org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml --- .../org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sourcecodebrowser/data/org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml b/sourcecodebrowser/data/org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml index c7313f2..8215cdf 100644 --- a/sourcecodebrowser/data/org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml +++ b/sourcecodebrowser/data/org.gnome.gedit.plugins.sourcecodebrowser.gschema.xml @@ -26,6 +26,10 @@ Ctags Executable Specifies the executable path for Exuberant Ctags. + + '' + Ctags Append + Specifies any command line modifiers to apply to Ctags when run by the parser. + -