[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [datasets 15/18] gui: New "entry-dialog" module for prompting for a
From: |
John Darrington |
Subject: |
Re: [datasets 15/18] gui: New "entry-dialog" module for prompting for a text string. |
Date: |
Sun, 1 May 2011 11:18:24 +0000 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Any reason why this cannot inherit from psppire-dialog.c ?
On Sat, Apr 30, 2011 at 10:36:43PM -0700, Ben Pfaff wrote:
This will be used in an upcoming commit to implement File|Rename
Dataset.
---
src/ui/gui/automake.mk | 2 +
src/ui/gui/entry-dialog.c | 64
+++++++++++++++++++++++++++++++++++++++++++++
src/ui/gui/entry-dialog.h | 27 +++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
create mode 100644 src/ui/gui/entry-dialog.c
create mode 100644 src/ui/gui/entry-dialog.h
diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk
index 5672b15..197f60f 100644
--- a/src/ui/gui/automake.mk
+++ b/src/ui/gui/automake.mk
@@ -144,6 +144,8 @@ src_ui_gui_psppire_SOURCES = \
src/ui/gui/dialog-common.h \
src/ui/gui/dict-display.h \
src/ui/gui/dict-display.c \
+ src/ui/gui/entry-dialog.c \
+ src/ui/gui/entry-dialog.h \
src/ui/gui/examine-dialog.c \
src/ui/gui/examine-dialog.h \
src/ui/gui/executor.c \
diff --git a/src/ui/gui/entry-dialog.c b/src/ui/gui/entry-dialog.c
new file mode 100644
index 0000000..019e883
--- /dev/null
+++ b/src/ui/gui/entry-dialog.c
@@ -0,0 +1,64 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2011 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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, see <http://www.gnu.org/licenses/>.
*/
+
+#include <config.h>
+
+#include "ui/gui/entry-dialog.h"
+
+#include "gl/xalloc.h"
+
+/* Creates a modal dialog with PARENT as its parent (this should be the
+ application window that the dialog is associated with), with TITLE as
its
+ title, that prompts for a text string with PROMPT as the explanation
and
+ DEFAULT_VALUE as the default value.
+
+ Returns a malloc()'d string owned by the caller if the user clicks on
OK or
+ otherwise accepts a value, or NULL if the user cancels. */
+char *
+entry_dialog_run (GtkWindow *parent,
+ const char *title,
+ const char *prompt,
+ const char *default_value)
+{
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GtkWidget *entry;
+ char *result;
+
+ dialog = gtk_dialog_new_with_buttons (title, parent,
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_ACCEPT);
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (prompt), TRUE,
FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (entry), default_value);
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, FALSE, 0);
+
+ gtk_widget_show_all (dialog);
+
+ result = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT
+ ? xstrdup (gtk_entry_get_text (GTK_ENTRY (entry)))
+ : NULL);
+ gtk_widget_destroy (dialog);
+
+ return result;
+}
diff --git a/src/ui/gui/entry-dialog.h b/src/ui/gui/entry-dialog.h
new file mode 100644
index 0000000..8f71acd
--- /dev/null
+++ b/src/ui/gui/entry-dialog.h
@@ -0,0 +1,27 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2011 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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, see <http://www.gnu.org/licenses/>.
*/
+
+#ifndef ENTRY_DIALOG_H
+#define ENTRY_DIALOG_H 1
+
+#include <gtk/gtk.h>
+
+char *entry_dialog_run (GtkWindow *parent,
+ const char *title,
+ const char *prompt,
+ const char *default_value);
+
+#endif /* ui/gui/entry-dialog.h */
--
1.7.2.5
_______________________________________________
pspp-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/pspp-dev
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature
- Re: [datasets 01/18] gui: Always convert file names to UTF-8 for use in syntax., (continued)
- [datasets 14/18] gui: Fix g_object_get() memory leaks for PsppireWindow's filename., Ben Pfaff, 2011/05/01
- [datasets 03/18] gui: Fix const-ness warning for measure_to_string() return type., Ben Pfaff, 2011/05/01
- [datasets 16/18] Implement DATASET commands., Ben Pfaff, 2011/05/01
- [datasets 10/18] gui: Prefer NULL to 0 for initializing pointers., Ben Pfaff, 2011/05/01
- [datasets 18/18] gui: Change View|Data and View|Variables to radio button menu items., Ben Pfaff, 2011/05/01
- [datasets 15/18] gui: New "entry-dialog" module for prompting for a text string., Ben Pfaff, 2011/05/01
- Re: [datasets 15/18] gui: New "entry-dialog" module for prompting for a text string.,
John Darrington <=
- [datasets 12/18] gui: Eliminate dataset-related global variables., Ben Pfaff, 2011/05/01
- [datasets 11/18] gui: Make syntax execution functions take a PsppireDataWindow argument., Ben Pfaff, 2011/05/01
- [datasets 04/18] gui: Fix const-ness warning in create_lines_tree_view()., Ben Pfaff, 2011/05/01
- [datasets 05/18] gui: Drop null base_finalize function from PsppireDataWindow., Ben Pfaff, 2011/05/01