Commit 69b2fb32 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Use wb_view_sheet_add.


2000-11-12  Jody Goldberg <jgoldberg@home.com>

	* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.

	* src/workbook-view.c (wb_view_sheet_add) : new function.
	(wb_view_format_feedback) : Ditto.
	(wb_view_auto_expr) : Store the display result.
	(wb_view_auto_expr_value_display) : renamed
	  from wb_view_auto_expr_value_set.
	(wb_view_destroy) : clear out the new members.

	* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
	  the style here.  This is transitory.  It will eventually move into
	  the sheet view when that is split.

	* src/workbook-control.c (wb_control_sheet_add) : Do this manually
	  so that if the new sheet is the focus sheet for the view we can
	  update the various feedback mechanisms.
	(workbook_control_sheets_init) : rather than here.

	* src/sheet.c (sheet_update) : prepare for having the wb_view handle
	  the selection.

	* src/Makefile.am : Add missing workbook-control.h

	* src/workbook-view.c (wb_view_auto_expr) : When the expression
	  changes, recalculate.

	* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
	  the ui.
	(cb_auto_expr_changed) : test the updating flag here, don't set it.
parent 63673248
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.
* src/workbook-view.c (wb_view_sheet_add) : new function.
(wb_view_format_feedback) : Ditto.
(wb_view_auto_expr) : Store the display result.
(wb_view_auto_expr_value_display) : renamed
from wb_view_auto_expr_value_set.
(wb_view_destroy) : clear out the new members.
* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
the style here. This is transitory. It will eventually move into
the sheet view when that is split.
* src/workbook-control.c (wb_control_sheet_add) : Do this manually
so that if the new sheet is the focus sheet for the view we can
update the various feedback mechanisms.
(workbook_control_sheets_init) : rather than here.
* src/sheet.c (sheet_update) : prepare for having the wb_view handle
the selection.
* src/Makefile.am : Add missing workbook-control.h
* src/workbook-view.c (wb_view_auto_expr) : When the expression
changes, recalculate.
* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
the ui.
(cb_auto_expr_changed) : test the updating flag here, don't set it.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/bonobo-io.c (gnumeric_bonobo_obj_write),
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.
* src/workbook-view.c (wb_view_sheet_add) : new function.
(wb_view_format_feedback) : Ditto.
(wb_view_auto_expr) : Store the display result.
(wb_view_auto_expr_value_display) : renamed
from wb_view_auto_expr_value_set.
(wb_view_destroy) : clear out the new members.
* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
the style here. This is transitory. It will eventually move into
the sheet view when that is split.
* src/workbook-control.c (wb_control_sheet_add) : Do this manually
so that if the new sheet is the focus sheet for the view we can
update the various feedback mechanisms.
(workbook_control_sheets_init) : rather than here.
* src/sheet.c (sheet_update) : prepare for having the wb_view handle
the selection.
* src/Makefile.am : Add missing workbook-control.h
* src/workbook-view.c (wb_view_auto_expr) : When the expression
changes, recalculate.
* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
the ui.
(cb_auto_expr_changed) : test the updating flag here, don't set it.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/bonobo-io.c (gnumeric_bonobo_obj_write),
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.
* src/workbook-view.c (wb_view_sheet_add) : new function.
(wb_view_format_feedback) : Ditto.
(wb_view_auto_expr) : Store the display result.
(wb_view_auto_expr_value_display) : renamed
from wb_view_auto_expr_value_set.
(wb_view_destroy) : clear out the new members.
* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
the style here. This is transitory. It will eventually move into
the sheet view when that is split.
* src/workbook-control.c (wb_control_sheet_add) : Do this manually
so that if the new sheet is the focus sheet for the view we can
update the various feedback mechanisms.
(workbook_control_sheets_init) : rather than here.
* src/sheet.c (sheet_update) : prepare for having the wb_view handle
the selection.
* src/Makefile.am : Add missing workbook-control.h
* src/workbook-view.c (wb_view_auto_expr) : When the expression
changes, recalculate.
* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
the ui.
(cb_auto_expr_changed) : test the updating flag here, don't set it.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/bonobo-io.c (gnumeric_bonobo_obj_write),
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.
* src/workbook-view.c (wb_view_sheet_add) : new function.
(wb_view_format_feedback) : Ditto.
(wb_view_auto_expr) : Store the display result.
(wb_view_auto_expr_value_display) : renamed
from wb_view_auto_expr_value_set.
(wb_view_destroy) : clear out the new members.
* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
the style here. This is transitory. It will eventually move into
the sheet view when that is split.
* src/workbook-control.c (wb_control_sheet_add) : Do this manually
so that if the new sheet is the focus sheet for the view we can
update the various feedback mechanisms.
(workbook_control_sheets_init) : rather than here.
* src/sheet.c (sheet_update) : prepare for having the wb_view handle
the selection.
* src/Makefile.am : Add missing workbook-control.h
* src/workbook-view.c (wb_view_auto_expr) : When the expression
changes, recalculate.
* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
the ui.
(cb_auto_expr_changed) : test the updating flag here, don't set it.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/bonobo-io.c (gnumeric_bonobo_obj_write),
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_sheet_attach) : Use wb_view_sheet_add.
* src/workbook-view.c (wb_view_sheet_add) : new function.
(wb_view_format_feedback) : Ditto.
(wb_view_auto_expr) : Store the display result.
(wb_view_auto_expr_value_display) : renamed
from wb_view_auto_expr_value_set.
(wb_view_destroy) : clear out the new members.
* src/workbook-format-toolbar.c (workbook_feedback_set) : Calculate
the style here. This is transitory. It will eventually move into
the sheet view when that is split.
* src/workbook-control.c (wb_control_sheet_add) : Do this manually
so that if the new sheet is the focus sheet for the view we can
update the various feedback mechanisms.
(workbook_control_sheets_init) : rather than here.
* src/sheet.c (sheet_update) : prepare for having the wb_view handle
the selection.
* src/Makefile.am : Add missing workbook-control.h
* src/workbook-view.c (wb_view_auto_expr) : When the expression
changes, recalculate.
* src/workbook-control-gui.c (wbcg_auto_expr_value) : Mark as updating
the ui.
(cb_auto_expr_changed) : test the updating flag here, don't set it.
2000-11-11 Michael Meeks <michael@helixcode.com>
* src/bonobo-io.c (gnumeric_bonobo_obj_write),
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* Makefile.am : remove the gif files.
2000-11-02 Almer S. Tigelaar <almer1@dds.nl>
Fix bug #29305 and #29308
......
......@@ -81,7 +81,7 @@ install-data-local: index.html
basefile=`basename $$file`; \
$(INSTALL_DATA) $$file $(DESTDIR)$(gnumeric_helpdir)/$$basefile; \
done
-for file in $(srcdir)/images/*.jpg $(srcdir)/images/*.png $(srcdir)/images/*.gif; do \
-for file in $(srcdir)/images/*.jpg $(srcdir)/images/*.png ; do \
$(INSTALL_DATA) $$file $(DESTDIR)$(gnumeric_helpdir)/images;\
done
......
2000-11-12 Jody Goldberg <jgoldberg@home.com>
* Makefile.am : remove the gif files.
2000-11-02 Almer S. Tigelaar <almer1@dds.nl>
Fix bug #29305 and #29308
......
......@@ -227,6 +227,7 @@ GNUMERIC_BASE_SOURCES = \
workbook-view.c \
workbook-view.h \
workbook-control.c \
workbook-control.h \
workbook-control-priv.h \
workbook-control-gui.c \
workbook-control-gui.h \
......
......@@ -790,23 +790,12 @@ sheet_update (Sheet const *sheet)
}
if (sheet->priv->edit_pos.format_changed) {
MStyle *mstyle;
sheet->priv->edit_pos.format_changed = FALSE;
mstyle = sheet_style_compute (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
WORKBOOK_FOREACH_VIEW (sheet->workbook, view,
{
if (wb_view_cur_sheet (view) == sheet) {
WORKBOOK_VIEW_FOREACH_CONTROL(view, control,
wb_control_format_feedback (control, mstyle););
}
if (wb_view_cur_sheet (view) == sheet)
wb_view_format_feedback (view, TRUE);
});
mstyle_unref (mstyle);
}
if (sheet->priv->edit_pos.location_changed) {
......@@ -827,7 +816,7 @@ sheet_update (Sheet const *sheet)
WORKBOOK_FOREACH_VIEW (sheet->workbook, view,
{
if (wb_view_cur_sheet (view) == sheet)
wb_view_auto_expr_recalc (view);
wb_view_auto_expr_recalc (view, TRUE);
});
}
}
......
......@@ -207,9 +207,9 @@ wbcg_progress_set (WorkbookControl *wbc, gfloat val)
}
static void
wbcg_format_feedback (WorkbookControl *wbc, MStyle *style)
wbcg_format_feedback (WorkbookControl *wbc)
{
workbook_feedback_set ((WorkbookControlGUI *)wbc, style);
workbook_feedback_set ((WorkbookControlGUI *)wbc);
}
static void
......@@ -636,18 +636,21 @@ cb_change_zoom (GtkWidget *caller, WorkbookControlGUI *wbcg)
}
static void
wbcg_auto_expr_value (WorkbookControl *wbc, char const *text)
wbcg_auto_expr_value (WorkbookControl *wbc)
{
WorkbookControlGUI *wbcg = (WorkbookControlGUI *)wbc;
WorkbookView *wbv = wb_control_view (wbc);
char *res;
g_return_if_fail (wbc != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (wbcg != NULL);
g_return_if_fail (wbv != NULL);
g_return_if_fail (wbv->auto_expr_value_as_string != NULL);
g_return_if_fail (!wbcg->updating_ui);
res = g_strconcat (wbv->auto_expr_desc->str, "=", text, NULL);
gnome_canvas_item_set (wbcg->auto_expr_label, "text", res, NULL);
g_free (res);
wbcg->updating_ui = TRUE;
gnome_canvas_item_set (wbcg->auto_expr_label,
"text", wbv->auto_expr_value_as_string,
NULL);
wbcg->updating_ui = FALSE;
}
static GtkComboStack *
......@@ -2750,14 +2753,13 @@ setup_progress_bar (WorkbookControlGUI *wbcg)
static void
cb_auto_expr_changed (GtkWidget *item, WorkbookControlGUI *wbcg)
{
g_return_if_fail (!wbcg->updating_ui);
if (wbcg->updating_ui)
return;
wbcg->updating_ui = TRUE;
wb_view_auto_expr (
wb_control_view (WORKBOOK_CONTROL (wbcg)),
gtk_object_get_data (GTK_OBJECT (item), "name"),
gtk_object_get_data (GTK_OBJECT (item), "expr"));
wbcg->updating_ui = FALSE;
}
static void
......
......@@ -2,6 +2,7 @@
#define GNUMERIC_WORKBOOK_CONTROL_PRIV_H
#include "command-context-priv.h"
#include "workbook-control.h"
struct _WorkbookControl {
CommandContext context;
......@@ -18,11 +19,11 @@ typedef struct {
void (*title_set) (WorkbookControl *wbc, char const *title);
void (*prefs_update) (WorkbookControl *wbc);
void (*progress_set) (WorkbookControl *wbc, gfloat val);
void (*format_feedback) (WorkbookControl *wbc, MStyle *style);
void (*format_feedback) (WorkbookControl *wbc);
void (*zoom_feedback) (WorkbookControl *wbc);
void (*edit_line_set) (WorkbookControl *wbc, char const *text);
void (*selection_descr_set) (WorkbookControl *wbc, char const *text);
void (*auto_expr_value) (WorkbookControl *wbc, char const *value);
void (*auto_expr_value) (WorkbookControl *wbc);
struct {
void (*add) (WorkbookControl *wbc, Sheet *sheet);
void (*remove) (WorkbookControl *wbc, Sheet *sheet);
......
......@@ -63,30 +63,26 @@ WBC_VIRTUAL (prefs_update,
(WorkbookControl *wbc), (wbc))
WBC_VIRTUAL (progress_set,
(WorkbookControl *wbc, gfloat val), (wbc, val))
WBC_VIRTUAL (format_feedback,
(WorkbookControl *wbc, MStyle *style), (wbc, style))
WBC_VIRTUAL (format_feedback, (WorkbookControl *wbc), (wbc))
WBC_VIRTUAL (zoom_feedback,
(WorkbookControl *wbc), (wbc))
(WorkbookControl *wbc), (wbc))
WBC_VIRTUAL (edit_line_set,
(WorkbookControl *wbc, char const *text), (wbc, text))
(WorkbookControl *wbc, char const *text), (wbc, text))
WBC_VIRTUAL (selection_descr_set,
(WorkbookControl *wbc, char const *text), (wbc, text))
WBC_VIRTUAL (auto_expr_value,
(WorkbookControl *wbc, char const *value), (wbc, value))
(WorkbookControl *wbc, char const *text), (wbc, text))
WBC_VIRTUAL (auto_expr_value, (WorkbookControl *wbc), (wbc))
WBC_VIRTUAL_FULL (sheet_add, sheet.add,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_remove, sheet.remove,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_rename, sheet.rename,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_focus, sheet.focus,
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
(WorkbookControl *wbc, Sheet *sheet), (wbc, sheet))
WBC_VIRTUAL_FULL (sheet_move, sheet.move,
(WorkbookControl *wbc, Sheet *sheet, int new_pos),
(wbc, sheet, new_pos))
(WorkbookControl *wbc, Sheet *sheet, int new_pos),
(wbc, sheet, new_pos))
WBC_VIRTUAL_FULL (sheet_remove_all, sheet.remove_all,
(WorkbookControl *wbc), (wbc))
(WorkbookControl *wbc), (wbc))
WBC_VIRTUAL_FULL (undo_redo_clear, undo_redo.clear,
(WorkbookControl *wbc, gboolean is_undo), (wbc, is_undo))
......@@ -105,6 +101,27 @@ WBC_VIRTUAL_FULL (paste_from_selection, paste.from_selection,
(WorkbookControl *wbc, PasteTarget const *pt, guint32 time),
(wbc, pt, time))
void
wb_control_sheet_add (WorkbookControl *wbc, Sheet *new_sheet)
{
WorkbookControlClass *wbc_class;
g_return_if_fail (IS_WORKBOOK_CONTROL (wbc));
wbc_class = WBC_CLASS (wbc);
if (wbc_class != NULL && wbc_class->sheet.add != NULL) {
wbc_class->sheet.add (wbc, new_sheet);
/* If this is the current sheet init the display */
if (new_sheet == wb_control_cur_sheet (wbc)) {
wb_control_sheet_focus (wbc, new_sheet);
wb_control_auto_expr_value (wbc);
wb_control_format_feedback (wbc);
}
}
}
gboolean
wb_control_claim_selection (WorkbookControl *wbc)
{
......@@ -196,7 +213,6 @@ workbook_control_set_view (WorkbookControl *wbc,
void
workbook_control_sheets_init (WorkbookControl *wbc)
{
Sheet *cur_sheet;
GList *sheets, *ptr;
/* Add views all all existing sheets */
......@@ -204,8 +220,4 @@ workbook_control_sheets_init (WorkbookControl *wbc)
for (ptr = sheets; ptr != NULL ; ptr = ptr->next)
wb_control_sheet_add (wbc, ptr->data);
g_list_free (sheets);
cur_sheet = wb_control_cur_sheet (wbc);
if (cur_sheet != NULL)
wb_control_sheet_focus (wbc, wb_control_cur_sheet (wbc));
}
......@@ -20,11 +20,11 @@ WorkbookControl *wb_control_wrapper_new (WorkbookControl *wbc,
void wb_control_title_set (WorkbookControl *wbc, char const *title);
void wb_control_prefs_update (WorkbookControl *wbc);
void wb_control_format_feedback (WorkbookControl *wbc, MStyle *style);
void wb_control_format_feedback (WorkbookControl *wbc);
void wb_control_zoom_feedback (WorkbookControl *wbc);
void wb_control_edit_line_set (WorkbookControl *wbc, char const *text);
void wb_control_selection_descr_set (WorkbookControl *wbc, char const *text);
void wb_control_auto_expr_value (WorkbookControl *wbc, char const *value);
void wb_control_auto_expr_value (WorkbookControl *wbc);
void wb_control_sheet_add (WorkbookControl *wbc, Sheet *sheet);
void wb_control_sheet_remove (WorkbookControl *wbc, Sheet *sheet);
......
......@@ -15,6 +15,7 @@
#include "workbook-format-toolbar.h"
#include "global-gnome-font.h"
#include "workbook-control-gui-priv.h"
#include "workbook-view.h"
#include "workbook.h"
#include "application.h"
#include "commands.h"
......@@ -863,18 +864,29 @@ workbook_format_halign_feedback_set (WorkbookControlGUI *wbcg,
* Updates the edit control state: bold, italic, font name and font size
*/
void
workbook_feedback_set (WorkbookControlGUI *wbcg, MStyle *style)
workbook_feedback_set (WorkbookControlGUI *wbcg)
{
#ifndef ENABLE_BONOBO
GnumericToolbar *toolbar;
#endif
GtkComboText *fontsel = GTK_COMBO_TEXT (wbcg->font_name_selector);
GtkComboText *fontsize= GTK_COMBO_TEXT (wbcg->font_size_selector);
WorkbookView *wb_view;
MStyle *style;
GtkComboText *fontsel;
GtkComboText *fontsize;
char size_str [40];
g_return_if_fail (wbcg != NULL);
g_return_if_fail (style != NULL);
wb_view = wb_control_view (WORKBOOK_CONTROL (wbcg));
g_return_if_fail (wb_view != NULL);
style = wb_view->current_format;
g_return_if_fail (style != NULL);
fontsel = GTK_COMBO_TEXT (wbcg->font_name_selector);
fontsize= GTK_COMBO_TEXT (wbcg->font_size_selector);
#ifndef ENABLE_BONOBO
toolbar = GNUMERIC_TOOLBAR (wbcg->format_toolbar);
g_return_if_fail (toolbar);
......
......@@ -5,6 +5,6 @@
#include "workbook-control-gui.h"
void workbook_create_format_toolbar (WorkbookControlGUI *wbcg);
void workbook_feedback_set (WorkbookControlGUI *wbc, MStyle *style);
void workbook_feedback_set (WorkbookControlGUI *wbc);
#endif /* GNUMERIC_WORKBOOK_FORMAT_TOOLBAR_H */
......@@ -6,7 +6,6 @@
*/
#include <config.h>
#include "workbook-control-priv.h"
#include "workbook-control.h"
#include "workbook-view.h"
#include "workbook.h"
#include "history.h"
......@@ -18,6 +17,7 @@
#include "format.h"
#include "expr.h"
#include "value.h"
#include "mstyle.h"
#include "position.h"
#include "parse-util.h"
#include "gnumeric-type-util.h"
......@@ -75,6 +75,21 @@ wb_view_sheet_focus (WorkbookView *wbv, Sheet *sheet)
}
}
void
wb_view_sheet_add (WorkbookView *wbv, Sheet *new_sheet)
{
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
if (wbv->current_sheet == NULL) {
wbv->current_sheet = new_sheet;
wb_view_auto_expr_recalc (wbv, FALSE);
wb_view_format_feedback (wbv, FALSE);
}
WORKBOOK_VIEW_FOREACH_CONTROL (wbv, control,
wb_control_sheet_add (control, new_sheet););
}
void
wb_view_set_attributev (WorkbookView *wbv, GList *list)
{
......@@ -125,13 +140,42 @@ wb_view_prefs_update (WorkbookView *view)
}
void
wb_view_auto_expr (WorkbookView *wbv, char const *name, char const *expression)
wb_view_format_feedback (WorkbookView *wbv, gboolean display)
{
Sheet *sheet;
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
sheet = wbv->current_sheet;
if (sheet != NULL) {
MStyle *mstyle = sheet_style_compute (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
if (wbv->current_format != NULL) {
mstyle_unref (wbv->current_format);
/* Cheap anti-flicker.
* Compare pointers (content may be invalid)
* No need for an expensive compare.
*/
if (mstyle == wbv->current_format)
return;
}
wbv->current_format = mstyle;
if (display) {
WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control,
wb_control_format_feedback (control););
}
}
}
void
wb_view_auto_expr (WorkbookView *wbv, char const *descr, char const *expression)
{
char *old_num_locale, *old_monetary_locale, *old_msg_locale;
ExprTree *new_auto_expr;
ParsePos pp;
ParseErr res;
String *new_descr;
old_num_locale = g_strdup (gnumeric_setlocale (LC_NUMERIC, NULL));
gnumeric_setlocale (LC_NUMERIC, "C");
......@@ -155,43 +199,50 @@ wb_view_auto_expr (WorkbookView *wbv, char const *name, char const *expression)
gnumeric_setlocale (LC_NUMERIC, old_num_locale);
g_free (old_num_locale);
new_descr = string_get (name);
if (wbv->auto_expr_desc)
string_unref (wbv->auto_expr_desc);
g_free (wbv->auto_expr_desc);
if (wbv->auto_expr)
expr_tree_unref (wbv->auto_expr);
wbv->auto_expr_desc = new_descr;
wbv->auto_expr_desc = g_strdup (descr);
wbv->auto_expr = new_auto_expr;
if (wbv->current_sheet != NULL)
wb_view_auto_expr_recalc (wbv, TRUE);
}
static void
wb_view_auto_expr_value_set (WorkbookView *wbv, char const *str)
wb_view_auto_expr_value_display (WorkbookView *wbv)
{
WORKBOOK_VIEW_FOREACH_CONTROL (wbv, control,
wb_control_auto_expr_value (control, str););
wb_control_auto_expr_value (control););
}
void
wb_view_auto_expr_recalc (WorkbookView *wbv)
wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display)
{
static CellPos const cp = {0, 0};
EvalPos ep;
Value *v;
EvalPos ep;
Value *v;
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
g_return_if_fail (wbv->auto_expr != NULL);
v = eval_expr (eval_pos_init (&ep, wbv->current_sheet, &cp),
wbv->auto_expr, EVAL_STRICT);
if (wbv->auto_expr_value_as_string)
g_free (wbv->auto_expr_value_as_string);
if (v) {
char *s = value_get_as_string (v);
wb_view_auto_expr_value_set (wbv, s);
g_free (s);
char *val_str = value_get_as_string (v);
wbv->auto_expr_value_as_string =
g_strconcat (wbv->auto_expr_desc, "=", val_str, NULL);
value_release (v);
g_free (val_str);
} else
wb_view_auto_expr_value_set (wbv, _("Internal ERROR"));
wbv->auto_expr_value_as_string = g_strdup (_("Internal ERROR"));
wb_view_auto_expr_value_display (wbv);
}
static void
......@@ -268,14 +319,23 @@ wb_view_destroy (GtkObject *object)
{
WorkbookView *wbv = WORKBOOK_VIEW (object);
if (wbv->auto_expr_desc) {
string_unref (wbv->auto_expr_desc);
wbv->auto_expr_desc = NULL;
}
if (wbv->auto_expr) {
expr_tree_unref (wbv->auto_expr);
wbv->auto_expr = NULL;
}
if (wbv->auto_expr_desc) {
g_free (wbv->auto_expr_desc);
wbv->auto_expr_desc = NULL;
}
if (wbv->auto_expr_value_as_string) {
g_free (wbv->auto_expr_value_as_string);
wbv->auto_expr_value_as_string = NULL;
}
if (wbv->current_format != NULL) {
mstyle_unref (wbv->current_format);
wbv->current_format = NULL;
}
if (wbv->wb != NULL)
workbook_detach_view (wbv);
......@@ -302,11 +362,6 @@ workbook_view_init (WorkbookView *wbv, Workbook *optional_workbook)
wbv->show_vertical_scrollbar = TRUE;
wbv->show_notebook_tabs = TRUE;
/* Set the default operation to be performed over selections */
wbv->auto_expr = NULL;
wbv->auto_expr_desc = NULL;
wb_view_auto_expr (wbv, _("Sum"), "sum(selection(0))");
/* Guess at the current sheet */
wbv->current_sheet = NULL;
if (optional_workbook != NULL) {
......@@ -316,6 +371,14 @@ workbook_view_init (WorkbookView *wbv, Workbook *optional_workbook)
g_list_free (sheets);
}
}
/* Set the default operation to be performed over selections */
wbv->auto_expr = NULL;
wbv->auto_expr_desc = NULL;
wbv->auto_expr_value_as_string = NULL;
wb_view_auto_expr (wbv, _("Sum"), "sum(selection(0))");
wbv->current_format = NULL;
}
static void
......
......@@ -10,17 +10,23 @@ struct _WorkbookView {
Workbook *wb;
GPtrArray *wb_controls;
/* The auto-expression */
ExprTree *auto_expr;
String *auto_expr_desc;
Sheet *current_sheet;
/* preferences */
gboolean show_horizontal_scrollbar;
gboolean show_vertical_scrollbar;
gboolean show_notebook_tabs;
/* Non-normative size information */
int preferred_width, preferred_height;
/* The auto-expression */
ExprTree *auto_expr;
char *auto_expr_desc;
char *auto_expr_value_as_string;
/* Format for feedback */
MStyle *current_format;
};
typedef struct {
......@@ -30,8 +36,8 @@ typedef struct {
#define WORKBOOK_VIEW_TYPE (workbook_view_get_type ())
#define WORKBOOK_VIEW(obj) (GTK_CHECK_CAST ((obj), WORKBOOK_VIEW_TYPE, WorkbookView))
#define WORKBOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), WORKBOOK_VIEW_TYPE, WorkbookViewClass))
#define IS_WORKBOOK_VIEW(o) (GTK_CHECK_TYPE ((o), WORKBOOK_VIEW_TYPE))
#define WORKBOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), WORKBOOK_VIEW_TYPE, WorkbookViewClass))
/* Lifecycle */
GtkType workbook_view_get_type (void);
......@@ -45,6 +51,7 @@ void wb_view_detach_control (WorkbookControl *wbc);
Workbook *wb_view_workbook (WorkbookView *wbv);
Sheet *wb_view_cur_sheet (WorkbookView *wbv);
void wb_view_sheet_focus (WorkbookView *wbv, Sheet *sheet);
void wb_view_sheet_add (WorkbookView *wbv, Sheet *new_sheet);
/* Manipulation */
GtkArg *wb_view_get_attributev (WorkbookView *wbv, guint *n_args);
......@@ -52,7 +59,8 @@ void wb_view_set_attributev (WorkbookView *wbv, GList *list);
void wb_view_preferred_size (WorkbookView *wbv,
int w_pixels, int h_pixels);
void wb_view_prefs_update (WorkbookView *wbv);
void wb_view_auto_expr_recalc (WorkbookView *wbv);
void wb_view_format_feedback (WorkbookView *wbv, gboolean display);
void wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display);
void wb_view_auto_expr (WorkbookView *wbv,
char const *name, char const *expr);
......
......@@ -954,14 +954,8 @@ workbook_sheet_attach (Workbook *wb, Sheet *new_sheet,
g_hash_table_insert (wb->sheet_hash_private,
new_sheet->name_unquoted, new_sheet);
WORKBOOK_FOREACH_CONTROL (wb, view, control,
wb_control_sheet_add (control, new_sheet););
WORKBOOK_FOREACH_VIEW (wb, view,
{
if (view->current_sheet == NULL)
</