e7fb62572d1c20baa11038a38979276aef6f04ad
[pspp-builds.git] / src / ui / gui / helper.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2004, 2009, 2010, 2011  Free Software Foundation
3
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.
8
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.
13
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/>. */
16
17
18 #ifndef __MISC_H__
19 #define __MISC_H__
20
21 #include "relocatable.h"
22
23 #include <data/format.h>
24 #include <data/value.h>
25
26 #include <gtk/gtk.h>
27
28 #include "psppire-dict.h"
29
30 #include "gl/configmake.h"
31
32 gchar *paste_syntax_to_window (gchar *syntax);
33
34 struct fmt_spec;
35
36 /* Returns a new GParamSpec for a string.  An attempt to store the empty string
37    in the parameter will be silently translated into storing a null pointer. */
38 static inline GParamSpec *
39 null_if_empty_param (const gchar *name, const gchar *nick,
40                      const gchar *blurb, const gchar *default_value,
41                      GParamFlags flags)
42 {
43   GParamSpec *param;
44
45   param = g_param_spec_string (name, nick, blurb, default_value, flags);
46   ((GParamSpecString *) param)->null_fold_if_empty = TRUE;
47   return param;
48 }
49
50
51 /* Formats a value according to FORMAT
52    The returned string must be freed when no longer required */
53 gchar * value_to_text (union value v, const PsppireDict *dict, struct fmt_spec format);
54
55
56 union value *
57 text_to_value (const gchar *text,
58                const PsppireDict *dict,
59                const struct variable *var,
60                union value *);
61
62 GObject *get_object_assert (GtkBuilder *builder, const gchar *name, GType type);
63 GtkAction * get_action_assert (GtkBuilder *builder, const gchar *name);
64 GtkWidget * get_widget_assert (GtkBuilder *builder, const gchar *name);
65
66 gchar * convert_glib_filename_to_system_filename (const gchar *fname,
67                                                   GError **err);
68
69 void connect_help (GtkBuilder *);
70
71 #define builder_new(NAME) builder_new_real (relocate (PKGDATADIR "/" NAME))
72
73 GtkBuilder *builder_new_real (const gchar *name);
74
75
76 /* Create a deep copy of SRC */
77 GtkListStore * clone_list_store (const GtkListStore *src);
78
79 void psppire_box_pack_start_defaults (GtkBox *box, GtkWidget *widget);
80
81
82 #endif