From: Ben Pfaff Date: Sun, 17 Jan 2010 06:11:47 +0000 (-0800) Subject: psppire: Reimplement overview pane for output viewer window. X-Git-Tag: fc11-i386-build76^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b0ea228805d060436b047e9d9ea389228e4fd73;p=pspp-builds.git psppire: Reimplement overview pane for output viewer window. --- diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index b2e821e2..ebca5533 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -24,8 +24,11 @@ #include #include #include +#include #include #include +#include +#include #include #include @@ -176,6 +179,10 @@ psppire_output_submit (struct output_driver *this, PsppireOutputWindow *viewer; GtkWidget *drawing_area; struct xr_rendering *r; + struct string title; + GtkTreeStore *store; + GtkTreePath *path; + GtkTreeIter iter; cairo_t *cr; int tw, th; @@ -187,6 +194,26 @@ psppire_output_submit (struct output_driver *this, } viewer = pod->viewer; + if (viewer->n_items >= viewer->allocated_items) + viewer->items = x2nrealloc (viewer->items, &viewer->allocated_items, + sizeof *viewer->items); + viewer->items[viewer->n_items++] = output_item_ref (item); + + if (is_text_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) + { + viewer->in_command = false; + return; + } + else if (text[0] == '\0') + return; + } + cr = gdk_cairo_create (GTK_WIDGET (pod->viewer)->window); if (pod->xr == NULL) pod->xr = xr_create_driver (cr); @@ -195,11 +222,6 @@ psppire_output_submit (struct output_driver *this, if (r == NULL) goto done; - if (viewer->n_items >= viewer->allocated_items) - viewer->items = x2nrealloc (viewer->items, &viewer->allocated_items, - sizeof *viewer->items); - viewer->items[viewer->n_items++] = output_item_ref (item); - xr_rendering_measure (r, &tw, &th); drawing_area = gtk_drawing_area_new (); @@ -213,6 +235,56 @@ psppire_output_submit (struct output_driver *this, g_signal_connect (G_OBJECT (drawing_area), "expose_event", G_CALLBACK (expose_event_callback), NULL); + if (!is_text_item (item) + || text_item_get_type (to_text_item (item)) != TEXT_ITEM_SYNTAX + || !viewer->in_command) + { + store = GTK_TREE_STORE (gtk_tree_view_get_model (viewer->overview)); + + ds_init_empty (&title); + if (is_text_item (item) + && text_item_get_type (to_text_item (item)) == TEXT_ITEM_COMMAND_OPEN) + { + gtk_tree_store_append (store, &iter, NULL); + viewer->cur_command = iter; /* XXX shouldn't save a GtkTreeIter */ + viewer->in_command = true; + } + else + { + GtkTreeIter *p = viewer->in_command ? &viewer->cur_command : NULL; + gtk_tree_store_append (store, &iter, p); + } + + ds_clear (&title); + if (is_text_item (item)) + ds_put_cstr (&title, text_item_get_text (to_text_item (item))); + else if (is_table_item (item)) + { + const char *caption = table_item_get_caption (to_table_item (item)); + if (caption != NULL) + ds_put_format (&title, "Table: %s", caption); + else + ds_put_cstr (&title, "Table"); + } + else if (is_chart_item (item)) + { + const char *s = chart_item_get_title (to_chart_item (item)); + if (s != NULL) + ds_put_format (&title, "Chart: %s", s); + else + ds_put_cstr (&title, "Chart"); + } + gtk_tree_store_set (store, &iter, + COL_TITLE, ds_cstr (&title), + COL_Y, viewer->y, + -1); + ds_destroy (&title); + + path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); + gtk_tree_view_expand_row (viewer->overview, path, TRUE); + gtk_tree_path_free (path); + } + if (pod->viewer->max_width < tw) pod->viewer->max_width = tw; pod->viewer->y += th; @@ -437,7 +509,8 @@ psppire_output_window_init (PsppireOutputWindow *window) N_COLS, G_TYPE_STRING, /* COL_TITLE */ G_TYPE_LONG))); /* COL_Y */ - window->last_table_num = -1; + + window->in_command = false; window->items = NULL; window->n_items = window->allocated_items = 0; diff --git a/src/ui/gui/psppire-output-window.h b/src/ui/gui/psppire-output-window.h index bc0da853..95deed93 100644 --- a/src/ui/gui/psppire-output-window.h +++ b/src/ui/gui/psppire-output-window.h @@ -58,8 +58,8 @@ struct _PsppireOutputWindow int y; GtkTreeView *overview; - int last_table_num; - GtkTreeIter last_top_level; + GtkTreeIter cur_command; + bool in_command; struct output_item **items; size_t n_items, allocated_items;