gui: Make Tab, Shift+Tab skip row head and new-var columns in data sheet.
[pspp] / src / ui / gui / pspp-sheet-view-column.c
index c586a4bdaee2e1b0839102f09c43a5e846ad0a0e..a8d9f4891880a8f11dcd0e5dce14aacccf1a4dd0 100644 (file)
@@ -72,7 +72,8 @@ enum
   PROP_QUICK_EDIT,
   PROP_SELECTED,
   PROP_SELECTABLE,
-  PROP_ROW_HEAD
+  PROP_ROW_HEAD,
+  PROP_TABBABLE
 };
 
 enum
@@ -426,6 +427,14 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class)
                                                          P_("If true, this column is a \"row head\", equivalent to a column head.  If rectangular selection is enabled, then shift+click and control+click in the column select row ranges and toggle row selection, respectively.  The column should ordinarily include a button cell; clicking on the button will select the row (and deselect all other rows)."),
                                                          FALSE,
                                                          GTK_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+                                   PROP_TABBABLE,
+                                   g_param_spec_boolean ("tabbable",
+                                                         P_("Tabbable"),
+                                                         P_("If true, Tab and Shift+Tab visit this column.  If false, Tab and Shift+Tab skip this column."),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
 }
 
 static void
@@ -468,6 +477,7 @@ pspp_sheet_view_column_init (PsppSheetViewColumn *tree_column)
   tree_column->selected = FALSE;
   tree_column->selectable = TRUE;
   tree_column->row_head = FALSE;
+  tree_column->tabbable = TRUE;
   tree_column->sort_order = GTK_SORT_ASCENDING;
   tree_column->show_sort_indicator = FALSE;
   tree_column->property_changed_signal = 0;
@@ -621,6 +631,11 @@ pspp_sheet_view_column_set_property (GObject         *object,
                                              g_value_get_boolean (value));
       break;
 
+    case PROP_TABBABLE:
+      pspp_sheet_view_column_set_tabbable (tree_column,
+                                           g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -739,6 +754,11 @@ pspp_sheet_view_column_get_property (GObject         *object,
                            pspp_sheet_view_column_get_row_head (tree_column));
       break;
 
+    case PROP_TABBABLE:
+      g_value_set_boolean (value,
+                           pspp_sheet_view_column_get_tabbable (tree_column));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2741,6 +2761,44 @@ pspp_sheet_view_column_get_row_head (PsppSheetViewColumn *tree_column)
 }
 
 
+/**
+ * pspp_sheet_view_column_set_tabbable:
+ * @tree_column: A #PsppSheetViewColumn
+ * @tabbable: If true, the column is "tabbable", meaning that Tab and Shift+Tab
+ * in the sheet visit this column.  If false, Tab and Shift+Tab skip this
+ * column.
+ **/
+void
+pspp_sheet_view_column_set_tabbable (PsppSheetViewColumn *tree_column,
+                                     gboolean           tabbable)
+{
+  g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column));
+
+  tabbable = !!tabbable;
+  if (tree_column->tabbable != tabbable)
+    {
+      tree_column->tabbable = tabbable;
+      g_object_notify (G_OBJECT (tree_column), "tabbable");
+    }
+}
+
+/**
+ * pspp_sheet_view_column_get_tabbable:
+ * @tree_column: A #PsppSheetViewColumn
+ *
+ * Returns %TRUE if the column is tabbable.
+ *
+ * Return value: %TRUE if the column is tabbable.
+ **/
+gboolean
+pspp_sheet_view_column_get_tabbable (PsppSheetViewColumn *tree_column)
+{
+  g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), FALSE);
+
+  return tree_column->tabbable;
+}
+
+
 /**
  * pspp_sheet_view_column_set_sort_column_id:
  * @tree_column: a #PsppSheetViewColumn