Botones
Botones en gtk+
El widget GtkButton se utiliza generalmente para conectar a una función que se llama cuando se presiona el botón. Las diversas señales y cómo utilizarlas se describen a continuación.
Tipos de Botones
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_stok(const gchar *stock_id);
Mas de los botones
GtkWidget* gtk_button_new(void);
Mira un ejemplo de esta función
#include <gtk/gtk.h>
int main(int argc, char* argv[]){
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* Llamamos al botón pero sin titulo dentro */
GtkWidget *boton = gtk_button_new();
/* Juntamos el botón con la ventana para que estén unidos */
gtk_container_add(GTK_CONTAINER(window),boton);
/* Mostramos la ventana y el botón */
gtk_widget_show_all(window);
gtk_main();
return;
}
Esta función sirve mas para cuando quieras juntar el botón con el titulo y una imagen o cualquier otra cosa que tu quieras.
GtkWidget* gtk_button_new_with_label(const gchar *label);
Mira un ejemplo de esta función
Este es el mismo código de arriba pero con una simple modificación en el código para llamar al botón
#include <gtk/gtk.h>
int main(int argc, char* argv[]){
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* Llamamos al botón pero esta ves con titulo dentro */
GtkWidget *boton = gtk_button_new_with_label("Hola Mundo");
/* Juntamos el botón con la ventana para que estén unidos */
gtk_container_add(GTK_CONTAINER(window),boton);
/* Mostramos la ventana y el botón */
gtk_widget_show_all(window);
gtk_main();
return;
}