mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
print dialog: Avoid gtk_style_context_save
There was one more call to gtk_style_context_save here that I overlooked. We can get rid of it by just setting the element name on the drawing area.
This commit is contained in:
parent
afc09d924e
commit
c2d0aa7851
@ -57,6 +57,7 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkdialogprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -710,6 +711,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
GtkPrintUnixDialogPrivate *priv;
|
||||
GtkTreeSortable *sort;
|
||||
GtkWidget *widget;
|
||||
GtkCssNode *widget_node;
|
||||
|
||||
dialog->priv = gtk_print_unix_dialog_get_instance_private (dialog);
|
||||
priv = dialog->priv;
|
||||
@ -794,6 +796,8 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
|
||||
/* Load custom papers */
|
||||
_gtk_print_load_custom_papers (priv->custom_paper_list);
|
||||
|
||||
gtk_css_node_set_name (gtk_widget_get_css_node (priv->collate_image), I_("paper"));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2224,8 +2228,6 @@ paint_page (GtkWidget *widget,
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_style_context_save_named (context, "paper");
|
||||
|
||||
gtk_render_background (context, cr, x, y, width, height);
|
||||
gtk_render_frame (context, cr, x, y, width, height);
|
||||
|
||||
@ -2235,8 +2237,6 @@ paint_page (GtkWidget *widget,
|
||||
cairo_set_font_size (cr, 9);
|
||||
cairo_move_to (cr, x + text_x, y + text_y);
|
||||
cairo_show_text (cr, text);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2286,7 +2286,7 @@ draw_collate_cb (GtkWidget *widget,
|
||||
|
||||
paint_page (widget, cr, x2 + p1, y, reverse ? "1" : "2", text_x);
|
||||
paint_page (widget, cr, x2 + p2, y + 10, collate == reverse ? "2" : "1", text_x);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2669,7 +2669,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
gdouble pos_x, pos_y;
|
||||
gint pages_per_sheet;
|
||||
gboolean ltr = TRUE;
|
||||
GtkStateFlags state;
|
||||
|
||||
orientation = gtk_page_setup_get_orientation (priv->page_setup);
|
||||
landscape =
|
||||
@ -2679,7 +2678,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
number_up_layout = dialog_get_number_up_layout (dialog);
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
@ -2760,10 +2758,7 @@ draw_page_cb (GtkWidget *widget,
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PAPER);
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
|
||||
gtk_style_context_get_color (context, gtk_style_context_get_state (context), &color);
|
||||
|
||||
pos_x = (width - w) / 2;
|
||||
pos_y = (height - h) / 2 - 10;
|
||||
@ -2771,7 +2766,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
|
||||
shadow_offset = 3;
|
||||
|
||||
gtk_style_context_get_color (context, state, &color);
|
||||
cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5);
|
||||
cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h);
|
||||
cairo_fill (cr);
|
||||
@ -2780,7 +2774,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_rectangle (cr, 0.5, 0.5, w + 1, h + 1);
|
||||
gtk_style_context_get_color (context, state, &color);
|
||||
gdk_cairo_set_source_rgba (cr, &color);
|
||||
cairo_stroke (cr);
|
||||
|
||||
@ -2982,7 +2975,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE,
|
||||
(height - layout_h / PANGO_SCALE) / 2);
|
||||
|
||||
gtk_style_context_get_color (context, state, &color);
|
||||
gdk_cairo_set_source_rgba (cr, &color);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
|
||||
@ -3001,7 +2993,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2,
|
||||
pos_y + h + shadow_offset + 2 * RULER_DISTANCE);
|
||||
|
||||
gtk_style_context_get_color (context, state, &color);
|
||||
gdk_cairo_set_source_rgba (cr, &color);
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
|
||||
@ -3011,7 +3002,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
|
||||
cairo_set_line_width (cr, 1);
|
||||
|
||||
gtk_style_context_get_color (context, state, &color);
|
||||
gdk_cairo_set_source_rgba (cr, &color);
|
||||
|
||||
if (ltr)
|
||||
@ -3056,8 +3046,6 @@ draw_page_cb (GtkWidget *widget,
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user