Packages‎ > ‎gnocl::gnome‎ > ‎

gnocl::appletFactory

A command which creates a Gnome panel applet.

Synopsis

gnocl::appletFactory iid command

Screenshot

Options

-background

type: color

Background colour of the widget.

-child

type: widget-ID

Widget ID of the child.

-dragTargets

type: list of strings

List of source targets (e.g. text/plain or application/x-color) which are supported.

-dropTargets

type: list of strings

List of destination targets (e.g. text/plain or application/x-color) which are supported.

-name

type: string

Name of the widget, can be used to set options in an rc file.

-onButtonPress

type: string (default: "")

Tcl command which is executed if a mouse button is press inside the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%t    type of event: one of buttonPress, button2Press or button3Press
%x    x coordinate
%y    y coordinate
%b    button number
%s    state of the buttons and modifiers (bitmask)

-onButtonRelease

type: string (default: "")

Tcl command which is executed if a mouse button is released inside the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%t    type of event: always buttonRelease
%x    x coordinate
%y    y coordinate
%b    button number
%s    state of the buttons and modifiers (bitmask)

-onChangeOrientation

type: string (default: "")

Command to be executed in the global scope if the panel including the applet changes its orientation. Before evaluation the following percent strings are substituted:

%w    widget name

-onChangeSize

type: string (default: "")

Command to be executed in the global scope if the panel including the applet changes its size. Before evaluation the following percent strings are substituted:

%w    widget name

-onDestroy

type: string (default: "")

Tcl command which is executed if the widget is destroyed. Before evaluation the following percent strings are substituted:

%w    widget name

-onDragData

type: string (default: "")

Tcl command which is executed if data is draged from this the widget to another. This command must return the data to be draged. Before evaluation the following percent strings are substituted:

%w    widget name
%t    time
%T    type of data

-onDropData

type: string (default: "")

Tcl command which is executed if data is dropped on the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%d    data
%l    length of data
%t    time
%T    type of data
%x    x coordinate
%y    y coordinate

-onMotion

type: string (default: "")

Tcl command which is executed if the mouse is moved inside the widget. Before evaluation the following percent strings are substituted:

%w    widget name
%x    x coordinate
%y    y coordinate
%s    state of the buttons and modifiers (bitmask)

-onPopupMenu

type: string (default: "")

Tcl command which is executed if the "popup-menu" signal is received, which is normally the case if the user presses Shift-F10. Before evaluation the following percent strings are substituted:

%w    widget name

-onRealize

type: string (default: "")

Tcl command whih is executed in the global scope if the widget has been realized. Before evaluation the following percent strings are substituted:

%w    widget name

-onShowHelp

type: string (default: "")

Tcl command which is executed in the global scope if the "show-help" signal is received, which is normally the case if the user presses F1 or Ctrl-F1. Before evaluation the following percent strings are substituted:

%w    widget name
%h    help type: either "whatsThis" or "tooltip"

-sensitive

type: boolean (default: 1)

Whether or not the item is sensitive to user input.

-tooltip

type: string

Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.

-visible

type: boolean (default: 1)

Whether or not the item is visible.

Description

The appletFactory creates a Gnome panel applet. An additional matching Bonobo Activation server file is needed. The appletFactory command has two parameters. iid is the ID which must correspond to the oaf_server iid entry in the server file.  Command is executed when gnome creates the applet. The following percent strings are substituted:

%w    name of the newly created applet

The above widget commands and options are applicable to this newly created applet.

Commands

id addMenuItem [-option value...]

Adds an entry to the panel menu.

Options

-text

type: percent-string (default: "")

Text or stock item of the entry.

-onClicked

type: string (default: "")

Command to be executed in the global scope if entry is chosen. Before evaluation the following percent strings are substituted:

% NEED TO BE COMPLETED

id addMenuSeparator

Adds a separator to the panel menu.

id getSize

Returns the size of the applet in pixel.

id getOrientation

Returns the orientation of the panel as one of up, down, left or right. The orientation is not the same as the side on the screen the panel is on. If the panel is for example on the right side of the screen, the orientation is left.

id configure [-option value...]

Configures the widget. Option may have any of the values accepted on creation of the widget.

id delete

Deletes the widget and the associated tcl command.

Example

#!/bin/sh
# The next line restarts using tclsh \
exec tclsh "$0" "$@"

# gnocl_test_applet

package require Gnocl
package require GnoclGnome

namespace eval gnocl {
set appName "gnocl_test_applet"
}

proc makeMenu { w } {
$w addMenuItem \
-text "%#About" \
-onClicked {gnocl::dialog -text "Gnocl Test Applet"}
}

proc createApplet {w iid} {
global Display

set Display [gnocl::label \
-text {%<<span foreground='blue'>Hello</span> \
<span foreground='red'>World</span>}]
set box [gnocl::box \
-orientation horizontal \
-children [list $Display]]
$w configure \
-child $box \
-onRealize "makeMenu %w" \
-onButtonRelease {gnocl::dialog \
-text "Clicked on the Hello World label"}
}

# For applets, this replaces gnocl::mainLoop. Substitutions performed for
# the callback: %w is the applet window, %i is the applet ID
gnocl::appletFactory OAFIID:gnocl_test_applet_factory {createApplet %w %i}




In order to install and run this example script, download the attachment below.

ċ
applet-2.tar.gz
(2k)
William Giddings,
21 Jan 2011, 09:42
Comments