GTK+ 3 Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Style Properties | Signals |
#include <gtk/gtk.h> struct GtkExpander; GtkWidget * gtk_expander_new (const gchar *label
); GtkWidget * gtk_expander_new_with_mnemonic (const gchar *label
); void gtk_expander_set_expanded (GtkExpander *expander
,gboolean expanded
); gboolean gtk_expander_get_expanded (GtkExpander *expander
); void gtk_expander_set_spacing (GtkExpander *expander
,gint spacing
); gint gtk_expander_get_spacing (GtkExpander *expander
); void gtk_expander_set_label (GtkExpander *expander
,const gchar *label
); const gchar * gtk_expander_get_label (GtkExpander *expander
); void gtk_expander_set_use_underline (GtkExpander *expander
,gboolean use_underline
); gboolean gtk_expander_get_use_underline (GtkExpander *expander
); void gtk_expander_set_use_markup (GtkExpander *expander
,gboolean use_markup
); gboolean gtk_expander_get_use_markup (GtkExpander *expander
); void gtk_expander_set_label_widget (GtkExpander *expander
,GtkWidget *label_widget
); GtkWidget * gtk_expander_get_label_widget (GtkExpander *expander
); void gtk_expander_set_label_fill (GtkExpander *expander
,gboolean label_fill
); gboolean gtk_expander_get_label_fill (GtkExpander *expander
);
GObject +----GInitiallyUnowned +----GtkWidget +----GtkContainer +----GtkBin +----GtkExpander
"expanded" gboolean : Read / Write / Construct "label" gchar* : Read / Write / Construct "label-fill" gboolean : Read / Write / Construct "label-widget" GtkWidget* : Read / Write "spacing" gint : Read / Write "use-markup" gboolean : Read / Write / Construct "use-underline" gboolean : Read / Write / Construct
A GtkExpander allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a GtkTreeView.
Normally you use an expander as you would use any other descendant
of GtkBin; you create the child widget and use gtk_container_add()
to add it to the expander. When the expander is toggled, it will take
care of showing and hiding the child automatically.
There are situations in which you may prefer to show and hide the expanded widget yourself, such as when you want to actually create the widget at expansion time. In this case, create a GtkExpander but do not add a child to it. The expander widget has an "expanded" property which can be used to monitor its expansion state. You should watch this property with a signal connection as follows:
expander = gtk_expander_new_with_mnemonic ("_More Options"); g_signal_connect (expander, "notify::expanded", G_CALLBACK (expander_callback), NULL); ... static void expander_callback (GObject *object, GParamSpec *param_spec, gpointer user_data) { GtkExpander *expander; expander = GTK_EXPANDER (object); if (gtk_expander_get_expanded (expander)) { /* Show or create widgets */ } else { /* Hide or destroy widgets */ } }
The GtkExpander implementation of the GtkBuildable interface supports placing a child in the label position by specifying "label" as the "type" attribute of a <child> element. A normal content child can be specified without specifying a <child> type attribute.
Example 93. A UI definition fragment with GtkExpander
1 2 3 4 5 6 7 8 |
<object class="GtkExpander"> <child type="label"> <object class="GtkLabel" id="expander-label"/> </child> <child> <object class="GtkEntry" id="expander-content"/> </child> </object> |
GtkWidget * gtk_expander_new (const gchar *label
);
Creates a new expander using label
as the text of the label.
|
the text of the label |
Returns : |
a new GtkExpander widget. |
Since 2.4
GtkWidget * gtk_expander_new_with_mnemonic (const gchar *label
);
Creates a new expander using label
as the text of the label.
If characters in label
are preceded by an underscore, they are underlined.
If you need a literal underscore character in a label, use '__' (two
underscores). The first underlined character represents a keyboard
accelerator called a mnemonic.
Pressing Alt and that key activates the button.
|
the text of the label with an underscore in front of the mnemonic character. [allow-none] |
Returns : |
a new GtkExpander widget. |
Since 2.4
void gtk_expander_set_expanded (GtkExpander *expander
,gboolean expanded
);
Sets the state of the expander. Set to TRUE
, if you want
the child widget to be revealed, and FALSE
if you want the
child widget to be hidden.
|
a GtkExpander |
|
whether the child widget is revealed |
Since 2.4
gboolean gtk_expander_get_expanded (GtkExpander *expander
);
Queries a GtkExpander and returns its current state. Returns TRUE
if the child widget is revealed.
See gtk_expander_set_expanded()
.
|
a GtkExpander |
Returns : |
the current state of the expander |
Since 2.4
void gtk_expander_set_spacing (GtkExpander *expander
,gint spacing
);
Sets the spacing field of expander
, which is the number of
pixels to place between expander and the child.
|
a GtkExpander |
|
distance between the expander and child in pixels |
Since 2.4
gint gtk_expander_get_spacing (GtkExpander *expander
);
Gets the value set by gtk_expander_set_spacing()
.
|
a GtkExpander |
Returns : |
spacing between the expander and child |
Since 2.4
void gtk_expander_set_label (GtkExpander *expander
,const gchar *label
);
Sets the text of the label of the expander to label
.
This will also clear any previously set labels.
|
a GtkExpander |
|
a string. [allow-none] |
Since 2.4
const gchar * gtk_expander_get_label (GtkExpander *expander
);
Fetches the text from a label widget including any embedded
underlines indicating mnemonics and Pango markup, as set by
gtk_expander_set_label()
. If the label text has not been set the
return value will be NULL
. This will be the case if you create an
empty button with gtk_button_new()
to use as a container.
Note that this function behaved differently in versions prior to 2.14 and used to return the label text stripped of embedded underlines indicating mnemonics and Pango markup. This problem can be avoided by fetching the label text directly from the label widget.
|
a GtkExpander |
Returns : |
The text of the label widget. This string is owned by the widget and must not be modified or freed. |
Since 2.4
void gtk_expander_set_use_underline (GtkExpander *expander
,gboolean use_underline
);
If true, an underline in the text of the expander label indicates the next character should be used for the mnemonic accelerator key.
|
a GtkExpander |
|
TRUE if underlines in the text indicate mnemonics |
Since 2.4
gboolean gtk_expander_get_use_underline (GtkExpander *expander
);
Returns whether an embedded underline in the expander label
indicates a mnemonic. See gtk_expander_set_use_underline()
.
|
a GtkExpander |
Returns : |
TRUE if an embedded underline in the expander
label indicates the mnemonic accelerator keys |
Since 2.4
void gtk_expander_set_use_markup (GtkExpander *expander
,gboolean use_markup
);
Sets whether the text of the label contains markup in gtk_label_set_markup()
.
|
a GtkExpander |
|
TRUE if the label's text should be parsed for markup |
Since 2.4
gboolean gtk_expander_get_use_markup (GtkExpander *expander
);
Returns whether the label's text is interpreted as marked up with
the gtk_expander_set_use_markup()
.
|
a GtkExpander |
Returns : |
TRUE if the label's text will be parsed for markup |
Since 2.4
void gtk_expander_set_label_widget (GtkExpander *expander
,GtkWidget *label_widget
);
Set the label widget for the expander. This is the widget that will appear embedded alongside the expander arrow.
|
a GtkExpander |
|
the new label widget. [allow-none] |
Since 2.4
GtkWidget * gtk_expander_get_label_widget (GtkExpander *expander
);
Retrieves the label widget for the frame. See
gtk_expander_set_label_widget()
.
|
a GtkExpander |
Returns : |
the label widget,
or NULL if there is none. [transfer none]
|
Since 2.4
void gtk_expander_set_label_fill (GtkExpander *expander
,gboolean label_fill
);
Sets whether the label widget should fill all available
horizontal space allocated to expander
.
|
a GtkExpander |
|
TRUE if the label should should fill
all available horizontal space |
Since 2.22
gboolean gtk_expander_get_label_fill (GtkExpander *expander
);
Returns whether the label widget will fill all available
horizontal space allocated to expander
.
|
a GtkExpander |
Returns : |
TRUE if the label widget will fill all
available horizontal space |
Since 2.22
"expanded"
property"expanded" gboolean : Read / Write / Construct
Whether the expander has been opened to reveal the child widget.
Default value: FALSE
"label"
property"label" gchar* : Read / Write / Construct
Text of the expander's label.
Default value: NULL
"label-fill"
property"label-fill" gboolean : Read / Write / Construct
Whether the label widget should fill all available horizontal space.
Default value: FALSE
"label-widget"
property"label-widget" GtkWidget* : Read / Write
A widget to display in place of the usual expander label.
"spacing"
property"spacing" gint : Read / Write
Space to put between the label and the child.
Allowed values: >= 0
Default value: 0
"use-markup"
property"use-markup" gboolean : Read / Write / Construct
The text of the label includes XML markup. See pango_parse_markup().
Default value: FALSE
"use-underline"
property"use-underline" gboolean : Read / Write / Construct
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Default value: FALSE
"expander-size"
style property"expander-size" gint : Read
Size of the expander arrow.
Allowed values: >= 0
Default value: 10
"expander-spacing"
style property"expander-spacing" gint : Read
Spacing around expander arrow.
Allowed values: >= 0
Default value: 2
"activate"
signalvoid user_function (GtkExpander *expander,
gpointer user_data) : Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |