[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/17] pspp-sheet-view: Add "fixed-height" and "fixed-height-set"
From: |
Ben Pfaff |
Subject: |
[PATCH 15/17] pspp-sheet-view: Add "fixed-height" and "fixed-height-set" properties. |
Date: |
Sun, 22 Apr 2012 11:12:33 -0700 |
The data sheet will use this in the "split view" to make sure that
side-by-side data sheets have the same row height.
---
src/ui/gui/pspp-sheet-private.h | 1 +
src/ui/gui/pspp-sheet-view.c | 82 ++++++++++++++++++++++++++++++++++++++-
src/ui/gui/pspp-sheet-view.h | 3 +
3 files changed, 85 insertions(+), 1 deletions(-)
diff --git a/src/ui/gui/pspp-sheet-private.h b/src/ui/gui/pspp-sheet-private.h
index 668efae..abb8366 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 0fea3cb..8ae1ab4 100644
--- a/src/ui/gui/pspp-sheet-view.c
+++ b/src/ui/gui/pspp-sheet-view.c
@@ -145,7 +145,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 */
@@ -638,6 +640,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
@@ -995,6 +1015,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;
@@ -1092,6 +1113,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;
@@ -1152,6 +1196,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;
@@ -5245,6 +5295,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;
@@ -5258,6 +5311,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");
}
}
@@ -12368,6 +12423,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 a80b545..73210f1 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,
--
1.7.2.5
- [PATCH 10/17] pspp-sheet-view: Add "special-cells" property to speed drawing many columns., (continued)
- [PATCH 10/17] pspp-sheet-view: Add "special-cells" property to speed drawing many columns., Ben Pfaff, 2012/04/22
- [PATCH 13/17] pspp-sheet-view: Improve look of sheet when there are few columns., Ben Pfaff, 2012/04/22
- [PATCH 11/17] pspp-widget-facade: New code to measure and render some GTK+ widgets., Ben Pfaff, 2012/04/22
- [PATCH 14/17] pspp-sheet-view: Make pspp_sheet_view_stop_editing() public., Ben Pfaff, 2012/04/22
- [PATCH 08/17] pspp-sheet-view: Support rectangular selection, column popup menus., Ben Pfaff, 2012/04/22
- [PATCH 12/17] pspp-sheet-view: Optimize by making column header widgets lazy., Ben Pfaff, 2012/04/22
- [PATCH 15/17] pspp-sheet-view: Add "fixed-height" and "fixed-height-set" properties.,
Ben Pfaff <=
- [PATCH 17/17] psppire-cell-renderer-button: Add "slash" property., Ben Pfaff, 2012/04/22
- [PATCH 16/17] psppire-cell-renderer-button: New cell renderer for GtkButton., Ben Pfaff, 2012/04/22
- [PATCH 02/17] pspp-sheet-view: Reduce time and memory cost to O(1) in number of rows., Ben Pfaff, 2012/04/22
- [PATCH 01/17] Import GtkTreeView from GTK+ 2.0-2.20.1 renamed as PsppSheetView., Ben Pfaff, 2012/04/22
- Re: [PATCH 00/17] Implement PsppSheetView, Ben Pfaff, 2012/04/24