output: Add overview pane to GUI output window.
authorBen Pfaff <blp@gnu.org>
Wed, 24 Jun 2009 06:10:00 +0000 (23:10 -0700)
committerBen Pfaff <blp@gnu.org>
Wed, 24 Jun 2009 06:10:00 +0000 (23:10 -0700)
src/ui/gui/output-viewer.glade
src/ui/gui/psppire-output-window.c
src/ui/gui/psppire-output-window.h

index a396a7a40086c2f3fb68a7448094cc598936d344..7c23e77df80f6bd7ead9c9d4bc3b70337151b1f7 100644 (file)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Tue Jun 16 22:17:34 2009 -->
+<?xml version="1.0"?>
 <glade-interface>
+  <!-- interface-requires gtk+ 2.16 -->
+  <!-- interface-naming-policy toplevel-contextual -->
   <widget class="GtkWindow" id="output-viewer-window">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="default_width">600</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
                       <widget class="GtkImageMenuItem" id="file_save">
+                        <property name="label">gtk-save</property>
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">gtk-save</property>
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                       </widget>
                     </child>
                     <child>
                       <widget class="GtkImageMenuItem" id="file_save-as">
+                        <property name="label">gtk-save-as</property>
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">gtk-save-as</property>
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                       </widget>
@@ -58,9 +58,9 @@
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
                       <widget class="GtkImageMenuItem" id="imagemenuitem7">
+                        <property name="label">gtk-copy</property>
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label" translatable="yes">gtk-copy</property>
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                       </widget>
           </widget>
           <packing>
             <property name="expand">False</property>
+            <property name="position">0</property>
           </packing>
         </child>
         <child>
-          <widget class="GtkScrolledWindow" id="scrolledwindow1">
+          <widget class="GtkHPaned" id="hpaned1">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <property name="position">112</property>
+            <property name="position_set">True</property>
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <widget class="GtkTreeView" id="overview">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="headers_visible">False</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="resize">True</property>
+                <property name="shrink">True</property>
+              </packing>
+            </child>
             <child>
-              <widget class="GtkLayout" id="output">
+              <widget class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
+                <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <widget class="GtkLayout" id="output">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                  </widget>
+                </child>
               </widget>
+              <packing>
+                <property name="resize">False</property>
+                <property name="shrink">True</property>
+              </packing>
             </child>
           </widget>
           <packing>
index 542e7b302c725f4caef14673e650d276382b7eeb..08e9f1d9c58701f7df0e02efa1a6a704aa17264c 100644 (file)
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
-
+enum
+  {
+    COL_TITLE,                  /* Table title. */
+    N_COLS
+  };
 
 static void psppire_output_window_base_finalize (PsppireOutputWindowClass *, gpointer);
 static void psppire_output_window_base_init     (PsppireOutputWindowClass *class);
@@ -156,6 +160,9 @@ psppire_output_submit (struct outp_driver *this, struct som_entity *entity)
       cairo_t *cairo = gdk_cairo_create (GDK_DRAWABLE (window));
       struct outp_driver *driver = xr_create_driver (cairo); /* XXX can fail */
       struct tab_table *t = entity->ext;
+      GtkTreeStore *store;
+      GtkTreeIter item;
+      GtkTreePath *path;
       GtkWidget *drawing_area;
       void *rendering;
       int tw, th;
@@ -187,6 +194,28 @@ psppire_output_submit (struct outp_driver *this, struct som_entity *entity)
 
       gtk_layout_set_size (the_output_viewer->output,
                            the_output_viewer->max_width, the_output_viewer->y);
+
+      store = GTK_TREE_STORE (gtk_tree_view_get_model (
+                                the_output_viewer->overview));
+      if (entity->table_num != the_output_viewer->last_table_num)
+        {
+          gtk_tree_store_append (store, &item, NULL);
+          gtk_tree_store_set (store, &item, COL_TITLE, entity->command_name,
+                              -1);
+
+          /* XXX shouldn't save a GtkTreeIter */
+          the_output_viewer->last_table_num = entity->table_num;
+          the_output_viewer->last_top_level = item;
+        }
+      gtk_tree_store_append (store, &item,
+                             &the_output_viewer->last_top_level);
+      gtk_tree_store_set (store, &item, COL_TITLE,
+                          t->title ? t->title : "(unnamed)", -1);
+
+      path = gtk_tree_model_get_path (GTK_TREE_MODEL (store),
+                                      &the_output_viewer->last_top_level);
+      gtk_tree_view_expand_row (the_output_viewer->overview, path, TRUE);
+      gtk_tree_path_free (path);
     }
 
   gtk_window_set_urgency_hint (GTK_WINDOW (the_output_viewer), TRUE);
@@ -245,13 +274,30 @@ cancel_urgency (GtkWindow *window,  gpointer data)
 static void
 psppire_output_window_init (PsppireOutputWindow *window)
 {
-  GtkBuilder *xml = builder_new ("output-viewer.ui");
+  GtkTreeViewColumn *column;
+  GtkCellRenderer *renderer;
+  GtkBuilder *xml;
+
+  xml = builder_new ("output-viewer.ui");
 
   gtk_widget_reparent (get_widget_assert (xml, "vbox1"), GTK_WIDGET (window));
 
   window->output = GTK_LAYOUT (get_widget_assert (xml, "output"));
   window->y = 0;
 
+  window->overview = GTK_TREE_VIEW (get_widget_assert (xml, "overview"));
+  gtk_tree_view_set_model (window->overview,
+                           GTK_TREE_MODEL (gtk_tree_store_new (
+                                             N_COLS,
+                                             G_TYPE_STRING))); /* COL_TITLE */
+  window->last_table_num = -1;
+
+  column = gtk_tree_view_column_new ();
+  gtk_tree_view_append_column (GTK_TREE_VIEW (window->overview), column);
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (column, renderer, TRUE);
+  gtk_tree_view_column_add_attribute (column, renderer, "text", COL_TITLE);
+
   gtk_widget_modify_bg (GTK_WIDGET (window->output), GTK_STATE_NORMAL,
                         &gtk_widget_get_style (GTK_WIDGET (window->output))->base[GTK_STATE_NORMAL]);
 
index 5cb2528e08a6d9defbe8bcb2a6a435c17542129d..ed06da91a91af9fa2dc927d21c491f42431a65b6 100644 (file)
@@ -54,6 +54,10 @@ struct _PsppireOutputWindow
   GtkLayout *output;
   int max_width;
   int y;
+
+  GtkTreeView *overview;
+  int last_table_num;
+  GtkTreeIter last_top_level;
 };
 
 struct _PsppireOutputWindowClass