#include "gtkcellrenderer.h"
#include "gtkcellrenderertext.h"
#include "gtkcellrendererpixbuf.h"
-#include "gtkcellsizerequest.h"
#include "gtkmarshalers.h"
#include "gtkbindings.h"
#include "gtkdnd.h"
guint prop_id,
GValue *value,
GParamSpec *pspec);
-
-/* GtkObject vfuncs */
-static void gtk_icon_view_destroy (GtkObject *object);
-
/* GtkWidget vfuncs */
+static void gtk_icon_view_destroy (GtkWidget *widget);
static void gtk_icon_view_realize (GtkWidget *widget);
static void gtk_icon_view_unrealize (GtkWidget *widget);
static void gtk_icon_view_style_set (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_icon_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gboolean gtk_icon_view_expose (GtkWidget *widget,
- GdkEventExpose *expose);
+static gboolean gtk_icon_view_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gtk_icon_view_motion (GtkWidget *widget,
GdkEventMotion *event);
static gboolean gtk_icon_view_button_press (GtkWidget *widget,
gint y,
gboolean draw_focus);
static void gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
- cairo_t *cr,
- GdkRectangle *area);
+ cairo_t *cr);
static void gtk_icon_view_queue_draw_path (GtkIconView *icon_view,
GtkTreePath *path);
static void gtk_icon_view_queue_draw_item (GtkIconView *icon_view,
gtk_icon_view_class_init (GtkIconViewClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkBindingSet *binding_set;
g_type_class_add_private (klass, sizeof (GtkIconViewPrivate));
gobject_class = (GObjectClass *) klass;
- object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
container_class = (GtkContainerClass *) klass;
gobject_class->set_property = gtk_icon_view_set_property;
gobject_class->get_property = gtk_icon_view_get_property;
- object_class->destroy = gtk_icon_view_destroy;
-
+ widget_class->destroy = gtk_icon_view_destroy;
widget_class->realize = gtk_icon_view_realize;
widget_class->unrealize = gtk_icon_view_unrealize;
widget_class->style_set = gtk_icon_view_style_set;
widget_class->get_accessible = gtk_icon_view_get_accessible;
widget_class->size_request = gtk_icon_view_size_request;
widget_class->size_allocate = gtk_icon_view_size_allocate;
- widget_class->expose_event = gtk_icon_view_expose;
+ widget_class->draw = gtk_icon_view_draw;
widget_class->motion_notify_event = gtk_icon_view_motion;
widget_class->button_press_event = gtk_icon_view_button_press;
widget_class->button_release_event = gtk_icon_view_button_release;
icon_view->priv->draw_focus = TRUE;
}
-static void
-gtk_icon_view_destroy (GtkObject *object)
-{
- GtkIconView *icon_view;
-
- icon_view = GTK_ICON_VIEW (object);
-
- gtk_icon_view_stop_editing (icon_view, TRUE);
-
- gtk_icon_view_set_model (icon_view, NULL);
-
- if (icon_view->priv->layout_idle_id != 0)
- {
- g_source_remove (icon_view->priv->layout_idle_id);
- icon_view->priv->layout_idle_id = 0;
- }
-
- if (icon_view->priv->scroll_to_path != NULL)
- {
- gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
- icon_view->priv->scroll_to_path = NULL;
- }
-
- remove_scroll_timeout (icon_view);
-
- if (icon_view->priv->hadjustment != NULL)
- {
- g_object_unref (icon_view->priv->hadjustment);
- icon_view->priv->hadjustment = NULL;
- }
-
- if (icon_view->priv->vadjustment != NULL)
- {
- g_object_unref (icon_view->priv->vadjustment);
- icon_view->priv->vadjustment = NULL;
- }
-
- GTK_OBJECT_CLASS (gtk_icon_view_parent_class)->destroy (object);
-}
-
/* GObject methods */
static void
gtk_icon_view_finalize (GObject *object)
}
}
-/* GtkWidget signals */
+/* GtkWidget methods */
+static void
+gtk_icon_view_destroy (GtkWidget *widget)
+{
+ GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+
+ gtk_icon_view_stop_editing (icon_view, TRUE);
+
+ gtk_icon_view_set_model (icon_view, NULL);
+
+ if (icon_view->priv->layout_idle_id != 0)
+ {
+ g_source_remove (icon_view->priv->layout_idle_id);
+ icon_view->priv->layout_idle_id = 0;
+ }
+
+ if (icon_view->priv->scroll_to_path != NULL)
+ {
+ gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
+ icon_view->priv->scroll_to_path = NULL;
+ }
+
+ remove_scroll_timeout (icon_view);
+
+ if (icon_view->priv->hadjustment != NULL)
+ {
+ g_object_unref (icon_view->priv->hadjustment);
+ icon_view->priv->hadjustment = NULL;
+ }
+
+ if (icon_view->priv->vadjustment != NULL)
+ {
+ g_object_unref (icon_view->priv->vadjustment);
+ icon_view->priv->vadjustment = NULL;
+ }
+
+ GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->destroy (widget);
+}
+
static void
gtk_icon_view_realize (GtkWidget *widget)
{
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
tmp_list = tmp_list->next;
if (gtk_widget_get_visible (child->widget))
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget,
+ &child_requisition, NULL);
}
}
}
static gboolean
-gtk_icon_view_expose (GtkWidget *widget,
- GdkEventExpose *expose)
+gtk_icon_view_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkIconView *icon_view;
GList *icons;
- cairo_t *cr;
GtkTreePath *path;
gint dest_index;
GtkIconViewDropPosition dest_pos;
icon_view = GTK_ICON_VIEW (widget);
- if (expose->window != icon_view->priv->bin_window)
+ if (!gtk_cairo_should_draw_window (cr, icon_view->priv->bin_window))
return FALSE;
+ cairo_save (cr);
+
+ gtk_cairo_transform_to_window (cr, widget, icon_view->priv->bin_window);
+
/* If a layout has been scheduled, do it now so that all
* cell view items have valid sizes before we proceed. */
if (icon_view->priv->layout_idle_id != 0)
gtk_icon_view_layout (icon_view);
- cr = gdk_cairo_create (icon_view->priv->bin_window);
cairo_set_line_width (cr, 1.);
gtk_icon_view_get_drag_dest_item (icon_view, &path, &dest_pos);
for (icons = icon_view->priv->items; icons; icons = icons->next)
{
GtkIconViewItem *item = icons->data;
- GdkRectangle area;
cairo_save (cr);
cairo_rectangle (cr, item->x, item->y, item->width, item->height);
cairo_clip (cr);
- area.x = item->x;
- area.y = item->y;
- area.width = item->width;
- area.height = item->height;
-
- if (cairo_region_contains_rectangle (expose->region, &area) != CAIRO_REGION_OVERLAP_OUT)
+ if (gdk_cairo_get_clip_rectangle (cr, NULL))
{
gtk_icon_view_paint_item (icon_view, cr, item,
item->x, item->y,
switch (dest_pos)
{
case GTK_ICON_VIEW_DROP_INTO:
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
state,
widget,
dest_item->width, dest_item->height);
break;
case GTK_ICON_VIEW_DROP_ABOVE:
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
state,
widget,
dest_item->width, 2);
break;
case GTK_ICON_VIEW_DROP_LEFT:
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
state,
widget,
2, dest_item->height);
break;
case GTK_ICON_VIEW_DROP_BELOW:
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
state,
widget,
dest_item->width, 2);
break;
case GTK_ICON_VIEW_DROP_RIGHT:
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
state,
widget,
}
if (icon_view->priv->doing_rubberband)
- {
- cairo_rectangle_int_t rectangle;
- gint n_rectangles;
-
- n_rectangles = cairo_region_num_rectangles (expose->region);
-
- while (n_rectangles--)
- {
- cairo_region_get_rectangle (expose->region, n_rectangles, &rectangle);
- gtk_icon_view_paint_rubberband (icon_view, cr, &rectangle);
- }
- }
+ gtk_icon_view_paint_rubberband (icon_view, cr);
- cairo_destroy (cr);
+ cairo_restore (cr);
- GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->expose_event (widget, expose);
+ GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->draw (widget, cr);
return TRUE;
}
if (hadj)
g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
else
- hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ hadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
if (vadj)
g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
else
- vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ vadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
if (icon_view->priv->hadjustment && (icon_view->priv->hadjustment != hadj))
{
pixbuf_info = g_list_nth_data (icon_view->priv->cell_list,
icon_view->priv->pixbuf_cell);
- gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (pixbuf_info->cell),
- GTK_WIDGET (icon_view),
- &min_size, NULL);
+ gtk_cell_renderer_get_preferred_size (pixbuf_info->cell,
+ GTK_WIDGET (icon_view),
+ &min_size, NULL);
if (icon_view->priv->item_width > 0)
item_width = icon_view->priv->item_width;
if (!gtk_cell_renderer_get_visible (info->cell))
continue;
- gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
- GTK_WIDGET (icon_view),
- &min_size, NULL);
+ gtk_cell_renderer_get_preferred_size (info->cell,
+ GTK_WIDGET (icon_view),
+ &min_size, NULL);
item->box[info->position].width = min_size.width;
item->box[info->position].height = min_size.height;
cell_area.height = max_height[i];
}
- gtk_cell_size_request_get_size (GTK_CELL_SIZE_REQUEST (info->cell),
- GTK_WIDGET (icon_view),
- &min_size, NULL);
+ gtk_cell_renderer_get_preferred_size (info->cell,
+ GTK_WIDGET (icon_view),
+ &min_size, NULL);
item->box[info->position].width = min_size.width;
item->box[info->position].height = min_size.height;
if (item->selected)
{
- gtk_cairo_paint_flat_box (style,
+ gtk_paint_flat_box (style,
cr,
GTK_STATE_SELECTED,
GTK_SHADOW_NONE,
cell_area.x = x - item->x + cell_area.x;
cell_area.y = y - item->y + cell_area.y;
- gtk_cell_renderer_render_cairo (info->cell,
- cr,
- widget,
- &cell_area, &cell_area, flags);
+ gtk_cell_renderer_render (info->cell,
+ cr,
+ widget,
+ &cell_area, &cell_area, flags);
}
if (draw_focus &&
if (i == icon_view->priv->cursor_cell)
{
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
GTK_STATE_NORMAL,
widget,
* around the whole item.
*/
if (icon_view->priv->cursor_cell < 0)
- gtk_cairo_paint_focus (style,
+ gtk_paint_focus (style,
cr,
GTK_STATE_NORMAL,
widget,
static void
gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
- cairo_t *cr,
- GdkRectangle *area)
+ cairo_t *cr)
{
GdkRectangle rect;
- GdkRectangle rubber_rect;
GdkColor *fill_color_gdk;
guchar fill_color_alpha;
- rubber_rect.x = MIN (icon_view->priv->rubberband_x1, icon_view->priv->rubberband_x2);
- rubber_rect.y = MIN (icon_view->priv->rubberband_y1, icon_view->priv->rubberband_y2);
- rubber_rect.width = ABS (icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) + 1;
- rubber_rect.height = ABS (icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) + 1;
+ cairo_save (cr);
- if (!gdk_rectangle_intersect (&rubber_rect, area, &rect))
- return;
+ rect.x = MIN (icon_view->priv->rubberband_x1, icon_view->priv->rubberband_x2);
+ rect.y = MIN (icon_view->priv->rubberband_y1, icon_view->priv->rubberband_y2);
+ rect.width = ABS (icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) + 1;
+ rect.height = ABS (icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) + 1;
gtk_widget_style_get (GTK_WIDGET (icon_view),
"selection-box-color", &fill_color_gdk,
if (!fill_color_gdk)
fill_color_gdk = gdk_color_copy (>k_widget_get_style (GTK_WIDGET (icon_view))->base[GTK_STATE_SELECTED]);
- cairo_set_source_rgba (cr,
- fill_color_gdk->red / 65535.,
- fill_color_gdk->green / 65535.,
- fill_color_gdk->blue / 65535.,
- fill_color_alpha / 255.);
+ gdk_cairo_set_source_color (cr, fill_color_gdk);
- cairo_save (cr);
gdk_cairo_rectangle (cr, &rect);
cairo_clip (cr);
- cairo_paint (cr);
- /* Draw the border without alpha */
- cairo_set_source_rgb (cr,
- fill_color_gdk->red / 65535.,
- fill_color_gdk->green / 65535.,
- fill_color_gdk->blue / 65535.);
+ cairo_paint_with_alpha (cr, fill_color_alpha / 255.);
+
cairo_rectangle (cr,
- rubber_rect.x + 0.5, rubber_rect.y + 0.5,
- rubber_rect.width - 1, rubber_rect.height - 1);
+ rect.x + 0.5, rect.y + 0.5,
+ rect.width - 1, rect.height - 1);
cairo_stroke (cr);
- cairo_restore (cr);
gdk_color_free (fill_color_gdk);
+
+ cairo_restore (cr);
}
static void
"focus-line-width", &focus_width,
NULL);
- gdk_drawable_get_size (GDK_DRAWABLE (icon_view->priv->bin_window),
- &width, &height);
+ width = gdk_window_get_width (icon_view->priv->bin_window);
+ height = gdk_window_get_height (icon_view->priv->bin_window);
gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
gtk_widget_get_allocation (widget, &allocation);
{
GtkIconView *icon_view;
GtkIconViewItem *item;
- GdkPixmap *icon;
+ cairo_surface_t *icon;
gint x, y;
GtkTreePath *path;
icon = gtk_icon_view_create_drag_icon (icon_view, path);
gtk_tree_path_free (path);
- gtk_drag_set_icon_pixmap (context,
- gdk_drawable_get_colormap (icon),
- icon,
- NULL,
- x, y);
+ cairo_surface_set_device_offset (icon, -x, -y);
+
+ gtk_drag_set_icon_surface (context, icon);
- g_object_unref (icon);
+ cairo_surface_destroy (icon);
}
static void
* @icon_view: a #GtkIconView
* @path: a #GtkTreePath in @icon_view
*
- * Creates a #GdkPixmap representation of the item at @path.
+ * Creates a #cairo_surface_t representation of the item at @path.
* This image is used for a drag icon.
*
- * Return value: (transfer full): a newly-allocated pixmap of the drag icon.
+ * Return value: (transfer full) a newly-allocated surface of the drag icon.
*
* Since: 2.8
**/
-GdkPixmap *
+cairo_surface_t *
gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
GtkTreePath *path)
{
GtkWidget *widget;
cairo_t *cr;
- GdkPixmap *drawable;
+ cairo_surface_t *surface;
GList *l;
gint index;
if (index == item->index)
{
- drawable = gdk_pixmap_new (icon_view->priv->bin_window,
- item->width + 2,
- item->height + 2,
- -1);
+ surface = gdk_window_create_similar_surface (icon_view->priv->bin_window,
+ CAIRO_CONTENT_COLOR,
+ item->width + 2,
+ item->height + 2);
- cr = gdk_cairo_create (drawable);
+ cr = cairo_create (surface);
cairo_set_line_width (cr, 1.);
gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
cairo_destroy (cr);
- return drawable;
+ return surface;
}
}