Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::G::Source Class Reference

A GSource C++ interface. More...

#include <xfc/glib/main.hh>

Inheritance diagram for Xfc::G::Source:

Xfc::Trackable Xfc::G::ChildWatchSource Xfc::G::IdleSource Xfc::G::IOSource Xfc::G::TimeoutSource List of all members.

Public Types

Public Member Functions

Accessors
Methods

Detailed Description

A GSource C++ interface.

A Source corresponds to a single source of input. When sources are created they aren't associated with any main context. Once attached, a source is permanently associated with a particular context and can't be moved to another context.

Source is the base class for the built-in ChildWatchSource, TimeoutSource, IdleSource and IOSource types. In most cases the built-in source types should be enough. When they aren't, or when you need something more powerful, you can create your own custom event source by subclassing G::CustomSource and overriding its pure virtual methods.


Member Typedef Documentation

typedef sigc::slot<bool> Xfc::G::Source::SourceSlot

Signature of the callback slot passed to timeout, idle and custom sources.

Example: Method signature for SourceSlot.

< bool method();
< // return: The slot should return false if the source should be removed.
<


Constructor & Destructor Documentation

Xfc::G::Source::Source ( GSource *  source,
bool  owns_reference = true 
)

Construct a source from an existing GSource object.

Parameters:
source A pointer to a GSource.
owns_reference Set true if the initial reference count is owned by this object.
The Source object takes over the ownership of the GSource and unreferences it when the destructor is called.

Xfc::G::Source::Source ( GSource *  source,
bool  owns_reference = true 
)

Construct a source from an existing GSource object.

Parameters:
source A pointer to a GSource.
owns_reference Set true if the initial reference count is owned by this object.
The Source object takes over the ownership of the GSource and unreferences it when the destructor is called.


Member Function Documentation

int Xfc::G::Source::get_priority (  )  const

Gets the priority of the source.

Returns:
The priority of the source.

bool Xfc::G::Source::get_can_recurse (  )  const

Checks whether a source is allowed to be called recursively (see set_can_recurse()).

Returns:
Whether recursion is allowed.

unsigned int Xfc::G::Source::get_id (  )  const

Gets the numeric ID for a particular source.

Returns:
The ID for the source.

Pointer<MainContext> Xfc::G::Source::get_context (  )  const

Gets the main context with which the source is associated.

Returns:
The associated MainContext, or null if a context has not yet been added to the source.
Calling this function on a destroyed source is an error.

void Xfc::G::Source::get_current_time ( TimeVal timeval  ) 

Gets the "current time" to be used when checking this source.

Parameters:
timeval A TimeVal object in which to store the current time.
The advantage of calling this function over calling G::get_current_time() directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system time.

bool Xfc::G::Source::is_attached ( G::MainContext context  )  const

Determines whether context is attached to this source.

Returns:
true if context is attached to this source.

virtual void Xfc::G::Source::unref (  )  [virtual]

Decrease the source reference count by one.

When the reference count becomes zero for a heap object delete is called. Remember, as with all XFC Objects you must call unref() on a dynamically allocated IOChannel, not delete. If you use a smart you don't need to call unref(), the smart pointer will do that for you. You don't need to call unref() on a source allocated on the stack unless you first called ref().

Reimplemented from Xfc::Trackable.

unsigned int Xfc::G::Source::attach ( MainContext context = 0  ) 

Adds the source to context so that it will be executed within that context.

Parameters:
context A MainContext, or null to use the default context.
Returns:
The ID for the source within the MainContext.

void Xfc::G::Source::destroy (  ) 

Removes a source from its MainContext, if any, and marks it as destroyed.

After calling this method the source cannot be subsequently added to another context.

void Xfc::G::Source::set_priority ( int  priority  ) 

Sets the priority of the source.

Parameters:
priority The new priority.
While the main loop is being run, the source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched.

void Xfc::G::Source::set_can_recurse ( bool  can_recurse  ) 

Sets whether a source can be called recursively.

Parameters:
can_recurse Whether recursion is allowed for this source.
If can_recurse is true, while the source is being dispatched the source will be processed normally. Otherwise, all processing of the source is blocked until the dispatch function returns.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3