| Top |
| CtkWidget * | ctk_toggle_button_new () |
| CtkWidget * | ctk_toggle_button_new_with_label () |
| CtkWidget * | ctk_toggle_button_new_with_mnemonic () |
| void | ctk_toggle_button_set_mode () |
| gboolean | ctk_toggle_button_get_mode () |
| void | ctk_toggle_button_toggled () |
| gboolean | ctk_toggle_button_get_active () |
| void | ctk_toggle_button_set_active () |
| gboolean | ctk_toggle_button_get_inconsistent () |
| void | ctk_toggle_button_set_inconsistent () |
| gboolean | active | Read / Write |
| gboolean | draw-indicator | Read / Write |
| gboolean | inconsistent | Read / Write |
GObject
╰── GInitiallyUnowned
╰── CtkWidget
╰── CtkContainer
╰── CtkBin
╰── CtkButton
╰── CtkToggleButton
├── CtkCheckButton
╰── CtkMenuButton
CtkToggleButton implements AtkImplementorIface, CtkBuildable, CtkActionable and CtkActivatable.
A CtkToggleButton is a CtkButton which will remain “pressed-in” when clicked. Clicking again will cause the toggle button to return to its normal state.
A toggle button is created by calling either ctk_toggle_button_new() or
ctk_toggle_button_new_with_label(). If using the former, it is advisable to
pack a widget, (such as a CtkLabel and/or a CtkImage), into the toggle
button’s container. (See CtkButton for more information).
The state of a CtkToggleButton can be set specifically using
ctk_toggle_button_set_active(), and retrieved using
ctk_toggle_button_get_active().
To simply switch the state of a toggle button, use ctk_toggle_button_toggled().
CtkToggleButton has a single CSS node with name button. To differentiate it from a plain CtkButton, it gets the .toggle style class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
static void output_state (CtkToggleButton *source, gpointer user_data) { printf ("Active: %d\n", ctk_toggle_button_get_active (source)); } void make_toggles (void) { CtkWidget *window, *toggle1, *toggle2; CtkWidget *box; const char *text; window = ctk_window_new (CTK_WINDOW_TOPLEVEL); box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 12); text = "Hi, I’m a toggle button."; toggle1 = ctk_toggle_button_new_with_label (text); // Makes this toggle button invisible ctk_toggle_button_set_mode (CTK_TOGGLE_BUTTON (toggle1), TRUE); g_signal_connect (toggle1, "toggled", G_CALLBACK (output_state), NULL); ctk_container_add (CTK_CONTAINER (box), toggle1); text = "Hi, I’m a toggle button."; toggle2 = ctk_toggle_button_new_with_label (text); ctk_toggle_button_set_mode (CTK_TOGGLE_BUTTON (toggle2), FALSE); g_signal_connect (toggle2, "toggled", G_CALLBACK (output_state), NULL); ctk_container_add (CTK_CONTAINER (box), toggle2); ctk_container_add (CTK_CONTAINER (window), box); ctk_widget_show_all (window); } |
CtkWidget *
ctk_toggle_button_new (void);
Creates a new toggle button. A widget should be packed into the button, as in ctk_button_new().
CtkWidget *
ctk_toggle_button_new_with_label (const gchar *label);
Creates a new toggle button with a text label.
CtkWidget *
ctk_toggle_button_new_with_mnemonic (const gchar *label);
Creates a new CtkToggleButton containing a label. The label
will be created using ctk_label_new_with_mnemonic(), so underscores
in label
indicate the mnemonic for the button.
void ctk_toggle_button_set_mode (CtkToggleButton *toggle_button,gboolean draw_indicator);
Sets whether the button is displayed as a separate indicator and label.
You can call this function on a checkbutton or a radiobutton with
draw_indicator
= FALSE to make the button look like a normal button.
This can be used to create linked strip of buttons that work like a CtkStackSwitcher.
This function only affects instances of classes like CtkCheckButton and CtkRadioButton that derive from CtkToggleButton, not instances of CtkToggleButton itself.
gboolean
ctk_toggle_button_get_mode (CtkToggleButton *toggle_button);
Retrieves whether the button is displayed as a separate indicator
and label. See ctk_toggle_button_set_mode().
void
ctk_toggle_button_toggled (CtkToggleButton *toggle_button);
Emits the “toggled” signal on the CtkToggleButton. There is no good reason for an application ever to call this function.
gboolean
ctk_toggle_button_get_active (CtkToggleButton *toggle_button);
Queries a CtkToggleButton and returns its current state. Returns TRUE if
the toggle button is pressed in and FALSE if it is raised.
void ctk_toggle_button_set_active (CtkToggleButton *toggle_button,gboolean is_active);
Sets the status of the toggle button. Set to TRUE if you want the
CtkToggleButton to be “pressed in”, and FALSE to raise it.
This action causes the “toggled” signal and the
“clicked” signal to be emitted.
gboolean
ctk_toggle_button_get_inconsistent (CtkToggleButton *toggle_button);
Gets the value set by ctk_toggle_button_set_inconsistent().
void ctk_toggle_button_set_inconsistent (CtkToggleButton *toggle_button,gboolean setting);
If the user has selected a range of elements (such as some text or
spreadsheet cells) that are affected by a toggle button, and the
current values in that range are inconsistent, you may want to
display the toggle in an “in between” state. This function turns on
“in between” display. Normally you would turn off the inconsistent
state again if the user toggles the toggle button. This has to be
done manually, ctk_toggle_button_set_inconsistent() only affects
visual appearance, it doesn’t affect the semantics of the button.
“active” property “active” gboolean
If the toggle button should be pressed in.
Owner: CtkToggleButton
Flags: Read / Write
Default value: FALSE
“draw-indicator” property “draw-indicator” gboolean
If the toggle part of the button is displayed.
Owner: CtkToggleButton
Flags: Read / Write
Default value: FALSE
“toggled” signalvoid user_function (CtkToggleButton *togglebutton, gpointer user_data)
Should be connected if you wish to perform an action whenever the CtkToggleButton's state is changed.
togglebutton |
the object which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First