file_selection

Description

file_selection.c is a Motif GUI source file, typically generated by an interface builder tool like X-Designer. Its purpose is to create and manage an XmFileSelectionBox widget within the “Submetrix 2000 unraveller” application. This is a standard graphical user interface element that allows users to browse the file system, select existing files for opening, or specify new file paths for saving.

How It Works

This file uses Motif (Xm) and Xt Intrinsics libraries to define and instantiate GUI widgets.

  1. create_FileSelectionBox(Widget parent) function:
    • Creates a DialogShell widget (widget0) as the parent for the file selection box.
    • Creates an XmFileSelectionBox widget (FSBox).
    • Sets initial resource values for the FileSelectionBox:
      • XmNdirectory: Sets the initial directory to the current directory (.).
      • XmNpattern: Sets a file pattern filter (e.g., *.sx?) to display files matching Submetrix extensions.
      • XmNdialogTitle: Sets the title of the dialog to “Configuration File”.
    • Retrieves references to the default “Cancel” and “OK” buttons within the FileSelectionBox.
    • Unmanages the “Help” button, making it invisible.
    • Attaches callback functions to the FileSelectionBox:
      • file_select_ok (for XmNokCallback): Called when the user clicks “OK” or double-clicks a file.
      • file_select_cancel (for XmNcancelCallback): Called when the user clicks “Cancel”. This file is primarily a structural definition of a GUI element and does not contain core data processing logic. The interaction logic (e.g., what happens when “OK” is pressed) is handled by the associated callback functions (e.g., in callbacks.c).