Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
15.  Advanced Front Panel Customization Defining Front Panel Controls To Create a New Control Creating a Control that Monitors a File  Previous   Contents   Next 
   
 
  • FILE_NAME: Specifies the file to be monitored.

    For example, the following control looks for the presence of a file named meetings that you expect to be transferred to your system using anonymous ftp. The control is placed at the top of the Personal Applications subpanel.

    CONTROL MonitorCalendar
     {
     	TYPE							file
     	CONTAINER_NAME				PersonalApps
     	CONTAINER_TYPE				SUBPANEL
     	POSITION_HINTS				first
     	FILE_NAME					/users/ftp/meetings
     	MONITOR_TYPE				file
     	ICON							meetingsno
     	ALTERNATE_ICON				meetingsyes
     }

Creating a One-Instance (Toggle) Control

A one-instance control checks to see whether the process started by the PUSH_ACTION is already running. If the process is not running, the PUSH_ACTION is run. If the process is already running, the window is moved to the top of the window stack in the current workspace.

Use these fields to define the control's behavior:

  • PUSH_RECALL: Set to True.

  • CLIENT_NAME: Specifies the name of the client to the control.

    The value of CLIENT_NAME must match the first string (res_name) in the WM_CLASS property on the application's top-level window. For more information, see the xprop(1) man page.

  • PUSH_ACTION: Describes the action run when the user clicks the control.

    For example, the following control runs one instance of an application whose action is named MyEditor.

    CONTROL MyEditor
     {
     	TYPE							icon
     	CONTAINER_NAME				Top
     	CONTAINER_TYPE				BOX
     	POSITION_HINTS				15
     	PUSH_RECALL					True
     	CLIENT_NAME					BestEditor
     	PUSH_ACTION					StartMyEditor
     	ICON							MyEd
     }

To Create a Client Window Control

A client window control is an application window embedded in the Front Panel. For example, you can put a system load meter in the Front Panel by creating an xload client window control.

  1. Define the control.

    Use these fields to define the control's behavior:

    • TYPE: Set to client.

    • CLIENT_NAME: Specifies the client to be started.

      The value of CLIENT_NAME must match the first string (res_name) in the WM_CLASS property on the application's top-level window. For more information, see the xprop(1) man page.

    • CLIENT_GEOMETRY: Specifies the size, in pixels, needed for the client's Front Panel window.

      The xwininfo(1) man page describes how to find out the size of a window in pixels.

  2. Choose Restart Workspace Manager from the Workspace menu.

  3. Start the client from a terminal emulator command line.

    For example, the following control displays a 30 × 20 pixel load meter.

    CONTROL LoadMeter
     {
     	TYPE							client
     	CONTAINER_NAME				Top
     	CONTAINER_TYPE				BOX
     	CLIENT_NAME					xload
     	CLIENT_GEOMETRY			30x20
     }

    If the client is not saved and restored between sessions, you may want to configure the control to start the client when the user clicks it. For example, you can configure the LoadMeter control to start xload by adding the following line to the definition:

    PUSH_ACTION				StartXload

    and creating the action:

    ACTION StartXload
     {
     	WINDOW_TYPE				NO_STDIO
     	EXEC_STRING				/usr/contrib/bin/X11/xload
     }

To Animate a Control

You can attach an animation sequence to be used when the user chooses the control or drops an object on it.

In order to have an animation sequence, a control must:

  • Be type icon

  • Have a PUSH_ACTION or DROP_ACTION

  1. Specify the animation sequence using the ANIMATION component:

    	ANIMATION animation_name
     	{
     		ANIMATION	icon1				[milisecond_delay]
     		ANIMATION	icon2				[milisecond_delay]
     		...
     	}

    where icon1, icon 2, etc. are the names of icons, and milisecond_delay is the time delay between animation icons in milliseconds. The default time delay is 200 milliseconds.

  2. Add the PUSH_ANIMATION and/or DROP_ANIMATION fields to the control definition. The value is the name of the ANIMATION sequence.

    For example, the following lines animate a control that starts the BestEditor application. The time delay between icons is 300 milliseconds. The example assumes you've created icon files frame1, frame2, etc.

    CONTROL BestEditor
     {
     	...
     	PUSH_ANIMATION BestEdAnimation
     	...
     }
     ANIMATION BestEdAnimation
     {
     	frame1			300
     	frame2
     	...
     }
 
 
 
  Previous   Contents   Next