File: message.c

package info (click to toggle)
digitaldj 0.6-7.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 268 kB
  • ctags: 264
  • sloc: ansic: 3,112; makefile: 90
file content (73 lines) | stat: -rwxr-xr-x 2,216 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*****************************************************************

  message.c -- message display dialog routines

  Copyright (c) 1999 by Mike Oliphant - oliphant@gtk.org

    http://www.ling.ed.ac.uk/~oliphant/grip

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

*****************************************************************/

#include <stdio.h>
#include <gtk/gtk.h>
#include "dialog.h"

void DisplayMsg(char *msg)
{
  BoolDialog(msg,"OK",NULL,NULL,NULL);
}

void BoolDialog(char *question,char *yes,GtkSignalFunc yesfunc,
		char *no,GtkSignalFunc nofunc)
{
  GtkWidget *dialog;
  GtkWidget *label;
  GtkWidget *yesbutton;
  GtkWidget *nobutton;

  dialog=gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(dialog),"System Message");

  gtk_container_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),5);

  label=gtk_label_new(question);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),label,TRUE,TRUE,0);
  gtk_widget_show(label);

  yesbutton=gtk_button_new_with_label(yes);
  if(yesfunc)
    gtk_signal_connect(GTK_OBJECT(yesbutton),"clicked",
		       yesfunc,NULL);
  gtk_signal_connect_object(GTK_OBJECT(yesbutton),"clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(dialog));
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),yesbutton,
		     TRUE,TRUE,0);
  gtk_widget_show(yesbutton);

  if(no) {
    nobutton=gtk_button_new_with_label(no);
    if(nofunc)
      gtk_signal_connect(GTK_OBJECT(nobutton),"clicked",
			 nofunc,NULL);
    gtk_signal_connect_object(GTK_OBJECT(nobutton),"clicked",
			      GTK_SIGNAL_FUNC(gtk_widget_destroy),
			      GTK_OBJECT(dialog));
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),nobutton,
		       TRUE,TRUE,0);
    gtk_widget_show(nobutton);
  }

  gtk_widget_show(dialog);

  gtk_grab_add(dialog);
}