Previous: Synchronizing 2 Ubuntu Systems with Unison
Next: GTK+ and Glade3 GUI Programming Tutorial - Part 1

Gedit Symbol Browser Plugin

November 14th, 2007

I have written a symbol browsing (function browser, class browser, etc.) plugin for Gedit, the default GNOME text editor. The plugin is based on Exuberant Ctags (ctags.sourceforge.net) which must be installed to use the plugin.


Function Browser for Gedit

Features

View Screen Shots

  • Supports 34 programming languages (based on ctags)
  • Symbols displayed in a tree grouped by symbol type
  • Icons for symbols can be added for any symbol type ctags can parse
  • Works with local and remote files (SSH, FTP, etc.)
  • View symbols from active tab or from all opened documents
  • Optionally show line number, programming language, and source file in the tree
  • Double-click a symbol to jump to it in the source code

Installation

The plugin is written in C and thus needs to be compiled with the Gedit sources for your distribution if a binary package isn't available. You can check which binary packages are available on the Gedit Symbol Browser Plugin SourceForge project page.

Binary Installation

cp gedit-symbol-browser-plugin*.tar.gz ~/.gnome2/gedit/
tar -xzf gedit-symbol-browser-plugin*.tar.gz

Source Installation

If a binary package isn't available, you have to compile the plugin yourself. If you do so, please email the plugin files to me at email (at) micahcarrick.com so that I can provide a binary package.

To compile the plugin, you must do so within the gedit source tree. Then, you can either install it with that build of gedit or copy the files yourself without compiling or installing gedit. Download and extract the gedit sources to a folder. Download Gedit Symbol Browser Plugin sources and extract to the gedit sources plugins folder (ex: gedit-2.20.3/plugins/).

Edit configure.ac, adding 2 lines to AC_CONFIG_FILES

plugins/symbolbrowser/Makefile
plugins/symbolbrowser/symbols/Makefile

Edit plugins/Makefile.am, adding to 'symbolbrowser' to DIST_SUBDIRS and SUBDIRS.

Run autoconf and automake, and ./configure in the gedit source dir and then make in the symbolbrowser plugin dir:


autoconf
automake
./configure
cd plugins/symbolbrowser
make

Now if you were to run 'make install' here, it might not install the plugin to the right location. This is because many distributions, by default, install binary (rpm's, dep's, etc.) into a different location that files built from source (/usr/ vs. /usr/local/). So, the easiest way to install the plugin is to simply copy plugin files to your home dir:


cp symbolbrowser.gedit-plugin .libs/libsymbolbrowser.so ~/.gnome2/gedit/plugins/
cp -r symbols ~/.gnome2/gedit/

If you want to install it for all users using 'make install', you'll have to pass the target during the ./configure step. You can find out where the other gedit plugins are already installed by doing:


updatedb
locate gedit-2/plugins

And look for them in something like /usr/lib. Then, you can rerun the configure as shown above passing in the lib dir:


./configure --libdir=/usr/lib

Assuming you're okay with the simpler method (installing the plugin in your home dir), the entire process might look something like this:


# DOWNLOAD AND EXTRACT SOURCES
cd ~
wget ftp://ftp.acc.umu.se/pub/GNOME/sources/gedit/2.20/gedit-2.20.3.tar.gz
tar -xzf gedit-2.20.3.tar.gz
cd gedit-2.20.3
cd plugins
wget http://superb-west.dl.sourceforge.net/sourceforge/symbol-browser/gedit-symbol-browser-plugin-0.1.tar.gz
tar -xzf gedit-symbol-browser-plugin-0.1.tar.gz
 
# EDIT MAKE AND CONFIGURE FILES
sed -i 's/SUBDIRS =/SUBDIRS = \t\\\n\tsymbolbrowser\t/g' Makefile.am
sed -i 's/DIST_SUBDIRS =/DIST_SUBDIRS =\t\\\n\tsymbolbrowser\t/g' Makefile.am
cd ..
sed -i 's/AC_CONFIG_FILES(\[/AC_CONFIG_FILES(\[\nplugins\/symbolbrowser\/Makefile/g' configure.ac
 
