Set the fg and bg of viewer's container and its children to the
text and base of the output window upon style change. This means that
the output viewer will respond to changes in style once even after the
program has been started.
We still need some way to set the foreground colours of the cairo output
after the driver has been created, but that doesn't seem to be currently
possible.
static void psppire_output_window_class_init (PsppireOutputWindowClass *class);
static void psppire_output_window_init (PsppireOutputWindow *window);
static void psppire_output_window_class_init (PsppireOutputWindowClass *class);
static void psppire_output_window_init (PsppireOutputWindow *window);
-static void psppire_output_window_realize (GtkWidget *window);
+static void psppire_output_window_style_set (GtkWidget *window, GtkStyle *prev);
parent_class = g_type_class_peek_parent (class);
object_class->dispose = psppire_output_window_dispose;
parent_class = g_type_class_peek_parent (class);
object_class->dispose = psppire_output_window_dispose;
- GTK_WIDGET_CLASS (object_class)->realize = psppire_output_window_realize;
+ GTK_WIDGET_CLASS (object_class)->style_set = psppire_output_window_style_set;
expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
struct xr_rendering *r = g_object_get_data (G_OBJECT (widget), "rendering");
expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
struct xr_rendering *r = g_object_get_data (G_OBJECT (widget), "rendering");
+ cairo_t *cr = gdk_cairo_create (widget->window);
- cr = gdk_cairo_create (widget->window);
xr_rendering_draw (r, cr, event->area.x, event->area.y,
event->area.width, event->area.height);
cairo_destroy (cr);
xr_rendering_draw (r, cr, event->area.x, event->area.y,
event->area.width, event->area.height);
cairo_destroy (cr);
for (i = 0; i < 5; ++i)
{
GdkColor *col = >k_widget_get_style (src)->base[i];
for (i = 0; i < 5; ++i)
{
GdkColor *col = >k_widget_get_style (src)->base[i];
gtk_widget_modify_bg (dest, i, col);
gtk_widget_modify_bg (dest, i, col);
+
+ col = >k_widget_get_style (src)->text[i];
+ gtk_widget_modify_fg (dest, i, col);
copy_base_to_bg (dwg_area, viewer);
}
copy_base_to_bg (dwg_area, viewer);
}
-psppire_output_window_realize (GtkWidget *w)
+psppire_output_window_style_set (GtkWidget *w, GtkStyle *prev)
{
GtkWidget *op = GTK_WIDGET (PSPPIRE_OUTPUT_WINDOW (w)->output);
{
GtkWidget *op = GTK_WIDGET (PSPPIRE_OUTPUT_WINDOW (w)->output);
- copy_base_to_bg (op, w);
+ /* Copy the base style from the parent widget to the container and
+ all its children.
+ We do this, because the container's primary purpose is to
+ display text. This way psppire appears to follow the chosen
+ gnome theme.
+ */
+ copy_base_to_bg (op, w);
+ gtk_container_foreach (GTK_CONTAINER (op), (GtkCallback) copy_base_to_bg,
+ PSPPIRE_OUTPUT_WINDOW (w)->output);
/* Chain up to the parent class */
/* Chain up to the parent class */
- GTK_WIDGET_CLASS (parent_class)->realize (w);
+ GTK_WIDGET_CLASS (parent_class)->style_set (w, prev);