[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug33254 3/6] gui: Move null_if_empty_param() from psppire-window to he
From: |
Ben Pfaff |
Subject: |
[bug33254 3/6] gui: Move null_if_empty_param() from psppire-window to helper. |
Date: |
Wed, 11 May 2011 22:42:04 -0700 |
An upcoming commit will introduce a new user of this function in a
different source file, so it seems best to have this defined in a
common header file.
---
src/ui/gui/helper.h | 16 +++++++++++++++-
src/ui/gui/psppire-window.c | 12 ------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h
index f7660dc..e7fb625 100644
--- a/src/ui/gui/helper.h
+++ b/src/ui/gui/helper.h
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2004, 2009, 2010 Free Software Foundation
+ Copyright (C) 2004, 2009, 2010, 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
@@ -33,6 +33,20 @@ gchar *paste_syntax_to_window (gchar *syntax);
struct fmt_spec;
+/* Returns a new GParamSpec for a string. An attempt to store the empty string
+ in the parameter will be silently translated into storing a null pointer. */
+static inline GParamSpec *
+null_if_empty_param (const gchar *name, const gchar *nick,
+ const gchar *blurb, const gchar *default_value,
+ GParamFlags flags)
+{
+ GParamSpec *param;
+
+ param = g_param_spec_string (name, nick, blurb, default_value, flags);
+ ((GParamSpecString *) param)->null_fold_if_empty = TRUE;
+ return param;
+}
+
/* Formats a value according to FORMAT
The returned string must be freed when no longer required */
diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c
index 6612a5d..fbb91a7 100644
--- a/src/ui/gui/psppire-window.c
+++ b/src/ui/gui/psppire-window.c
@@ -271,18 +271,6 @@ psppire_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static GParamSpec *
-null_if_empty_param (const gchar *name, const gchar *nick,
- const gchar *blurb, const gchar *default_value,
- GParamFlags flags)
-{
- GParamSpec *param;
-
- param = g_param_spec_string (name, nick, blurb, default_value, flags);
- ((GParamSpecString *) param)->null_fold_if_empty = TRUE;
- return param;
-}
-
static void
psppire_window_class_init (PsppireWindowClass *class)
{
--
1.7.2.5
- [bug33254 1/6] encoding-guesser: New function encoding_guess_whole_file()., Ben Pfaff, 2011/05/12
- [bug33254 6/6] gui: Make File|Recent Files remember the correct encoding., Ben Pfaff, 2011/05/12
- [bug33254 2/6] i18n: New function is_encoding_supported()., Ben Pfaff, 2011/05/12
- [bug33254 3/6] gui: Move null_if_empty_param() from psppire-window to helper.,
Ben Pfaff <=
- [bug33254 5/6] gui: Recode syntax files on load and save., Ben Pfaff, 2011/05/12
- [bug33254 4/6] gui: Refactor checking for .sav and .por suffixes., Ben Pfaff, 2011/05/12
- Re: [bug33254 1/6] encoding-guesser: New function encoding_guess_whole_file()., John Darrington, 2011/05/12