GMaxima :: Documentation

Skip navigation

Main menu

Application specification

GMaxima is a GTK+ front-end to symbolical manipulator Maxima . It enables user to operate several tasks in Maxima by GUI, without any knowledge of Maxima commands.

Main features

Basic structure of the application

The structure of the application can be divided into several sections

  1. Communication with Maxima
  2. Inner data structures variables, arrays, functions, history storage
  3. Handling user actions
  4. User interface
  5. Other

Communication with Maxima

Modules in charge:


Basic communication with Maxima makes use of pipe() system call. In the main.c module, fork () is called, the Maxima executed, and I/O redirected to the pipe.


Most important role of the input.c module is sending commands to Maxima. The scenario is as following:

At the beginning, input file descriptor has to be set this is done by input_set_cmd_target() call in main.c . It simply sets module-visible variable input_target to the value returned by pipe() call.

Then, according to user actions, send_cmd() is called. This starts the command handling and is connected to several other tasks, such as command history, and Maxima working status. These topics will be discussed below.


This module consists of functions, which read and parse the output Maxima produces. Following scenario is used when reading the output:

At the beginning, output file descriptor is set this is done by output_set_target() call.

Then, output file descriptor and output callback ( on_maxima_output in callbacks.c ) is registered at GDK library by gdk_input_add() .

When any output from Maxima is available, on_maxima_output() simply calls output_read() , which reads data from the pipe and passes them to the most important function of the output.c module parse_output() .

Command types

There are two types of commands hidden, which are delimited by $ and whose results are not displayed on user screen, and normal, delimited by ;, whose results are displayed in the output window and are saved in the history

Inner data structures

Structures used for saving data

There are two basic data structures used for saving data. First, the GtkCList component is used when saving simple data (Maxima variables, functions, as well as command results). For saving arrays, linked list structure is used (the glibc g_list structure).

Command history and results saving

Main idea of the command history saving is following: Maxima flag display2d enables users to switch between two different forms of results display. When display2d set to true (default), multi-line output is produced. On the other hand, when display2d is set to false , one-line results are showed.

The command execution algorithm

Figure 1 illustrates the algorithm of command execution and result storing. It recognizes two types of Maxima commands. Commands, that end with a dollar sign $, are only executed, but Maxima does not display any results. These commands are not stored in the command history list. Other commands are executed by Maxima for the first time. After first-time execution, Maxima displays its result in an inline format, which is suitable for storing in the history list. Then, its time for second execution, which is used to display results in Maxima-native (that means multi-line) format on the user screen.

Command execution algorithm

Figure 1: Command execution


For arrays, another data structure is used. Accessing the information about array fields directly from Maxima would be time-consuming, thats why arrays are stored in a linked list of array_list_item elements. The array_list_item stores array name, size, and values of array fields. Array fields data are stored as string in a single-dimensional array of strings.

Handling user actions

Modules in charge:


This module consists of several signal handlers, that are supposed to respond on user actions.

User interface

Glade user interface designer creates the user interface module interface.c according to XML file .


Dialogs are handled by the dialogs.c module. This module contains functions that create and open dialogs, verification of data input, and input handling.


Error handling

The module error.c contains functions, that display several error messages to user. Function error_show_msg() displays a simple window with specified text and icon as set by 3 rd parameter.