# BUILD THE PLUGIN
autoconf
automake
./configure
cd plugins/symbolbrowser
make
 
# COPY TO HOME FOLDER
# Note: if you ran ./configure --libdir=/usr/lib then make install may work
cp symbolbrowser.gedit-plugin .libs/libsymbolbrowser.so ~/.gnome2/gedit/plugins/
cp -r symbols ~/.gnome2/gedit/

Adding Symbols

If ctags finds a type of symbol, then Gedit Symbol Browser Plugin adds it to the tree view. If it doesn't find the icon for that symbol you can add it yourself if you wish (send them to me too!). All symbol icons are simply named "symbol-.png" and live in the '~./gnome2/gedit/symbols' directory where is the type as determined by ctags. For example, ctags finds symbols of type 'function' and therefore, there is a png file called 'symbol-function.png'.

Download

Download Paypal IPN Script Download From SourceForge.net

User Contributions



Categories
Linux Web Development GTK+ C Programming

Related Posts


Technorati Tags

20 Responses to “Gedit Symbol Browser Plugin”

RSS Subscription Comments RSS Feed

  1. Bart Says:

    Congratulation, Micah that is really nice!

    That is what i needed to port SweeTS ( typo3.area42.de ) to gEdit/ Linux.
    Did you know how to add own formats to Ctags?

    BTW I wrote some gEdit plugins too:
    http://my.opera.com/area42/blog/gedit-browser-preview-plugin
    http://my.opera.com/area42/blog/gedit-language-reference-plugin

  2. Bart Says:

    Hello Micah,

    i played around with it and started compiling ctags myself with css support using this source:
    http://cssed.sourceforge.net/ctags/css.c

    But the HTML support looks quite bad too :( But I'm not goog in regular expressions for doing something fine, i looked in the html.c of ctags sources and it looks really poor.

  3. Chris Says:

    Great idea!

    Few notes on the source install instructions:

    config.ac should be configure.ac

    ./configure needed after automake and before cd plugins/symbolbrowser

    To get "make install" to put the symbols in the place the plugin is expecting I had to:

    sed -i "s:symbolsdir = \$(libdir)/gedit-2/symbols:symbolsdir = \$(datadir)/gedit-2/symbolbrowser/symbols:" symbols/Makefile.am

  4. Tomás Vírseda Says:

    Hi!

    Thank so much for this plugin. I like a lot and as you request I've compiled the source and I got the library (ia32). I wanted to mail you with it and my screenshot :) but I can't find your email.

    If you are interested I have a tar.gz ready to send. I wrote down my email in the form so I suppose that you can reach me.

    Thanks again.

  5. Micah Says:

    I've updated the build instructions. Thanks for the feedback guys.

  6. Prem Says:

    I have been using Gedit only as a notepad replacement all the while ... so was very excited with both your articles on Gedit! I had done the changes with the preferences already ... and was very eager to try out the symbol browser plugin ... I got that installed but I found that I had to install ctags on my Ubuntu installation.

    'sudo apt-get install ctags'

    did the trick for me, but am still unable to figure out how to get that tree structure in my Gedit :(

  7. polypus Says:

    will come in handy. although like the html, the ruby ctags seems to have a few issues, but that's not your fault. thanks for that! p.s. i did a little write up on gedit for ruby on ubuntu which you might be interested in: http://crepuscular-homunculus.blogspot.com/2007/10/gedit-for-ruby-and-everything-else-on.html

  8. fbloeink Says:

    Hey, thanks for the plugin, i found it very useful.

    Just one thing i noticed when i installed the plugin on my machine:
    Gentoo renames the binary from "ctags" to "exuberant-ctags" due to another binary named ctags in the system.
    In the ctags-ebuild from gentoo it says "namepace collision with X/Emacs-provided /usr/bin/ctags".
    This requires to exchange "ctags" for "exuberant-ctags" twice in the file "gedit-symbol-browser-plugin-defs.h" , followed by a "make" and copying over the files for the plugin to work on this systems.

  9. Micah Says:

    RE: fbloeink

    Thanks for the information! I'll have to modify the file so that it uses a define in the makefile to determine the ctags command it will used. Perhaps erhaps exuberant-ctags will work on all systems. I'll ask around.

  10. Micah Says:

    Re: prem

    Once ctags is installed, and the plugin is installed, you activate it through:
    edit > preferences > plugins
    If "Symbol Browser" isn't in the list, then the plugin isn't installed correctly. If it is in the list, make sure it's checked and that ctags is found. Click 'Configure' and the configure dialog should either show the output of 'ctags --version' or say 'NOT INSTALLED'.

    Once it's installed and activated, the treeview lives in the left pane which can be seen using 'View' > 'Left Pane'

  11. 一任阶前点滴到天明 » Blog Archive » Gedit 特色插件: Gedit Symbol Browser Plugin Says:

    [...] Gedit Symbol Browser Plugin 是一个不错的 Gedit 插件,该插件基于 Ctags,提供包括函数浏览、类浏览等功能。Gedit Symbol Browser Plugin 支持 34 种程序语言,可根据符号类型按树状结构分组显示,能为符号类型添加图标,支持本地和远程的文件,可从活动标签或打开的文档查看符号,能够显示行号、程序语言、以及源文件,双击符号可跳转到源代码中的相应位置等等。 [...]

  12. Mattiko Says:

    Hey!

    I get following error when I run make inside directory gedit/plugins/symbolbrowser. Previous installing setps I did as told. I have Fedora Core 7.

    *** No rule to make target `am--refresh'. Stop.

    P.S. I am quite few experiences with linux yet.

  13. Micah Says:

    Re: Mattiko

    Sounds a bit like you didn't run autoconf, automake, and ./configure in the top-level gedit source directory. I know this can be a bit confusing for a beginner.

    I think I have a Fedora installation on another machine, and I'll see if I can build a fedora binary (which you would just have to copy to the right folder instead of compiling).

  14. Gianni Says:

    Just installed exuberant-ctags on Ubuntu Gutsy, and downloaded the gedit symbol browser bin i386 archive

    http://downloads.sourceforge.net/symbol-browser/gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz?modtime=1195036992&big_mirror=0

    Unpack this in ~/.gnome2/gedit

    Start gedit, edit > preferences > plugins and enable the symbol browser. It's that easy!

  15. Micah Says:

    Yes, there is a binary for ubuntu i386 and ubuntu amd64. If anybody can help me out, I'll post the binaries for FC7 too.

  16. michael depetrillo Says:

    Is this supposed to show class methods? Mine only shows class variables.

  17. Micah Says:

    Re: michael depetrillo

    It is based on ctags. So if ctags can find your class methods as methods, then it will show up in the plugin. It just parses the output of ctags and groups them in the treeview by type.

    So you may want to read up on ctags at ctags.sourceforge.net for the language you are talking about.

  18. Gocho Says:

    I just installed the ubuntu binaries and load a php file en gedit. (example.module)

    But the Symbol Browser panel it's empty.
    I installed exuberant-ctags, but is still empty.

    Then I renamed example.module to example.php and the plugin works :)

    Can't symbol Browser detect the file type automatically?

  19. Micah Says:

    Gocho:

    It passes the file to ctags, so it depends on how ctags determines the type. Curious, what does gedit report as the mime type? Perhaps I could use gedit's mime-type determination and force the type when calling ctags.

  20. gege2061 Says:

    Very nice, thanks :D

    I have compiling on i386 Debian : ftp://ftp-developpez.com/nicolasj/temp/gedit-symbol-browser-plugin-bin-debian-i386-0.1.tar.gz

    Ready to unpack in ~/.gnome2/gedit/ ;)

Leave a Reply