Removed silencing of gtk warning logs from gtk3.22-client.
[freeciv.git] / client / gui-xaw / inputdlg.c
blob287da6d58cf53849823cb03def26242378f90e8f
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 #include <stdio.h>
20 #include <X11/Intrinsic.h>
21 #include <X11/StringDefs.h>
22 #include <X11/Xaw/Form.h>
23 #include <X11/Xaw/Label.h>
24 #include <X11/Xaw/SimpleMenu.h>
25 #include <X11/Xaw/Command.h>
26 #include <X11/Xaw/AsciiText.h>
28 #include "fcintl.h"
30 #include "gui_stuff.h"
32 #include "inputdlg.h"
34 /****************************************************************
35 ...
36 *****************************************************************/
37 char *input_dialog_get_input(Widget button)
39 XtPointer dp;
40 Widget winput;
42 winput=XtNameToWidget(XtParent(button), "iinput");
44 XtVaGetValues(winput, XtNstring, &dp, NULL);
46 return dp;
50 /****************************************************************
51 ...
52 *****************************************************************/
53 void input_dialog_destroy(Widget button)
55 XtSetSensitive(XtParent(XtParent(XtParent(button))), TRUE);
57 XtDestroyWidget(XtParent(XtParent(button)));
60 /****************************************************************
61 ...
62 *****************************************************************/
63 void inputdlg_key_ok(Widget w)
65 x_simulate_button_click(XtNameToWidget(XtParent(w), "iokcommand"));
69 /****************************************************************
70 ...
71 *****************************************************************/
72 Widget input_dialog_create(Widget parent, const char *dialogname,
73 const char *text, const char *postinputtest,
74 XtCallbackProc ok_callback,
75 XtPointer ok_cli_data,
76 XtCallbackProc cancel_callback,
77 XtPointer cancel_cli_data)
79 Widget shell, form, label, input, ok, cancel;
81 XtSetSensitive(parent, FALSE);
83 I_T(shell=XtCreatePopupShell(dialogname, transientShellWidgetClass,
84 parent, NULL, 0));
86 form=XtVaCreateManagedWidget("iform", formWidgetClass, shell, NULL);
88 /* Caller should i18n the text passed in as desired */
89 label=XtVaCreateManagedWidget("ilabel", labelWidgetClass, form,
90 XtNlabel, (XtArgVal)text, NULL);
92 input=XtVaCreateManagedWidget("iinput",
93 asciiTextWidgetClass,
94 form,
95 XtNfromVert, (XtArgVal)label,
96 XtNeditType, XawtextEdit,
97 XtNstring, postinputtest,
98 NULL);
100 ok=XtVaCreateManagedWidget("iokcommand",
101 commandWidgetClass,
102 form,
103 XtNlabel, (XtArgVal)_("Ok"),
104 XtNfromVert, input,
105 NULL);
107 cancel=XtVaCreateManagedWidget("icancelcommand",
108 commandWidgetClass,
109 form,
110 XtNlabel, (XtArgVal)_("Cancel"),
111 XtNfromVert, input,
112 XtNfromHoriz, ok,
113 NULL);
115 xaw_set_relative_position(parent, shell, 10, 10);
116 XtPopup(shell, XtGrabNone);
118 XtAddCallback(ok, XtNcallback, ok_callback, ok_cli_data);
119 XtAddCallback(cancel, XtNcallback, cancel_callback,
120 cancel_cli_data);
122 XtSetKeyboardFocus(parent, input);
124 return shell;