/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012, 2013, 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
struct _PsppSheetViewChild
{
GtkWidget *widget;
- gint x;
- gint y;
- gint width;
- gint height;
+ PsppSheetViewColumn *column;
+ int node;
};
static gint pspp_sheet_view_focus (GtkWidget *widget,
GtkDirectionType direction);
static void pspp_sheet_view_grab_focus (GtkWidget *widget);
-static void pspp_sheet_view_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void pspp_sheet_view_style_updated (GtkWidget *widget);
static void pspp_sheet_view_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void pspp_sheet_view_state_changed (GtkWidget *widget,
static void pspp_sheet_view_search_disable_popdown (GtkEntry *entry,
GtkMenu *menu,
gpointer data);
-#if GTK3_TRANSITION
-static void pspp_sheet_view_search_preedit_changed (GtkIMContext *im_context,
- PsppSheetView *tree_view);
-#endif
static void pspp_sheet_view_search_activate (GtkEntry *entry,
PsppSheetView *tree_view);
static gboolean pspp_sheet_view_real_search_enable_popdown(gpointer data);
PsppSheetView *tree_view);
static void pspp_sheet_view_put (PsppSheetView *tree_view,
GtkWidget *child_widget,
- gint x,
- gint y,
- gint width,
- gint height);
+ GtkTreePath *path,
+ PsppSheetViewColumn *column);
static gboolean pspp_sheet_view_start_editing (PsppSheetView *tree_view,
GtkTreePath *cursor_path);
static gboolean pspp_sheet_view_editable_button_press_event (GtkWidget *,
widget_class->drag_data_received = pspp_sheet_view_drag_data_received;
widget_class->focus = pspp_sheet_view_focus;
widget_class->grab_focus = pspp_sheet_view_grab_focus;
- widget_class->style_set = pspp_sheet_view_style_set;
+ widget_class->style_updated = pspp_sheet_view_style_updated;
widget_class->grab_notify = pspp_sheet_view_grab_notify;
widget_class->state_changed = pspp_sheet_view_state_changed;
GTK_PARAM_READABLE));
/* Signals */
-#if GTK3_TRANSITION
- /**
- * PsppSheetView::set-scroll-adjustments
- * @horizontal: the horizontal #GtkAdjustment
- * @vertical: the vertical #GtkAdjustment
- *
- * Set the scroll adjustments for the tree view. Usually scrolled containers
- * like #GtkScrolledWindow will emit this signal to connect two instances
- * of #GtkScrollbar to the scroll directions of the #PsppSheetView.
- */
- widget_class->set_scroll_adjustments_signal =
- g_signal_new ("set-scroll-adjustments",
- G_TYPE_FROM_CLASS (o_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (PsppSheetViewClass, set_scroll_adjustments),
- NULL, NULL,
- psppire_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ADJUSTMENT,
- GTK_TYPE_ADJUSTMENT);
-#endif
/**
* PsppSheetView::row-activated:
pspp_sheet_view_do_set_vadjustment (tree_view, NULL);
pspp_sheet_view_do_set_hadjustment (tree_view, NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (tree_view)),
+ GTK_STYLE_CLASS_VIEW);
}
\f
{
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
GList *tmp_list;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
GtkAllocation allocation;
- GtkAllocation old_allocation;
gtk_widget_set_realized (widget, TRUE);
gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_allocation (widget, &old_allocation);
/* Make the main, clipping window */
attributes.window_type = GDK_WINDOW_CHILD;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
- gtk_widget_set_window (widget,
- gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask));
- gdk_window_set_user_data (gtk_widget_get_window (widget), widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+
+ gtk_widget_register_window (widget, window);
+ gtk_widget_get_allocation (widget, &allocation);
/* Make the window for the tree */
attributes.x = 0;
attributes.y = TREE_VIEW_HEADER_HEIGHT (tree_view);
- attributes.width = MAX (tree_view->priv->width, old_allocation.width);
- attributes.height = old_allocation.height;
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
+ attributes.height = allocation.height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->bin_window = gdk_window_new (gtk_widget_get_window (widget),
+ tree_view->priv->bin_window = gdk_window_new (window,
&attributes, attributes_mask);
- gdk_window_set_user_data (tree_view->priv->bin_window, widget);
+ gtk_widget_register_window (widget, tree_view->priv->bin_window);
+ gtk_widget_get_allocation (widget, &allocation);
/* Make the column header window */
attributes.x = 0;
attributes.y = 0;
- attributes.width = MAX (tree_view->priv->width, old_allocation.width);
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
attributes.height = tree_view->priv->header_height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
GDK_KEY_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->header_window = gdk_window_new (gtk_widget_get_window (widget),
+ tree_view->priv->header_window = gdk_window_new (window,
&attributes, attributes_mask);
- gdk_window_set_user_data (tree_view->priv->header_window, widget);
+ gtk_widget_register_window (widget, tree_view->priv->header_window);
+
+ { /* Ensure Background */
+ GtkStyleContext *context;
- /* Add them all up. */
- gtk_widget_set_style (widget,
- gtk_style_attach (gtk_widget_get_style (widget), gtk_widget_get_window (widget)));
- gdk_window_set_background (tree_view->priv->bin_window, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
- gtk_style_set_background (gtk_widget_get_style (widget), tree_view->priv->header_window, GTK_STATE_NORMAL);
+ context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
+
+ gtk_style_context_set_background (context, gtk_widget_get_window (GTK_WIDGET (tree_view)));
+ gtk_style_context_set_background (context, tree_view->priv->header_window);
+ }
tmp_list = tree_view->priv->children;
while (tmp_list)
tmp_list = tmp_list->next;
if (gtk_widget_get_visible (child->widget))
- gtk_widget_size_request (child->widget, &child_requisition);
+ {
+ gtk_widget_get_preferred_size (child->widget, NULL, &child_requisition);
+ }
}
}
pspp_sheet_view_column_size_allocate (column, &col_allocation);
- if (span_intersects (col_allocation.x, col_allocation.width,
- gtk_adjustment_get_value (tree_view->priv->hadjustment),
- allocation.width)
- && gtk_widget_get_realized (widget))
- pspp_sheet_view_column_set_need_button (column, TRUE);
-
if (column->window)
gdk_window_move_resize (column->window,
col_allocation.x + (rtl ? 0 : col_allocation.width) - TREE_VIEW_DRAG_WIDTH/2,
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
}
+static void
+update_childrens_allocation (PsppSheetView *tree_view)
+{
+ GList *tmp_list;
+ for (tmp_list = tree_view->priv->children; tmp_list; tmp_list = tmp_list->next)
+ {
+ PsppSheetViewChild *child = tmp_list->data;
+ GtkAllocation allocation;
+ GtkTreePath *path;
+
+ /* totally ignore our child's requisition */
+ path = _pspp_sheet_view_find_path (tree_view, child->node);
+ pspp_sheet_view_get_cell_area (tree_view, path, child->column, &allocation);
+ gtk_tree_path_free (path);
+ gtk_widget_size_allocate (child->widget, &allocation);
+ }
+}
+
static void
pspp_sheet_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
if (allocation->width != old_allocation.width)
width_changed = TRUE;
+ if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
+ allocation->x += allocation->width - tree_view->priv->width ;
gtk_widget_set_allocation (widget, allocation);
- tmp_list = tree_view->priv->children;
-
- while (tmp_list)
- {
- GtkAllocation allocation;
-
- PsppSheetViewChild *child = tmp_list->data;
- tmp_list = tmp_list->next;
-
- /* totally ignore our child's requisition */
- allocation.x = child->x;
- allocation.y = child->y;
- allocation.width = child->width;
- allocation.height = child->height;
- gtk_widget_size_allocate (child->widget, &allocation);
- }
-
/* We size-allocate the columns first because the width of the
* tree view (used in updating the adjustments below) might change.
*/
else
gtk_widget_queue_draw (widget);
}
+ update_childrens_allocation(tree_view);
}
}
{
gpointer drag_data;
- if (gdk_pointer_grab (column->window, FALSE,
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_BUTTON_RELEASE_MASK,
- NULL, NULL, event->time))
+ if (GDK_GRAB_SUCCESS != gdk_device_grab (event->device,
+ column->window,
+ GDK_OWNERSHIP_NONE,
+ FALSE,
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_BUTTON_RELEASE_MASK,
+ NULL, event->time))
return FALSE;
gtk_grab_add (widget);
PSPP_SHEET_VIEW_UNSET_FLAG (tree_view, PSPP_SHEET_VIEW_IN_COLUMN_RESIZE);
gtk_grab_remove (widget);
- gdk_display_pointer_ungrab (gdk_window_get_display (event->window),
- event->time);
+ gdk_device_ungrab (event->device, event->time);
+
return TRUE;
}
static void
pspp_sheet_view_motion_draw_column_motion_arrow (PsppSheetView *tree_view)
{
-#if GTK3_TRANSITION
- PsppSheetViewColumnReorder *reorder = tree_view->priv->cur_reorder;
- GtkWidget *widget = GTK_WIDGET (tree_view);
- GdkBitmap *mask = NULL;
- gint x;
- gint y;
- gint width;
- gint height;
- gint arrow_type = DRAG_COLUMN_WINDOW_STATE_UNSET;
- GdkWindowAttr attributes;
- guint attributes_mask;
-
- if (!reorder ||
- reorder->left_column == tree_view->priv->drag_column ||
- reorder->right_column == tree_view->priv->drag_column)
- arrow_type = DRAG_COLUMN_WINDOW_STATE_ORIGINAL;
- else if (reorder->left_column || reorder->right_column)
- {
- GdkRectangle visible_rect;
- pspp_sheet_view_get_visible_rect (tree_view, &visible_rect);
- if (reorder->left_column)
- x = reorder->left_column->allocation.x + reorder->left_column->allocation.width;
- else
- x = reorder->right_column->allocation.x;
-
- if (x < visible_rect.x)
- arrow_type = DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT;
- else if (x > visible_rect.x + visible_rect.width)
- arrow_type = DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT;
- else
- arrow_type = DRAG_COLUMN_WINDOW_STATE_ARROW;
- }
-
- /* We want to draw the rectangle over the initial location. */
- if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ORIGINAL)
- {
- GdkGC *gc;
- GdkColor col;
-
- if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ORIGINAL)
- {
- if (tree_view->priv->drag_highlight_window)
- {
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window,
- NULL);
- gdk_window_destroy (tree_view->priv->drag_highlight_window);
- }
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.x = tree_view->priv->drag_column_x;
- attributes.y = 0;
- width = attributes.width = tree_view->priv->drag_column->allocation.width;
- height = attributes.height = tree_view->priv->drag_column->allocation.height;
- attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
- attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
- attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- tree_view->priv->drag_highlight_window = gdk_window_new (tree_view->priv->header_window, &attributes, attributes_mask);
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
-
- mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
- gc = gdk_gc_new (mask);
- col.pixel = 1;
- gdk_gc_set_foreground (gc, &col);
- gdk_draw_rectangle (mask, gc, TRUE, 0, 0, width, height);
- col.pixel = 0;
- gdk_gc_set_foreground(gc, &col);
- gdk_draw_rectangle (mask, gc, TRUE, 2, 2, width - 4, height - 4);
- g_object_unref (gc);
-
- gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
- mask, 0, 0);
- if (mask) g_object_unref (mask);
- tree_view->priv->drag_column_window_state = DRAG_COLUMN_WINDOW_STATE_ORIGINAL;
- }
- }
- else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW)
- {
- gint i, j = 1;
- GdkGC *gc;
- GdkColor col;
-
- width = tree_view->priv->expander_size;
-
- /* Get x, y, width, height of arrow */
- gdk_window_get_origin (tree_view->priv->header_window, &x, &y);
- if (reorder->left_column)
- {
- x += reorder->left_column->allocation.x + reorder->left_column->allocation.width - width/2;
- height = reorder->left_column->allocation.height;
- }
- else
- {
- x += reorder->right_column->allocation.x - width/2;
- height = reorder->right_column->allocation.height;
- }
- y -= tree_view->priv->expander_size/2; /* The arrow takes up only half the space */
- height += tree_view->priv->expander_size;
-
- /* Create the new window */
- if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW)
- {
- if (tree_view->priv->drag_highlight_window)
- {
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window,
- NULL);
- gdk_window_destroy (tree_view->priv->drag_highlight_window);
- }
-
- attributes.window_type = GDK_WINDOW_TEMP;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
- attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
- attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = x;
- attributes.y = y;
- attributes.width = width;
- attributes.height = height;
- tree_view->priv->drag_highlight_window = gdk_window_new (gtk_widget_get_root_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
-
- mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
- gc = gdk_gc_new (mask);
- col.pixel = 1;
- gdk_gc_set_foreground (gc, &col);
- gdk_draw_rectangle (mask, gc, TRUE, 0, 0, width, height);
-
- /* Draw the 2 arrows as per above */
- col.pixel = 0;
- gdk_gc_set_foreground (gc, &col);
- for (i = 0; i < width; i ++)
- {
- if (i == (width/2 - 1))
- continue;
- gdk_draw_line (mask, gc, i, j, i, height - j);
- if (i < (width/2 - 1))
- j++;
- else
- j--;
- }
- g_object_unref (gc);
- gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
- mask, 0, 0);
- if (mask) g_object_unref (mask);
- }
-
- tree_view->priv->drag_column_window_state = DRAG_COLUMN_WINDOW_STATE_ARROW;
- gdk_window_move (tree_view->priv->drag_highlight_window, x, y);
- }
- else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT ||
- arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
- {
- gint i, j = 1;
- GdkGC *gc;
- GdkColor col;
-
- width = tree_view->priv->expander_size;
-
- /* Get x, y, width, height of arrow */
- width = width/2; /* remember, the arrow only takes half the available width */
- gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
- if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
- x += widget->allocation.width - width;
-
- if (reorder->left_column)
- height = reorder->left_column->allocation.height;
- else
- height = reorder->right_column->allocation.height;
-
- y -= tree_view->priv->expander_size;
- height += 2*tree_view->priv->expander_size;
-
- /* Create the new window */
- if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT &&
- tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
- {
- if (tree_view->priv->drag_highlight_window)
- {
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window,
- NULL);
- gdk_window_destroy (tree_view->priv->drag_highlight_window);
- }
-
- attributes.window_type = GDK_WINDOW_TEMP;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
- attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
- attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = x;
- attributes.y = y;
- attributes.width = width;
- attributes.height = height;
- tree_view->priv->drag_highlight_window = gdk_window_new (NULL, &attributes, attributes_mask);
- gdk_window_set_user_data (tree_view->priv->drag_highlight_window, GTK_WIDGET (tree_view));
-
- mask = gdk_pixmap_new (tree_view->priv->drag_highlight_window, width, height, 1);
- gc = gdk_gc_new (mask);
- col.pixel = 1;
- gdk_gc_set_foreground (gc, &col);
- gdk_draw_rectangle (mask, gc, TRUE, 0, 0, width, height);
-
- /* Draw the 2 arrows as per above */
- col.pixel = 0;
- gdk_gc_set_foreground (gc, &col);
- j = tree_view->priv->expander_size;
- for (i = 0; i < width; i ++)
- {
- gint k;
- if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT)
- k = width - i - 1;
- else
- k = i;
- gdk_draw_line (mask, gc, k, j, k, height - j);
- gdk_draw_line (mask, gc, k, 0, k, tree_view->priv->expander_size - j);
- gdk_draw_line (mask, gc, k, height, k, height - tree_view->priv->expander_size + j);
- j--;
- }
- g_object_unref (gc);
- gdk_window_shape_combine_mask (tree_view->priv->drag_highlight_window,
- mask, 0, 0);
- if (mask) g_object_unref (mask);
- }
-
- tree_view->priv->drag_column_window_state = arrow_type;
- gdk_window_move (tree_view->priv->drag_highlight_window, x, y);
- }
- else
- {
- g_warning (G_STRLOC"Invalid PsppSheetViewColumnReorder struct");
- gdk_window_hide (tree_view->priv->drag_highlight_window);
- return;
- }
-
- gdk_window_show (tree_view->priv->drag_highlight_window);
- gdk_window_raise (tree_view->priv->drag_highlight_window);
-#endif
}
static gboolean
pspp_sheet_view_update_rubber_band_selection (tree_view);
}
-#if GTK3_TRANSITION
-static void
-pspp_sheet_view_paint_rubber_band (PsppSheetView *tree_view,
- GdkRectangle *area)
-{
- cairo_t *cr;
- GdkRectangle rect;
- GdkRectangle rubber_rect;
- GtkStyle *style;
-
- return;
- rubber_rect.x = MIN (tree_view->priv->press_start_x, tree_view->priv->rubber_band_x);
- rubber_rect.y = MIN (tree_view->priv->press_start_y, tree_view->priv->rubber_band_y) - tree_view->priv->dy;
- rubber_rect.width = ABS (tree_view->priv->press_start_x - tree_view->priv->rubber_band_x) + 1;
- rubber_rect.height = ABS (tree_view->priv->press_start_y - tree_view->priv->rubber_band_y) + 1;
-
- if (!gdk_rectangle_intersect (&rubber_rect, area, &rect))
- return;
-
- cr = gdk_cairo_create (tree_view->priv->bin_window);
- cairo_set_line_width (cr, 1.0);
-
- style = gtk_widget_get_style (GTK_WIDGET (tree_view));
- cairo_set_source_rgba (cr,
- style->fg[GTK_STATE_NORMAL].red / 65535.,
- style->fg[GTK_STATE_NORMAL].green / 65535.,
- style->fg[GTK_STATE_NORMAL].blue / 65535.,
- .25);
-
- gdk_cairo_rectangle (cr, &rect);
- cairo_clip (cr);
- cairo_paint (cr);
-
- cairo_set_source_rgb (cr,
- style->fg[GTK_STATE_NORMAL].red / 65535.,
- style->fg[GTK_STATE_NORMAL].green / 65535.,
- style->fg[GTK_STATE_NORMAL].blue / 65535.);
-
- cairo_rectangle (cr,
- rubber_rect.x + 0.5, rubber_rect.y + 0.5,
- rubber_rect.width - 1, rubber_rect.height - 1);
- cairo_stroke (cr);
-
- cairo_destroy (cr);
-}
-#endif
static gboolean
gint max_y)
{
GList *list = tree_view->priv->columns;
- gint i = 0;
- gint current_x = 0;
+ gint x = 0;
if (tree_view->priv->grid_lines != PSPP_SHEET_VIEW_GRID_LINES_VERTICAL
&& tree_view->priv->grid_lines != PSPP_SHEET_VIEW_GRID_LINES_BOTH)
return;
/* Only draw the lines for visible rows and columns */
- for (list = tree_view->priv->columns; list; list = list->next, i++)
+ gboolean rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
+
+ for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
+ list;
+ list = (rtl ? list->prev : list->next))
{
PsppSheetViewColumn *column = list->data;
- gint x;
if (! column->visible)
continue;
- current_x += column->width;
-
- /* Generally the grid lines should fit within the column, but for the
- last visible column we put it just past the end of the column.
- (Otherwise horizontal grid lines sometimes stick out by one pixel.) */
- x = current_x;
- if (i != n_visible_columns - 1)
- x--;
+ if (!rtl)
+ x += column->width;
cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_move_to (cr, x + 0.5, min_y);
- cairo_line_to (cr, x + 0.5, max_y - min_y);
+ cairo_line_to (cr, x + 0.5, max_y - min_y - 0.5);
cairo_stroke (cr);
+
+ if (rtl)
+ x += column->width;
}
}
* KEEP IN SYNC WITH pspp_sheet_view_create_row_drag_icon()!
* FIXME: It's not...
*/
-static gboolean
-pspp_sheet_view_bin_expose (GtkWidget *widget,
- cairo_t *cr)
+static void
+pspp_sheet_view_draw_bin (GtkWidget *widget,
+ cairo_t *cr)
{
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
GtkTreePath *path;
gint horizontal_separator;
gint focus_line_width;
gboolean allow_rules;
- gboolean has_special_cell;
gboolean rtl;
gint n_visible_columns;
gint grid_line_width;
gboolean row_ending_details;
gboolean draw_vgrid_lines, draw_hgrid_lines;
gint min_y, max_y;
+ GtkStyleContext *context;
+ context = gtk_widget_get_style_context (widget);
GdkRectangle Zarea;
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
+ GdkRectangle exposed_rect;
+ gdk_cairo_get_clip_rectangle (cr, &exposed_rect);
+
Zarea.x = 0;
Zarea.y = 0;
Zarea.height = allocation.height;
if (tree_view->priv->row_count == 0)
{
draw_empty_focus (tree_view);
- return TRUE;
+ return;
}
-#if GTK3_TRANSITION
- /* clip event->area to the visible area */
- if (Zarea.height < 0.5)
- return TRUE;
-#endif
-
validate_visible_area (tree_view);
new_y = TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, Zarea.y);
}
if (node < 0)
- return TRUE;
+ return;
/* find the path for the node */
path = _pspp_sheet_view_find_path ((PsppSheetView *)widget, node);
parity = node % 2;
- if (tree_view->priv->special_cells == PSPP_SHEET_VIEW_SPECIAL_CELLS_DETECT)
- {
- /* we *need* to set cell data on all cells before the call
- * to _has_special_cell, else _has_special_cell() does not
- * return a correct value.
- */
- for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
- list;
- list = (rtl ? list->prev : list->next))
- {
- PsppSheetViewColumn *column = list->data;
- pspp_sheet_view_column_cell_set_cell_data (column,
- tree_view->priv->model,
- &iter);
- }
-
- has_special_cell = pspp_sheet_view_has_special_cell (tree_view);
- }
- else
- has_special_cell = tree_view->priv->special_cells == PSPP_SHEET_VIEW_SPECIAL_CELLS_YES;
-
for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
list;
list = (rtl ? list->prev : list->next))
else
selected_column = TRUE;
-#if GTK3_TRANSITION
- if (cell_offset > Zarea.x + Zarea.width ||
- cell_offset + column->width < Zarea.x)
- {
- cell_offset += column->width;
- continue;
- }
-#endif
-
if (selected && selected_column)
flags |= GTK_CELL_RENDERER_SELECTED;
else
cell_area.height -= grid_line_width;
}
-#if GTK3_TRANSITION
- if (gdk_region_rect_in (event->region, &background_area) == GDK_OVERLAP_RECTANGLE_OUT)
+ if (!gdk_rectangle_intersect (&background_area, &exposed_rect, NULL))
{
cell_offset += column->width;
continue;
}
-#endif
+
pspp_sheet_view_column_cell_set_cell_data (column,
tree_view->priv->model,
g_assert (detail);
- if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE)
- state = GTK_STATE_INSENSITIVE;
- else if (flags & GTK_CELL_RENDERER_SELECTED)
- state = GTK_STATE_SELECTED;
- else
- state = GTK_STATE_NORMAL;
+ gtk_style_context_save (context);
+ state = gtk_cell_renderer_get_state (NULL, widget, flags);
+ gtk_style_context_set_state (context, state);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_CELL);
/* Draw background */
- if (row_ending_details)
- {
- char new_detail[128];
-
- is_first = (rtl ? !list->next : !list->prev);
- is_last = (rtl ? !list->prev : !list->next);
-
- /* (I don't like the snprintfs either, but couldn't find a
- * less messy way).
- */
- if (is_first && is_last)
- g_snprintf (new_detail, 127, "%s", detail);
- else if (is_first)
- g_snprintf (new_detail, 127, "%s_start", detail);
- else if (is_last)
- g_snprintf (new_detail, 127, "%s_end", detail);
- else
- g_snprintf (new_detail, 128, "%s_middle", detail);
-
- gtk_paint_flat_box (gtk_widget_get_style (widget),
- cr,
- state,
- GTK_SHADOW_NONE,
- widget,
- new_detail,
- background_area.x,
- background_area.y,
- background_area.width,
- background_area.height);
- }
- else
- {
- gtk_paint_flat_box (gtk_widget_get_style (widget),
- cr,
- state,
- GTK_SHADOW_NONE,
- widget,
- detail,
- background_area.x,
- background_area.y,
- background_area.width,
- background_area.height);
- }
+ gtk_render_background (context, cr,
+ background_area.x,
+ background_area.y,
+ background_area.width,
+ background_area.height);
+
+ /* Draw frame */
+ gtk_render_frame (context, cr,
+ background_area.x,
+ background_area.y,
+ background_area.width,
+ background_area.height);
if (draw_hgrid_lines)
{
if (background_area.y >= 0)
{
-#if GTK3_TRANSITION
- gdk_draw_line (event->window,
- tree_view->priv->grid_line_gc[widget->state],
- background_area.x, background_area.y,
- background_area.x + background_area.width,
- background_area.y);
-#else
cairo_move_to (cr, background_area.x, background_area.y - 0.5);
cairo_line_to (cr, background_area.x + background_area.width,
background_area.y - 0.5);
-#endif
}
if (y_offset + max_height <= Zarea.height - 0.5)
{
-#if GTK3_TRANSITION
- gdk_draw_line (event->window,
- tree_view->priv->grid_line_gc[widget->state],
- background_area.x, background_area.y + max_height,
- background_area.x + background_area.width,
- background_area.y + max_height);
-#else
-
cairo_move_to (cr, background_area.x, background_area.y + max_height - 0.5);
cairo_line_to (cr, background_area.x + background_area.width,
background_area.y + max_height - 0.5);
-#endif
}
cairo_stroke (cr);
}
&cell_area,
flags);
- if (node == cursor && has_special_cell &&
- ((column == tree_view->priv->focus_column &&
- PSPP_SHEET_VIEW_FLAG_SET (tree_view, PSPP_SHEET_VIEW_DRAW_KEYFOCUS) &&
- gtk_widget_has_focus (widget)) ||
- (column == tree_view->priv->edited_column)))
- {
- _pspp_sheet_view_column_cell_draw_focus (column,
- cr,
- &background_area,
- &cell_area,
- flags);
- }
cell_offset += column->width;
+ gtk_style_context_restore (context);
}
- if (cell_offset < Zarea.x)
- {
- gtk_paint_flat_box (gtk_widget_get_style (widget),
- cr,
- GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- widget,
- "base",
- cell_offset,
- background_area.y,
- Zarea.x - cell_offset,
- background_area.height);
- }
-
if (node == drag_highlight)
{
/* Draw indicator for the drop
break;
}
-#if GTK3_TRANSITION
- if (highlight_y >= 0)
- {
- gdk_draw_line (event->window,
- widget->style->fg_gc[gtk_widget_get_state (widget)],
- 0,
- highlight_y,
- rtl ? 0 : bin_window_width,
- highlight_y);
- }
-#endif
}
- /* draw the big row-spanning focus rectangle, if needed */
- if (!has_special_cell && node == cursor &&
- PSPP_SHEET_VIEW_FLAG_SET (tree_view, PSPP_SHEET_VIEW_DRAW_KEYFOCUS) &&
- gtk_widget_has_focus (widget))
- {
- gint tmp_y, tmp_height;
- gint width;
- GtkStateType focus_rect_state;
-
- focus_rect_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));
-
- width = gdk_window_get_width (tree_view->priv->bin_window);
-
- if (draw_hgrid_lines)
- {
- tmp_y = BACKGROUND_FIRST_PIXEL (tree_view, node) + grid_line_width / 2;
- tmp_height = ROW_HEIGHT (tree_view) - grid_line_width;
- }
- else
- {
- tmp_y = BACKGROUND_FIRST_PIXEL (tree_view, node);
- tmp_height = ROW_HEIGHT (tree_view);
- }
-
- if (row_ending_details)
- gtk_paint_focus (gtk_widget_get_style (widget),
- cr,
- focus_rect_state,
- widget,
- (is_first
- ? (is_last ? "treeview" : "treeview-left" )
- : (is_last ? "treeview-right" : "treeview-middle" )),
- 0, tmp_y,
- width, tmp_height);
- else
- gtk_paint_focus (gtk_widget_get_style (widget),
- cr,
- focus_rect_state,
- widget,
- "treeview",
- 0, tmp_y,
- width, tmp_height);
- }
-
y_offset += max_height;
do
done = TRUE;
/* Sanity Check! */
- TREE_VIEW_INTERNAL_ASSERT (has_next, FALSE);
+ TREE_VIEW_INTERNAL_ASSERT_VOID (has_next);
}
else
goto done;
pspp_sheet_view_draw_vertical_grid_lines (tree_view, cr, n_visible_columns,
min_y, max_y);
-#if GTK3_TRANSITION
- if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
- {
- GdkRectangle *rectangles;
- gint n_rectangles;
-
- gdk_region_get_rectangles (event->region,
- &rectangles,
- &n_rectangles);
-
- while (n_rectangles--)
- pspp_sheet_view_paint_rubber_band (tree_view, &rectangles[n_rectangles]);
-
- g_free (rectangles);
- }
-#endif
-
if (cursor_path)
gtk_tree_path_free (cursor_path);
if (drag_dest_path)
gtk_tree_path_free (drag_dest_path);
- return FALSE;
+ return;
}
cairo_t *cr)
{
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
-
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (widget);
+
if (gtk_cairo_should_draw_window (cr, tree_view->priv->bin_window))
{
- gboolean retval;
GList *tmp_list;
cairo_save (cr);
gtk_cairo_transform_to_window(cr,widget,tree_view->priv->bin_window);
- retval = pspp_sheet_view_bin_expose (widget, cr);
+ pspp_sheet_view_draw_bin (widget, cr);
cairo_restore (cr);
/* We can't just chain up to Container::expose as it will try to send the
tmp_list = tmp_list->next;
gtk_container_propagate_draw (GTK_CONTAINER (tree_view), child->widget, cr);
- }
-
- return retval;
+ }
+ }
+ else
+ {
+ gtk_render_background (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
}
- else if (gtk_cairo_should_draw_window (cr, tree_view->priv->header_window))
+
+ gtk_style_context_save (context);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VIEW);
+
+ if (gtk_cairo_should_draw_window (cr, tree_view->priv->header_window))
{
gint n_visible_columns;
GList *list;
0,
TREE_VIEW_HEADER_HEIGHT (tree_view));
cairo_restore (cr);
-
- return TRUE;
}
- else if (gtk_cairo_should_draw_window (cr, tree_view->priv->drag_window))
+ if (tree_view->priv->drag_window &&
+ gtk_cairo_should_draw_window (cr, tree_view->priv->drag_window))
{
gtk_container_propagate_draw (GTK_CONTAINER (tree_view),
tree_view->priv->drag_column->button,
cr);
-
- return TRUE;
}
+ gtk_style_context_restore (context);
return FALSE;
}
GtkTreePath *above_path = NULL;
GtkTreeIter iter;
int node = -1;
- gboolean size_changed = FALSE;
gint total_height;
gint area_above = 0;
gint area_below = 0;
pspp_sheet_view_set_top_row (tree_view, above_path, -area_above);
pspp_sheet_view_top_row_to_dy (tree_view);
- /* update width/height and queue a resize */
- if (size_changed)
- {
- GtkRequisition requisition;
-
- /* We temporarily guess a size, under the assumption that it will be the
- * same when we get our next size_allocate. If we don't do this, we'll be
- * in an inconsistent state if we call top_row_to_dy. */
-
- gtk_widget_size_request (GTK_WIDGET (tree_view), &requisition);
- gtk_adjustment_set_upper (tree_view->priv->hadjustment, MAX (gtk_adjustment_get_upper (tree_view->priv->hadjustment), (gfloat)requisition.width));
- gtk_adjustment_set_upper (tree_view->priv->vadjustment, MAX (gtk_adjustment_get_upper (tree_view->priv->vadjustment), (gfloat)requisition.height));
- gtk_adjustment_changed (tree_view->priv->hadjustment);
- gtk_adjustment_changed (tree_view->priv->vadjustment);
- gtk_widget_queue_resize (GTK_WIDGET (tree_view));
- }
-
gtk_tree_row_reference_free (tree_view->priv->scroll_to_path);
tree_view->priv->scroll_to_path = NULL;
if (! gtk_widget_get_realized (GTK_WIDGET (tree_view)))
return FALSE;
- gtk_widget_size_request (GTK_WIDGET (tree_view), &requisition);
+ gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), NULL, &requisition);
gtk_adjustment_set_upper (tree_view->priv->hadjustment, MAX (gtk_adjustment_get_upper (tree_view->priv->hadjustment), (gfloat)requisition.width));
gtk_adjustment_set_upper (tree_view->priv->vadjustment, MAX (gtk_adjustment_get_upper (tree_view->priv->vadjustment), (gfloat)requisition.height));
pspp_sheet_view_drag_begin (GtkWidget *widget,
GdkDragContext *context)
{
-#if GTK3_TRANSITION
- PsppSheetView *tree_view;
- GtkTreePath *path = NULL;
- gint cell_x, cell_y;
- GdkPixmap *row_pix;
- TreeViewDragInfo *di;
-
- tree_view = PSPP_SHEET_VIEW (widget);
-
- /* if the user uses a custom DND source impl, we don't set the icon here */
- di = get_info (tree_view);
-
- if (di == NULL || !di->source_set)
- return;
-
- pspp_sheet_view_get_path_at_pos (tree_view,
- tree_view->priv->press_start_x,
- tree_view->priv->press_start_y,
- &path,
- NULL,
- &cell_x,
- &cell_y);
-
- g_return_if_fail (path != NULL);
-
- row_pix = pspp_sheet_view_create_row_drag_icon (tree_view,
- path);
-
- gtk_drag_set_icon_pixmap (context,
- gdk_drawable_get_colormap (row_pix),
- row_pix,
- NULL,
- /* the + 1 is for the black border in the icon */
- tree_view->priv->press_start_x + 1,
- cell_y + 1);
-
- g_object_unref (row_pix);
- gtk_tree_path_free (path);
-#endif
}
g_return_if_fail (focus_column != NULL);
tree_view->priv->focus_column = focus_column;
- if (!focus_column->button)
- {
- pspp_sheet_view_column_set_need_button (focus_column, TRUE);
- // g_return_if_fail (focus_column->button != NULL);
- if (focus_column->button == NULL)
- return;
- }
if (gtk_container_get_focus_child (GTK_CONTAINER (tree_view)) != focus_column->button)
gtk_widget_grab_focus (focus_column->button);
if (column->visible &&
pspp_sheet_view_column_can_focus (column))
{
- pspp_sheet_view_column_set_need_button (column, TRUE);
if (column->button)
{
pspp_sheet_view_focus_column (tree_view, column,
}
static void
-pspp_sheet_view_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+pspp_sheet_view_style_updated (GtkWidget *widget)
{
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
GList *list;
PsppSheetViewColumn *column;
+ GtkStyleContext *context;
+
+ GTK_WIDGET_CLASS (pspp_sheet_view_parent_class)->style_updated (widget);
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_background (tree_view->priv->bin_window, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
- gtk_style_set_background (gtk_widget_get_style (widget), tree_view->priv->header_window, GTK_STATE_NORMAL);
+ context = gtk_widget_get_style_context (GTK_WIDGET (tree_view));
+ gtk_style_context_set_background (context, gtk_widget_get_window (GTK_WIDGET (tree_view)));
+ gtk_style_context_set_background (context, tree_view->priv->header_window);
pspp_sheet_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
}
static void
pspp_sheet_view_put (PsppSheetView *tree_view,
- GtkWidget *child_widget,
- /* in bin_window coordinates */
- gint x,
- gint y,
- gint width,
- gint height)
+ GtkWidget *child_widget,
+ GtkTreePath *path,
+ PsppSheetViewColumn *column)
{
PsppSheetViewChild *child;
child = g_slice_new (PsppSheetViewChild);
child->widget = child_widget;
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
+ _pspp_sheet_view_find_node (tree_view, path, &child->node);
+ if (child->node < 0)
+ {
+ g_assert_not_reached ();
+ }
+ child->column = column;
tree_view->priv->children = g_list_append (tree_view->priv->children, child);
gtk_widget_set_parent (child_widget, GTK_WIDGET (tree_view));
}
-void
-_pspp_sheet_view_child_move_resize (PsppSheetView *tree_view,
- GtkWidget *widget,
- /* in tree coordinates */
- gint x,
- gint y,
- gint width,
- gint height)
-{
- PsppSheetViewChild *child = NULL;
- GList *list;
- GdkRectangle allocation;
-
- g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- for (list = tree_view->priv->children; list; list = list->next)
- {
- if (((PsppSheetViewChild *)list->data)->widget == widget)
- {
- child = list->data;
- break;
- }
- }
- if (child == NULL)
- return;
-
- allocation.x = child->x = x;
- allocation.y = child->y = y;
- allocation.width = child->width = width;
- allocation.height = child->height = height;
-
- if (gtk_widget_get_realized (widget))
- gtk_widget_size_allocate (widget, &allocation);
-}
-
-
/* TreeModel Callbacks
*/
gtk_widget_show (frame);
gtk_container_add (GTK_CONTAINER (tree_view->priv->search_window), frame);
- vbox = gtk_vbox_new (FALSE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
"activate", G_CALLBACK (pspp_sheet_view_search_activate),
tree_view);
-#if GTK3_TRANSITION
- g_signal_connect (GTK_ENTRY (tree_view->priv->search_entry)->im_context,
- "preedit-changed",
- G_CALLBACK (pspp_sheet_view_search_preedit_changed),
- tree_view);
-#endif
-
gtk_container_add (GTK_CONTAINER (vbox),
tree_view->priv->search_entry);
return width;
}
-
-/* FIXME this adjust_allocation is a big cut-and-paste from
- * GtkCList, needs to be some "official" way to do this
- * factored out.
- */
-typedef struct
-{
- GdkWindow *window;
- int dx;
- int dy;
-} ScrollData;
-
-/* The window to which gtk_widget_get_window (widget) is relative */
-#define ALLOCATION_WINDOW(widget) \
- (!gtk_widget_get_has_window (widget) ? \
- gtk_widget_get_window (widget) : \
- gdk_window_get_parent (gtk_widget_get_window (widget)))
-
-static void
-adjust_allocation_recurse (GtkWidget *widget,
- gpointer data)
-{
- ScrollData *scroll_data = data;
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
- /* Need to really size allocate instead of just poking
- * into widget->allocation if the widget is not realized.
- * FIXME someone figure out why this was.
- */
- if (!gtk_widget_get_realized (widget))
- {
- if (gtk_widget_get_visible (widget))
- {
- GdkRectangle tmp_rectangle = allocation;
- tmp_rectangle.x += scroll_data->dx;
- tmp_rectangle.y += scroll_data->dy;
-
- gtk_widget_size_allocate (widget, &tmp_rectangle);
- }
- }
- else
- {
- if (ALLOCATION_WINDOW (widget) == scroll_data->window)
- {
- allocation.x += scroll_data->dx;
- allocation.y += scroll_data->dy;
-
- if (GTK_IS_CONTAINER (widget))
- gtk_container_forall (GTK_CONTAINER (widget),
- adjust_allocation_recurse,
- data);
- }
- }
-}
-
-static void
-adjust_allocation (GtkWidget *widget,
- int dx,
- int dy)
-{
- ScrollData scroll_data;
-
- if (gtk_widget_get_realized (widget))
- scroll_data.window = ALLOCATION_WINDOW (widget);
- else
- scroll_data.window = NULL;
-
- scroll_data.dx = dx;
- scroll_data.dy = dy;
-
- adjust_allocation_recurse (widget, &scroll_data);
-}
-
void
pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column);
{
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
{
- GList *list;
gint dy;
-
+
gdk_window_move (tree_view->priv->bin_window,
- gtk_adjustment_get_value (tree_view->priv->hadjustment),
TREE_VIEW_HEADER_HEIGHT (tree_view));
- gtk_adjustment_get_value (tree_view->priv->hadjustment),
0);
dy = tree_view->priv->dy - (int) gtk_adjustment_get_value (tree_view->priv->vadjustment);
- if (dy)
- {
- update_prelight (tree_view,
- tree_view->priv->event_last_x,
- tree_view->priv->event_last_y - dy);
-
- if (tree_view->priv->edited_column &&
- GTK_IS_WIDGET (tree_view->priv->edited_column->editable_widget))
- {
- GList *list;
- GtkWidget *widget;
- PsppSheetViewChild *child = NULL;
- widget = GTK_WIDGET (tree_view->priv->edited_column->editable_widget);
- adjust_allocation (widget, 0, dy);
-
- for (list = tree_view->priv->children; list; list = list->next)
- {
- child = (PsppSheetViewChild *)list->data;
- if (child->widget == widget)
- {
- child->y += dy;
- break;
- }
- }
- }
- }
gdk_window_scroll (tree_view->priv->bin_window, 0, dy);
- if (tree_view->priv->dy != (int) gtk_adjustment_get_value (tree_view->priv->vadjustment))
+ if (dy != 0)
{
/* update our dy and top_row */
tree_view->priv->dy = (int) gtk_adjustment_get_value (tree_view->priv->vadjustment);
+ update_prelight (tree_view,
+ tree_view->priv->event_last_x,
+ tree_view->priv->event_last_y);
+
if (!tree_view->priv->in_top_row_to_dy)
pspp_sheet_view_dy_to_top_row (tree_view);
}
- for (list = tree_view->priv->columns; list; list = list->next)
- {
- PsppSheetViewColumn *column = list->data;
- GtkAllocation *col_allocation = &column->allocation;
- GtkAllocation widget_allocation;
- gtk_widget_get_allocation (GTK_WIDGET (tree_view), &widget_allocation);
-
- if (span_intersects (col_allocation->x, col_allocation->width,
- gtk_adjustment_get_value (tree_view->priv->hadjustment),
- widget_allocation.width))
- {
- pspp_sheet_view_column_set_need_button (column, TRUE);
- if (!column->button)
- pspp_sheet_view_column_update_button (column);
- }
- }
+ update_childrens_allocation(tree_view);
}
}
-\f
-
/* Public methods
*/
}
-#if GTK3_TRANSITION
-/* KEEP IN SYNC WITH PSPP_SHEET_VIEW_BIN_EXPOSE */
-/**
- * pspp_sheet_view_create_row_drag_icon:
- * @tree_view: a #PsppSheetView
- * @path: a #GtkTreePath in @tree_view
- *
- * Creates a #GdkPixmap representation of the row at @path.
- * This image is used for a drag icon.
- *
- * Return value: a newly-allocated pixmap of the drag icon.
- **/
-GdkPixmap *
-pspp_sheet_view_create_row_drag_icon (PsppSheetView *tree_view,
- GtkTreePath *path)
-{
- GtkTreeIter iter;
- int node;
- gint cell_offset;
- GList *list;
- GdkRectangle background_area;
- GdkRectangle expose_area;
- GtkWidget *widget;
- /* start drawing inside the black outline */
- gint x = 1, y = 1;
- GdkDrawable *drawable;
- gint bin_window_width;
- gboolean rtl;
-
- g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- widget = GTK_WIDGET (tree_view);
-
- if (!gtk_widget_get_realized (widget))
- return NULL;
-
- _pspp_sheet_view_find_node (tree_view,
- path,
- &node);
-
- if (node < 0)
- return NULL;
-
- if (!gtk_tree_model_get_iter (tree_view->priv->model,
- &iter,
- path))
- return NULL;
-
- cell_offset = x;
-
- background_area.y = y;
- background_area.height = ROW_HEIGHT (tree_view);
-
- bin_window_width = gdk_window_get_width (tree_view->priv->bin_window);
-
- drawable = gdk_pixmap_new (tree_view->priv->bin_window,
- bin_window_width + 2,
- background_area.height + 2,
- -1);
-
- expose_area.x = 0;
- expose_area.y = 0;
- expose_area.width = bin_window_width + 2;
- expose_area.height = background_area.height + 2;
-
-#if GTK3_TRANSITION
- gdk_draw_rectangle (drawable,
- widget->style->base_gc [gtk_widget_get_state (widget)],
- TRUE,
- 0, 0,
- bin_window_width + 2,
- background_area.height + 2);
-#endif
-
- rtl = gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL;
-
- for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
- list;
- list = (rtl ? list->prev : list->next))
- {
- PsppSheetViewColumn *column = list->data;
- GdkRectangle cell_area;
- gint vertical_separator;
-
- if (!column->visible)
- continue;
-
- pspp_sheet_view_column_cell_set_cell_data (column, tree_view->priv->model, &iter);
-
- background_area.x = cell_offset;
- background_area.width = column->width;
-
- gtk_widget_style_get (widget,
- "vertical-separator", &vertical_separator,
- NULL);
-
- cell_area = background_area;
-
- cell_area.y += vertical_separator / 2;
- cell_area.height -= vertical_separator;
-
- if (pspp_sheet_view_column_cell_is_visible (column))
- _pspp_sheet_view_column_cell_render (column,
- drawable,
- &background_area,
- &cell_area,
- &expose_area,
- 0);
- cell_offset += column->width;
- }
-
-#if GTK3_TRANSITION
- gdk_draw_rectangle (drawable,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- bin_window_width + 1,
- background_area.height + 1);
-#endif
-
- return drawable;
-}
-#endif
/**
* pspp_sheet_view_set_destroy_count_func:
G_CALLBACK (pspp_sheet_view_search_enable_popdown), data);
}
-#if GTK3_TRANSITION
-/* Because we're visible but offscreen, we just set a flag in the preedit
- * callback.
- */
-static void
-pspp_sheet_view_search_preedit_changed (GtkIMContext *im_context,
- PsppSheetView *tree_view)
-{
- tree_view->priv->imcontext_changed = 1;
- if (tree_view->priv->typeselect_flush_timeout)
- {
- g_source_remove (tree_view->priv->typeselect_flush_timeout);
- tree_view->priv->typeselect_flush_timeout =
- gdk_threads_add_timeout (PSPP_SHEET_VIEW_SEARCH_DIALOG_TIMEOUT,
- (GSourceFunc) pspp_sheet_view_search_entry_flush_timeout,
- tree_view);
- }
-
-}
-#endif
static void
pspp_sheet_view_search_activate (GtkEntry *entry,
{
PsppSheetSelectionMode mode = pspp_sheet_selection_get_mode (tree_view->priv->selection);
gint pre_val = gtk_adjustment_get_value (tree_view->priv->vadjustment);
- GtkRequisition requisition;
gint row;
g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
pspp_sheet_selection_select_column (tree_view->priv->selection, column);
tree_view->priv->anchor_column = column;
- gtk_widget_size_request (GTK_WIDGET (cell_editable), &requisition);
-
PSPP_SHEET_VIEW_SET_FLAG (tree_view, PSPP_SHEET_VIEW_DRAW_KEYFOCUS);
- if (requisition.height < cell_area->height)
- {
- gint diff = cell_area->height - requisition.height;
- pspp_sheet_view_put (tree_view,
- GTK_WIDGET (cell_editable),
- cell_area->x, cell_area->y + diff/2,
- cell_area->width, requisition.height);
- }
- else
- {
- pspp_sheet_view_put (tree_view,
- GTK_WIDGET (cell_editable),
- cell_area->x, cell_area->y,
- cell_area->width, cell_area->height);
- }
+ pspp_sheet_view_put (tree_view,
+ GTK_WIDGET (cell_editable),
+ path,
+ column);
gtk_cell_editable_start_editing (GTK_CELL_EDITABLE (cell_editable),
(GdkEvent *)event);