Re: question about dialog boxes
- From: Satyajit <satyajit kanungo wipro com>
- To: Peter Jay Salzman <p dirac org>
- Cc: gtk-list gnome org
- Subject: Re: question about dialog boxes
- Date: Sat, 22 Jun 2002 15:44:27 +0530
Hi,
You can create all you buttons while creating the dialog box
and then add a response signal which will handle the callbacks.
something like this ...(let's say you want a ok and a help button)
static void response_cb(GtkDialog *dialog, int response_id, gpointer
data)
{
if(response_id == GTK_RESPONSE_HELP) {
//do what you want
}
else if (response_id == GTK_RESPONSE_OK) {
gtk_widget_destroy(dialog);
}
}
AboutWindow = gtk_dialog_new_with_buttons( "blah",NULL,0,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
GTK_STOCK_OK,
GTK_RESPONSE_OK,
NULL);
/* you can add your own buttons also by adding the
* "name", and the response ID
*/
g_signal_connect (G_OBJECT (AboutWindow),
"response", G_CALLBACK (response_cb),
NULL);
Satya
Peter Jay Salzman wrote:
> I've got a dialog box that pops up when the user clicks Help | About:
>
> void CreateAboutDialog(void)
> {
> GtkWidget *AboutWindow, *AboutLabel, *OkButton;
>
> AboutWindow = gtk_dialog_new();
> AboutLabel = gtk_label_new("blah");
> OkButton = gtk_button_new_with_label("OK");
>
> gtk_box_pack_start(GTK_BOX(GTK_DIALOG(AboutWindow)->vbox),
> AboutLabel, EXPAND, FILL, NO_SPACING);
> gtk_box_pack_start(GTK_BOX(GTK_DIALOG(AboutWindow)->action_area),
> OkButton, EXPAND, NO_FILL, NO_SPACING);
>
> gtk_signal_connect(GTK_OBJECT(OkButton), "clicked",
> GTK_SIGNAL_FUNC(dialog_callback_delete), AboutWindow);
>
> gtk_widget_show_all(AboutWindow);
> }
>
>
>
> gboolean dialog_callback_delete(GtkWidget *widget, GtkWidget *Dialog)
> {
> gtk_widget_destroy(Dialog);
> return TRUE;
> }
>
> This works, even though I only slightly know what i'm doing. The
> problem is that this generates a compiler warning because GtkWidget
> *widget is unused in dialog_callback_delete().
>
> The thing is, I can't take "GtkWidget *widget" out of the function
> parameter list because then Dialog refers to the button, rather than the
> dialog window. That causes just the button to disappear when you press
> "Ok" rather than the whole dialog box.
>
> What's the correct way of doing this so that gcc doesn't complain about
> unused variables?
>
> Thanks!
> Pete
>
> --
> GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]