Overview
The codelisting plugin is designed to parse ctags generated tag files. ctags generates plain text files containing information on source code 'tags'. These tags are classes, functions, variables, defines, typedefs, namespaces etc. for a number of languages (including, C, C++, java). See also http://ctags.sourceforge.net/ for more information on ctags. The plugin provides loading a tag file, parsing it and generating a tree of available tags. You could think of a tags file like a project file. This way you'll get a full tree of every class/function etc available in your project. This plugin makes use of the new side-panel.
Tag file loading
At the moment you'll have to load a tag file by hand. This is done by providing a menu (I'm not happy with it, so this will probably change). It has an items for opening and refreshing files. And it has a quicklist (same as the gedit open button) to provide easy access to previously loaded files.
Full tree generation
When a tagfile is loaded, it will be parsed and the full tree gets generated in the background. What this will look like can be viewed at the screenshots section below. The full tree is useful to have a full overview of one's project. A small tag-information table is placed right below the list. At the moment containing the location of the tag (file), and the linenumber the tag is on. This gets filled on selecting a tag in the treeview.
Inner workings
I've first looked at the readtags.c library which comes with ctags. But in my opinion it was very badly coded, and so I've rewritten it to a GObject parser object. When starting the parse an idle function is added (possibly threads in the future). This idle function then parses the whole file, storing tag entry's internally. Whenever a tag is parsed a signal is emitted. Also, at the end a parse done is emitted. This way the treestore can be filled at the same time the tree is being parsed. This involves some parenting creation logic because parent nodes can easily appear after their child nodes in the tag file.
Searching
Of course, with large projects it's hard to find something specific in the full tree. So searching is needed. This is provided by a search text entry in the panel. To search something you simply enter the query and press 'enter'. The search is started and the list will now get filled with matched entries.
Inner workings
As we've stored the tags already withing our parser object, this list will be used to search for tag matches. At first I wanted to have some clever sorted representation but this would involve a lot of work to make it useful for partial searching. Therefor I first implemented a linear search algorithm with no sorting whatsoever. This is still fast. Searching is also done from an idle func (possibly threads in the future), and matched entries are added to a new list on the fly.
To get back to the full tree view you only need to clear the search text entry and press 'enter'.
Go to a tag
Of course just having a list doesn't add much functionality. Therefor you can go to a tag by dubble-clicking a tag in the tree view (both the full list as the search list). At this point the plugin will look if the source file has already been opened and activates it. If this is not the case the source file will get loaded and activated. Then the selected tag will be selected in the source file and the view scrolls to this selection.
Screenshots
Selecting and lookup
http://www.icecrew.nl/files/gedit/code_listing_selection.png
Selecting and lookup again
http://www.icecrew.nl/files/gedit/code_listing_selection2.png
Search and lookup
http://www.icecrew.nl/files/gedit/code_listing_search.png
Source
Source is attached to the wiki page: gedit_code_listing_plugin.tar.bz2
Note that this is just a development 'release' sort of thing. Note that I hardcoded the pixmap location (so this will only work when gedit gets started from the gedit source directory). The gedit source patches are no longer necessary.
For those interested, there is a i386 binary codelisting-bin.tar.bz2. Unpack it in ~/.gnome2/gedit/plugins/ and it should work. Just mind that it may crash gedit, and that you don't get icons.
ChangeLog
2005-11-23 Jesse van den Kieboom <jesse@icecrew.nl> * gedit-code-listing-plugin-panel.c: Changed gedit_document_get_uri_ to gedit_document_get_uri and make sure to free the returned uri 2005-11-09 Jesse van den Kieboom <jesse@icecrew.nl> * gedit-code-listing-plugin.c: No longer using GEDIT_PLUGIN_REGISTER_TYPE, patches to gedit source are no longer needed * gedit-code-listing-plugin-panel.h: Added GPM_PLUGINS_DIR definition, patches to gedit source are no longer needed 2005-05-25 Jesse van den Kieboom <jesse@icecrew.nl> * Initial changelog creation * gedit-code-listing-plugin-parser.c: Added cancel function to cancel parsing and searching. Removed _position _size functions. Added _parse_progress function. * gedit-code-listing-plugin-panel.c: Added Ctrl-double-click to enable definition jumping as well as implementation jumping (without Ctrl) Added cancel button to cancel parse or search Fixed tooltips to be more informative