Skip to content

Commit 01f04d0

Browse files
committed
Gedit 40 update
1 parent f6f7b58 commit 01f04d0

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

README.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Gedit Source Code Browser
22
=========================
33

4-
![No Longer Maintained](https://img.shields.io/badge/maintained-no-red.svg)
4+
![Currently Maintained](https://img.shields.io/badge/maintained-yes-brightgreen.svg)
55

6-
A source code class and function browser plugin for Gedit 3.
6+
A source code class and function browser plugin for Gedit 40.
77

88
This plugin will add a new tab to the side pane in the Gedit text editor which
99
shows symbols (functions, classes, variables, etc.) for the active document.
@@ -17,7 +17,7 @@ for a list of the 41 programming languages supported by this plugin.
1717
Requirements
1818
------------
1919

20-
This plugins is for Gedit 3 and is **not compatible with Gedit 2.x**.
20+
This plugins is for Gedit 40.
2121

2222
The Gedit Source Code Browser plugin uses
2323
[Exuberant Ctags](http://ctags.sourceforge.net/) to parse symbols
@@ -36,7 +36,7 @@ Installation
3636
1. Download this repository by clicking the Downloads button at the top of the
3737
github page or issue the following command in a terminal:
3838

39-
git clone git://github.com/MicahCarrick/gedit-source-code-browser.git
39+
git clone git://github.com/Supreeeme/gedit-source-code-browser.git
4040

4141
2. Copy the file `sourcecodebrowser.plugin` and the folder `sourcecodebrowser` to
4242
`~/.local/share/gedit/plugins/`.

screenshot.png

72.5 KB
Loading

sourcecodebrowser.plugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Plugin]
2-
Loader=python
2+
Loader=python3
33
Module=sourcecodebrowser
44
IAge=3
55
Name=Source Code Browser

sourcecodebrowser/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import plugin
2-
from plugin import SourceCodeBrowserPlugin
1+
from . import plugin
2+
from .plugin import SourceCodeBrowserPlugin
33

sourcecodebrowser/ctags.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,15 @@ def _parse_text(self, text):
9595
Parses ctags text which may have come from a TAG file or from raw output
9696
from a ctags command.
9797
"""
98+
#print(str(text, 'utf-8'))
9899
for line in text.splitlines():
99100
name = None
100101
file = None
101102
ex_command = None
102103
kind = None
103-
for i, field in enumerate(line.split("\t")):
104+
for i, f in enumerate(line.split(b'\t')):
105+
# print(i, f)
106+
field = str(f, 'utf-8')
104107
if i == 0: tag = Tag(field)
105108
elif i == 1: tag.file = field
106109
elif i == 2: tag.ex_command = field
@@ -146,4 +149,7 @@ def get_tree(self):
146149
return tree
147150
"""
148151

149-
152+
153+
if __name__ == "__main__":
154+
the_parser = Parser()
155+
the_parser.parse("ctags -nu --fields=fiKlmnsSzt -f - ctags.py", "ctags")

sourcecodebrowser/plugin.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
import sys
33
import logging
44
import tempfile
5-
import ctags
5+
from . import ctags
66
from gi.repository import GObject, GdkPixbuf, Gedit, Gtk, PeasGtk, Gio
77

8+
import gi
9+
gi.require_version('Tepl', '6')
10+
from gi.repository import Tepl
11+
812
logging.basicConfig()
913
LOG_LEVEL = logging.WARN
1014
SETTINGS_SCHEMA = "org.gnome.gedit.plugins.sourcecodebrowser"
@@ -330,7 +334,7 @@ def do_activate(self):
330334
self._sourcetree.expand_rows = self.expand_rows
331335
self._sourcetree.sort_list = self.sort_list
332336
panel = self.window.get_side_panel()
333-
panel.add_item(self._sourcetree, "SymbolBrowserPlugin", "Source Code", self.icon)
337+
panel.add_titled(self._sourcetree, "SymbolBrowserPlugin", "Source Code")
334338
self._handlers = []
335339
hid = self._sourcetree.connect("focus", self.on_sourcetree_focus)
336340
self._handlers.append((self._sourcetree, hid))
@@ -353,7 +357,7 @@ def do_deactivate(self):
353357
obj.disconnect(hid)
354358
self._handlers = None
355359
pane = self.window.get_side_panel()
356-
pane.remove_item(self._sourcetree)
360+
pane.remove(self._sourcetree)
357361
self._sourcetree = None
358362

359363
def _has_settings_schema(self):
@@ -393,12 +397,12 @@ def _load_active_document_symbols(self):
393397
self._is_loaded = False
394398
# do not load if not the active tab in the panel
395399
panel = self.window.get_side_panel()
396-
if not panel.item_is_active(self._sourcetree):
400+
if panel.get_visible_child() != self._sourcetree:
397401
return
398402

399403
document = self.window.get_active_document()
400404
if document:
401-
location = document.get_location()
405+
location = document.get_file().get_location()
402406
if location:
403407
uri = location.get_uri()
404408
self._log.debug("Loading %s...", uri)
@@ -470,8 +474,8 @@ def on_tag_activated(self, sourcetree, location, data=None):
470474
document = self.window.get_active_document()
471475
view = self.window.get_active_view()
472476
line = int(line) - 1 # lines start from 0
473-
document.goto_line(line)
474-
view.scroll_to_cursor()
477+
478+
Tepl.View.goto_line(view, line)
475479

476480
def _version_check(self):
477481
""" Make sure the exhuberant ctags is installed. """
@@ -481,4 +485,4 @@ def _version_check(self):
481485
(self.ctags_executable))
482486

483487

484-
488+

0 commit comments

Comments
 (0)