Dialog Result
- From: Michael Oswell <oswell mail ocis net>
- To: gtk-list redhat com
- Subject: Dialog Result
- Date: Wed, 22 Apr 1998 22:16:56 -0700 (PDT)
Is it possible to have a dialog box pop up with say two buttons, one
labeled "Yes" and one "No", and have the result returned to the calling
function which called the dialog?
ie.
int MakeDialog(....)
{ GtkWidget *dialog;
int x = 0;
...
Make the Dialog Box here..
gtk_signal_connect(GTK_OBJECT(button1), "clicked",
GTK_SIGNAL_FUNC(x++), NULL);
return(x);
}
void testfunc(void)
{ int x = 0;
x = makedialog();
if ( x == 1) {
....
}
}
----------
The reason for this being that I want to make a sort of all purpose dialog
box such as:
int yesnodialog(char *b1, char *b2, char *title, char *label, ...)
{ GtkWidget *dialog, *table;
GtkWidget *text, *button1, *button2;
va_list args, args2;
char *buf;
va_start(args, label);
va_start(args2, label);
buf = (char *)g_vsprintf(label, &args, &args2);
va_end(args);
va_end(args2);
dialog = gtk_window_new(GTK_WINDOW_DIALOG);
gtk_window_set_title(GTK_WINDOW(dialog), title);
gtk_container_border_width (GTK_CONTAINER (dialog), 10);
gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
gtk_grab_add(dialog);
table = gtk_table_new(6,5,1);
gtk_container_add(GTK_CONTAINER(dialog), table);
text = gtk_label_new(buf);
button1 = gtk_button_new_with_label(b1);
button2 = gtk_button_new_with_label(b2);
gtk_signal_connect(GTK_OBJECT(button1), "clicked",
GTK_SIGNAL_FUNC(button1_push), dialog);
gtk_signal_connect(GTK_OBJECT(button2), "clicked",
GTK_SIGNAL_FUNC(button2_push), dialog);
gtk_table_attach_defaults(GTK_TABLE(table), text, 1,4,1,2);
gtk_table_attach_defaults(GTK_TABLE(table), button1, 1,2,4,5);
gtk_table_attach_defaults(GTK_TABLE(table), button2, 3,4,4,5);
gtk_widget_show(text);
gtk_widget_show(button1);
gtk_widget_show(button2);
gtk_widget_show(table);
gtk_widget_show(dialog);
return(x);
}
But I want the buttons to affect the number returned at the bottom...
Make sense?
---
Michael Oswell
On Call Internet Services Ltd.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]