1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2011 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "ui/gui/entry-dialog.h"
21 #include "ui/gui/helper.h"
22 #include "ui/gui/psppire-dialog.h"
24 #include "gl/xalloc.h"
26 /* Creates a modal dialog with PARENT as its parent (this should be the
27 application window that the dialog is associated with), with TITLE as its
28 title, that prompts for a text string with PROMPT as the explanation and
29 DEFAULT_VALUE as the default value.
31 Returns a malloc()'d string owned by the caller if the user clicks on OK or
32 otherwise accepts a value, or NULL if the user cancels. */
34 entry_dialog_run (GtkWindow *parent,
37 const char *default_value)
39 GtkBuilder *xml = builder_new ("entry-dialog.ui");
45 dialog = get_widget_assert (xml, "entry-dialog");
46 gtk_window_set_title (GTK_WINDOW (dialog), title);
47 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
49 label = get_widget_assert (xml, "label");
50 gtk_label_set_text (GTK_LABEL (label), prompt);
52 entry = get_widget_assert (xml, "entry");
53 gtk_entry_set_text (GTK_ENTRY (entry), default_value);
55 result = (psppire_dialog_run (PSPPIRE_DIALOG (dialog)) == GTK_RESPONSE_OK
56 ? xstrdup (gtk_entry_get_text (GTK_ENTRY (entry)))