From: Ben Pfaff Date: Thu, 2 Feb 2012 05:44:50 +0000 (-0800) Subject: pspp-sheet-view: Add "fixed-height" and "fixed-height-set" properties. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=66c331cda3ecc00d81761ac9fdc62ac6c475be03 pspp-sheet-view: Add "fixed-height" and "fixed-height-set" properties. The data sheet will use this in the "split view" to make sure that side-by-side data sheets have the same row height. --- diff --git a/src/ui/gui/pspp-sheet-private.h b/src/ui/gui/pspp-sheet-private.h index 668efaeced..abb8366c6a 100644 --- a/src/ui/gui/pspp-sheet-private.h +++ b/src/ui/gui/pspp-sheet-private.h @@ -215,6 +215,7 @@ struct _PsppSheetViewPrivate /* fixed height */ gint fixed_height; + gboolean fixed_height_set; /* Scroll-to functionality when unrealized */ GtkTreeRowReference *scroll_to_path; diff --git a/src/ui/gui/pspp-sheet-view.c b/src/ui/gui/pspp-sheet-view.c index 5ddef9d821..eb7654fab9 100644 --- a/src/ui/gui/pspp-sheet-view.c +++ b/src/ui/gui/pspp-sheet-view.c @@ -144,7 +144,9 @@ enum { PROP_RUBBER_BANDING, PROP_ENABLE_GRID_LINES, PROP_TOOLTIP_COLUMN, - PROP_SPECIAL_CELLS + PROP_SPECIAL_CELLS, + PROP_FIXED_HEIGHT, + PROP_FIXED_HEIGHT_SET }; /* object signals */ @@ -637,6 +639,24 @@ pspp_sheet_view_class_init (PsppSheetViewClass *class) PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT, GTK_PARAM_READWRITE)); + g_object_class_install_property (o_class, + PROP_FIXED_HEIGHT, + g_param_spec_int ("fixed-height", + P_("Fixed Height"), + P_("Height of a single row. Normally the height of a row is determined automatically. Writing this property sets fixed-height-set to true, preventing this property's value from changing."), + -1, + G_MAXINT, + -1, + GTK_PARAM_READWRITE)); + + g_object_class_install_property (o_class, + PROP_FIXED_HEIGHT_SET, + g_param_spec_boolean ("fixed-height-set", + P_("Fixed Height Set"), + P_("Whether fixed-height was set externally."), + FALSE, + GTK_PARAM_READWRITE)); + /* Style properties */ #define _TREE_VIEW_EXPANDER_SIZE 12 #define _TREE_VIEW_VERTICAL_SEPARATOR 2 @@ -994,6 +1014,7 @@ pspp_sheet_view_init (PsppSheetView *tree_view) tree_view->priv->presize_handler_timer = 0; tree_view->priv->scroll_sync_timer = 0; tree_view->priv->fixed_height = -1; + tree_view->priv->fixed_height_set = FALSE; pspp_sheet_view_set_adjustments (tree_view, NULL, NULL); tree_view->priv->selection = _pspp_sheet_selection_new_with_tree_view (tree_view); tree_view->priv->enable_search = TRUE; @@ -1091,6 +1112,29 @@ pspp_sheet_view_set_property (GObject *object, case PROP_SPECIAL_CELLS: pspp_sheet_view_set_special_cells (tree_view, g_value_get_enum (value)); break; + case PROP_FIXED_HEIGHT: + pspp_sheet_view_set_fixed_height (tree_view, g_value_get_int (value)); + break; + case PROP_FIXED_HEIGHT_SET: + if (g_value_get_boolean (value)) + { + if (!tree_view->priv->fixed_height_set + && tree_view->priv->fixed_height >= 0) + { + tree_view->priv->fixed_height_set = true; + g_object_notify (G_OBJECT (tree_view), "fixed-height-set"); + } + } + else + { + if (tree_view->priv->fixed_height_set) + { + tree_view->priv->fixed_height_set = false; + g_object_notify (G_OBJECT (tree_view), "fixed-height-set"); + install_presize_handler (tree_view); + } + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1151,6 +1195,12 @@ pspp_sheet_view_get_property (GObject *object, case PROP_SPECIAL_CELLS: g_value_set_enum (value, tree_view->priv->special_cells); break; + case PROP_FIXED_HEIGHT: + g_value_set_int (value, pspp_sheet_view_get_fixed_height (tree_view)); + break; + case PROP_FIXED_HEIGHT_SET: + g_value_set_boolean (value, tree_view->priv->fixed_height_set); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -5244,6 +5294,9 @@ initialize_fixed_height_mode (PsppSheetView *tree_view) if (!tree_view->priv->row_count) return; + if (tree_view->priv->fixed_height_set) + return; + if (tree_view->priv->fixed_height < 0) { GtkTreeIter iter; @@ -5257,6 +5310,8 @@ initialize_fixed_height_mode (PsppSheetView *tree_view) tree_view->priv->fixed_height = validate_row (tree_view, node, &iter, path); gtk_tree_path_free (path); + + g_object_notify (G_OBJECT (tree_view), "fixed-height"); } } @@ -12367,6 +12422,31 @@ pspp_sheet_view_set_special_cells (PsppSheetView *tree_view, } } +int +pspp_sheet_view_get_fixed_height (const PsppSheetView *tree_view) +{ + /* XXX (re)calculate fixed_height if necessary */ + return tree_view->priv->fixed_height; +} + +void +pspp_sheet_view_set_fixed_height (PsppSheetView *tree_view, + int fixed_height) +{ + g_return_if_fail (fixed_height > 0); + + if (tree_view->priv->fixed_height != fixed_height) + { + tree_view->priv->fixed_height = fixed_height; + g_object_notify (G_OBJECT (tree_view), "fixed-height"); + } + if (!tree_view->priv->fixed_height_set) + { + tree_view->priv->fixed_height_set = TRUE; + g_object_notify (G_OBJECT (tree_view), "fixed-height-set"); + } +} + /** * pspp_sheet_view_set_tooltip_row: * @tree_view: a #PsppSheetView diff --git a/src/ui/gui/pspp-sheet-view.h b/src/ui/gui/pspp-sheet-view.h index a80b5452b4..73210f1521 100644 --- a/src/ui/gui/pspp-sheet-view.h +++ b/src/ui/gui/pspp-sheet-view.h @@ -391,6 +391,9 @@ PsppSheetViewSpecialCells pspp_sheet_view_get_special_cells (PsppSheetView void pspp_sheet_view_set_special_cells (PsppSheetView *tree_view, PsppSheetViewSpecialCells); +int pspp_sheet_view_get_fixed_height (const PsppSheetView *); +void pspp_sheet_view_set_fixed_height (PsppSheetView *, + int fixed_height); /* Convenience functions for setting tooltips */ void pspp_sheet_view_set_tooltip_row (PsppSheetView *tree_view,