projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved behaviour of arrow keys
[pspp-builds.git]
/
src
/
ui
/
gui
/
psppire-var-sheet.c
diff --git
a/src/ui/gui/psppire-var-sheet.c
b/src/ui/gui/psppire-var-sheet.c
index 79446fb3a812c32cb498602d5627688caf310fed..60b968ef811eb84f97ad9a8b172bb2f9328e1276 100644
(file)
--- a/
src/ui/gui/psppire-var-sheet.c
+++ b/
src/ui/gui/psppire-var-sheet.c
@@
-1,4
+1,3
@@
-
/* PSPPIRE - a graphical user interface for PSPP.
Copyright (C) 2008 Free Software Foundation, Inc.
/* PSPPIRE - a graphical user interface for PSPP.
Copyright (C) 2008 Free Software Foundation, Inc.
@@
-33,7
+32,7
@@
static void psppire_var_sheet_class_init (PsppireVarSheetClass *klass);
static void psppire_var_sheet_init (PsppireVarSheet *vs);
static void psppire_var_sheet_class_init (PsppireVarSheetClass *klass);
static void psppire_var_sheet_init (PsppireVarSheet *vs);
-enum
+enum
{
PSPPIRE_VAR_SHEET_MAY_CREATE_VARS = 1
};
{
PSPPIRE_VAR_SHEET_MAY_CREATE_VARS = 1
};
@@
-251,12
+250,12
@@
change_measure (GtkComboBox *cb,
}
}
-
+/* Moves the focus to a new cell.
+ Returns TRUE iff the move should be disallowed */
static gboolean
traverse_cell_callback (GtkSheet *sheet,
gint row, gint column,
static gboolean
traverse_cell_callback (GtkSheet *sheet,
gint row, gint column,
- gint *new_row, gint *new_column
- )
+ gint *new_row, gint *new_column)
{
PsppireVarSheet *var_sheet = PSPPIRE_VAR_SHEET (sheet);
PsppireVarStore *var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
{
PsppireVarSheet *var_sheet = PSPPIRE_VAR_SHEET (sheet);
PsppireVarStore *var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
@@
-264,7
+263,8
@@
traverse_cell_callback (GtkSheet *sheet,
gint n_vars = psppire_var_store_get_var_cnt (var_store);
if (*new_row >= n_vars && !var_sheet->may_create_vars)
gint n_vars = psppire_var_store_get_var_cnt (var_store);
if (*new_row >= n_vars && !var_sheet->may_create_vars)
- return FALSE;
+ return TRUE;
+
if ( row == n_vars && *new_row >= n_vars)
{
if ( row == n_vars && *new_row >= n_vars)
{
@@
-273,13
+273,14
@@
traverse_cell_callback (GtkSheet *sheet,
const gchar *name = gtk_entry_get_text (entry);
if (! psppire_dict_check_name (var_store->dict, name, TRUE))
const gchar *name = gtk_entry_get_text (entry);
if (! psppire_dict_check_name (var_store->dict, name, TRUE))
- return
FALS
E;
+ return
TRU
E;
psppire_dict_insert_variable (var_store->dict, row, name);
psppire_dict_insert_variable (var_store->dict, row, name);
- return
TRU
E;
+ return
FALS
E;
}
}
+
/* If the destination cell is outside the current variables, then
automatically create variables for the new rows.
*/
/* If the destination cell is outside the current variables, then
automatically create variables for the new rows.
*/
@@
-291,51
+292,42
@@
traverse_cell_callback (GtkSheet *sheet,
psppire_dict_insert_variable (var_store->dict, i, NULL);
}
psppire_dict_insert_variable (var_store->dict, i, NULL);
}
- return TRUE;
-}
+ return FALSE;
+}
-/*
- Callback whenever the pointer leaves a cell on the var sheet.
-*/
-static gboolean
-var_sheet_cell_entry_leave (GtkSheet * sheet, gint row, gint column,
- gpointer data)
-{
- gtk_sheet_change_entry (sheet, GTK_TYPE_ENTRY);
- return TRUE;
-}
/*
/*
- Callback whenever the
pointer enters a cell
on the var sheet.
+ Callback whenever the
active cell changes
on the var sheet.
*/
*/
-static gboolean
-var_sheet_cell_entry_enter (PsppireVarSheet *vs, gint row, gint column,
- gpointer data)
+static void
+var_sheet_change_active_cell (PsppireVarSheet *vs,
+ gint row, gint column,
+ gint oldrow, gint oldcolumn,
+ gpointer data)
{
GtkSheetCellAttr attributes;
{
GtkSheetCellAttr attributes;
- PsppireVarStore *var_store
;
+ PsppireVarStore *var_store;
PsppireVarSheetClass *vs_class =
PSPPIRE_VAR_SHEET_CLASS(G_OBJECT_GET_CLASS (vs));
struct variable *var ;
GtkSheet *sheet = GTK_SHEET (vs);
PsppireVarSheetClass *vs_class =
PSPPIRE_VAR_SHEET_CLASS(G_OBJECT_GET_CLASS (vs));
struct variable *var ;
GtkSheet *sheet = GTK_SHEET (vs);
- g_return_
val_if_fail (sheet != NULL, FALSE
);
+ g_return_
if_fail (sheet != NULL
);
var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
g_assert (var_store);
var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
g_assert (var_store);
- if ( row >= psppire_var_store_get_var_cnt (var_store))
-
return TRUE
;
+ g_return_if_fail (oldcolumn == PSPPIRE_VAR_STORE_COL_NAME ||
+
row < psppire_var_store_get_var_cnt (var_store))
;
gtk_sheet_get_attributes (sheet, row, column, &attributes);
gtk_sheet_get_attributes (sheet, row, column, &attributes);
-
var = psppire_var_store_get_var (var_store, row);
switch (column)
var = psppire_var_store_get_var (var_store, row);
switch (column)
@@
-504,9
+496,6
@@
var_sheet_cell_entry_enter (PsppireVarSheet *vs, gint row, gint column,
gtk_sheet_change_entry (sheet, GTK_TYPE_ENTRY);
break;
}
gtk_sheet_change_entry (sheet, GTK_TYPE_ENTRY);
break;
}
-
-
- return TRUE;
}
}
@@
-526,6
+515,7
@@
psppire_var_sheet_init (PsppireVarSheet *vs)
g_object_unref (xml);
vs->dispose_has_run = FALSE;
g_object_unref (xml);
vs->dispose_has_run = FALSE;
+ vs->may_create_vars = TRUE;
for (i = 0 ; i < PSPPIRE_VAR_STORE_n_COLS ; ++i )
{
for (i = 0 ; i < PSPPIRE_VAR_STORE_n_COLS ; ++i )
{
@@
-538,13
+528,8
@@
psppire_var_sheet_init (PsppireVarSheet *vs)
g_object_set (vs, "column-geometry", geo, NULL);
g_object_set (vs, "column-geometry", geo, NULL);
-
g_signal_connect (vs, "activate",
g_signal_connect (vs, "activate",
- G_CALLBACK (var_sheet_cell_entry_enter),
- NULL);
-
- g_signal_connect (vs, "deactivate",
- G_CALLBACK (var_sheet_cell_entry_leave),
+ G_CALLBACK (var_sheet_change_active_cell),
NULL);
g_signal_connect (vs, "traverse",
NULL);
g_signal_connect (vs, "traverse",