Cursing gtk

There's famous library, called curses. It allows you to use terminals, but is really strange and likes to segfault as soon as possible. Its name should warn you...

Motivation

It would be nice (for full-screen program) to be able to run both under X-windows and under text console. Running under X-windows is nice (it looks pretty), but X are not always available (think about system crash), it is impossible to run X programs over telnet etc. So it would be nice if full-screen X application were able to fall-back to text only mode.

Some time ago, there was project Igi, which had very similar goals. It had one more goal: to be able to generate command-line interface automatically (not everyone has intelligent terminal and command-lines are very handy for controlling one application from another. Unfortunately, this goal will not be achieved by cursing gtk. Oh well. Good thing is that we do not have to reinvent UI system from scratch.

Implementation

Gtk is strong enough to support this. It already supports themes (which allow add-on modules to define how things look), and its rendering engine uses almost no fixed values. Additionally, gtk does not (well, with few exceptions) call X functions directly; it uses thin gdk layer.

So only two big things are necessary: cursed gdk and cursed theme. (Ok, you need few minor modifications to gtk, like killing all calls to X windows, but diff is pretty small).

Cursed gdk

Original gdk can do lots of things: draw lines, fill rectangles, paint letters etc. Text terminals can only paint letters. So I simply killed all gdk functions (replaced them with do-nothing stubs, in fact) and implemented only those working with texts. Furthermore, I had to do my own emulation of overlapping windows, and fake events for key presses.

This alone works, somehow. Unfortunately, gtk likes to represent vital information (like if checkbox is checked or not) with paintings only. We can not paint, so we ignore drawing. Too bad, information was lost.

So we need

Cursed theme

which represents all necessary information with letters, only. So unchecked checkbox now looks like [ ], and checked checkbox looks like [x]. Cursed theme is pretty easy to do, and you can even use it under X windows ;-).

download

Advantages

There are several reasons why cursing gtk is good thing:

There is one reason why cursing gtk is bad thing:

Status

Johanka Dolezalova made a way better version of cursed gtk port, available at sourceforge zemljanka pages.

Screenshots (very old version)

Everyone loves screenshots. And these are easy to generate :-).

testgtk main screen:

       Gtk+ v1.1.12


                        ^
     [    button box    |
     [     buttons      |
     [  check buttons   |
                        |
     [      clist       |
     [ color selection  |
     [      ctree       |
     [     cursors      |
                        |
     [      dialog      |
     [      entry       |
     [  event watcher   |
     *  file selection
     
     [  font selection
     [   gamma curve
     [    handle box
     [   item factory
     
     [      labels
     [      layout
     [       list
     [      menus

     [   modal window
     [     notebook
     [      panes       v

    <-------------    >

File selection dialog:


 [  Create Dir   ][  Delete File  ][  Rename File  ]


                        /etc !



  [ Directories        ] ^   [ Files                ^

  ./                     |   HOSTNAME               |
  ../                    |   Muttrc
  GNUstep/               |   Muttrc~
  X11/                   |   TextConfig
  ae/                    |   XF86Config
  alternatives/          |   XF86Config~
  apache/                    adduser.conf

  autoconf/                  adjtime
  cfingerd/                  ae.rc
  chatscripts/               aliases
  cron.d/                    aliases.db
  cron.daily/                at.deny
  cron.monthly/              bashrc
  cron.weekly/               bootparams
  default/                   bootptabchecksecurity.
                             conf                   v
  dpkg/
  elm-me+/                   <----------------   >
  emacs/                 v


      [ Hide Fileops ]          [ Show Fileops ]

 Selection: /etc

Download (very old version)

If you have any comments about cursed gtk, feel free to contact me at pavel@ucw.cz. I'm currently interested in it, so any suggestions/help is welcome.


Pavel Machek
Last modified: Mon Feb 8 23:41:21 CET 1999