[gtk+/rendering-cleanup-next: 63/153] notebook: Port to draw vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 63/153] notebook: Port to draw vfunc
- Date: Sat, 11 Sep 2010 04:56:43 +0000 (UTC)
commit d105263f49b58a807d16866178df2b53aab5225f
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 7 02:39:44 2010 +0200
notebook: Port to draw vfunc
gtk/gtknotebook.c | 92 +++++++++++++++++++++++++++++-----------------------
1 files changed, 51 insertions(+), 41 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index b2a4f7a..e4e6ea1 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -281,8 +281,10 @@ static void gtk_notebook_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_notebook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gint gtk_notebook_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gtk_notebook_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height);
static gboolean gtk_notebook_scroll (GtkWidget *widget,
GdkEventScroll *event);
static gint gtk_notebook_button_press (GtkWidget *widget,
@@ -401,7 +403,7 @@ static void gtk_notebook_child_reordered (GtkNotebook *notebook,
/*** GtkNotebook Drawing Functions ***/
static void gtk_notebook_paint (GtkWidget *widget,
- GdkRectangle *area);
+ cairo_t *cr);
static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page,
cairo_t *cr);
@@ -557,7 +559,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->unrealize = gtk_notebook_unrealize;
widget_class->size_request = gtk_notebook_size_request;
widget_class->size_allocate = gtk_notebook_size_allocate;
- widget_class->expose_event = gtk_notebook_expose;
+ widget_class->draw = gtk_notebook_draw;
widget_class->scroll_event = gtk_notebook_scroll;
widget_class->button_press_event = gtk_notebook_button_press;
widget_class->button_release_event = gtk_notebook_button_release;
@@ -1578,7 +1580,7 @@ gtk_notebook_get_property (GObject *object,
* gtk_notebook_realize
* gtk_notebook_size_request
* gtk_notebook_size_allocate
- * gtk_notebook_expose
+ * gtk_notebook_draw
* gtk_notebook_scroll
* gtk_notebook_button_press
* gtk_notebook_button_release
@@ -2248,16 +2250,29 @@ gtk_notebook_size_allocate (GtkWidget *widget,
}
static gint
-gtk_notebook_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_notebook_draw (GtkWidget *widget,
+ cairo_t *cr,
+ int width,
+ int height)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
+ GtkAllocation allocation;
+ GdkWindow *window;
gint i;
- if (gtk_widget_is_drawable (widget))
+ gtk_widget_get_allocation (widget, &allocation);
+
+ window = gtk_widget_get_window (widget);
+ if (gtk_cairo_should_draw_window (cr, window))
{
- gtk_notebook_paint (widget, &event->area);
+ cairo_save (cr);
+
+ cairo_translate (cr, -allocation.x, -allocation.y);
+ gtk_notebook_paint (widget, cr);
+
+ cairo_restore (cr);
+
if (priv->show_tabs)
{
GtkNotebookPage *page;
@@ -2267,32 +2282,31 @@ gtk_notebook_expose (GtkWidget *widget,
{
page = GTK_NOTEBOOK_PAGE (pages);
- if (gtk_widget_get_window (page->tab_label) == event->window &&
- gtk_widget_is_drawable (page->tab_label))
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- page->tab_label, event);
+ if (gtk_widget_get_parent (page->tab_label) == widget)
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ page->tab_label, cr);
}
}
- if (priv->cur_page)
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->cur_page->child,
- event);
+ if (priv->cur_page && priv->operation != DRAG_OPERATION_REORDER)
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->cur_page->child,
+ cr);
if (priv->show_tabs)
{
for (i = 0; i < N_ACTION_WIDGETS; i++)
{
- if (priv->action_widget[i] &&
- gtk_widget_is_drawable (priv->action_widget[i]))
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->action_widget[i], event);
+ if (priv->action_widget[i])
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->action_widget[i], cr);
}
}
}
- if (event->window == priv->drag_window)
+ if (priv->operation == DRAG_OPERATION_REORDER &&
+ gtk_cairo_should_draw_window (cr, priv->drag_window))
{
- cairo_t *cr;
+ int x, y;
/* FIXME: This is a workaround to make tabs reordering work better
* with engines with rounded tabs. If the drag window background
@@ -2301,16 +2315,21 @@ gtk_notebook_expose (GtkWidget *widget,
* Ideally, these corners should be made transparent, Either by using
* ARGB visuals or shape windows.
*/
- cr = gdk_cairo_create (priv->drag_window);
+ cairo_save (cr);
+ gdk_window_get_position (priv->drag_window, &x, &y);
+ cairo_translate (cr, x - allocation.x, y - allocation.y);
+
gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
cairo_paint (cr);
gtk_notebook_draw_tab (notebook,
priv->cur_page,
cr);
- cairo_destroy (cr);
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->cur_page->tab_label, event);
+
+ cairo_restore (cr);
+
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->cur_page->tab_label, cr);
}
return FALSE;
@@ -4784,7 +4803,7 @@ gtk_notebook_search_page (GtkNotebook *notebook,
*/
static void
gtk_notebook_paint (GtkWidget *widget,
- GdkRectangle *area)
+ cairo_t *cr)
{
GtkNotebook *notebook;
GtkNotebookPrivate *priv;
@@ -4798,7 +4817,6 @@ gtk_notebook_paint (GtkWidget *widget,
gint gap_x = 0, gap_width = 0, step = STEP_PREV;
gboolean is_rtl;
gint tab_pos;
- cairo_t *cr;
notebook = GTK_NOTEBOOK (widget);
priv = notebook->priv;
@@ -4818,10 +4836,9 @@ gtk_notebook_paint (GtkWidget *widget,
if (priv->show_border && (!priv->show_tabs || !priv->children))
{
- gtk_paint_box (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ gtk_cairo_paint_box (gtk_widget_get_style (widget), cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- area, widget, "notebook",
+ widget, "notebook",
x, y, width, height);
return;
}
@@ -4882,17 +4899,12 @@ gtk_notebook_paint (GtkWidget *widget,
break;
}
}
- gtk_paint_box_gap (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ gtk_cairo_paint_box_gap (gtk_widget_get_style (widget), cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- area, widget, "notebook",
+ widget, "notebook",
x, y, width, height,
tab_pos, gap_x, gap_width);
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- gdk_cairo_rectangle (cr, area);
- cairo_clip (cr);
-
showarrow = FALSE;
children = gtk_notebook_search_page (notebook, NULL, step, TRUE);
while (children)
@@ -4922,8 +4934,6 @@ gtk_notebook_paint (GtkWidget *widget,
if (priv->operation != DRAG_OPERATION_REORDER)
gtk_notebook_draw_tab (notebook, priv->cur_page, cr);
-
- cairo_destroy (cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]