Synopsis#include <gtk/gtk.h> 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); const 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 use_stock); gboolean gtk_button_get_use_underline (GtkButton *button); void gtk_button_set_use_underline (GtkButton *button, gboolean use_underline); void gtk_button_set_focus_on_click (GtkButton *button, gboolean focus_on_click); gboolean gtk_button_get_focus_on_click (GtkButton *button); void gtk_button_set_alignment (GtkButton *button, gfloat xalign, gfloat yalign); void gtk_button_get_alignment (GtkButton *button, gfloat *xalign, gfloat *yalign); void gtk_button_set_image (GtkButton *button, GtkWidget *image); GtkWidget* gtk_button_get_image (GtkButton *button); void gtk_button_set_image_position (GtkButton *button, GtkPositionType position); GtkPositionType gtk_button_get_image_position (GtkButton *button); Object HierarchyGObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkContainer +----GtkBin +----GtkButton +----GtkToggleButton +----GtkColorButton +----GtkFontButton +----GtkLinkButton +----GtkOptionMenu +----GtkScaleButton Properties"focus-on-click" gboolean : Read / Write "image" GtkWidget* : Read / Write "image-position" GtkPositionType : Read / Write "label" gchar* : Read / Write / Construct "relief" GtkReliefStyle : Read / Write "use-stock" gboolean : Read / Write / Construct "use-underline" gboolean : Read / Write / Construct "xalign" gfloat : Read / Write "yalign" gfloat : Read / Write Style Properties"child-displacement-x" gint : Read "child-displacement-y" gint : Read "default-border" GtkBorder* : Read "default-outside-border" GtkBorder* : Read "displace-focus" gboolean : Read "image-spacing" gint : Read "inner-border" GtkBorder* : Read Signals"activate" : Run First / Action "clicked" : Run First / Action "enter" : Run First "leave" : Run First "pressed" : Run First "released" : Run First DescriptionThe 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. DetailsGtkButtontypedef struct _GtkButton GtkButton; This should not be accessed directly. Use the accessor functions below. gtk_button_new ()GtkWidget* gtk_button_new (void);
Creates a new GtkButton widget. To add a child widget to the button,
use
gtk_button_new_with_label ()GtkWidget* gtk_button_new_with_label (const gchar *label); Creates a GtkButton widget with a GtkLabel child containing the given text. gtk_button_new_with_mnemonic ()GtkWidget* gtk_button_new_with_mnemonic (const gchar *label);
Creates a new GtkButton containing a label.
If characters in
gtk_button_new_from_stock ()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
gtk_button_pressed ()void gtk_button_pressed (GtkButton *button); Emits a "pressed" signal to the given GtkButton.
gtk_button_released ()void gtk_button_released (GtkButton *button); Emits a "released" signal to the given GtkButton.
gtk_button_clicked ()void gtk_button_clicked (GtkButton *button); Emits a "clicked" signal to the given GtkButton.
gtk_button_enter ()void gtk_button_enter (GtkButton *button); Emits a "enter" signal to the given GtkButton.
gtk_button_leave ()void gtk_button_leave (GtkButton *button); Emits a "leave" signal to the given GtkButton.
gtk_button_set_relief ()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.
gtk_button_get_relief ()GtkReliefStyle gtk_button_get_relief (GtkButton *button); Returns the current relief style of the given GtkButton.
gtk_button_get_label ()const gchar* gtk_button_get_label (GtkButton *button);
Fetches the text from the label of the button, as set by
gtk_button_set_label ()void gtk_button_set_label (GtkButton *button, const gchar *label);
Sets the text of the label of the button to This will also clear any previously set labels.
gtk_button_get_use_stock ()gboolean gtk_button_get_use_stock (GtkButton *button); Returns whether the button label is a stock item.
gtk_button_set_use_stock ()void gtk_button_set_use_stock (GtkButton *button, gboolean use_stock);
If
gtk_button_get_use_underline ()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 ()void gtk_button_set_use_underline (GtkButton *button, gboolean use_underline); If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
gtk_button_set_focus_on_click ()void gtk_button_set_focus_on_click (GtkButton *button, gboolean focus_on_click); Sets whether the button will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.
Since 2.4 gtk_button_get_focus_on_click ()gboolean gtk_button_get_focus_on_click (GtkButton *button);
Returns whether the button grabs focus when it is clicked with the mouse.
See
Since 2.4 gtk_button_set_alignment ()void gtk_button_set_alignment (GtkButton *button, gfloat xalign, gfloat yalign); Sets the alignment of the child. This property has no effect unless the child is a GtkMisc or a GtkAligment.
Since 2.4 gtk_button_get_alignment ()void gtk_button_get_alignment (GtkButton *button, gfloat *xalign, gfloat *yalign); Gets the alignment of the child in the button.
Since 2.4 gtk_button_set_image ()void gtk_button_set_image (GtkButton *button, GtkWidget *image);
Set the image of
Since 2.6 gtk_button_get_image ()GtkWidget* gtk_button_get_image (GtkButton *button);
Gets the widget that is currenty set as the image of
Since 2.6 gtk_button_set_image_position ()void gtk_button_set_image_position (GtkButton *button, GtkPositionType position); Sets the position of the image relative to the text inside the button.
Since 2.10 gtk_button_get_image_position ()GtkPositionType gtk_button_get_image_position (GtkButton *button); Gets the position of the image relative to the text inside the button.
Since 2.10 Property DetailsThe
|
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"clicked"
signalvoid user_function (GtkButton *button, gpointer user_data) : Run First / Action
Emitted when the button has been activated (pressed and released).
|
the object that received the signal |
|
user data set when the signal handler was connected. |
"enter"
signalvoid user_function (GtkButton *button, gpointer user_data) : Run First
Emitted when the pointer enters the button.
|
the object that received the signal |
|
user data set when the signal handler was connected. |
"leave"
signalvoid user_function (GtkButton *button, gpointer user_data) : Run First
Emitted when the pointer leaves the button.
|
the object that received the signal |
|
user data set when the signal handler was connected. |
"pressed"
signalvoid user_function (GtkButton *button, gpointer user_data) : Run First
Emitted when the button is pressed.
|
the object that received the signal |
|
user data set when the signal handler was connected. |
"released"
signalvoid user_function (GtkButton *button, gpointer user_data) : Run First
Emitted when the button is released.
|
the object that received the signal |
|
user data set when the signal handler was connected. |