Clutter.Script

g Clutter.Script Clutter.Script GObject.Object GObject.Object GObject.Object->Clutter.Script

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_search_paths (paths)

add_states (name, state)

connect_signals (user_data)

connect_signals_full (func, *user_data)

ensure_objects ()

get_object (name)

get_states (name)

get_translation_domain ()

get_type_from_name (type_name)

list_objects ()

load_from_data (data, length)

load_from_file (filename)

load_from_resource (resource_path)

lookup_filename (filename)

set_translation_domain (domain)

unmerge_objects (merge_id)

Virtual Methods

Inherited:

GObject.Object (7)

do_get_type_from_name (type_name)

Properties

Name

Type

Flags

Short Description

filename

str

r

The path of the currently parsed file

filename-set

bool

r

Whether the :filename property is set

translation-domain

str

r/w

The translation domain used to localize string

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Clutter.Script(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Clutter.ScriptClass

The Clutter.Script structure contains only private data and should be accessed using the provided API

New in version 0.6.

classmethod new()
Returns:

the newly created Clutter.Script instance. Use GObject.Object.unref() when done.

Return type:

Clutter.Script

Creates a new Clutter.Script instance. Clutter.Script can be used to load objects definitions for scenegraph elements, like actors, or behavioural elements, like behaviours and timelines. The definitions must be encoded using the JavaScript Object Notation (JSON) language.

New in version 0.6.

add_search_paths(paths)
Parameters:

paths ([str]) – an array of strings containing different search paths

Adds paths to the list of search paths held by self.

The search paths are used by Clutter.Script.lookup_filename(), which can be used to define search paths for the textures source file name or other custom, file-based properties.

New in version 0.8.

add_states(name, state)
Parameters:

Associates a Clutter.State to the Clutter.Script instance using the given name.

The Clutter.Script instance will use state to resolve target states when connecting signal handlers.

The Clutter.Script instance will take a reference on the Clutter.State passed to this function.

New in version 1.8.

Deprecated since version 1.12.

connect_signals(user_data)
Parameters:

user_data (object or None) – data to be passed to the signal handlers, or None

Connects all the signals defined into a UI definition file to their handlers.

This method invokes Clutter.Script.connect_signals_full() internally and uses GModule.Module's introspective features (by opening the current module’s scope) to look at the application’s symbol table.

Note that this function will not work if GModule.Module is not supported by the platform Clutter is running on.

New in version 0.6.

connect_signals_full(func, *user_data)
Parameters:

Connects all the signals defined into a UI definition file to their handlers.

This function allows to control how the signal handlers are going to be connected to their respective signals. It is meant primarily for language bindings to allow resolving the function names using the native API, but it can also be used on platforms that do not support GModule.Module.

Applications should use Clutter.Script.connect_signals().

New in version 0.6.

ensure_objects()

Ensure that every object defined inside self is correctly constructed. You should rarely need to use this function.

New in version 0.6.

get_object(name)
Parameters:

name (str) – the name of the object to retrieve

Returns:

the named object, or None if no object with the given name was available

Return type:

GObject.Object

Retrieves the object bound to name. This function does not increment the reference count of the returned object.

New in version 0.6.

get_states(name)
Parameters:

name (str or None) – the name of the Clutter.State, or None

Returns:

a pointer to the Clutter.State for the given name. The Clutter.State is owned by the Clutter.Script instance and it should not be unreferenced

Return type:

Clutter.State

Retrieves the Clutter.State for the given state_name.

If name is None, this function will return the default Clutter.State instance.

New in version 1.8.

Deprecated since version 1.12.

get_translation_domain()
Returns:

the translation domain, if any is set, or None

Return type:

str

Retrieves the translation domain set using Clutter.Script.set_translation_domain().

New in version 1.10.

get_type_from_name(type_name)
Parameters:

type_name (str) – name of the type to look up

Returns:

the type for the requested type name, or GObject.TYPE_INVALID if not corresponding type was found.

Return type:

GObject.GType

Looks up a type by name, using the virtual function that Clutter.Script has for that purpose. This function should rarely be used.

New in version 0.6.

list_objects()
Returns:

a list of GObject.Object s, or None. The objects are owned by the Clutter.Script instance. Use g_list_free() on the returned list when done.

Return type:

[GObject.Object]

Retrieves all the objects created by self.

Note: this function does not increment the reference count of the objects it returns.

New in version 0.8.

load_from_data(data, length)
Parameters:
  • data (str) – a buffer containing the definitions

  • length (int) – the length of the buffer, or -1 if data is a NUL-terminated buffer

Raises:

GLib.Error

Returns:

on error, zero is returned and error is set accordingly. On success, the merge id for the UI definitions is returned. You can use the merge id with Clutter.Script.unmerge_objects().

Return type:

int

Loads the definitions from data into self and merges with the currently loaded ones, if any.

New in version 0.6.

load_from_file(filename)
Parameters:

filename (str) – the full path to the definition file

Raises:

GLib.Error

Returns:

on error, zero is returned and error is set accordingly. On success, the merge id for the UI definitions is returned. You can use the merge id with Clutter.Script.unmerge_objects().

Return type:

int

Loads the definitions from filename into self and merges with the currently loaded ones, if any.

New in version 0.6.

load_from_resource(resource_path)
Parameters:

resource_path (str) – the resource path of the file to parse

Raises:

GLib.Error

Returns:

on error, zero is returned and error is set accordingly. On success, the merge id for the UI definitions is returned. You can use the merge id with Clutter.Script.unmerge_objects().

Return type:

int

Loads the definitions from a resource file into self and merges with the currently loaded ones, if any.

New in version 1.10.

lookup_filename(filename)
Parameters:

filename (str) – the name of the file to lookup

Returns:

the full path of filename or None if no path was found.

Return type:

str

Looks up filename inside the search paths of self. If filename is found, its full path will be returned .

New in version 0.8.

set_translation_domain(domain)
Parameters:

domain (str or None) – the translation domain, or None

Sets the translation domain for self.

New in version 1.10.

unmerge_objects(merge_id)
Parameters:

merge_id (int) – merge id returned when loading a UI definition

Unmerges the objects identified by merge_id.

New in version 0.6.

do_get_type_from_name(type_name) virtual
Parameters:

type_name (str) – name of the type to look up

Returns:

the type for the requested type name, or GObject.TYPE_INVALID if not corresponding type was found.

Return type:

GObject.GType

Looks up a type by name, using the virtual function that Clutter.Script has for that purpose. This function should rarely be used.

New in version 0.6.

Property Details

Clutter.Script.props.filename
Name:

filename

Type:

str

Default Value:

None

Flags:

READABLE

The path of the currently parsed file. If Clutter.Script :filename-set is False then the value of this property is undefined.

New in version 0.6.

Clutter.Script.props.filename_set
Name:

filename-set

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the Clutter.Script :filename property is set. If this property is True then the currently parsed data comes from a file, and the file name is stored inside the Clutter.Script :filename property.

New in version 0.6.

Clutter.Script.props.translation_domain
Name:

translation-domain

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The translation domain, used to localize strings marked as translatable inside a UI definition.

If Clutter.Script :translation-domain is set to None, Clutter.Script will use gettext(), otherwise GLib.dgettext() will be used.

New in version 1.10.