psppire-output-view: Fix background color for output viewer.
[pspp] / src / ui / gui / psppire-output-view.c
index dd8618f7337d37560f8570e010440446babea4df..0a2b4c797072a13f583bd67e0c30c83b7dbe0fb3 100644 (file)
@@ -27,6 +27,7 @@
 #include "output/driver-provider.h"
 #include "output/driver.h"
 #include "output/chart-item.h"
+#include "output/group-item.h"
 #include "output/message-item.h"
 #include "output/output-item.h"
 #include "output/table-item.h"
@@ -82,6 +83,24 @@ enum
     N_COLS
   };
 
+/* Draws a white background on the GtkLayout to match the white background of
+   each of the output items. */
+static gboolean
+layout_draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+  cairo_save (cr);
+
+  int width = gtk_widget_get_allocated_width (widget);
+  int height = gtk_widget_get_allocated_height (widget);
+  cairo_rectangle (cr, 0, 0, width, height);
+  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  cairo_fill (cr);
+
+  cairo_restore (cr);
+
+  return FALSE;                 /* Continue drawing the GtkDrawingAreas. */
+}
+
 static gboolean
 draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
 {
@@ -292,18 +311,19 @@ psppire_output_view_put (struct psppire_output_view *view,
   GtkTreeIter iter;
   int tw, th;
 
-  if (is_text_item (item))
+  if (is_group_close_item (item))
     {
-      const struct text_item *text_item = to_text_item (item);
-      enum text_item_type type = text_item_get_type (text_item);
-      const char *text = text_item_get_text (text_item);
-
-      if (type == TEXT_ITEM_COMMAND_CLOSE)
+      if (output_get_group_level () == 0)
         {
           view->in_command = false;
           return;
         }
-      else if (text[0] == '\0')
+    }
+  else if (is_text_item (item))
+    {
+      const struct text_item *text_item = to_text_item (item);
+      const char *text = text_item_get_text (text_item);
+      if (text[0] == '\0')
         return;
     }
 
@@ -344,8 +364,7 @@ psppire_output_view_put (struct psppire_output_view *view,
       store = GTK_TREE_STORE (gtk_tree_view_get_model (view->overview));
 
       ds_init_empty (&name);
-      if (is_text_item (item)
-          && text_item_get_type (to_text_item (item)) == TEXT_ITEM_COMMAND_OPEN)
+      if (is_group_open_item (item) && output_get_group_level () == 1)
         {
           gtk_tree_store_append (store, &iter, NULL);
           view->cur_command = iter; /* XXX shouldn't save a GtkTreeIter */
@@ -384,6 +403,8 @@ psppire_output_view_put (struct psppire_output_view *view,
           else
             ds_put_cstr (&name, "Chart");
         }
+      else if (is_group_open_item (item))
+        ds_put_cstr (&name, to_group_open_item (item)->command_name);
       gtk_tree_store_set (store, &iter,
                           COL_NAME, ds_cstr (&name),
                          COL_ADDR, item,
@@ -688,6 +709,8 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview)
   view->print_n_pages = 0;
   view->paginated = FALSE;
 
+  g_signal_connect (output, "draw", G_CALLBACK (layout_draw_callback), NULL);
+
   g_signal_connect (output, "style-updated", G_CALLBACK (on_style_updated), view);
 
   g_signal_connect (output, "size-allocate", G_CALLBACK (on_size_allocate), view);