/* 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
#include "ui/gui/psppire-marshal.h"
#include "ui/gui/pspp-sheet-selection.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
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
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;
/**
* PsppSheetView:hover-selection:
- *
+ *
* Enables of disables the hover selection mode of @tree_view.
* Hover selection makes the selected row follow the pointer.
- * Currently, this works only for the selection modes
+ * Currently, this works only for the selection modes
* %PSPP_SHEET_SELECTION_SINGLE and %PSPP_SHEET_SELECTION_BROWSE.
*
* This mode is primarily intended for treeviews in popups, e.g.
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:
* @column: the #PsppSheetViewColumn in which the activation occurred
*
* The "row-activated" signal is emitted when the method
- * pspp_sheet_view_row_activated() is called or the user double clicks
- * a treeview row. It is also emitted when a non-editable row is
- * selected and one of the keys: Space, Shift+Space, Return or
+ * pspp_sheet_view_row_activated() is called or the user double clicks
+ * a treeview row. It is also emitted when a non-editable row is
+ * selected and one of the keys: Space, Shift+Space, Return or
* Enter is pressed.
- *
- * For selection handling refer to the <link linkend="TreeWidget">tree
+ *
+ * For selection handling refer to the <link linkend="TreeWidget">tree
* widget conceptual overview</link> as well as #PsppSheetSelection.
*/
tree_view_signals[ROW_ACTIVATED] =
/**
* PsppSheetView::columns-changed:
- * @tree_view: the object on which the signal is emitted
- *
+ * @tree_view: the object on which the signal is emitted
+ *
* The number of columns of the treeview has changed.
*/
tree_view_signals[COLUMNS_CHANGED] =
/**
* PsppSheetView::cursor-changed:
* @tree_view: the object on which the signal is emitted
- *
+ *
* The position of the cursor (focused cell) has changed.
*/
tree_view_signals[CURSOR_CHANGED] =
tree_view->priv->search_equal_func = pspp_sheet_view_search_equal_func;
tree_view->priv->search_custom_entry_set = FALSE;
tree_view->priv->typeselect_flush_timeout = 0;
- tree_view->priv->init_hadjust_value = TRUE;
+ tree_view->priv->init_hadjust_value = TRUE;
tree_view->priv->width = 0;
-
+
tree_view->priv->hover_selection = FALSE;
tree_view->priv->rubber_banding_enable = FALSE;
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)
/* Need to call those here, since they create GCs */
pspp_sheet_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
- install_presize_handler (tree_view);
+ install_presize_handler (tree_view);
}
static void
g_source_remove (priv->typeselect_flush_timeout);
priv->typeselect_flush_timeout = 0;
}
-
+
for (list = priv->columns; list; list = list->next)
_pspp_sheet_view_column_unrealize_button (PSPP_SHEET_VIEW_COLUMN (list->data));
if (tree_view->priv->model == NULL)
{
tree_view->priv->width = 0;
- tree_view->priv->prev_width = 0;
+ tree_view->priv->prev_width = 0;
tree_view->priv->height = 0;
return;
}
- tree_view->priv->prev_width = tree_view->priv->width;
+ tree_view->priv->prev_width = tree_view->priv->width;
tree_view->priv->width = 0;
/* keep this in sync with size_allocate below */
PsppSheetView *tree_view = PSPP_SHEET_VIEW (widget);
GList *tmp_list;
- /* we validate some rows initially just to make sure we have some size.
+ /* we validate some rows initially just to make sure we have some size.
* In practice, with a lot of static lists, this should get a good width.
*/
initialize_fixed_height_mode (tree_view);
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);
+ }
}
}
invalid_rect.y = 0;
invalid_rect.width = column->width;
invalid_rect.height = allocation.height;
-
+
gdk_window_invalidate_rect (gtk_widget_get_window (widget), &invalid_rect, TRUE);
break;
}
-
+
column_offset += tmpcolumn->width;
}
}
else
extra_per_column = 0;
- for (list = (rtl ? last_column : first_column);
+ for (list = (rtl ? last_column : first_column);
list != (rtl ? first_column->prev : last_column->next);
- list = (rtl ? list->prev : list->next))
+ list = (rtl ? list->prev : list->next))
{
gint real_requested_width = 0;
gint old_width;
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.
*/
gtk_adjustment_set_lower (tree_view->priv->hadjustment, 0);
gtk_adjustment_set_upper (tree_view->priv->hadjustment, MAX (gtk_adjustment_get_page_size (tree_view->priv->hadjustment), tree_view->priv->width));
- if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
+ if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
{
if (allocation->width < tree_view->priv->width)
{
pspp_sheet_view_top_row_to_dy (tree_view);
else
pspp_sheet_view_dy_to_top_row (tree_view);
-
+
if (gtk_widget_get_realized (widget))
{
gdk_window_move_resize (gtk_widget_get_window (widget),
else
gtk_widget_queue_draw (widget);
}
+ update_childrens_allocation(tree_view);
}
+
+ tree_view->priv->resized = TRUE;
}
/* Grabs the focus and unsets the PSPP_SHEET_VIEW_DRAW_KEYFOCUS flag */
{
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;
}
gint y)
{
PsppSheetSelectionMode mode = pspp_sheet_selection_get_mode (tree_view->priv->selection);
-
+
if (tree_view->priv->hover_selection &&
(mode == PSPP_SHEET_SELECTION_SINGLE || mode == PSPP_SHEET_SELECTION_BROWSE) &&
!(tree_view->priv->edited_column &&
if (!pspp_sheet_view_node_is_selected (tree_view, node))
{
GtkTreePath *path;
-
+
path = _pspp_sheet_view_find_path (tree_view, node);
pspp_sheet_selection_select_path (tree_view->priv->selection, path);
if (pspp_sheet_view_node_is_selected (tree_view, node))
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
x = CLAMP (x + (gint)event->x - column->drag_x, 0,
MAX (tree_view->priv->width, allocation.width) - column->allocation.width);
gdk_window_move (tree_view->priv->drag_window, x, y);
-
+
/* autoscroll, if needed */
pspp_sheet_view_horizontal_autoscroll (tree_view);
/* Update the current reorder position and arrow; */
invalid_region = cairo_region_create_rectangle (&old_area);
cairo_region_union_rectangle (invalid_region, &new_area);
- gdk_rectangle_intersect (GDK_RECTANGLE_PTR (&old_area),
+ gdk_rectangle_intersect (GDK_RECTANGLE_PTR (&old_area),
GDK_RECTANGLE_PTR (&new_area), GDK_RECTANGLE_PTR (&common));
if (common.width > 2 && common.height > 2)
{
}
#if GTK_MAJOR_VERSION == 3
- gdk_window_invalidate_region (tree_view->priv->bin_window, invalid_region, TRUE);
+ gdk_window_invalidate_region (tree_view->priv->bin_window, invalid_region, TRUE);
#else
{
cairo_rectangle_int_t extents;
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;
- /* We don't want a line for the last column */
- if (i == n_visible_columns - 1)
- break;
-
if (! column->visible)
continue;
- current_x += column->width;
+ 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, current_x - 0.5, min_y);
- cairo_line_to (cr, current_x - 0.5 , max_y - min_y);
-
+ cairo_move_to (cr, x + 0.5, 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 (new_y < 0)
new_y = 0;
y_offset = -pspp_sheet_view_find_offset (tree_view, new_y, &node);
- bin_window_width =
+ bin_window_width =
gdk_window_get_width (tree_view->priv->bin_window);
- bin_window_height =
+ bin_window_height =
gdk_window_get_height (tree_view->priv->bin_window);
}
if (node < 0)
- return TRUE;
+ return;
/* find the path for the node */
path = _pspp_sheet_view_find_path ((PsppSheetView *)widget, node);
&iter,
path);
gtk_tree_path_free (path);
-
+
cursor_path = NULL;
drag_dest_path = NULL;
if (draw_vgrid_lines || draw_hgrid_lines)
gtk_widget_style_get (widget, "grid-line-width", &grid_line_width, NULL);
-
+
n_visible_columns = 0;
for (list = tree_view->priv->columns; list; list = list->next)
{
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 (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);
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
-
+ 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);
- cairo_translate (cr, 0, gdk_window_get_height (tree_view->priv->header_window));
- retval = pspp_sheet_view_bin_expose (widget, cr);
+ gtk_cairo_transform_to_window(cr,widget,tree_view->priv->bin_window);
+ 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 if (gtk_cairo_should_draw_window (cr, tree_view->priv->header_window))
+ else
+ {
+ gtk_render_background (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+ }
+
+ 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;
- gtk_paint_flat_box (gtk_widget_get_style (widget),
- cr,
- GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- widget,
- "cell_odd",
- allocation.x,
- allocation.y,
- allocation.width,
- allocation.height
- );
-
for (list = tree_view->priv->columns; list != NULL; list = list->next)
{
PsppSheetViewColumn *column = list->data;
continue;
if (span_intersects (column->allocation.x, column->allocation.width,
- allocation.x, allocation.width)
+ (int) gtk_adjustment_get_value (tree_view->priv->hadjustment),
+ (int) gtk_widget_get_allocated_width (widget))
&& column->button != NULL)
gtk_container_propagate_draw (GTK_CONTAINER (tree_view),
column->button, cr);
continue;
n_visible_columns ++;
}
+ cairo_save (cr);
+ gtk_cairo_transform_to_window(cr,widget,tree_view->priv->header_window);
pspp_sheet_view_draw_vertical_grid_lines (tree_view,
cr,
n_visible_columns,
- allocation.y,
- allocation.height);
-
- return TRUE;
+ 0,
+ TREE_VIEW_HEADER_HEIGHT (tree_view));
+ cairo_restore (cr);
}
- 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;
}
((GdkEventKey *) new_event)->window = g_object_ref (gtk_widget_get_window (tree_view->priv->search_window));
gtk_widget_realize (tree_view->priv->search_window);
- popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
+ popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
"popup-menu", G_CALLBACK (gtk_true),
NULL);
gdk_event_free (new_event);
gtk_widget_hide (tree_view->priv->search_window);
- g_signal_handler_disconnect (tree_view->priv->search_entry,
+ g_signal_handler_disconnect (tree_view->priv->search_entry,
popup_menu_id);
/* We check to make sure that the entry tried to handle the text, and that
"wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
-
+
draw_vgrid_lines =
tree_view->priv->grid_lines == PSPP_SHEET_VIEW_GRID_LINES_VERTICAL
|| tree_view->priv->grid_lines == PSPP_SHEET_VIEW_GRID_LINES_BOTH;
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));
gtk_adjustment_changed (tree_view->priv->hadjustment);
gtk_adjustment_changed (tree_view->priv->vadjustment);
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
-
+
return FALSE;
}
presize_handler_callback (gpointer data)
{
do_presize_handler (PSPP_SHEET_VIEW (data));
-
+
return FALSE;
}
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;
-
+
g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
g_return_if_fail (GTK_IS_WIDGET (child_widget));
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);
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
gtk_widget_set_parent_window (child->widget, tree_view->priv->bin_window);
-
- 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);
+ gtk_widget_set_parent (child_widget, GTK_WIDGET (tree_view));
}
-
/* TreeModel Callbacks
*/
if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
pspp_sheet_view_node_queue_redraw (tree_view, node);
}
-
+
if (free_path)
gtk_tree_path_free (path);
}
GtkMovementStep step,
gint count)
{
-
+
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
"move-cursor", 2,
G_TYPE_ENUM, step,
/* We know there are always 2 slots possbile, as you can always return column. */
/* If that's all there is, return */
- if (tree_view->priv->column_drag_info->next == NULL ||
+ if (tree_view->priv->column_drag_info->next == NULL ||
(tree_view->priv->column_drag_info->next->next == NULL &&
((PsppSheetViewColumnReorder *)tree_view->priv->column_drag_info->data)->right_column == column &&
((PsppSheetViewColumnReorder *)tree_view->priv->column_drag_info->next->data)->left_column == column))
send_event->button.axes = NULL;
send_event->button.state = 0;
send_event->button.button = 1;
- send_event->button.device =
+ send_event->button.device =
gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
send_event->button.x_root = 0;
if (!(mode & PSPP_SHEET_SELECT_MODE_EXTEND))
pspp_sheet_view_row_activated (tree_view, cursor_path,
tree_view->priv->focus_column);
-
+
gtk_tree_path_free (cursor_path);
return TRUE;
fevent->focus_change.type = GDK_FOCUS_CHANGE;
fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));
fevent->focus_change.in = in;
-
+
gtk_widget_send_focus_change (widget, fevent);
gdk_event_free (fevent);
}
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
return;
}
-
+
tree_view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (tree_view->priv->search_window), screen);
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);
}
/* Pops up the interactive search entry. If keybinding is TRUE then the user
- * started this by typing the start_interactive_search keybinding. Otherwise, it came from
+ * started this by typing the start_interactive_search keybinding. Otherwise, it came from
*/
static gboolean
pspp_sheet_view_real_start_interactive_search (PsppSheetView *tree_view,
GList *list;
gboolean found_focus = FALSE;
GtkWidgetClass *entry_parent_class;
-
+
if (!tree_view->priv->enable_search && !keybinding)
return FALSE;
break;
}
}
-
+
if (gtk_widget_has_focus (GTK_WIDGET (tree_view)))
found_focus = TRUE;
rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
column = g_list_nth (tree_view->priv->columns, i)->data;
width = rtl ? (column->allocation.x + column->allocation.width - *x) : (*x - column->allocation.x);
-
+
/* Clamp down the value */
if (column->min_width == -1)
width = MAX (column->button_request, width);
width = MIN (width, column->max_width);
*x = rtl ? (column->allocation.x + column->allocation.width - width) : (column->allocation.x + width);
-
- 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);
+ return width;
}
-void
+void
pspp_sheet_view_column_update_button (PsppSheetViewColumn *tree_column);
/* Callbacks */
{
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
*/
gdk_window_get_position (tree_view->priv->bin_window, &x, &y);
if (headers_visible)
{
- gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
+ gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
tree_view->priv->width, allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
if (gtk_widget_get_mapped (GTK_WIDGET (tree_view)))
*
* Since: 2.10
**/
-gboolean
+gboolean
pspp_sheet_view_get_headers_clickable (PsppSheetView *tree_view)
{
GList *list;
-
+
g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), FALSE);
for (list = tree_view->priv->columns; list; list = list->next)
}
if (tree_view->priv->n_columns == 0 &&
- pspp_sheet_view_get_headers_visible (tree_view) &&
+ pspp_sheet_view_get_headers_visible (tree_view) &&
tree_view->priv->header_window)
gdk_window_hide (tree_view->priv->header_window);
*
* Sets the current keyboard focus to be at @path, and selects it. This is
* useful when you want to focus the user's attention on a particular row. If
- * @focus_column is not %NULL, then focus is given to the column specified by
- * it. Additionally, if @focus_column is specified, and @start_editing is
- * %TRUE, then editing should be started in the specified cell.
- * This function is often followed by @gtk_widget_grab_focus (@tree_view)
- * in order to give keyboard focus to the widget. Please note that editing
+ * @focus_column is not %NULL, then focus is given to the column specified by
+ * it. Additionally, if @focus_column is specified, and @start_editing is
+ * %TRUE, then editing should be started in the specified cell.
+ * This function is often followed by @gtk_widget_grab_focus (@tree_view)
+ * in order to give keyboard focus to the widget. Please note that editing
* can only happen when the widget is realized.
*
* If @path is invalid for @model, the current cursor (if any) will be unset
/**
* pspp_sheet_view_get_bin_window:
* @tree_view: A #PsppSheetView
- *
+ *
* Returns the window that @tree_view renders to. This is used primarily to
* compare to <literal>event->window</literal> to confirm that the event on
* @tree_view is on the right window.
- *
+ *
* Return value: A #GdkWindow, or %NULL when @tree_view hasn't been realized yet
**/
GdkWindow *
{
if (column)
*column = last_column;
-
+
if (cell_x)
*cell_x = last_column->width + remaining_x;
}
{
int node;
gboolean retval;
-
+
g_return_val_if_fail (PSPP_IS_SHEET_VIEW (tree_view), FALSE);
if (!tree_view->priv->row_count)
* @n_targets: the number of items in @targets
* @actions: the bitmask of possible actions for a drag from this
* widget
- *
+ *
* Turns @tree_view into a drop destination for automatic DND. Calling
* this method sets #PsppSheetView:reorderable to %FALSE.
**/
if (!di->dest_set && !di->source_set)
remove_info (tree_view);
}
-
+
unset_reorderable (tree_view);
}
* @tree_view: a #PsppSheetView
* @path: (allow-none): The path of the row to highlight, or %NULL.
* @pos: Specifies whether to drop before, after or into the row
- *
+ *
* Sets the row that is highlighted for feedback.
**/
void
* @tree_view: a #PsppSheetView
* @path: (allow-none): Return location for the path of the highlighted row, or %NULL.
* @pos: (allow-none): Return location for the drop position, or %NULL
- *
+ *
* Gets information about the row that is highlighted for feedback.
**/
void
* @drag_y: the position to determine the destination row for
* @path: (allow-none): Return location for the path of the highlighted row, or %NULL.
* @pos: (allow-none): Return location for the drop position, or %NULL
- *
+ *
* Determines the destination row for a given position. @drag_x and
* @drag_y are expected to be in widget coordinates. This function is only
* meaningful if @tree_view is realized. Therefore this function will always
* return %FALSE if @tree_view is not realized or does not have a model.
- *
+ *
* Return value: whether there is a row at the given position, %TRUE if this
* is indeed the case.
**/
}
-#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:
*
* If @enable_search is set, then the user can type in text to search through
* the tree interactively (this is sometimes called "typeahead find").
- *
- * Note that even if this is %FALSE, the user can still initiate a search
+ *
+ * Note that even if this is %FALSE, the user can still initiate a search
* using the "start-interactive-search" key binding.
*/
void
g_return_if_fail (PSPP_IS_SHEET_VIEW (tree_view));
enable_search = !!enable_search;
-
+
if (tree_view->priv->enable_search != enable_search)
{
tree_view->priv->enable_search = enable_search;
* pspp_sheet_view_get_enable_search:
* @tree_view: A #PsppSheetView
*
- * Returns whether or not the tree allows to start interactive searching
+ * Returns whether or not the tree allows to start interactive searching
* by typing in text.
*
* Return value: whether or not to let the user search interactively
* @column: the column of the model to search in, or -1 to disable searching
*
* Sets @column as the column where the interactive search code should
- * search in for the current model.
- *
+ * search in for the current model.
+ *
* If the search column is set, users can use the "start-interactive-search"
* key binding to bring up search popup. The enable-search property controls
* whether simply typing text will also start an interactive search.
*
- * Note that @column refers to a column of the current model. The search
+ * Note that @column refers to a column of the current model. The search
* column is reset to -1 when the model is changed.
*/
void
G_CALLBACK (pspp_sheet_view_search_init),
tree_view);
}
-
+
g_signal_connect (tree_view->priv->search_entry, "key-press-event",
G_CALLBACK (pspp_sheet_view_search_key_press_event),
tree_view);
g_source_remove (tree_view->priv->typeselect_flush_timeout);
tree_view->priv->typeselect_flush_timeout = 0;
}
-
+
if (gtk_widget_get_visible (search_dialog))
{
/* send focus-in event */
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,
if (gtk_tree_row_reference_valid (tree_view->priv->cursor))
{
path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
-
+
_pspp_sheet_view_find_node (tree_view, path, &node);
-
+
if (node >= 0 && pspp_sheet_view_node_is_selected (tree_view, node))
pspp_sheet_view_row_activated (tree_view, path, tree_view->priv->focus_column);
-
+
gtk_tree_path_free (path);
}
}
tree_view);
gtk_container_remove (GTK_CONTAINER (tree_view),
- GTK_WIDGET (cell_editable));
+ GTK_WIDGET (cell_editable));
/* FIXME should only redraw a single node */
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
{
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);
*
* Enables of disables the hover selection mode of @tree_view.
* Hover selection makes the selected row follow the pointer.
- * Currently, this works only for the selection modes
+ * Currently, this works only for the selection modes
* %PSPP_SHEET_SELECTION_SINGLE and %PSPP_SHEET_SELECTION_BROWSE.
- *
+ *
* Since: 2.6
**/
-void
+void
pspp_sheet_view_set_hover_selection (PsppSheetView *tree_view,
gboolean hover)
{
/**
* pspp_sheet_view_get_hover_selection:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether hover selection mode is turned on for @tree_view.
- *
+ *
* Return value: %TRUE if @tree_view is in hover selection mode
*
- * Since: 2.6
+ * Since: 2.6
**/
-gboolean
+gboolean
pspp_sheet_view_get_hover_selection (PsppSheetView *tree_view)
{
return tree_view->priv->hover_selection;
* Enables or disables rubber banding in @tree_view. If the selection mode is
* #PSPP_SHEET_SELECTION_MULTIPLE or #PSPP_SHEET_SELECTION_RECTANGLE, rubber
* banding will allow the user to select multiple rows by dragging the mouse.
- *
+ *
* Since: 2.10
**/
void
/**
* pspp_sheet_view_get_rubber_banding:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether rubber banding is turned on for @tree_view. If the
* selection mode is #PSPP_SHEET_SELECTION_MULTIPLE or
* #PSPP_SHEET_SELECTION_RECTANGLE, rubber banding will allow the user to
* select multiple rows by dragging the mouse.
- *
+ *
* Return value: %TRUE if rubber banding in @tree_view is enabled.
*
* Since: 2.10
/**
* pspp_sheet_view_is_rubber_banding_active:
* @tree_view: a #PsppSheetView
- *
+ *
* Returns whether a rubber banding operation is currently being done
* in @tree_view.
*
old_grid_lines = priv->grid_lines;
priv->grid_lines = grid_lines;
-
+
if (old_grid_lines != grid_lines)
{
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
-
+
g_object_notify (G_OBJECT (tree_view), "enable-grid-lines");
}
}
{
gboolean continue_emission;
gboolean signal_handled;
-
+
signal_handled = g_value_get_boolean (handler_return);
g_value_set_boolean (return_accu, signal_handled);
continue_emission = !signal_handled;
-
+
return continue_emission;
}