X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpspp-sheet-view-column.c;h=5e5804e812a87926e98d6b951d091081de002b82;hb=refs%2Fbuilds%2F20131105032650%2Fpspp;hp=6ce216760ccb424fb969ca6d7a901f5d1449573a;hpb=45861388123559f96d05eb8d4f9356ad00ced281;p=pspp diff --git a/src/ui/gui/pspp-sheet-view-column.c b/src/ui/gui/pspp-sheet-view-column.c index 6ce216760c..5e5804e812 100644 --- a/src/ui/gui/pspp-sheet-view-column.c +++ b/src/ui/gui/pspp-sheet-view-column.c @@ -72,7 +72,8 @@ enum PROP_QUICK_EDIT, PROP_SELECTED, PROP_SELECTABLE, - PROP_ROW_HEAD + PROP_ROW_HEAD, + PROP_TABBABLE }; enum @@ -185,7 +186,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, @@ -426,14 +427,44 @@ 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 _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 @@ -468,6 +499,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 +653,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 +776,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; @@ -1065,10 +1107,10 @@ pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column) if (! tree_column->button) return; - hbox = GTK_BIN (tree_column->button)->child; + hbox = gtk_bin_get_child (GTK_BIN (tree_column->button)); alignment = tree_column->alignment; arrow = tree_column->arrow; - current_child = GTK_BIN (alignment)->child; + current_child = gtk_bin_get_child (GTK_BIN (alignment)); /* Set up the actual button */ gtk_alignment_set (GTK_ALIGNMENT (alignment), tree_column->xalign, @@ -1228,7 +1270,7 @@ 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_pointer (gtk_button_get_event_window (GTK_BUTTON (widget)), &column->drag_x, &column->drag_y, NULL); @@ -1366,8 +1408,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; } @@ -1527,6 +1574,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; @@ -1551,7 +1599,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 | @@ -1559,13 +1606,13 @@ _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); @@ -1649,9 +1696,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; } @@ -1679,9 +1729,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++; } @@ -2338,7 +2391,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); @@ -2364,7 +2417,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; @@ -2545,10 +2598,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"); } @@ -2585,7 +2639,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"); } } @@ -2629,7 +2683,7 @@ pspp_sheet_view_column_set_selected (PsppSheetViewColumn *tree_column, if (tree_column->tree_view != NULL) gtk_widget_queue_draw (GTK_WIDGET (tree_column->tree_view)); - tree_column->selected = (selected?TRUE:FALSE); + tree_column->selected = selected; g_object_notify (G_OBJECT (tree_column), "selected"); sheet_view = PSPP_SHEET_VIEW (pspp_sheet_view_column_get_tree_view ( @@ -2674,7 +2728,7 @@ pspp_sheet_view_column_set_selectable (PsppSheetViewColumn *tree_column, { if (tree_column->tree_view != NULL) gtk_widget_queue_draw (GTK_WIDGET (tree_column->tree_view)); - tree_column->selectable = (selectable?TRUE:FALSE); + tree_column->selectable = selectable; g_object_notify (G_OBJECT (tree_column), "selectable"); } } @@ -2713,7 +2767,7 @@ pspp_sheet_view_column_set_row_head (PsppSheetViewColumn *tree_column, row_head = !!row_head; if (tree_column->row_head != row_head) { - tree_column->row_head = (row_head?TRUE:FALSE); + tree_column->row_head = row_head; g_object_notify (G_OBJECT (tree_column), "row_head"); } } @@ -2735,6 +2789,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 @@ -3030,12 +3122,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 */ @@ -3044,7 +3135,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; @@ -3117,7 +3207,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) @@ -3144,7 +3234,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) @@ -3189,11 +3279,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 */ @@ -3319,7 +3408,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) @@ -3354,11 +3443,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 */ @@ -3502,7 +3590,6 @@ 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 @@ -3510,24 +3597,21 @@ pspp_sheet_view_column_cell_process_action (PsppSheetViewColumn *tree_column, **/ 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); } @@ -3548,7 +3632,7 @@ _pspp_sheet_view_column_cell_event (PsppSheetViewColumn *tree_column, cell_area, flags, CELL_ACTION_EVENT, - NULL, NULL, + NULL, editable_widget, event, path_string); @@ -3566,7 +3650,6 @@ _pspp_sheet_view_column_get_focus_area (PsppSheetViewColumn *tree_column, cell_area, 0, CELL_ACTION_FOCUS, - NULL, focus_area, NULL, NULL, NULL); } @@ -3822,10 +3905,9 @@ _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; @@ -3855,22 +3937,21 @@ _pspp_sheet_view_column_cell_draw_focus (PsppSheetViewColumn *tree_column, { 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, @@ -3901,7 +3982,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; } @@ -4025,7 +4106,7 @@ _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column, if (info->cell == cell) break; - if (info->cell->visible) + if (gtk_cell_renderer_get_visible (info->cell)) l += info->real_width + column->spacing; } @@ -4035,7 +4116,7 @@ _pspp_sheet_view_column_get_neighbor_sizes (PsppSheetViewColumn *column, 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; } @@ -4082,7 +4163,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; } @@ -4209,8 +4290,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, @@ -4237,8 +4318,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, @@ -4251,8 +4332,8 @@ _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)