diff options
author | Xan Lopez <xan@gnome.org> | 2010-05-23 21:17:23 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2010-05-23 21:18:12 +0800 |
commit | c55b5b72a1c037c3b8845f9447a0b8751d48ade6 (patch) | |
tree | 7faafa9f117bb801563d1dec666769e4ba5bf75b /embed | |
parent | c04180dc6d7053c39b144d7953d9e4314277a81e (diff) | |
download | gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar.gz gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar.bz2 gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar.lz gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar.xz gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.tar.zst gsoc2013-epiphany-c55b5b72a1c037c3b8845f9447a0b8751d48ade6.zip |
ephy-web-view: factor statusbar drawing code out of expose handler
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-web-view.c | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 9f2fa34c1..3dc400433 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1402,60 +1402,68 @@ ephy_web_view_constructed (GObject *object) NULL); } -static gboolean -ephy_web_view_expose_event (GtkWidget *widget, GdkEventExpose *event) +static void +_ephy_web_view_draw_statusbar(GtkWidget *widget) { + gint width, height; + guint border_width, statusbar_border_width; + PangoLayout *layout; + GtkAllocation allocation; + GdkWindow *window; + GtkStyle *style; EphyWebViewPrivate *priv; - GTK_WIDGET_CLASS (ephy_web_view_parent_class)->expose_event (widget, event); - priv = EPHY_WEB_VIEW (widget)->priv; - if (priv->text && priv->text[0] != '\0') { - gint width, height; - guint border_width, statusbar_border_width; - PangoLayout *layout; - GtkAllocation allocation; - GdkWindow *window; - GtkStyle *style; + gtk_widget_get_allocation (widget, &allocation); - gtk_widget_get_allocation (widget, &allocation); + layout = gtk_widget_create_pango_layout (widget, priv->text); + pango_layout_set_width (layout, PANGO_SCALE * (allocation.width * 0.9)); + pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); - layout = gtk_widget_create_pango_layout (widget, priv->text); - pango_layout_set_width (layout, PANGO_SCALE * (allocation.width * 0.9)); - pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); + pango_layout_get_pixel_size (layout, &width, &height); - pango_layout_get_pixel_size (layout, &width, &height); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + window = gtk_widget_get_window (widget); + style = gtk_widget_get_style (widget); - window = gtk_widget_get_window (widget); - style = gtk_widget_get_style (widget); + statusbar_border_width = 4; /* FIXME: what should we use here? */ - statusbar_border_width = 4; /* FIXME: what should we use here? */ + priv->text_rectangle.x = border_width; + priv->text_rectangle.y = allocation.height - height - border_width - (statusbar_border_width * 2); + priv->text_rectangle.width = width + (statusbar_border_width * 2); + priv->text_rectangle.height = height + (statusbar_border_width * 2); - priv->text_rectangle.x = border_width; - priv->text_rectangle.y = allocation.height - height - border_width - (statusbar_border_width * 2); - priv->text_rectangle.width = width + (statusbar_border_width * 2); - priv->text_rectangle.height = height + (statusbar_border_width * 2); + gtk_paint_box (style, window, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + NULL, widget, NULL, + priv->text_rectangle.x, + priv->text_rectangle.y, + priv->text_rectangle.width, + priv->text_rectangle.height); - gtk_paint_box (style, window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - NULL, widget, NULL, - priv->text_rectangle.x, - priv->text_rectangle.y, - priv->text_rectangle.width, - priv->text_rectangle.height); + gtk_paint_layout (style, window, + GTK_STATE_NORMAL, FALSE, + NULL, widget, NULL, + priv->text_rectangle.x + statusbar_border_width, + priv->text_rectangle.y + statusbar_border_width, + layout); - gtk_paint_layout (style, window, - GTK_STATE_NORMAL, FALSE, - NULL, widget, NULL, - priv->text_rectangle.x + statusbar_border_width, - priv->text_rectangle.y + statusbar_border_width, - layout); + g_object_unref (layout); +} - g_object_unref (layout); - } +static gboolean +ephy_web_view_expose_event (GtkWidget *widget, GdkEventExpose *event) +{ + EphyWebViewPrivate *priv; + + GTK_WIDGET_CLASS (ephy_web_view_parent_class)->expose_event (widget, event); + + priv = EPHY_WEB_VIEW (widget)->priv; + + if (priv->text && priv->text[0] != '\0') + _ephy_web_view_draw_statusbar (widget); return FALSE; } |