X/Motif Programming

And God said “Let there be light”!
Declaring Callback Functions

Callback functions have the following format:

void functionNameCallback (Widget w, XtPointer
client_data, XmPushButtonCallbackStruct *cbs)

The callback function parameters are:

  1. The first parameter of the function is the widget associated with the function (button in our case).

  2. The second parameter is used to pass client data to the function. It is not used in our sample program.

  3. The third parameter is a pointer to a structure that contains data specific to the particular widget that called the function and information on the event that triggered the call. The structure we have used is a XmPushButtonCallbackStruct, since we are using the PushButton Widget.

There are two final actions every Motif program must perform. First, it must tell X to display or realize the widgets. This is achieved via the XtRealizeWidget function; realizing the widget creates the actual window for the widget. In helloworld.c, we pass the top-level widget, topWidget, to the function so that all child widgets are displayed. Second, the Motif program enters the main event-handling loop; the call to XtAppMainLoop turns control of the application over to the X Toolkit Intrinsics. Xt handles the dispatching of events to the appropriate widgets, which in turn pass them to the application via callbacks.

Closing

This article was a mere introduction to the world of X/Motif programming. We've looked at a simple Motif program to introduce the basic concepts in building the graphical user interface. For more information, see Resources.

Naming Motif

Resources

Ibrahim Haddad (ibrahim@ieee.org) is a Ph.D. student in the computer science department at Concordia University in Montréal, Canada. Ibrahim was first introduced to Linux (0.99) and Motif at the Lebanese American University. Among his interests are e-commerce, web applications, distributed objects and helping his friends at LinuxLeb.com (Linux Lebanon).

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

how do i save this page?

Anonymous's picture

how do i save this page?

Funny cartoon.

Anonymous's picture

Yes.. But there is no god.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix