Fix constness problem in spreadsheet reader dialog
[pspp] / src / ui / gui / pspp-sheet-view-column.c
index f51fcff1a9b7f4dbe653785aad17f9f696e96eb6..f3ae12cdfc0f40720a0239e42d695a4cbaa74828 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;
@@ -1366,8 +1386,13 @@ on_pspp_sheet_view_column_button_clicked (PsppSheetViewColumn *column)
   if (pspp_sheet_selection_get_mode (selection) == PSPP_SHEET_SELECTION_RECTANGLE)
     {
       pspp_sheet_selection_select_all (selection);
-      pspp_sheet_selection_unselect_all_columns (selection);
-      pspp_sheet_selection_select_column (selection, column);
+      if (pspp_sheet_view_column_get_row_head (column))
+        pspp_sheet_selection_select_all_columns (selection);
+      else
+        {
+          pspp_sheet_selection_unselect_all_columns (selection);
+          pspp_sheet_selection_select_column (selection, column);
+        }
       sheet_view->priv->anchor_column = column;
       return TRUE;
     }
@@ -2338,7 +2363,7 @@ pspp_sheet_view_column_set_title (PsppSheetViewColumn *tree_column,
  * Return value: the title of the column. This string should not be
  * modified or freed.
  **/
-G_CONST_RETURN gchar *
+const gchar *
 pspp_sheet_view_column_get_title (PsppSheetViewColumn *tree_column)
 {
   g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), NULL);
@@ -2736,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