GTK+ Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gtk/gtk.h> struct GtkButton; GtkWidget* gtk_button_new (void); GtkWidget* gtk_button_new_with_label (const gchar *label); GtkWidget* gtk_button_new_with_mnemonic (const gchar *label); GtkWidget* gtk_button_new_from_stock (const gchar *stock_id); void gtk_button_pressed (GtkButton *button); void gtk_button_released (GtkButton *button); void gtk_button_clicked (GtkButton *button); void gtk_button_enter (GtkButton *button); void gtk_button_leave (GtkButton *button); void gtk_button_set_relief (GtkButton *button, GtkReliefStyle newstyle); GtkReliefStyle gtk_button_get_relief (GtkButton *button); G_CONST_RETURN gchar* gtk_button_get_label (GtkButton *button); void gtk_button_set_label (GtkButton *button, const gchar *label); gboolean gtk_button_get_use_stock (GtkButton *button); void gtk_button_set_use_stock (GtkButton *button, gboolean value); gboolean gtk_button_get_use_underline (GtkButton *button); void gtk_button_set_use_underline (GtkButton *button, gboolean value); |
"label" gchararray : Read / Write / Construct "relief" GtkReliefStyle : Read / Write "use-underline" gboolean : Read / Write / Construct "use-stock" gboolean : Read / Write / Construct |
"activate" void user_function (GtkButton *button, gpointer user_data); "clicked" void user_function (GtkButton *button, gpointer user_data); "enter" void user_function (GtkButton *button, gpointer user_data); "leave" void user_function (GtkButton *button, gpointer user_data); "pressed" void user_function (GtkButton *button, gpointer user_data); "released" void user_function (GtkButton *button, gpointer user_data); |
The GtkButton widget is generally used to attach a function to that is called when the button is pressed. The various signals and how to use them are outlined below.
The GtkButton widget can hold any valid child widget. That is it can hold most any other standard GtkWidget. The most commonly used child is the GtkLabel.
struct GtkButton; |
This should not be accessed directly. Use the accessor functions below.
GtkWidget* gtk_button_new (void); |
Creates a new GtkButton widget.
Returns : | The newly created GtkButton widget. |
GtkWidget* gtk_button_new_with_label (const gchar *label); |
Creates a GtkButton widget with a GtkLabel child containing the given text.
GtkWidget* gtk_button_new_with_mnemonic (const gchar *label); |
Creates a new GtkButton containing a label. If characters in label are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.
label : | The text of the button, with an underscore in front of the mnemonic character |
Returns : | a new GtkButton |
GtkWidget* gtk_button_new_from_stock (const gchar *stock_id); |
Creates a new GtkButton containing the image and text from a stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK and GTK_STOCK_APPLY.
If stock_id is unknown, then it will be treated as a mnemonic label (as for gtk_button_new_with_mnemonic()).
stock_id : | the name of the stock item |
Returns : | a new GtkButton |
void gtk_button_pressed (GtkButton *button); |
Emits a GtkButton::pressed signal to the given GtkButton.
button : | The GtkButton you want to send the signal to. |
void gtk_button_released (GtkButton *button); |
Emits a GtkButton::released signal to the given GtkButton.
button : | The GtkButton you want to send the signal to. |
void gtk_button_clicked (GtkButton *button); |
Emits a GtkButton::clicked signal to the given GtkButton.
button : | The GtkButton you want to send the signal to. |
void gtk_button_enter (GtkButton *button); |
Emits a GtkButton::enter signal to the given GtkButton.
button : | The GtkButton you want to send the signal to. |
void gtk_button_leave (GtkButton *button); |
Emits a GtkButton::leave signal to the given GtkButton.
button : | The GtkButton you want to send the signal to. |
void gtk_button_set_relief (GtkButton *button, GtkReliefStyle newstyle); |
Sets the relief style of the edges of the given GtkButton widget. Three styles exist, GTK_RELIEF_NORMAL, GTK_RELIEF_HALF, GTK_RELIEF_NONE. The default style is, as one can guess, GTK_RELIEF_NORMAL.
button : | The GtkButton you want to set relief styles of. |
newstyle : | The GtkReliefStyle as described above. |
GtkReliefStyle gtk_button_get_relief (GtkButton *button); |
Returns the current relief style of the given GtkButton.
button : | The GtkButton you want the GtkReliefStyle from. |
Returns : | The current GtkReliefStyle |
G_CONST_RETURN gchar* gtk_button_get_label (GtkButton *button); |
Fetches the text from the label of the button, as set by gtk_button_set_label().
button : | a GtkButton |
Returns : | the text of the label widget. This string is owned by the widget and must not be modified or freed. 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. |
void gtk_button_set_label (GtkButton *button, const gchar *label); |
Sets the text of the label of the button to str. This text is also used to select the stock item if gtk_button_set_use_stock() is used.
This will also clear any previously set labels.
button : | a GtkButton |
label : | a string |
gboolean gtk_button_get_use_stock (GtkButton *button); |
Returns whether the button label is a stock item.
button : | a GtkButton |
Returns : | TRUE if the button label is used to select a stock item instead of being used directly as the label text. |
void gtk_button_set_use_stock (GtkButton *button, gboolean value); |
If true, the label set on the button is used as a stock id to select the stock item for the button.
button : | a GtkButton |
value : |
gboolean gtk_button_get_use_underline (GtkButton *button); |
Returns whether an embedded underline in the button label indicates a mnemonic. See gtk_button_set_use_underline().
The text within the child GtkLabel of the GtkButton. Only useful if there is actually a GtkLabel inside of the GtkButton.
The GtkReliefStyle as outlined in gtk_button_set_relief().
void user_function (GtkButton *button, gpointer user_data); |
Emitted when a button clicked on by the mouse and the cursor stays on the button. If the cursor is not on the button when the mouse button is released, the signal is not emitted.
void user_function (GtkButton *button, gpointer user_data); |
Emitted when the mouse cursor enters the region of the button.
void user_function (GtkButton *button, gpointer user_data); |
Emitted when the mouse cursor leaves the region of the button.
void user_function (GtkButton *button, gpointer user_data); |
Emitted when the button is initially pressed.