X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpspp-sheet-view-column.c;h=cd3fae3c6ec1e9927d34f328314fdb4b6b7cf28c;hb=ecad37996f533d5cd8348ad68659470e821f5ebd;hp=9f88156fd265700199aec292a9ab6c27c4dc896e;hpb=c040ea5dd9a6c87e45b864974b27ef79a64660e7;p=pspp diff --git a/src/ui/gui/pspp-sheet-view-column.c b/src/ui/gui/pspp-sheet-view-column.c index 9f88156fd2..cd3fae3c6e 100644 --- a/src/ui/gui/pspp-sheet-view-column.c +++ b/src/ui/gui/pspp-sheet-view-column.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2011, 2012 Free Software Foundation, Inc. + Copyright (C) 2011, 2012, 2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,10 @@ #include #include "ui/gui/psppire-marshal.h" +#include "ui/gui/pspp-sheet-selection.h" +#include "ui/gui/pspp-widget-facade.h" + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS #define P_(STRING) STRING #define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB @@ -67,13 +71,19 @@ enum PROP_SORT_INDICATOR, PROP_SORT_ORDER, PROP_SORT_COLUMN_ID, - PROP_QUICK_EDIT + PROP_QUICK_EDIT, + PROP_SELECTED, + PROP_SELECTABLE, + PROP_ROW_HEAD, + PROP_TABBABLE }; enum { CLICKED, QUERY_TOOLTIP, + POPUP_MENU, + BUTTON_PRESS_EVENT, LAST_SIGNAL }; @@ -133,17 +143,22 @@ static GList *pspp_sheet_view_column_cell_layout_get_cells (GtkCellLayout /* Button handling code */ static void pspp_sheet_view_column_create_button (PsppSheetViewColumn *tree_column); -static void pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column); +void pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column); /* Button signal handlers */ static gint pspp_sheet_view_column_button_event (GtkWidget *widget, - GdkEvent *event, + GdkEventButton *event, gpointer data); static void pspp_sheet_view_column_button_clicked (GtkWidget *widget, gpointer data); +static void pspp_sheet_view_column_button_popup_menu (GtkWidget *widget, + gpointer data); static gboolean pspp_sheet_view_column_mnemonic_activate (GtkWidget *widget, gboolean group_cycling, gpointer data); +static gboolean on_pspp_sheet_view_column_button_clicked (PsppSheetViewColumn *); +static gboolean on_pspp_sheet_view_column_button_press_event (PsppSheetViewColumn *, + GdkEventButton *); /* Property handlers */ static void pspp_sheet_view_model_sort_column_changed (GtkTreeSortable *sortable, @@ -173,7 +188,7 @@ static void pspp_sheet_view_column_buildable_init (GtkBuildableI static guint tree_column_signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE_WITH_CODE (PsppSheetViewColumn, pspp_sheet_view_column, GTK_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (PsppSheetViewColumn, pspp_sheet_view_column, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, pspp_sheet_view_column_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -187,17 +202,27 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) object_class = (GObjectClass*) class; - class->clicked = NULL; + class->clicked = on_pspp_sheet_view_column_button_clicked; + class->button_press_event = on_pspp_sheet_view_column_button_press_event; object_class->finalize = pspp_sheet_view_column_finalize; object_class->set_property = pspp_sheet_view_column_set_property; object_class->get_property = pspp_sheet_view_column_get_property; - + tree_column_signals[CLICKED] = g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (PsppSheetViewColumnClass, clicked), + g_signal_accumulator_true_handled, NULL, + psppire_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); + + tree_column_signals[POPUP_MENU] = + g_signal_new ("popup-menu", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -212,6 +237,16 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) G_TYPE_BOOLEAN, 1, GTK_TYPE_TOOLTIP); + tree_column_signals[BUTTON_PRESS_EVENT] = + g_signal_new ("button-press-event", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (PsppSheetViewColumnClass, button_press_event), + g_signal_accumulator_true_handled, NULL, + psppire_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + g_object_class_install_property (object_class, PROP_VISIBLE, g_param_spec_boolean ("visible", @@ -219,7 +254,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("Whether to display the column"), TRUE, GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_RESIZABLE, g_param_spec_boolean ("resizable", @@ -227,7 +262,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("Column is user-resizable"), FALSE, GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_WIDTH, g_param_spec_int ("width", @@ -246,7 +281,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) G_MAXINT, 0, GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_FIXED_WIDTH, g_param_spec_int ("fixed-width", @@ -284,7 +319,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("Title to appear in column header"), "", GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_EXPAND, g_param_spec_boolean ("expand", @@ -292,7 +327,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("Column gets share of extra width allocated to the widget"), FALSE, GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_CLICKABLE, g_param_spec_boolean ("clickable", @@ -300,7 +335,7 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("Whether the header can be clicked"), FALSE, GTK_PARAM_READWRITE)); - + g_object_class_install_property (object_class, PROP_WIDGET, @@ -370,14 +405,68 @@ pspp_sheet_view_column_class_init (PsppSheetViewColumnClass *class) P_("If true, editing starts upon the first click in the column. If false, the first click selects the column and a second click is needed to begin editing. This has no effect on cells that are not editable."), TRUE, GTK_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_SELECTED, + g_param_spec_boolean ("selected", + P_("Selected"), + P_("If true, this column is selected as part of a rectangular selection."), + FALSE, + GTK_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_SELECTABLE, + g_param_spec_boolean ("selectable", + P_("Selectable"), + P_("If true, this column may be selected as part of a rectangular selection."), + TRUE, + GTK_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_ROW_HEAD, + g_param_spec_boolean ("row-head", + P_("Row head"), + 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 _cell_layout_buildable_custom_tag_end (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer *data); + + +static void _cell_layout_buildable_add_child (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *type); + + +static gboolean _cell_layout_buildable_custom_tag_start (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + GMarkupParser *parser, + gpointer *data); + + static void pspp_sheet_view_column_buildable_init (GtkBuildableIface *iface) { - iface->add_child = _gtk_cell_layout_buildable_add_child; - iface->custom_tag_start = _gtk_cell_layout_buildable_custom_tag_start; - iface->custom_tag_end = _gtk_cell_layout_buildable_custom_tag_end; + iface->add_child = _cell_layout_buildable_add_child; + iface->custom_tag_start = _cell_layout_buildable_custom_tag_start; + iface->custom_tag_end = _cell_layout_buildable_custom_tag_end; } static void @@ -397,7 +486,7 @@ static void pspp_sheet_view_column_init (PsppSheetViewColumn *tree_column) { tree_column->button = NULL; - tree_column->xalign = 0.0; + tree_column->halign = GTK_ALIGN_START; tree_column->width = 0; tree_column->spacing = 0; tree_column->requested_width = -1; @@ -409,6 +498,10 @@ pspp_sheet_view_column_init (PsppSheetViewColumn *tree_column) tree_column->expand = FALSE; tree_column->clickable = FALSE; tree_column->dirty = TRUE; + 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; @@ -535,7 +628,7 @@ pspp_sheet_view_column_set_property (GObject *object, pspp_sheet_view_column_set_sort_order (tree_column, g_value_get_enum (value)); break; - + case PROP_SORT_COLUMN_ID: pspp_sheet_view_column_set_sort_column_id (tree_column, g_value_get_int (value)); @@ -546,6 +639,26 @@ pspp_sheet_view_column_set_property (GObject *object, g_value_get_boolean (value)); break; + case PROP_SELECTED: + pspp_sheet_view_column_set_selected (tree_column, + g_value_get_boolean (value)); + break; + + case PROP_SELECTABLE: + pspp_sheet_view_column_set_selectable (tree_column, + g_value_get_boolean (value)); + break; + + case PROP_ROW_HEAD: + pspp_sheet_view_column_set_row_head (tree_column, + 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; @@ -638,7 +751,7 @@ pspp_sheet_view_column_get_property (GObject *object, g_value_set_enum (value, pspp_sheet_view_column_get_sort_order (tree_column)); break; - + case PROP_SORT_COLUMN_ID: g_value_set_int (value, pspp_sheet_view_column_get_sort_column_id (tree_column)); @@ -649,6 +762,26 @@ pspp_sheet_view_column_get_property (GObject *object, pspp_sheet_view_column_get_quick_edit (tree_column)); break; + case PROP_SELECTED: + g_value_set_boolean (value, + pspp_sheet_view_column_get_selected (tree_column)); + break; + + case PROP_SELECTABLE: + g_value_set_boolean (value, + pspp_sheet_view_column_get_selectable (tree_column)); + break; + + case PROP_ROW_HEAD: + g_value_set_boolean (value, + 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; @@ -721,7 +854,7 @@ pspp_sheet_view_column_cell_layout_clear (GtkCellLayout *cell_layout) pspp_sheet_view_column_cell_layout_clear_attributes (cell_layout, info->cell); g_object_unref (info->cell); g_free (info); - column->cell_list = g_list_delete_link (column->cell_list, + column->cell_list = g_list_delete_link (column->cell_list, column->cell_list); } } @@ -859,6 +992,19 @@ on_query_tooltip (GtkWidget *widget, return handled; } +static gboolean +on_button_pressed (GtkWidget *widget, GdkEventButton *event, + gpointer user_data) +{ + PsppSheetViewColumn *tree_column = user_data; + gboolean handled; + + /* XXX See "Implement GtkWidget::popup_menu" in GTK+ reference manual. */ + g_signal_emit (tree_column, tree_column_signals[BUTTON_PRESS_EVENT], + 0, event, &handled); + return handled; +} + /* Helper functions */ @@ -876,10 +1022,8 @@ pspp_sheet_view_column_create_button (PsppSheetViewColumn *tree_column) g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view)); g_return_if_fail (tree_column->button == NULL); - gtk_widget_push_composite_child (); tree_column->button = gtk_button_new (); gtk_widget_add_events (tree_column->button, GDK_POINTER_MOTION_MASK); - gtk_widget_pop_composite_child (); /* make sure we own a reference to it as well. */ if (tree_view->priv->header_window) @@ -892,15 +1036,20 @@ pspp_sheet_view_column_create_button (PsppSheetViewColumn *tree_column) g_signal_connect (tree_column->button, "clicked", G_CALLBACK (pspp_sheet_view_column_button_clicked), tree_column); + g_signal_connect (tree_column->button, "popup-menu", + G_CALLBACK (pspp_sheet_view_column_button_popup_menu), + tree_column); + g_signal_connect (tree_column->button, "button-press-event", + G_CALLBACK (on_button_pressed), tree_column); g_signal_connect (tree_column->button, "query-tooltip", G_CALLBACK (on_query_tooltip), tree_column); g_object_set (tree_column->button, "has-tooltip", TRUE, NULL); - tree_column->alignment = gtk_alignment_new (tree_column->xalign, 0.5, 0.0, 0.0); + tree_column->bin = gtk_event_box_new (); + g_object_set (tree_column->bin, "halign", GTK_ALIGN_CENTER, NULL); - hbox = gtk_hbox_new (FALSE, 2); - tree_column->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); if (tree_column->child) child = tree_column->child; @@ -914,31 +1063,25 @@ pspp_sheet_view_column_create_button (PsppSheetViewColumn *tree_column) G_CALLBACK (pspp_sheet_view_column_mnemonic_activate), tree_column); - if (tree_column->xalign <= 0.5) - gtk_box_pack_end (GTK_BOX (hbox), tree_column->arrow, FALSE, FALSE, 0); - else - gtk_box_pack_start (GTK_BOX (hbox), tree_column->arrow, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), tree_column->alignment, TRUE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (tree_column->alignment), child); + gtk_box_pack_start (GTK_BOX (hbox), tree_column->bin, TRUE, TRUE, 0); + + gtk_container_add (GTK_CONTAINER (tree_column->bin), child); gtk_container_add (GTK_CONTAINER (tree_column->button), hbox); gtk_widget_show (hbox); - gtk_widget_show (tree_column->alignment); + gtk_widget_show (tree_column->bin); pspp_sheet_view_column_update_button (tree_column); } -static void +void pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) { gint sort_column_id = -1; - GtkWidget *hbox; GtkWidget *alignment; - GtkWidget *arrow; GtkWidget *current_child; - GtkArrowType arrow_type = GTK_ARROW_NONE; GtkTreeModel *model; + gboolean can_focus; if (tree_column->tree_view) model = pspp_sheet_view_get_model (PSPP_SHEET_VIEW (tree_column->tree_view)); @@ -951,19 +1094,18 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) tree_column->tree_view && gtk_widget_get_realized (tree_column->tree_view)) pspp_sheet_view_column_create_button (tree_column); - + if (! tree_column->button) return; - hbox = GTK_BIN (tree_column->button)->child; - alignment = tree_column->alignment; - arrow = tree_column->arrow; - current_child = GTK_BIN (alignment)->child; + alignment = tree_column->bin; + current_child = gtk_bin_get_child (GTK_BIN (alignment)); /* Set up the actual button */ - gtk_alignment_set (GTK_ALIGNMENT (alignment), tree_column->xalign, - 0.5, 0.0, 0.0); - + g_object_set (alignment, + "halign", tree_column->halign, + "valign", GTK_ALIGN_CENTER, NULL); + if (tree_column->child) { if (current_child != tree_column->child) @@ -974,7 +1116,7 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) tree_column->child); } } - else + else { if (current_child == NULL) { @@ -999,58 +1141,6 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) &sort_column_id, NULL); - if (tree_column->show_sort_indicator) - { - gboolean alternative; - - g_object_get (gtk_widget_get_settings (tree_column->tree_view), - "gtk-alternative-sort-arrows", &alternative, - NULL); - - switch (tree_column->sort_order) - { - case GTK_SORT_ASCENDING: - arrow_type = alternative ? GTK_ARROW_UP : GTK_ARROW_DOWN; - break; - - case GTK_SORT_DESCENDING: - arrow_type = alternative ? GTK_ARROW_DOWN : GTK_ARROW_UP; - break; - - default: - g_warning (G_STRLOC": bad sort order"); - break; - } - } - - gtk_arrow_set (GTK_ARROW (arrow), - arrow_type, - GTK_SHADOW_IN); - - /* Put arrow on the right if the text is left-or-center justified, and on the - * left otherwise; do this by packing boxes, so flipping text direction will - * reverse things - */ - g_object_ref (arrow); - gtk_container_remove (GTK_CONTAINER (hbox), arrow); - - if (tree_column->xalign <= 0.5) - { - gtk_box_pack_end (GTK_BOX (hbox), arrow, FALSE, FALSE, 0); - } - else - { - gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0); - /* move it to the front */ - gtk_box_reorder_child (GTK_BOX (hbox), arrow, 0); - } - g_object_unref (arrow); - - if (tree_column->show_sort_indicator - || (GTK_IS_TREE_SORTABLE (model) && tree_column->sort_column_id >= 0)) - gtk_widget_show (arrow); - else - gtk_widget_hide (arrow); /* It's always safe to hide the button. It isn't always safe to show it, as * if you show it before it's realized, it'll get the wrong window. */ @@ -1060,7 +1150,7 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) { if (tree_column->visible) { - gtk_widget_show_now (tree_column->button); + gtk_widget_show (tree_column->button); if (tree_column->window) { if (tree_column->resizable) @@ -1081,23 +1171,18 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) gdk_window_hide (tree_column->window); } } - - if (tree_column->reorderable || tree_column->clickable) - { - gtk_widget_set_can_focus (tree_column->button, TRUE); - } - else + + can_focus = pspp_sheet_view_column_can_focus (tree_column); + gtk_widget_set_can_focus (tree_column->button, can_focus); + if (!can_focus && gtk_widget_has_focus (tree_column->button)) { - gtk_widget_set_can_focus (tree_column->button, FALSE); - if (gtk_widget_has_focus (tree_column->button)) - { - GtkWidget *toplevel = gtk_widget_get_toplevel (tree_column->tree_view); - if (gtk_widget_is_toplevel (toplevel)) - { - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); - } - } + GtkWidget *toplevel = gtk_widget_get_toplevel (tree_column->tree_view); + if (gtk_widget_is_toplevel (toplevel)) + { + gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); + } } + /* Queue a resize on the assumption that we always want to catch all changes * and columns don't change all that often. */ @@ -1111,7 +1196,7 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) static gint pspp_sheet_view_column_button_event (GtkWidget *widget, - GdkEvent *event, + GdkEventButton *event, gpointer data) { PsppSheetViewColumn *column = (PsppSheetViewColumn *) data; @@ -1123,7 +1208,8 @@ pspp_sheet_view_column_button_event (GtkWidget *widget, ((GdkEventButton *)event)->button == 1) { column->maybe_reordered = TRUE; - gdk_window_get_pointer (GTK_BUTTON (widget)->event_window, + gdk_window_get_device_position (gtk_button_get_event_window (GTK_BUTTON (widget)), + event->device, &column->drag_x, &column->drag_y, NULL); @@ -1133,7 +1219,7 @@ pspp_sheet_view_column_button_event (GtkWidget *widget, if (event->type == GDK_BUTTON_RELEASE || event->type == GDK_LEAVE_NOTIFY) column->maybe_reordered = FALSE; - + if (event->type == GDK_MOTION_NOTIFY && column->maybe_reordered && (gtk_drag_check_threshold (widget, @@ -1150,9 +1236,6 @@ pspp_sheet_view_column_button_event (GtkWidget *widget, { switch (event->type) { - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: case GDK_MOTION_NOTIFY: case GDK_BUTTON_RELEASE: case GDK_ENTER_NOTIFY: @@ -1165,11 +1248,131 @@ pspp_sheet_view_column_button_event (GtkWidget *widget, return FALSE; } +static gboolean +all_rows_selected (PsppSheetView *sheet_view) +{ + PsppSheetSelection *selection = sheet_view->priv->selection; + gint n_rows, n_selected_rows; + + n_rows = sheet_view->priv->row_count; + n_selected_rows = pspp_sheet_selection_count_selected_rows (selection); + + return n_rows > 0 && n_selected_rows >= n_rows; +} + +static gboolean +on_pspp_sheet_view_column_button_press_event (PsppSheetViewColumn *column, + GdkEventButton *event) +{ + PsppSheetView *sheet_view = PSPP_SHEET_VIEW (column->tree_view); + PsppSheetSelection *selection; + GSignalInvocationHint *hint; + guint modifiers; + + /* We only want to run first, not last, but combining that with return type + `gboolean' makes GObject warn, so just ignore the run_last call. */ + hint = g_signal_get_invocation_hint (column); + g_return_val_if_fail (hint != NULL, FALSE); + if (hint->run_type != G_SIGNAL_RUN_FIRST) + return FALSE; + + g_return_val_if_fail (sheet_view != NULL, FALSE); + + selection = sheet_view->priv->selection; + g_return_val_if_fail (selection != NULL, FALSE); + + if (pspp_sheet_selection_get_mode (selection) != PSPP_SHEET_SELECTION_RECTANGLE) + return FALSE; + + modifiers = event->state & gtk_accelerator_get_default_mod_mask (); + if (event->type == GDK_BUTTON_PRESS && event->button == 3) + { + if (pspp_sheet_selection_count_selected_columns (selection) <= 1 + || !all_rows_selected (sheet_view)) + { + pspp_sheet_selection_select_all (selection); + pspp_sheet_selection_unselect_all_columns (selection); + pspp_sheet_selection_select_column (selection, column); + sheet_view->priv->anchor_column = column; + } + return FALSE; + } + else if (event->type == GDK_BUTTON_PRESS && event->button == 1 + && modifiers == GDK_CONTROL_MASK) + { + gboolean is_selected; + + if (!all_rows_selected (sheet_view)) + { + pspp_sheet_selection_select_all (selection); + pspp_sheet_selection_unselect_all_columns (selection); + } + sheet_view->priv->anchor_column = column; + + is_selected = pspp_sheet_view_column_get_selected (column); + pspp_sheet_view_column_set_selected (column, !is_selected); + + return TRUE; + } + else if (event->type == GDK_BUTTON_PRESS && event->button == 1 + && modifiers == GDK_SHIFT_MASK) + { + if (!all_rows_selected (sheet_view)) + { + pspp_sheet_selection_select_all (selection); + pspp_sheet_selection_unselect_all_columns (selection); + sheet_view->priv->anchor_column = column; + } + else if (sheet_view->priv->anchor_column == NULL) + sheet_view->priv->anchor_column = column; + + pspp_sheet_selection_unselect_all_columns (selection); + pspp_sheet_selection_select_column_range (selection, + sheet_view->priv->anchor_column, + column); + return TRUE; + } + + return FALSE; +} + +static gboolean +on_pspp_sheet_view_column_button_clicked (PsppSheetViewColumn *column) +{ + PsppSheetSelection *selection; + PsppSheetView *sheet_view; + + sheet_view = PSPP_SHEET_VIEW (pspp_sheet_view_column_get_tree_view (column)); + selection = pspp_sheet_view_get_selection (sheet_view); + if (pspp_sheet_selection_get_mode (selection) == PSPP_SHEET_SELECTION_RECTANGLE) + { + pspp_sheet_selection_select_all (selection); + 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; + } + return FALSE; +} static void pspp_sheet_view_column_button_clicked (GtkWidget *widget, gpointer data) { - g_signal_emit_by_name (data, "clicked"); + PsppSheetViewColumn *column = data; + gboolean handled; + + g_signal_emit (column, tree_column_signals[CLICKED], 0, &handled); +} + +static void +pspp_sheet_view_column_button_popup_menu (GtkWidget *widget, gpointer data) +{ + g_signal_emit_by_name (data, "popup-menu"); } static gboolean @@ -1286,7 +1489,7 @@ pspp_sheet_view_column_setup_sort_column_id_callback (PsppSheetViewColumn *tree_ g_signal_connect (model, "sort-column-changed", G_CALLBACK (pspp_sheet_view_model_sort_column_changed), tree_column); - + if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &real_sort_column_id, &real_order) && @@ -1295,7 +1498,7 @@ pspp_sheet_view_column_setup_sort_column_id_callback (PsppSheetViewColumn *tree_ pspp_sheet_view_column_set_sort_indicator (tree_column, TRUE); pspp_sheet_view_column_set_sort_order (tree_column, real_order); } - else + else { pspp_sheet_view_column_set_sort_indicator (tree_column, FALSE); } @@ -1310,6 +1513,7 @@ pspp_sheet_view_column_setup_sort_column_id_callback (PsppSheetViewColumn *tree_ void _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column) { + GtkAllocation allocation; PsppSheetView *tree_view; GdkWindowAttr attr; guint attributes_mask; @@ -1321,6 +1525,9 @@ _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column) g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view)); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (tree_view))); g_return_if_fail (tree_view->priv->header_window != NULL); + if (!column->button) + return; + g_return_if_fail (column->button != NULL); gtk_widget_set_parent_window (column->button, tree_view->priv->header_window); @@ -1331,7 +1538,6 @@ _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column) attr.window_type = GDK_WINDOW_CHILD; attr.wclass = GDK_INPUT_ONLY; attr.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view)); - attr.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view)); attr.event_mask = gtk_widget_get_events (GTK_WIDGET (tree_view)) | (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -1339,31 +1545,32 @@ _pspp_sheet_view_column_realize_button (PsppSheetViewColumn *column) GDK_POINTER_MOTION_HINT_MASK | GDK_KEY_PRESS_MASK); attributes_mask = GDK_WA_CURSOR | GDK_WA_X | GDK_WA_Y; - attr.cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (tree_view->priv->header_window), + attr.cursor = gdk_cursor_new_for_display (gdk_window_get_display (tree_view->priv->header_window), GDK_SB_H_DOUBLE_ARROW); attr.y = 0; attr.width = TREE_VIEW_DRAG_WIDTH; attr.height = tree_view->priv->header_height; - - attr.x = (column->button->allocation.x + (rtl ? 0 : column->button->allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2; + gtk_widget_get_allocation (column->button, &allocation); + attr.x = (allocation.x + (rtl ? 0 : allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2; column->window = gdk_window_new (tree_view->priv->header_window, &attr, attributes_mask); gdk_window_set_user_data (column->window, tree_view); pspp_sheet_view_column_update_button (column); - gdk_cursor_unref (attr.cursor); + g_object_unref (attr.cursor); } void _pspp_sheet_view_column_unrealize_button (PsppSheetViewColumn *column) { g_return_if_fail (column != NULL); - g_return_if_fail (column->window != NULL); - - gdk_window_set_user_data (column->window, NULL); - gdk_window_destroy (column->window); - column->window = NULL; + if (column->window != NULL) + { + gdk_window_set_user_data (column->window, NULL); + gdk_window_destroy (column->window); + column->window = NULL; + } } void @@ -1427,9 +1634,12 @@ _pspp_sheet_view_column_has_editable_cell (PsppSheetViewColumn *column) GList *list; for (list = column->cell_list; list; list = list->next) - if (((PsppSheetViewColumnCellInfo *)list->data)->cell->mode == - GTK_CELL_RENDERER_MODE_EDITABLE) - return TRUE; + { + GtkCellRendererMode mode; + g_object_get (((PsppSheetViewColumnCellInfo *)list->data)->cell, "mode", &mode, NULL); + if (mode == GTK_CELL_RENDERER_MODE_EDITABLE) + return TRUE; + } return FALSE; } @@ -1457,9 +1667,12 @@ _pspp_sheet_view_column_count_special_cells (PsppSheetViewColumn *column) { PsppSheetViewColumnCellInfo *cellinfo = list->data; - if ((cellinfo->cell->mode == GTK_CELL_RENDERER_MODE_EDITABLE || - cellinfo->cell->mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE) && - cellinfo->cell->visible) + GtkCellRendererMode mode; + g_object_get (cellinfo->cell, "mode", &mode, NULL); + + if ((mode == GTK_CELL_RENDERER_MODE_EDITABLE || + mode == GTK_CELL_RENDERER_MODE_ACTIVATABLE) && + gtk_cell_renderer_get_visible (cellinfo->cell)) i++; } @@ -1490,9 +1703,9 @@ _pspp_sheet_view_column_get_cell_at_pos (PsppSheetViewColumn *column, /** * pspp_sheet_view_column_new: - * + * * Creates a new #PsppSheetViewColumn. - * + * * Return value: A newly created #PsppSheetViewColumn. **/ PsppSheetViewColumn * @@ -1510,7 +1723,7 @@ pspp_sheet_view_column_new (void) * @title: The title to set the header to. * @cell: The #GtkCellRenderer. * @Varargs: A %NULL-terminated list of attributes. - * + * * Creates a new #PsppSheetViewColumn with a number of default values. This is * equivalent to calling pspp_sheet_view_column_set_title(), * pspp_sheet_view_column_pack_start(), and @@ -1523,7 +1736,7 @@ pspp_sheet_view_column_new (void) * { * PsppSheetViewColumn *column; * GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - * + * * column = pspp_sheet_view_column_new_with_attributes ("Title", * renderer, * "text", TEXT_COLUMN, @@ -1531,7 +1744,7 @@ pspp_sheet_view_column_new (void) * NULL); * } * ]| - * + * * Return value: A newly created #PsppSheetViewColumn. **/ PsppSheetViewColumn * @@ -1569,7 +1782,7 @@ pspp_sheet_view_column_get_cell_info (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_pack_start: * @tree_column: A #PsppSheetViewColumn. - * @cell: The #GtkCellRenderer. + * @cell: The #GtkCellRenderer. * @expand: %TRUE if @cell is to be given extra space allocated to @tree_column. * * Packs the @cell into the beginning of the column. If @expand is %FALSE, then @@ -1587,7 +1800,7 @@ pspp_sheet_view_column_pack_start (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_pack_end: * @tree_column: A #PsppSheetViewColumn. - * @cell: The #GtkCellRenderer. + * @cell: The #GtkCellRenderer. * @expand: %TRUE if @cell is to be given extra space allocated to @tree_column. * * Adds the @cell to end of the column. If @expand is %FALSE, then the @cell @@ -1605,7 +1818,7 @@ pspp_sheet_view_column_pack_end (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_clear: * @tree_column: A #PsppSheetViewColumn - * + * * Unsets all the mappings on all renderers on the @tree_column. **/ void @@ -1655,7 +1868,7 @@ pspp_sheet_view_column_get_cell_renderers (PsppSheetViewColumn *tree_column) * @cell_renderer: the #GtkCellRenderer to set attributes on * @attribute: An attribute on the renderer * @column: The column position on the model to get the attribute from. - * + * * Adds an attribute mapping to the list in @tree_column. The @column is the * column of the model to get a value from, and the @attribute is the * parameter on @cell_renderer to be set from the value. So for example @@ -1684,7 +1897,7 @@ pspp_sheet_view_column_set_attributesv (PsppSheetViewColumn *tree_column, attribute = va_arg (args, gchar *); pspp_sheet_view_column_clear_attributes (tree_column, cell_renderer); - + while (attribute != NULL) { column = va_arg (args, gint); @@ -1698,7 +1911,7 @@ pspp_sheet_view_column_set_attributesv (PsppSheetViewColumn *tree_column, * @tree_column: A #PsppSheetViewColumn. * @cell_renderer: the #GtkCellRenderer we're setting the attributes of * @Varargs: A %NULL-terminated list of attributes. - * + * * Sets the attributes in the list as the attributes of @tree_column. * The attributes should be in attribute/column order, as in * pspp_sheet_view_column_add_attribute(). All existing attributes @@ -1725,10 +1938,10 @@ pspp_sheet_view_column_set_attributes (PsppSheetViewColumn *tree_column, * pspp_sheet_view_column_set_cell_data_func: * @tree_column: A #PsppSheetViewColumn * @cell_renderer: A #GtkCellRenderer - * @func: The #PsppSheetViewColumnFunc to use. + * @func: The #PsppSheetViewColumnFunc to use. * @func_data: The user data for @func. * @destroy: The destroy notification for @func_data - * + * * Sets the #PsppSheetViewColumnFunc to use for the column. This * function is used instead of the standard attributes mapping for * setting the column value, and should set the value of @tree_column's @@ -1753,7 +1966,7 @@ pspp_sheet_view_column_set_cell_data_func (PsppSheetViewColumn *tree_column, * pspp_sheet_view_column_clear_attributes: * @tree_column: a #PsppSheetViewColumn * @cell_renderer: a #GtkCellRenderer to clear the attribute mapping on. - * + * * Clears all existing attributes previously set with * pspp_sheet_view_column_set_attributes(). **/ @@ -1769,7 +1982,7 @@ pspp_sheet_view_column_clear_attributes (PsppSheetViewColumn *tree_column, * pspp_sheet_view_column_set_spacing: * @tree_column: A #PsppSheetViewColumn. * @spacing: distance between cell renderers in pixels. - * + * * Sets the spacing field of @tree_column, which is the number of pixels to * place between cell renderers packed into it. **/ @@ -1791,9 +2004,9 @@ pspp_sheet_view_column_set_spacing (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_spacing: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the spacing of @tree_column. - * + * * Return value: the spacing of @tree_column. **/ gint @@ -1810,7 +2023,7 @@ pspp_sheet_view_column_get_spacing (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_visible: * @tree_column: A #PsppSheetViewColumn. * @visible: %TRUE if the @tree_column is visible. - * + * * Sets the visibility of @tree_column. **/ void @@ -1820,7 +2033,7 @@ pspp_sheet_view_column_set_visible (PsppSheetViewColumn *tree_column, g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); visible = !! visible; - + if (tree_column->visible == visible) return; @@ -1836,9 +2049,9 @@ pspp_sheet_view_column_set_visible (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_visible: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns %TRUE if @tree_column is visible. - * + * * Return value: whether the column is visible or not. If it is visible, then * the tree will show the column. **/ @@ -1854,7 +2067,7 @@ pspp_sheet_view_column_get_visible (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_resizable: * @tree_column: A #PsppSheetViewColumn * @resizable: %TRUE, if the column can be resized - * + * * If @resizable is %TRUE, then the user can explicitly resize the column by * grabbing the outer edge of the column button. **/ @@ -1879,9 +2092,9 @@ pspp_sheet_view_column_set_resizable (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_resizable: * @tree_column: A #PsppSheetViewColumn - * + * * Returns %TRUE if the @tree_column can be resized by the end user. - * + * * Return value: %TRUE, if the @tree_column can be resized. **/ gboolean @@ -1896,9 +2109,9 @@ pspp_sheet_view_column_get_resizable (PsppSheetViewColumn *tree_column) /** * pspp_sheet_view_column_get_width: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the current size of @tree_column in pixels. - * + * * Return value: The current width of @tree_column. **/ gint @@ -1913,7 +2126,7 @@ pspp_sheet_view_column_get_width (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_fixed_width: * @tree_column: A #PsppSheetViewColumn. * @fixed_width: The size to set @tree_column to. Must be greater than 0. - * + * * Sets the size of the column in pixels. The size of the column is clamped to * the min/max width for the column. Please note that the min/max width of the * column doesn't actually affect the "fixed_width" property of the widget, just @@ -1941,10 +2154,10 @@ pspp_sheet_view_column_set_fixed_width (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_fixed_width: * @tree_column: a #PsppSheetViewColumn - * + * * Gets the fixed width of the column. This value is only meaning may not be * the actual width of the column on the screen, just what is requested. - * + * * Return value: the fixed width of the column **/ gint @@ -1959,7 +2172,7 @@ pspp_sheet_view_column_get_fixed_width (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_min_width: * @tree_column: A #PsppSheetViewColumn. * @min_width: The minimum width of the column in pixels, or -1. - * + * * Sets the minimum width of the @tree_column. If @min_width is -1, then the * minimum width is unset. **/ @@ -1995,10 +2208,10 @@ pspp_sheet_view_column_set_min_width (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_min_width: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the minimum width in pixels of the @tree_column, or -1 if no minimum * width is set. - * + * * Return value: The minimum width of the @tree_column. **/ gint @@ -2013,7 +2226,7 @@ pspp_sheet_view_column_get_min_width (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_max_width: * @tree_column: A #PsppSheetViewColumn. * @max_width: The maximum width of the column in pixels, or -1. - * + * * Sets the maximum width of the @tree_column. If @max_width is -1, then the * maximum width is unset. Note, the column can actually be wider than max * width if it's the last column in a view. In this case, the column expands to @@ -2051,10 +2264,10 @@ pspp_sheet_view_column_set_max_width (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_max_width: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the maximum width in pixels of the @tree_column, or -1 if no maximum * width is set. - * + * * Return value: The maximum width of the @tree_column. **/ gint @@ -2068,7 +2281,7 @@ pspp_sheet_view_column_get_max_width (PsppSheetViewColumn *tree_column) /** * pspp_sheet_view_column_clicked: * @tree_column: a #PsppSheetViewColumn - * + * * Emits the "clicked" signal on the column. This function will only work if * @tree_column is clickable. **/ @@ -2087,7 +2300,7 @@ pspp_sheet_view_column_clicked (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_title: * @tree_column: A #PsppSheetViewColumn. * @title: The title of the @tree_column. - * + * * Sets the title of the @tree_column. If a custom widget has been set, then * this value is ignored. **/ @@ -2096,7 +2309,7 @@ pspp_sheet_view_column_set_title (PsppSheetViewColumn *tree_column, const gchar *title) { gchar *new_title; - + g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); new_title = g_strdup (title); @@ -2110,13 +2323,13 @@ pspp_sheet_view_column_set_title (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_title: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the title of the widget. - * + * * 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); @@ -2128,7 +2341,7 @@ pspp_sheet_view_column_get_title (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_expand: * @tree_column: A #PsppSheetViewColumn * @expand: %TRUE if the column should take available extra space, %FALSE if not - * + * * Sets the column to take available extra space. This space is shared equally * amongst all columns that have the expand set to %TRUE. If no column has this * option set, then the last column gets all extra space. By default, every @@ -2142,7 +2355,7 @@ pspp_sheet_view_column_set_expand (PsppSheetViewColumn *tree_column, { g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); - expand = expand?TRUE:FALSE; + expand = !!expand; if (tree_column->expand == expand) return; tree_column->expand = expand; @@ -2167,9 +2380,9 @@ pspp_sheet_view_column_set_expand (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_expand: * @tree_column: a #PsppSheetViewColumn - * + * * Return %TRUE if the column expands to take any available space. - * + * * Return value: %TRUE, if the column expands * * Since: 2.4 @@ -2186,7 +2399,7 @@ pspp_sheet_view_column_get_expand (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_clickable: * @tree_column: A #PsppSheetViewColumn. * @clickable: %TRUE if the header is active. - * + * * Sets the header to be active if @active is %TRUE. When the header is active, * then it can take keyboard focus, and can be clicked. **/ @@ -2208,9 +2421,9 @@ pspp_sheet_view_column_set_clickable (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_clickable: * @tree_column: a #PsppSheetViewColumn - * + * * Returns %TRUE if the user can click on the header for the column. - * + * * Return value: %TRUE if user can click the column header. **/ gboolean @@ -2239,7 +2452,7 @@ pspp_sheet_view_column_set_widget (PsppSheetViewColumn *tree_column, if (widget) g_object_ref_sink (widget); - if (tree_column->child) + if (tree_column->child) g_object_unref (tree_column->child); tree_column->child = widget; @@ -2250,10 +2463,10 @@ pspp_sheet_view_column_set_widget (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_widget: * @tree_column: A #PsppSheetViewColumn. - * + * * Returns the #GtkWidget in the button on the column header. If a custom * widget has not been set then %NULL is returned. - * + * * Return value: The #GtkWidget in the column header, or %NULL **/ GtkWidget * @@ -2268,23 +2481,21 @@ pspp_sheet_view_column_get_widget (PsppSheetViewColumn *tree_column) * pspp_sheet_view_column_set_alignment: * @tree_column: A #PsppSheetViewColumn. * @xalign: The alignment, which is between [0.0 and 1.0] inclusive. - * + * * Sets the alignment of the title or custom widget inside the column header. - * The alignment determines its location inside the button -- 0.0 for left, 0.5 - * for center, 1.0 for right. + * The alignment determines its location inside the button. **/ void pspp_sheet_view_column_set_alignment (PsppSheetViewColumn *tree_column, - gfloat xalign) + GtkAlign xalign) { g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); - xalign = CLAMP (xalign, 0.0, 1.0); - if (tree_column->xalign == xalign) + if (tree_column->halign == xalign) return; - tree_column->xalign = xalign; + tree_column->halign = xalign; pspp_sheet_view_column_update_button (tree_column); g_object_notify (G_OBJECT (tree_column), "alignment"); } @@ -2292,25 +2503,25 @@ pspp_sheet_view_column_set_alignment (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_alignment: * @tree_column: A #PsppSheetViewColumn. - * - * Returns the current x alignment of @tree_column. This value can range - * between 0.0 and 1.0. - * + * + * Returns the current x alignment of @tree_column. + * * Return value: The current alignent of @tree_column. **/ -gfloat +GtkAlign pspp_sheet_view_column_get_alignment (PsppSheetViewColumn *tree_column) { - g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), 0.5); + g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), GTK_ALIGN_CENTER); - return tree_column->xalign; + return tree_column->halign; } + /** * pspp_sheet_view_column_set_reorderable: * @tree_column: A #PsppSheetViewColumn * @reorderable: %TRUE, if the column can be reordered. - * + * * If @reorderable is %TRUE, then the column can be reordered by the end user * dragging the header. **/ @@ -2323,10 +2534,11 @@ pspp_sheet_view_column_set_reorderable (PsppSheetViewColumn *tree_column, /* if (reorderable) pspp_sheet_view_column_set_clickable (tree_column, TRUE);*/ - if (tree_column->reorderable == (reorderable?TRUE:FALSE)) + reorderable = !!reorderable; + if (tree_column->reorderable == reorderable) return; - tree_column->reorderable = (reorderable?TRUE:FALSE); + tree_column->reorderable = reorderable; pspp_sheet_view_column_update_button (tree_column); g_object_notify (G_OBJECT (tree_column), "reorderable"); } @@ -2334,9 +2546,9 @@ pspp_sheet_view_column_set_reorderable (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_reorderable: * @tree_column: A #PsppSheetViewColumn - * + * * Returns %TRUE if the @tree_column can be reordered by the user. - * + * * Return value: %TRUE if the @tree_column can be reordered by the user. **/ gboolean @@ -2363,7 +2575,7 @@ pspp_sheet_view_column_set_quick_edit (PsppSheetViewColumn *tree_column, quick_edit = !!quick_edit; if (tree_column->quick_edit != quick_edit) { - tree_column->quick_edit = (quick_edit?TRUE:FALSE); + tree_column->quick_edit = quick_edit; g_object_notify (G_OBJECT (tree_column), "quick-edit"); } } @@ -2387,12 +2599,176 @@ pspp_sheet_view_column_get_quick_edit (PsppSheetViewColumn *tree_column) } +/** + * pspp_sheet_view_column_set_selected: + * @tree_column: A #PsppSheetViewColumn + * @selected: If true, the column is selected as part of a rectangular + * selection. + **/ +void +pspp_sheet_view_column_set_selected (PsppSheetViewColumn *tree_column, + gboolean selected) +{ + g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); + + selected = !!selected; + if (tree_column->selected != selected) + { + PsppSheetSelection *selection; + PsppSheetView *sheet_view; + + if (tree_column->tree_view != NULL) + gtk_widget_queue_draw (GTK_WIDGET (tree_column->tree_view)); + tree_column->selected = selected; + g_object_notify (G_OBJECT (tree_column), "selected"); + + sheet_view = PSPP_SHEET_VIEW (pspp_sheet_view_column_get_tree_view ( + tree_column)); + selection = pspp_sheet_view_get_selection (sheet_view); + _pspp_sheet_selection_emit_changed (selection); + } +} + +/** + * pspp_sheet_view_column_get_selected: + * @tree_column: A #PsppSheetViewColumn + * + * Returns %TRUE if the column is selected as part of a rectangular + * selection. + * + * Return value: %TRUE if the column is selected as part of a rectangular + * selection. + **/ +gboolean +pspp_sheet_view_column_get_selected (PsppSheetViewColumn *tree_column) +{ + g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), FALSE); + + return tree_column->selected; +} + +/** + * pspp_sheet_view_column_set_selectable: + * @tree_column: A #PsppSheetViewColumn + * @selectable: If true, the column may be selected as part of a rectangular + * selection. + **/ +void +pspp_sheet_view_column_set_selectable (PsppSheetViewColumn *tree_column, + gboolean selectable) +{ + g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); + + selectable = !!selectable; + if (tree_column->selectable != selectable) + { + if (tree_column->tree_view != NULL) + gtk_widget_queue_draw (GTK_WIDGET (tree_column->tree_view)); + tree_column->selectable = selectable; + g_object_notify (G_OBJECT (tree_column), "selectable"); + } +} + +/** + * pspp_sheet_view_column_get_selectable: + * @tree_column: A #PsppSheetViewColumn + * + * Returns %TRUE if the column may be selected as part of a rectangular + * selection. + * + * Return value: %TRUE if the column may be selected as part of a rectangular + * selection. + **/ +gboolean +pspp_sheet_view_column_get_selectable (PsppSheetViewColumn *tree_column) +{ + g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), FALSE); + + return tree_column->selectable; +} + + +/** + * pspp_sheet_view_column_set_row_head: + * @tree_column: A #PsppSheetViewColumn + * @row_head: If true, the column is a "row head", analogous to a column head. + * See the description of the row-head property for more information. + **/ +void +pspp_sheet_view_column_set_row_head (PsppSheetViewColumn *tree_column, + gboolean row_head) +{ + g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); + + row_head = !!row_head; + if (tree_column->row_head != row_head) + { + tree_column->row_head = row_head; + g_object_notify (G_OBJECT (tree_column), "row_head"); + } +} + +/** + * pspp_sheet_view_column_get_row_head: + * @tree_column: A #PsppSheetViewColumn + * + * Returns %TRUE if the column is a row head. + * + * Return value: %TRUE if the column is a row head. + **/ +gboolean +pspp_sheet_view_column_get_row_head (PsppSheetViewColumn *tree_column) +{ + g_return_val_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column), FALSE); + + return tree_column->row_head; +} + + +/** + * 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 * @sort_column_id: The @sort_column_id of the model to sort on. * - * Sets the logical @sort_column_id that this column sorts on when this column + * Sets the logical @sort_column_id that this column sorts on when this column * is selected for sorting. Doing so makes the column header clickable. **/ void @@ -2471,7 +2847,7 @@ pspp_sheet_view_column_get_sort_column_id (PsppSheetViewColumn *tree_column) * the header button indicating the column is sorted. Call * pspp_sheet_view_column_set_sort_order() to change the direction of * the arrow. - * + * **/ void pspp_sheet_view_column_set_sort_indicator (PsppSheetViewColumn *tree_column, @@ -2492,9 +2868,9 @@ pspp_sheet_view_column_set_sort_indicator (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_get_sort_indicator: * @tree_column: a #PsppSheetViewColumn - * + * * Gets the value set by pspp_sheet_view_column_set_sort_indicator(). - * + * * Return value: whether the sort indicator arrow is displayed **/ gboolean @@ -2510,16 +2886,16 @@ pspp_sheet_view_column_get_sort_indicator (PsppSheetViewColumn *tree_column * @tree_column: a #PsppSheetViewColumn * @order: sort order that the sort indicator should indicate * - * Changes the appearance of the sort indicator. - * + * Changes the appearance of the sort indicator. + * * This does not actually sort the model. Use * pspp_sheet_view_column_set_sort_column_id() if you want automatic sorting * support. This function is primarily for custom sorting behavior, and should * be used in conjunction with gtk_tree_sortable_set_sort_column() to do - * that. For custom models, the mechanism will vary. - * + * that. For custom models, the mechanism will vary. + * * The sort indicator changes direction to indicate normal sort or reverse sort. - * Note that you must have the sort indicator enabled to see anything when + * Note that you must have the sort indicator enabled to see anything when * calling this function; see pspp_sheet_view_column_set_sort_indicator(). **/ void @@ -2539,9 +2915,9 @@ pspp_sheet_view_column_set_sort_order (PsppSheetViewColumn *tree_column /** * pspp_sheet_view_column_get_sort_order: * @tree_column: a #PsppSheetViewColumn - * + * * Gets the value set by pspp_sheet_view_column_set_sort_order(). - * + * * Return value: the sort order the sort indicator is indicating **/ GtkSortType @@ -2557,7 +2933,7 @@ pspp_sheet_view_column_get_sort_order (PsppSheetViewColumn *tree_column * @tree_column: A #PsppSheetViewColumn. * @tree_model: The #GtkTreeModel to to get the cell renderers attributes from. * @iter: The #GtkTreeIter to to get the cell renderer's attributes from. - * + * * Sets the cell renderer based on the @tree_model and @iter. That is, for * every attribute mapping in @tree_column, it will get a value from the set * column on the @iter, and use that value to set the attribute on the cell @@ -2611,7 +2987,7 @@ pspp_sheet_view_column_cell_set_cell_data (PsppSheetViewColumn *tree_column, * @y_offset: (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL * @width: (allow-none): location to return width needed to render a cell, or %NULL * @height: (allow-none): location to return height needed to render a cell, or %NULL - * + * * Obtains the width and height needed to render the column. This is used * primarily by the #PsppSheetView. **/ @@ -2635,7 +3011,7 @@ pspp_sheet_view_column_cell_get_size (PsppSheetViewColumn *tree_column, * width = 0; gtk_widget_style_get (tree_column->tree_view, "focus-line-width", &focus_line_width, NULL); - + for (list = tree_column->cell_list; list; list = list->next) { PsppSheetViewColumnCellInfo *info = (PsppSheetViewColumnCellInfo *) list->data; @@ -2650,13 +3026,13 @@ pspp_sheet_view_column_cell_get_size (PsppSheetViewColumn *tree_column, if (first_cell == FALSE && width) *width += tree_column->spacing; - gtk_cell_renderer_get_size (info->cell, - tree_column->tree_view, - cell_area, - x_offset, - y_offset, - &new_width, - &new_height); + gtk_cell_renderer_get_padding (info->cell, x_offset, y_offset); + gtk_cell_renderer_get_preferred_width (info->cell, tree_column->tree_view, + NULL, &new_width); + + gtk_cell_renderer_get_preferred_height (info->cell, tree_column->tree_view, + NULL, &new_height); + if (height) * height = MAX (*height, new_height + focus_line_width * 2); @@ -2682,12 +3058,11 @@ enum { static gboolean pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, - GdkWindow *window, + cairo_t *cr, const GdkRectangle *background_area, const GdkRectangle *cell_area, guint flags, gint action, - const GdkRectangle *expose_area, /* RENDER */ GdkRectangle *focus_rectangle, /* FOCUS */ GtkCellEditable **editable_widget, /* EVENT */ GdkEvent *event, /* EVENT */ @@ -2696,7 +3071,6 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, GList *list; GdkRectangle real_cell_area; GdkRectangle real_background_area; - GdkRectangle real_expose_area = *cell_area; gint depth = 0; gint expand_cell_count = 0; gint full_requested_width = 0; @@ -2769,7 +3143,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, { PsppSheetViewColumnCellInfo *info = (PsppSheetViewColumnCellInfo *)list->data; - if (! info->cell->visible) + if (! gtk_cell_renderer_get_visible (info->cell)) continue; if (info->expand == TRUE) @@ -2796,7 +3170,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (info->pack == GTK_PACK_END) continue; - if (! info->cell->visible) + if (! gtk_cell_renderer_get_visible (info->cell)) continue; if ((info->has_focus || special_cells == 1) && cursor_row) @@ -2810,7 +3184,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (real_cell_area.x - focus_line_width + info->real_width > cell_area->x + cell_area->width) { info->real_width = cell_area->x + cell_area->width - real_cell_area.x; - } + } if (real_cell_area.x > cell_area->x + cell_area->width) break; @@ -2830,7 +3204,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, rtl_cell_area = real_cell_area; rtl_background_area = real_background_area; - + if (rtl) { rtl_cell_area.x = cell_area->x + cell_area->width - (real_cell_area.x - cell_area->x) - real_cell_area.width; @@ -2841,11 +3215,10 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (action == CELL_ACTION_RENDER) { gtk_cell_renderer_render (info->cell, - window, + cr, tree_column->tree_view, &rtl_background_area, &rtl_cell_area, - &real_expose_area, flags); } /* FOCUS */ @@ -2853,11 +3226,15 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, { gint x_offset, y_offset, width, height; - gtk_cell_renderer_get_size (info->cell, - tree_column->tree_view, - &rtl_cell_area, - &x_offset, &y_offset, - &width, &height); + gtk_cell_renderer_get_preferred_height (info->cell, tree_column->tree_view, + NULL, &height); + + gtk_cell_renderer_get_preferred_width (info->cell, tree_column->tree_view, + NULL, &width); + + + gtk_cell_renderer_get_padding (info->cell, + &x_offset, &y_offset); if (special_cells > 1) { @@ -2945,7 +3322,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, g_return_val_if_fail (GTK_IS_CELL_EDITABLE (*editable_widget), FALSE); info->in_editing_mode = TRUE; pspp_sheet_view_column_focus_cell (tree_column, info->cell); - + flags &= ~GTK_CELL_RENDERER_FOCUSED; return TRUE; @@ -2971,7 +3348,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (info->pack == GTK_PACK_START) continue; - if (! info->cell->visible) + if (! gtk_cell_renderer_get_visible (info->cell)) continue; if ((info->has_focus || special_cells == 1) && cursor_row) @@ -2985,7 +3362,7 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (real_cell_area.x - focus_line_width + info->real_width > cell_area->x + cell_area->width) { info->real_width = cell_area->x + cell_area->width - real_cell_area.x; - } + } if (real_cell_area.x > cell_area->x + cell_area->width) break; @@ -3006,11 +3383,10 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, if (action == CELL_ACTION_RENDER) { gtk_cell_renderer_render (info->cell, - window, + cr, tree_column->tree_view, &rtl_background_area, &rtl_cell_area, - &real_expose_area, flags); } /* FOCUS */ @@ -3018,11 +3394,15 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, { gint x_offset, y_offset, width, height; - gtk_cell_renderer_get_size (info->cell, - tree_column->tree_view, - &rtl_cell_area, - &x_offset, &y_offset, - &width, &height); + gtk_cell_renderer_get_preferred_height (info->cell, tree_column->tree_view, + NULL, &height); + + gtk_cell_renderer_get_preferred_width (info->cell, tree_column->tree_view, + NULL, &width); + + + gtk_cell_renderer_get_padding (info->cell, + &x_offset, &y_offset); if (special_cells > 1) { @@ -3154,32 +3534,28 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, * @window: a #GdkDrawable to draw to * @background_area: entire cell area (including tree expanders and maybe padding on the sides) * @cell_area: area normally rendered by a cell renderer - * @expose_area: area that actually needs updating * @flags: flags that affect rendering - * + * * Renders the cell contained by #tree_column. This is used primarily by the * #PsppSheetView. **/ void _pspp_sheet_view_column_cell_render (PsppSheetViewColumn *tree_column, - GdkWindow *window, + cairo_t *cr, const GdkRectangle *background_area, const GdkRectangle *cell_area, - const GdkRectangle *expose_area, guint flags) { g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); g_return_if_fail (background_area != NULL); g_return_if_fail (cell_area != NULL); - g_return_if_fail (expose_area != NULL); pspp_sheet_view_column_cell_process_action (tree_column, - window, + cr, background_area, cell_area, flags, CELL_ACTION_RENDER, - expose_area, NULL, NULL, NULL, NULL); } @@ -3200,7 +3576,7 @@ _pspp_sheet_view_column_cell_event (PsppSheetViewColumn *tree_column, cell_area, flags, CELL_ACTION_EVENT, - NULL, NULL, + NULL, editable_widget, event, path_string); @@ -3218,7 +3594,6 @@ _pspp_sheet_view_column_get_focus_area (PsppSheetViewColumn *tree_column, cell_area, 0, CELL_ACTION_FOCUS, - NULL, focus_area, NULL, NULL, NULL); } @@ -3277,6 +3652,7 @@ pspp_sheet_view_column_cell_last (PsppSheetViewColumn *tree_column) return NULL; } + static GList * pspp_sheet_view_column_cell_next (PsppSheetViewColumn *tree_column, GList *current) @@ -3474,15 +3850,14 @@ _pspp_sheet_view_column_cell_focus (PsppSheetViewColumn *tree_column, void _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column, - GdkWindow *window, + cairo_t *cr, const GdkRectangle *background_area, const GdkRectangle *cell_area, - const GdkRectangle *expose_area, guint flags) { gint focus_line_width; GtkStateType cell_state; - + g_return_if_fail (PSPP_IS_SHEET_VIEW_COLUMN (tree_column)); gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view), "focus-line-width", &focus_line_width, NULL); @@ -3501,28 +3876,27 @@ _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column, cell_area->y - focus_line_width, cell_area->width + 2 * focus_line_width, cell_area->height + 2 * focus_line_width); -#endif +#endif } else { GdkRectangle focus_rectangle; pspp_sheet_view_column_cell_process_action (tree_column, - window, + cr, background_area, cell_area, flags, CELL_ACTION_FOCUS, - expose_area, &focus_rectangle, NULL, NULL, NULL); cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED : (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT : (flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL)); - gtk_paint_focus (tree_column->tree_view->style, - window, + + gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (tree_column->tree_view)), + cr, cell_state, - cell_area, tree_column->tree_view, "treeview", focus_rectangle.x, @@ -3535,11 +3909,11 @@ _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column, /** * pspp_sheet_view_column_cell_is_visible: * @tree_column: A #PsppSheetViewColumn - * + * * Returns %TRUE if any of the cells packed into the @tree_column are visible. * For this to be meaningful, you must first initialize the cells with * pspp_sheet_view_column_cell_set_cell_data() - * + * * Return value: %TRUE, if any of the cells packed into the @tree_column are currently visible **/ gboolean @@ -3553,7 +3927,7 @@ pspp_sheet_view_column_cell_is_visible (PsppSheetViewColumn *tree_column) { PsppSheetViewColumnCellInfo *info = (PsppSheetViewColumnCellInfo *) list->data; - if (info->cell->visible) + if (gtk_cell_renderer_get_visible (info->cell)) return TRUE; } @@ -3625,8 +3999,10 @@ _pspp_sheet_view_column_cell_set_dirty (PsppSheetViewColumn *tree_column) tree_column->width = 0; if (tree_column->tree_view && + PSPP_SHEET_VIEW (tree_column->tree_view)->priv->resized && gtk_widget_get_realized (tree_column->tree_view)) { + PSPP_SHEET_VIEW (tree_column->tree_view)->priv->resized = FALSE; _pspp_sheet_view_install_mark_rows_col_dirty (PSPP_SHEET_VIEW (tree_column->tree_view)); gtk_widget_queue_resize (tree_column->tree_view); } @@ -3666,28 +4042,28 @@ _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column, l = r = 0; - list = pspp_sheet_view_column_cell_first (column); + list = pspp_sheet_view_column_cell_first (column); while (list) { info = (PsppSheetViewColumnCellInfo *)list->data; - + list = pspp_sheet_view_column_cell_next (column, list); if (info->cell == cell) break; - - if (info->cell->visible) + + if (gtk_cell_renderer_get_visible (info->cell)) l += info->real_width + column->spacing; } while (list) { info = (PsppSheetViewColumnCellInfo *)list->data; - + list = pspp_sheet_view_column_cell_next (column, list); - if (info->cell->visible) + if (gtk_cell_renderer_get_visible (info->cell)) r += info->real_width + column->spacing; } @@ -3710,7 +4086,7 @@ _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column, * Obtains the horizontal position and size of a cell in a column. If the * cell is not found in the column, @start_pos and @width are not changed and * %FALSE is returned. - * + * * Return value: %TRUE if @cell belongs to @tree_column. */ gboolean @@ -3734,7 +4110,7 @@ pspp_sheet_view_column_cell_get_position (PsppSheetViewColumn *tree_column, break; } - if (cellinfo->cell->visible) + if (gtk_cell_renderer_get_visible (cellinfo->cell)) current_x += cellinfo->real_width; } @@ -3828,7 +4204,7 @@ attributes_text_element (GMarkupParseContext *context, glong l; gchar *endptr; gchar *string; - + if (!parser_data->attr_name) return; @@ -3837,7 +4213,7 @@ attributes_text_element (GMarkupParseContext *context, l = strtol (string, &endptr, 0); if (errno || endptr == string) { - g_set_error (error, + g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE, "Could not parse integer `%s'", @@ -3861,8 +4237,8 @@ static const GMarkupParser attributes_parser = attributes_text_element, }; -gboolean -_gtk_cell_layout_buildable_custom_tag_start (GtkBuildable *buildable, +static gboolean +_cell_layout_buildable_custom_tag_start (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *tagname, @@ -3889,8 +4265,8 @@ _gtk_cell_layout_buildable_custom_tag_start (GtkBuildable *buildable, return FALSE; } -void -_gtk_cell_layout_buildable_custom_tag_end (GtkBuildable *buildable, +static void +_cell_layout_buildable_custom_tag_end (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *tagname, @@ -3903,14 +4279,14 @@ _gtk_cell_layout_buildable_custom_tag_end (GtkBuildable *buildable, g_slice_free (AttributesSubParserData, parser_data); } -void -_gtk_cell_layout_buildable_add_child (GtkBuildable *buildable, +static void +_cell_layout_buildable_add_child (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, const gchar *type) { GtkCellLayoutIface *iface; - + g_return_if_fail (GTK_IS_CELL_LAYOUT (buildable)); g_return_if_fail (GTK_IS_CELL_RENDERER (child)); @@ -3918,3 +4294,52 @@ _gtk_cell_layout_buildable_add_child (GtkBuildable *buildable, g_return_if_fail (iface->pack_start != NULL); iface->pack_start (GTK_CELL_LAYOUT (buildable), GTK_CELL_RENDERER (child), FALSE); } + +void +pspp_sheet_view_column_size_request (PsppSheetViewColumn *tree_column, + GtkRequisition *request) +{ + GtkWidget *base = GTK_WIDGET (tree_column->tree_view); + GtkRequisition label_req; + GtkRequisition align_req; + GtkRequisition arrow_req; + GtkRequisition hbox_req; + GtkStyle **button_style; + + if (tree_column->button) + { + gtk_widget_get_preferred_size (tree_column->button, NULL, request); + return; + } + + facade_label_get_size_request (0, 0, base, tree_column->title, &label_req); + facade_alignment_get_size_request (0, 0, 0, 0, 0, &label_req, &align_req); + facade_arrow_get_size_request (0, 0, &arrow_req); + + facade_hbox_get_base_size_request (0, 2, 2, &hbox_req); + facade_hbox_add_child_size_request (0, &arrow_req, 0, &hbox_req); + facade_hbox_add_child_size_request (0, &align_req, 0, &hbox_req); + + button_style = &PSPP_SHEET_VIEW (tree_column->tree_view)->priv->button_style; + if (*button_style == NULL) + { + *button_style = facade_get_style (base, GTK_TYPE_BUTTON, 0); + g_object_ref (*button_style); + } + facade_button_get_size_request (0, base, *button_style, &hbox_req, request); +} + +void +pspp_sheet_view_column_size_allocate (PsppSheetViewColumn *tree_column, + GtkAllocation *allocation) +{ + tree_column->allocation = *allocation; + if (tree_column->button) + gtk_widget_size_allocate (tree_column->button, allocation); +} + +gboolean +pspp_sheet_view_column_can_focus (PsppSheetViewColumn *tree_column) +{ + return tree_column->reorderable || tree_column->clickable; +}