help regarding gtk_window_default
- From: Deekshit Mantampady <dmantamp gmail com>
- To: gtk-app-devel-list gnome org
- Subject: help regarding gtk_window_default
- Date: Wed, 26 Oct 2005 21:57:57 +0530
Hi all,
I have been trying to make a button on my WINDOW a default one, so
that even if my foxus is on entry field, pressing ENTER should
activate the button. I have try the following peice of code. But it
didn't work. Please help me.
===============================================================
void default_button_clicked(GtkWidget *wid, gpointer d)
{
printf("Default button clicked...\n");
}
void non_default_button_clicked(GtkWidget *wid, gpointer d)
{
printf("NON-Default button clicked...\n");
}
int main(int argc, char *argv[])
{
GtkWidget *window, *vbox, *hbox, *btn, *entry;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(window, 400,400);
vbox = gtk_vbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 10);
gtk_widget_show(hbox);
entry = gtk_entry_new_with_max_length(10);
gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 10);
gtk_widget_show(entry);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 10);
gtk_widget_show(hbox);
btn = gtk_button_new_with_label(" Non Default ");
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
GTK_SIGNAL_FUNC(non_default_button_clicked), NULL);
gtk_box_pack_start(GTK_BOX(hbox), btn, TRUE, FALSE, 10);
gtk_widget_show(btn);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 10);
gtk_widget_show(hbox);
btn = gtk_button_new_with_label(" Default");
GTK_WIDGET_SET_FLAGS(btn, GTK_CAN_DEFAULT);
gtk_window_set_default(GTK_WINDOW(window), btn);
gtk_signal_connect(GTK_OBJECT(btn), "clicked",
GTK_SIGNAL_FUNC(default_button_clicked), NULL);
gtk_box_pack_start(GTK_BOX(hbox), btn, TRUE, FALSE, 10);
gtk_widget_show(btn);
gtk_widget_show(window);
gtk_main();
return 0;
}
=====================================================================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]