GtkSwitch

GtkSwitch — A "light switch" style toggle

Synopsis

#include <gtk/gtk.h>

                    GtkSwitch;
GtkWidget *         gtk_switch_new                      (void);
void                gtk_switch_set_active               (GtkSwitch *sw,
                                                         gboolean is_active);
gboolean            gtk_switch_get_active               (GtkSwitch *sw);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkWidget
               +----GtkSwitch

Implemented Interfaces

GtkSwitch implements AtkImplementorIface, GtkBuildable and GtkActivatable.

Properties

  "active"                   gboolean              : Read / Write

Style Properties

  "slider-width"             gint                  : Read

Description

GtkSwitch is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.

Details

GtkSwitch

typedef struct _GtkSwitch GtkSwitch;

The GtkSwitch structure contains private data and it should only be accessed using the provided API.


gtk_switch_new ()

GtkWidget *         gtk_switch_new                      (void);

Creates a new GtkSwitch widget.

Returns :

the newly created GtkSwitch instance

gtk_switch_set_active ()

void                gtk_switch_set_active               (GtkSwitch *sw,
                                                         gboolean is_active);

Changes the state of sw to the desired one.

sw :

a GtkSwitch

is_active :

TRUE if sw should be active, and FALSE otherwise

gtk_switch_get_active ()

gboolean            gtk_switch_get_active               (GtkSwitch *sw);

Gets whether the GtkSwitch is in its "on" or "off" state.

sw :

a GtkSwitch

Returns :

TRUE if the GtkSwitch is active, and FALSE otherwise

Property Details

The "active" property

  "active"                   gboolean              : Read / Write

Whether the GtkSwitch widget is in its on or off state.

Default value: FALSE

Style Property Details

The "slider-width" style property

  "slider-width"             gint                  : Read

The minimum width of the GtkSwitch handle, in pixels.

Allowed values: >= 36

Default value: 36

See Also

GtkToggleButton