Introduction

Why another editor? Don't we have enough already?

Well, yes indeed. There are quite a lot of different - and not so different - editors one can download from the Internet. Anyway...

  1. I wanted a simple project to try GUI programming in Unix.
  2. I have an old machine (Pentium 166 MHz, 32 MB RAM) with Slackware Linux 9.0. This machine runs Xfce 3.8, based on GTK+ 1.2.
  3. There's no decent GUI editor for this machine. All are too slow, too bloated or too ugly.

OK, In fact I did found an editor that works fine. It's called gnotepad+, but it too takes too long to load (about 2 seconds) in this old machine. There's plenty of room for improvements here, I thought.

And so gtkedit begun. I only wanted the most basic editing features: cut, copy, paste, basic undo/redo... nothing fancy. The obvious model to copy was, of course, Notepad.

What is it ?

Gtkedit is a simple editor, written using the GTK+ 1.2 toolkit. It aims to be (in that order) light, useful and simple (source code-wise).

Being a simple project, it also can serve as a real world GTK+ tutorial.

Compiling and running

To compile the source, issue the following command from a terminal window:

  make
or alternatively:
   gcc $(gtk-config --cflags --libs) -O -o gtkedit gtkedit.c

I assumed you use GNU bash. If you use any other shell, use this instead:

   gcc `gtk-config --cflags --libs` -O -o gtkedit gtkedit.c

(Beware of the back-quotes (`), as they are not the same as single quotes (') if you happen to be a Unix shell).

Once the compilation finishes you can start the program with the command:

   ./gtkedit

This opens the editor with a blank unnamed file. You can add the name of a file to have it loaded, if you wish. Alternatively you can use the file manager to drag file over the editor window.

Using the editor

gtkedit is very simple to use. It understands the basic common shortcut keys, like <Ctrl>C for copy. You will find them listed next to each menu item.

Very basic undo/redo capabilities are provided, because the editor can only undo the very last text insertion or removal.

You can find and replace text, and there is a menu option that will allow you to quickly go to any particular line, which is handy if one is writting a program and wants locate an error line.

One useful feature is the ability to open files by dragging them from your file manager into the editor window, replacing the current open one.

Finally, you can change the font used for text display, or toggle the wrapping of long lines.

Configuring gtkedit

Gtkedit will save your settings in a file in your home directory named .gtkeditrc. The program will store there your prefered font, the last window size and whether line-wrappnig was on or off the last time you used the program.

It is not recommended to modify this configuration file by hand, because gtkedit is very strict with its format, and will silently rewrite it with defaults if any error is found.