Commit e2a98475 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New function.

2005-03-28  Morten Welinder  <terra@gnome.org>

	* src/workbook-view.c (wb_view_auto_expr_precision): New function.

	* src/workbook-control-gui.c (cb_auto_expr_precision_toggled): New
	function.
	(cb_select_auto_expr): Add a check item to control whether maximum
	precision is used.
parent a0b972c8
2005-03-28 Morten Welinder <terra@gnome.org>
* src/workbook-view.c (wb_view_auto_expr_precision): New function.
* src/workbook-control-gui.c (cb_auto_expr_precision_toggled): New
function.
(cb_select_auto_expr): Add a check item to control whether maximum
precision is used.
2005-03-28 Jon K Hellan <hellan@acm.org>
* src/clipboard.[ch]: (clipboard_copy_obj): New. Returns a cell
......
......@@ -61,6 +61,7 @@ Morten:
tons of autogenerated strings and things need to settle down
a bit first.
* Fix modality issue causing crashes. [#170958]
* Use a better format for auto expressions.
--------------------------------------------------------------------------
Gnumeric 1.5.0
......
2005-03-28 Morten Welinder <terra@gnome.org>
* src/workbook-view.c (wb_view_auto_expr_precision): New function.
* src/workbook-control-gui.c (cb_auto_expr_precision_toggled): New
function.
(cb_select_auto_expr): Add a check item to control whether maximum
precision is used.
2005-03-28 Jon K Hellan <hellan@acm.org>
* src/clipboard.[ch]: (clipboard_copy_obj): New. Returns a cell
......
......@@ -79,6 +79,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkseparatormenuitem.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
......@@ -1837,8 +1838,18 @@ cb_auto_expr_changed (GtkWidget *item, WorkbookControlGUI *wbcg)
g_object_get_data (G_OBJECT (item), "expr"));
}
static void
cb_auto_expr_precision_toggled (GtkWidget *item, WorkbookControlGUI *wbcg)
{
WorkbookView *wbv = wb_control_view (WORKBOOK_CONTROL (wbcg));
if (wbcg->updating_ui)
return;
wb_view_auto_expr_precision (wbv, !wbv->auto_expr_use_max_precision);
}
static gboolean
cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, Workbook *wbcg)
cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, WorkbookControlGUI *wbcg)
{
/*
* WARNING * WARNING * WARNING
......@@ -1867,7 +1878,6 @@ cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, Workbook *wbcg)
};
GtkWidget *menu;
GtkWidget *item;
int i;
if (event->button != 3)
......@@ -1879,6 +1889,7 @@ cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, Workbook *wbcg)
GnmParsePos pp;
const char *expr = quick_compute_routines [i].function;
const GnmExpr *new_auto_expr;
GtkWidget *item;
/* Test the expression... */
parse_pos_init (&pp, wb_control_workbook (WORKBOOK_CONTROL (wbcg)), NULL, 0, 0);
......@@ -1899,6 +1910,25 @@ cb_select_auto_expr (GtkWidget *widget, GdkEventButton *event, Workbook *wbcg)
gtk_widget_show (item);
}
{
GtkWidget *item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
{
GtkWidget *item = gtk_check_menu_item_new_with_label
(_("Use maximum precision"));
WorkbookView *wbv = wb_control_view (WORKBOOK_CONTROL (wbcg));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
wbv->auto_expr_use_max_precision);
g_signal_connect (G_OBJECT (item),
"activate",
G_CALLBACK (cb_auto_expr_precision_toggled), wbcg);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}
gnumeric_popup_menu (GTK_MENU (menu), event);
return TRUE;
}
......
......@@ -363,6 +363,20 @@ wb_view_auto_expr (WorkbookView *wbv, char const *descr, char const *func_name)
wb_view_auto_expr_recalc (wbv, TRUE);
}
void
wb_view_auto_expr_precision (WorkbookView *wbv, gboolean use_max_precision)
{
use_max_precision = !!use_max_precision;
if (wbv->auto_expr_use_max_precision == use_max_precision)
return;
wbv->auto_expr_use_max_precision = use_max_precision;
if (wbv->current_sheet != NULL)
wb_view_auto_expr_recalc (wbv, TRUE);
}
static void
wb_view_auto_expr_value_display (WorkbookView *wbv)
{
......@@ -395,7 +409,6 @@ wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display)
GnmExprList *selection = NULL;
GnmValue *v;
SheetView *sv;
gboolean no_auto_expr_format = FALSE; /* FIXME */
g_return_if_fail (IS_WORKBOOK_VIEW (wbv));
g_return_if_fail (wbv->auto_expr != NULL);
......@@ -419,7 +432,7 @@ wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display)
GOFormat *tmp_format = NULL;
g_string_append_c (str, '=');
if (!no_auto_expr_format) {
if (!wbv->auto_expr_use_max_precision) {
format = VALUE_FMT (v);
if (!format) {
const GnmExpr *fcall =
......@@ -565,6 +578,7 @@ workbook_view_new (Workbook *wb)
wbv->auto_expr = NULL;
wbv->auto_expr_desc = NULL;
wbv->auto_expr_value_as_string = NULL;
wbv->auto_expr_use_max_precision = FALSE;
wb_view_auto_expr (wbv, _("Sum"), "sum");
wbv->current_format = NULL;
......
......@@ -28,6 +28,7 @@ struct _WorkbookView {
GnmExpr const *auto_expr;
char *auto_expr_desc;
char *auto_expr_value_as_string;
gboolean auto_expr_use_max_precision;
/* selection */
char *selection_description;
......@@ -76,6 +77,8 @@ void wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display);
void wb_view_auto_expr (WorkbookView *wbv,
char const *name,
char const *func_name);
void wb_view_auto_expr_precision (WorkbookView *wbv,
gboolean use_max_precision);
/* I/O routines */
gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment