# AMAYA with GTK

This release aims to start the migration from MOTIF to GTK user interface. It implements features needed to use AMAYA just like a browser and not like an Editor/Browser. In further release, I hope that a Browser/Editor version will be avaliable. We make this GTK release in order to get some feedback, and maybe some contribution to help the current development. I know there is a lot of bug in it, and I hope that most of them will be fixed soon.

  Amaya (GTK) Screenshot

1. Libs needed to compile Amaya with GTK

   You can find it on: ftp://ftp.gtk.org/pub/gtk/v1.2

   - With Debian:
     - libglib1.2_1.2.x_i386.deb
     - libglib1.2-dev_1.2.x-1_386.deb
     - libgtk1.2_1.2.x-1_i386.deb
     - libgtk1.2-dev_1.2.x-1_i386.deb
   - With RedHat or Suse:
     - glib-1.2.x-1.i386.rpm
     - glib-devel-1.2.x-1.i386.rpm
     - gtk+-1.2.x-1.i386.rpm
     - gtk+-devel-1.2.x-1.i386.rpm
   - You need also the ImLib, used for pictures drawing.

2. How to compile Amaya with GTK
   - Get the source code package
   - Untar the package and do the following commands:
     - cd Amaya
     - mkdir GTK
     - cd GTK
     - ../configure --with-gtk
     - make
   - class="paragraphe"Now (after a long time), you can execute amaya by typing:
     - bin/amaya

3. New features
   - User interface:

     Dynamic widget creation, built on the thotlib kernel.

     - Main frame
     - Menus
     - Dialogue box
   - Document drawing:
     - JPEG, GIF, PNG, TIFF, XPM, PPM, PGM, EIM Pictures drawing.
     - Basic SVG drawing.
     - Text with different font and different style drawing.
     - Form drawing.
   - Document browsing:
     - Connection to the web (libwww)
     - Text insertion
     - Link activated by double click.

4. Missing features
   - Document browsing:
     - Access Key
   - Document drawing:
     - Picture editing (SVG, scaling...)
   - User Interface:
     - Color Selector widget.
     - Other dialogue relooking.
5. Known bugs
   - Bad scrolls bar update.
   - UP and DOWN keys must be overloaded when drawing area has focus. Actualy these keys force focus to change.
   - Amaya bugs when you click on: 'Mode Editeur', 'Montrer les cibles', 'Grossire', and 'Reduire'
   - Sometime, freezing when Amaya access to the network.
   - Background image Tiled not supported
   - Amaya bugs when using 'Attributs' menu with 'lang' attribut.

6. How did I work

   How did I proceed to implement GTK, in AMAYA sources ? First of all, I have learned the GTK lib by compiling a lot of small and easy codes. When I was partially ok with GTK lib, I looked the thotlib sources. It was not easy but I finaly understand globally how work thotlib. Looking and understanding the thotlib code was the harder job.

   Now, I can start to work and produce something.

   I choose to generate all form dialogue by using the thotlib functions used by motif. Motif is able to produce widget dynamically, Windows is not able to, and GTK is able to. So thotlib function was able to generate dynamically Motif widget. My work was just to replace the Motif code by the GTK equivalent code !!

   Here a small example:

     w = AddInFormulary (parentCatalogue, &i, &ent, &adbloc); /* Reserve one place in the dialogue box and return a pointer on this container (w) */

     #ifndef _GTK

     n = 0;

     title_string = XmStringCreateSimple (text);/* Create a Motif string in order to put the label into */

     XtSetArg (args[n], XmNfontList, DefaultFont);/* Assigne the label Font */

     n++;

     XtSetArg (args[n], XmNlabelString, title_string);/* Assigne the string to the label */

     n++;

     XtSetArg (args[n], XmNbackground, BgMenu_Color);/* Put the label color backgroung */

     n++;

     XtSetArg (args[n], XmNforeground, FgMenu_Color);/* Put the label color foreground */

     n++;

     w = XmCreateLabel (w, "Dialogue", args, n); /* Create the label widget, and put it in the reserved container (w)*/

     #else /* _GTK */

     tmpw = gtk_label_new (text); /* Create the label widget */

     gtk_misc_set_alignment (GTK_MISC (tmpw), 0.0, 0.5); /* Left justify the label */

     gtk_widget_show (GTK_WIDGET(tmpw)); /* Show the label */

     tmpw->style->font=DefaultFont;/* Assigne the label Font */

     gtk_box_pack_start (GTK_BOX(w), GTK_WIDGET(tmpw), FALSE, FALSE, 0);/* Put the label in the reserved container */

     w=tmpw;/* w become the pointer on the label widget */

     #endif /* !_GTK */

     /* Initialise the thotlib structure catalogue */

     catalogue->Cat_Widget = w;

     catalogue->Cat_Ref = ref;

     catalogue->Cat_Type = CAT_LABEL;

     catalogue->Cat_PtParent = parentCatalogue;

     adbloc->E_ThotWidget[ent] = (ThotWidget) (catalogue);

     adbloc->E_Free[ent] = 'N';

     catalogue->Cat_EntryParent = i;

     catalogue->Cat_Entries = NULL;

   In green: the motif code
   In orange: the GTK code
   In dark blue: the common GTK and Motif code (Thotlib code)
   I have added #ifndef _GTK #else #endif precompilation codes in order to compile with Motif flag or with GTK flag.
   My job was just to replace the XWindow (Motif) code by the GTK equivalent functions.
   To create a label, the Motif function is: XmCreateLabel and the equivalent GTK function is: gtk_label_new. Most of the time, function name which become with 'X' are XWindow or Motif functions.

   I have adopted the same strategie for all the thotlib functions with some XWindow & Motif reference. I try to find the correct function which could do the same action in GTK. Sometime no function was avaliable. Also, I try to make the equivalent function with many other GTK function.

   This job is not easy because you must understand the thotlib function aim and find the right GTK function which could be used to do the same action.

7. Glossary
   - ThotLib:

     It's the amaya kernel also in LINUX and in WINDOWS version.

   - LibWWW:

     It's the lib used to make the link between AMAYA and the network. (HTTP, FTP protocols)

   - Widget:

     It's an element which is used to build a dialogue. It's could be a button, a label, an editbox, a window...

Last modified: 3 July; 2001