Integrating applications into the Desktop

Creating icons for user data files

You can use application rules to define special icons for certain types of files, and to start your application when a user double-click on one of those icons. For example, specially formatted calendar files created and displayed by a calendar program could be represented by a calendar file icons.

To define special icons for data files:

  1. Create a pixmap for the file icon.

    The name of the pixmap file must end in the .px extension.

    To help users identify it as a file icon, you should base the design of your data file icon on the standard SCO OpenServer system file icon. For example, a C header file is represented by a file icon labeled with an ``.h'':

  2. Write a rule that assigns the icon to a type of file.

    For example, the following rule specifies that files with the .cal suffix will be represented by the icon pixmap file Cal_file.px. The rule also specifies that double-clicking on one of these file icons will have the same effect as dropping the file icon on the application's icon: it will start the calendar program with the calendar file displayed. For more about Desktop rules, see the Graphical Environment Guide.

      1 icon_rules
      2 {
      3   *.cal /F
      4   {
      5     picture=Cal_file.px;                      

    6 trigger_action: activate 7 { 8 filetype /usr/bin/calendar 9 if [ == $_type(1) F ] && [ == $_type(2) X ] 10 then 11 /usr/bin/calendar $* $static_arg 12 else 13 fyi -t 'Calendar' 'Calendar is not installed on your system' 14 fi 15 } 16 } 17 }

    line 1
    Identifies the start of the icon_rule section of your rule file.

    lines 3-5
    Specify that files with names ending in .cal will display the Cal_file.px pixmap. The system searches certain directories below /usr/lib/X11/IXI/XDesktop/bitmaps for the file.

    lines 6-15
    Define what happens when the user double-clicks (the activate or drop trigger) on the file icon.

    lines 8-9
    Check the file type of /usr/bin/calendar. If it is an executable, do line 11. If not, do line 13.

    line 11
    Executes the calendar program. $* includes any arguments the user enters in the drop trigger dialog box. The filename(s) represented by the dropped icon(s) are substituted for $static_arg.

    line 13
    Prints an error message if /usr/bin/calendar is not executable. The message assumes that not having execute permission for the file is, for the Desktop user, functionally equivalent to its not being installed.

  3. Use the deskconfobj tool to install your pixmap and rule.

    Use the following syntax to install your pixmap:

       deskconfobj -alrg -name pixmap_name -src file
    Use the -alrg (add large pixmap) option to add a pixmap. For pixmap_name, substitute the name of the pixmap file (Cal_file.px for the above example). For file, substitute the pathname of the pixmap file to be copied.

    Use the following syntax to install your rule:

       deskconfobj -arule -name rule_name -src file
    For rule_name, substitute a name that is unlikely to be duplicated by other programs (typically your application's class name). For file, substitute the pathname of the file that contains the rules to be copied.

    NOTE: Newly installed rules will not be recognized until the system is restarted.

    The data file's name will be used as the icon label. For more about using deskconfobj, see ``Install icon files''.

Next topic: Adapting to display resolution at run time
Previous topic: Localizing icon labels and messages

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003