Synopsis

#include <ntd-widgets.h>

struct              NtdSwitch;

GtkWidget *         ntd_switch_new                      (void);
GtkWidget *         ntd_switch_new_with_label           (const gchar *label);
GtkWidget *         ntd_switch_new_readonly_with_label  (const gchar *label);
GtkWidget *         ntd_switch_new_unstable_with_label  (const gchar *label);
GtkWidget *         ntd_switch_new_tristate_with_label  (const gchar *label);

gboolean            ntd_switch_get_readonly             (NtdSwitch *the_switch);
void                ntd_switch_set_readonly             (NtdSwitch *the_switch,
                                                         gboolean readonly);
NtdDigitalState     ntd_switch_get_default_state        (NtdSwitch *the_switch);
void                ntd_switch_set_default_state        (NtdSwitch *the_switch,
                                                         NtdDigitalState default_state);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkBin
                                 +----NtdLed
                                       +----NtdSwitch

Implemented Interfaces

NtdSwitch implements AtkImplementorIface, GtkBuildable and NtdDigital.

Properties

  "default-state"            NtdDigitalState       : Read / Write / Construct
  "readonly"                 gboolean              : Read / Write / Construct

Description

Details

struct NtdSwitch

struct NtdSwitch;

ntd_switch_new ()

GtkWidget *         ntd_switch_new                      (void);

Creates a new NtdSwitch widget. Its starting state is NTD_DIGITAL_UNDEF.

Returns :

the newly created widget.

ntd_switch_new_with_label ()

GtkWidget *         ntd_switch_new_with_label           (const gchar *label);

Creates a new NtdSwitch widget with a GtkLabel as child widget. Its starting state is NTD_DIGITAL_OFF.

label :

the text to show.

Returns :

the newly created widget.

ntd_switch_new_readonly_with_label ()

GtkWidget *         ntd_switch_new_readonly_with_label  (const gchar *label);

Creates a new read-only NtdSwitch widget with a GtkLabel as child widget. The read-only widget do not responde to any event: its state can be only changed via software througth the NtdDigital interface.

label :

the text to show.

Returns :

the newly created widget.

ntd_switch_new_unstable_with_label ()

GtkWidget *         ntd_switch_new_unstable_with_label  (const gchar *label);

Creates a new 0-1 unstable NtdSwitch widget with a GtkLabel as child widget.

label :

the text to show.

Returns :

the newly created widget.

ntd_switch_new_tristate_with_label ()

GtkWidget *         ntd_switch_new_tristate_with_label  (const gchar *label);

Creates a new 1-0-2 stable NtdSwitch widget with a GtkLabel as child widget.

label :

the text to show.

Returns :

the newly created widget.

ntd_switch_get_readonly ()

gboolean            ntd_switch_get_readonly             (NtdSwitch *the_switch);

Retrieves the read-only flag from a NtdSwitch widget, that is it returns TRUE if the_switch is a read-only switch. Take a look to ntd_switch_set_readonly() for a description on what is a read-only switch.

the_switch :

a NtdSwitch.

Returns :

TRUE if the widget is a read-only switch.

ntd_switch_set_readonly ()

void                ntd_switch_set_readonly             (NtdSwitch *the_switch,
                                                         gboolean readonly);

Sets the read-only flag to get a read-only NtdSwitch widget. This kind of widget works as a NtdLed widget, that is it does not respond to any event and you must change its state throught the NtdDigital interface.

In a read-only switch, the instable flag has no meaning because the switch do not responde to the release_button and to the leave signals. You can use a read-only switch to monitor a digital output without allowing to change its state,

the_switch :

a NtdSwitch.

readonly :

TRUE to get read-only switches.

ntd_switch_get_default_state ()

NtdDigitalState     ntd_switch_get_default_state        (NtdSwitch *the_switch);

Retrieves the default state from a NtdSwitch widget, that is it returns a value different from NTD_DIGITAL_INVALID if the_switch is an unstable switch. Take a look to ntd_switch_set_default_state() for a description on what is an unstable switch.

the_switch :

a NtdSwitch.

Returns :

NTD_DIGITAL_INVALID if the widget is a standard switch, or the default state for unstable switches.

ntd_switch_set_default_state ()

void                ntd_switch_set_default_state        (NtdSwitch *the_switch,
                                                         NtdDigitalState default_state);

Sets the default state to get unstable switches, that is a switch that do not retain its state. As you release the mouse button or the widget looses the focus, the state is changed to its default state.

An unstable switch can also be tristate, that is it ever returns to its default state and, when pressed, toggles between the other two discrete states.

To reset to the default behaviour (the state is maintained until the next click), set the default state to NTD_DIGITAL_INVALID.

the_switch :

a NtdSwitch.

default_state :

the default state of the switch.

Property Details

The "default-state" property

  "default-state"            NtdDigitalState       : Read / Write / Construct

If different from NTD_DIGITAL_INVALID, specify the switch is unstable (that is, it ever returns to a default state).

Default value: NTD_DIGITAL_INVALID


The "readonly" property

  "readonly"                 gboolean              : Read / Write / Construct

Specify if the switch must work in the same way of a NtdLed (but showing switch icons).

Default value: FALSE