projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8aa1c70
)
formats page: Construction is initialisation
author
John Darrington
<john@darrington.wattle.id.au>
Thu, 24 Jan 2013 18:58:51 +0000
(19:58 +0100)
committer
John Darrington
<john@darrington.wattle.id.au>
Sat, 16 Feb 2013 14:03:29 +0000
(15:03 +0100)
src/ui/gui/page-assistant.c
patch
|
blob
|
history
src/ui/gui/page-formats.c
patch
|
blob
|
history
src/ui/gui/page-sheet-spec.c
patch
|
blob
|
history
src/ui/gui/text-data-import-dialog.c
patch
|
blob
|
history
src/ui/gui/text-data-import-dialog.h
patch
|
blob
|
history
diff --git
a/src/ui/gui/page-assistant.c
b/src/ui/gui/page-assistant.c
index 480133046e63897d5b9564289276ceadc33928ac..dfe7748b140f22dd55d0df706802f85a600cd0a3 100644
(file)
--- a/
src/ui/gui/page-assistant.c
+++ b/
src/ui/gui/page-assistant.c
@@
-93,9
+93,7
@@
init_assistant (GtkWindow *parent_window)
ia->first_line = first_line_page_create (ia);
ia->first_line = first_line_page_create (ia);
- ia->formats = xzalloc (sizeof *ia->formats);
-
-
+ ia->formats = formats_page_create (ia);
g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia);
g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia);
@@
-190,13
+188,15
@@
on_prepare (GtkAssistant *assistant, GtkWidget *page,
}
}
-#endif
+
gtk_widget_show (ia->asst.reset_button);
if (page == ia->formats->page)
gtk_widget_show (ia->asst.paste_button);
else
gtk_widget_hide (ia->asst.paste_button);
gtk_widget_show (ia->asst.reset_button);
if (page == ia->formats->page)
gtk_widget_show (ia->asst.paste_button);
else
gtk_widget_hide (ia->asst.paste_button);
+
+#endif
}
/* Called when the Cancel button in the assistant is clicked. */
}
/* Called when the Cancel button in the assistant is clicked. */
diff --git
a/src/ui/gui/page-formats.c
b/src/ui/gui/page-formats.c
index 3a3df83a043dc560f5229fa799ff75babc1a92b3..9bce4d3204ceb7260cef7e9388aca05cbf194f02 100644
(file)
--- a/
src/ui/gui/page-formats.c
+++ b/
src/ui/gui/page-formats.c
@@
-58,6
+58,16
@@
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
+/* Page where the user verifies and adjusts input formats. */
+struct formats_page
+ {
+ GtkWidget *page;
+ GtkTreeView *data_tree_view;
+ PsppireDict *psppire_dict;
+ struct variable **modified_vars;
+ size_t modified_var_cnt;
+ };
+
/* The "formats" page of the assistant. */
static void on_variable_change (PsppireDict *dict, int idx,
/* The "formats" page of the assistant. */
static void on_variable_change (PsppireDict *dict, int idx,
@@
-65,18
+75,20
@@
static void on_variable_change (PsppireDict *dict, int idx,
static void clear_modified_vars (struct import_assistant *);
/* Initializes IA's formats substructure. */
static void clear_modified_vars (struct import_assistant *);
/* Initializes IA's formats substructure. */
-void
-init_formats_page (struct import_assistant *ia)
+
+struct formats_page *
+formats_page_create (struct import_assistant *ia)
{
GtkBuilder *builder = ia->asst.builder;
{
GtkBuilder *builder = ia->asst.builder;
- struct formats_page *p =
ia->formats
;
+ struct formats_page *p =
xzalloc (sizeof *p)
;
p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Formats"),
GTK_ASSISTANT_PAGE_CONFIRM);
p->data_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "data"));
p->modified_vars = NULL;
p->modified_var_cnt = 0;
p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Formats"),
GTK_ASSISTANT_PAGE_CONFIRM);
p->data_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "data"));
p->modified_vars = NULL;
p->modified_var_cnt = 0;
- p->dict = NULL;
+
+ return p;
}
/* Frees IA's formats substructure. */
}
/* Frees IA's formats substructure. */
@@
-159,7
+171,7
@@
prepare_formats_page (struct import_assistant *ia)
psppire_dict = psppire_dict_new_from_dict (dict);
g_signal_connect (psppire_dict, "variable_changed",
G_CALLBACK (on_variable_change), ia);
psppire_dict = psppire_dict_new_from_dict (dict);
g_signal_connect (psppire_dict, "variable_changed",
G_CALLBACK (on_variable_change), ia);
- ia->
formats->
dict = dict;
+ ia->dict = dict;
ia->formats->psppire_dict = psppire_dict;
/* XXX: PsppireVarStore doesn't hold a reference to
ia->formats->psppire_dict = psppire_dict;
/* XXX: PsppireVarStore doesn't hold a reference to
diff --git
a/src/ui/gui/page-sheet-spec.c
b/src/ui/gui/page-sheet-spec.c
index 6f6695f51b7f06bda51292ea0fc44b99be721b5a..84de6a86c9be6a3da5c4b5ddb1a03254195d85e4 100644
(file)
--- a/
src/ui/gui/page-sheet-spec.c
+++ b/
src/ui/gui/page-sheet-spec.c
@@
-53,6
+53,8
@@
#include "ui/gui/psppire-scanf.h"
#include "ui/syntax-gen.h"
#include "ui/gui/psppire-scanf.h"
#include "ui/syntax-gen.h"
+#include <data/casereader.h>
+
#include "gl/error.h"
#include "gl/intprops.h"
#include "gl/xalloc.h"
#include "gl/error.h"
#include "gl/intprops.h"
#include "gl/xalloc.h"
@@
-64,6
+66,7
@@
struct import_assistant;
struct import_assistant;
+
/* The "sheet-spec" page of the assistant. */
/* The sheet_spec page of the assistant (only relevant for spreadsheet imports). */
/* The "sheet-spec" page of the assistant. */
/* The sheet_spec page of the assistant (only relevant for spreadsheet imports). */
@@
-206,7
+209,6
@@
void
update_assistant (struct import_assistant *ia)
{
struct sheet_spec_page *ssp = ia->sheet_spec;
update_assistant (struct import_assistant *ia)
{
struct sheet_spec_page *ssp = ia->sheet_spec;
- // struct file *file = &ia->file;
int rows = 0;
int rows = 0;
diff --git
a/src/ui/gui/text-data-import-dialog.c
b/src/ui/gui/text-data-import-dialog.c
index 6d41b0f9c9800a15b9c79329008c50732f792136..0d66e8a20ea81e60324e005beb531e99f457cee1 100644
(file)
--- a/
src/ui/gui/text-data-import-dialog.c
+++ b/
src/ui/gui/text-data-import-dialog.c
@@
-82,8
+82,6
@@
text_data_import_assistant (PsppireDataWindow *dw)
ssp = ia->sheet_spec;
ssp = ia->sheet_spec;
- init_formats_page (ia);
-
gtk_widget_show_all (GTK_WIDGET (ia->asst.assistant));
ia->asst.main_loop = g_main_loop_new (NULL, false);
gtk_widget_show_all (GTK_WIDGET (ia->asst.assistant));
ia->asst.main_loop = g_main_loop_new (NULL, false);
@@
-377,16
+375,15
@@
parse_field (struct import_assistant *ia,
size_t row, size_t column,
char **outputp, char **tooltipp)
{
size_t row, size_t column,
char **outputp, char **tooltipp)
{
- struct substring field;
- union value val;
- struct variable *var;
const struct fmt_spec *in;
struct fmt_spec out;
char *tooltip;
bool ok;
const struct fmt_spec *in;
struct fmt_spec out;
char *tooltip;
bool ok;
- field = ia->columns[column].contents[row];
- var = dict_get_var (ia->formats->dict, column);
+ struct substring field = ia->columns[column].contents[row];
+ struct variable *var = dict_get_var (ia->dict, column);
+ union value val;
+
value_init (&val, var_get_width (var));
in = var_get_print_format (var);
out = fmt_for_output_from_input (in);
value_init (&val, var_get_width (var));
in = var_get_print_format (var);
out = fmt_for_output_from_input (in);
@@
-396,7
+393,7
@@
parse_field (struct import_assistant *ia,
char *error;
error = data_in (field, "UTF-8", in->type, &val, var_get_width (var),
char *error;
error = data_in (field, "UTF-8", in->type, &val, var_get_width (var),
- dict_get_encoding (ia->
formats->
dict));
+ dict_get_encoding (ia->dict));
if (error != NULL)
{
tooltip = xasprintf (_("Cannot parse field content `%.*s' as "
if (error != NULL)
{
tooltip = xasprintf (_("Cannot parse field content `%.*s' as "
@@
-414,7
+411,7
@@
parse_field (struct import_assistant *ia,
}
if (outputp != NULL)
{
}
if (outputp != NULL)
{
- *outputp = data_out (&val, dict_get_encoding (ia->
formats->
dict), &out);
+ *outputp = data_out (&val, dict_get_encoding (ia->dict), &out);
}
value_destroy (&val, var_get_width (var));
}
value_destroy (&val, var_get_width (var));
@@
-623,7
+620,7
@@
make_data_column (struct import_assistant *ia, GtkTreeView *tree_view,
if (input)
column = &ia->columns[dict_idx];
else
if (input)
column = &ia->columns[dict_idx];
else
- var = dict_get_var (ia->
formats->
dict, dict_idx);
+ var = dict_get_var (ia->dict, dict_idx);
name = escape_underscores (input ? column->name : var_get_name (var));
char_cnt = input ? column->width : var_get_print_format (var)->w;
name = escape_underscores (input ? column->name : var_get_name (var));
char_cnt = input ? column->width : var_get_print_format (var)->w;
diff --git
a/src/ui/gui/text-data-import-dialog.h
b/src/ui/gui/text-data-import-dialog.h
index 60dced703d29a34705c4dfb06815cbc6ddbcfab6..0122312300af74ff30a2e496d4bacc80d96f9693 100644
(file)
--- a/
src/ui/gui/text-data-import-dialog.h
+++ b/
src/ui/gui/text-data-import-dialog.h
@@
-54,24
+54,8
@@
struct assistant
GtkCellRenderer *prop_renderer;
GtkCellRenderer *fixed_renderer;
GtkCellRenderer *prop_renderer;
GtkCellRenderer *fixed_renderer;
-
};
};
-
-
-/* Page where the user verifies and adjusts input formats. */
-struct formats_page
- {
- struct dictionary *dict;
-
- GtkWidget *page;
- GtkTreeView *data_tree_view;
- PsppireDict *psppire_dict;
- struct variable **modified_vars;
- size_t modified_var_cnt;
- };
-
-
struct import_assistant
{
struct file file;
struct import_assistant
{
struct file file;
@@
-89,11
+73,9
@@
struct import_assistant
int skip_lines; /* Number of initial lines to skip? */
bool variable_names; /* Variable names above first line of data? */
int skip_lines; /* Number of initial lines to skip? */
bool variable_names; /* Variable names above first line of data? */
+ struct dictionary *dict;
};
};
-
-
-
struct column
{
/* Variable name for this column. This is the variable name
struct column
{
/* Variable name for this column. This is the variable name
@@
-157,7
+139,6
@@
void prepare_sheet_spec_page (struct import_assistant *ia);
void reset_sheet_spec_page (struct import_assistant *);
void post_sheet_spec_page (struct import_assistant *ia);
void reset_sheet_spec_page (struct import_assistant *);
void post_sheet_spec_page (struct import_assistant *ia);
-void init_first_line_page (struct import_assistant *ia);
void prepare_first_line_page (struct import_assistant *ia);
void reset_first_line_page (struct import_assistant *);
void prepare_first_line_page (struct import_assistant *ia);
void reset_first_line_page (struct import_assistant *);
@@
-165,7
+146,6
@@
void prepare_separators_page (struct import_assistant *ia);
void reset_separators_page (struct import_assistant *);
void destroy_separators_page (struct import_assistant *ia);
void reset_separators_page (struct import_assistant *);
void destroy_separators_page (struct import_assistant *ia);
-void init_formats_page (struct import_assistant *ia);
void prepare_formats_page (struct import_assistant *ia);
void reset_formats_page (struct import_assistant *);
void destroy_formats_page (struct import_assistant *ia);
void prepare_formats_page (struct import_assistant *ia);
void reset_formats_page (struct import_assistant *);
void destroy_formats_page (struct import_assistant *ia);