Commit dc7cfe89 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

rename from gnumeric_expr_entry_set_rangesel_from_text and make it more

2001-09-30  Jody Goldberg <jgoldberg@home.com>

	* gnumeric-expr-entry.c (gnumeric_expr_entry_set_rangesel_from_dep) :
	  rename from gnumeric_expr_entry_set_rangesel_from_text and make it
	  more applicable.  This gives us easier access to the parsed
	  expression.
	(gnumeric_expr_entry_key_press_event) : Alt-Enter should be supported
	  in all entries, but only the main entry should get ctrl-enter
	  support.
2001-10-01  Jody Goldberg <jgoldberg@home.com>

	* dialog-graph-guru.c (vector_state_fill) : Use
	  gnumeric_expr_entry_clear, gnumeric_expr_entry_set_rangesel_from_dep.
	(cb_graph_guru_entry_changed) : flag changes.
	(vector_state_new) : init the new flags and connect he changed signal,
	  and the gtk_object_data.
	(vector_state_destroy) : clear the stored vector.
	(graph_guru_init_data_page) : disable the debug spew.
	(cb_graph_guru_focus) : use window::set_focus in place of
	  focus-{in,out} for each entry.  This is still a stub.
	(graph_guru_init) : connect cb_graph_guru_focus.
2001-09-30  Jody Goldberg <jgoldberg@home.com>

	* src/sheet-object-widget.c (sheet_widget_checkbox_user_config) : Use
	  gnumeric_expr_entry_set_rangesel_from_dep.
parent 30ddd928
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config) : Use
gnumeric_expr_entry_set_rangesel_from_dep.
2001-10-01 Zbigniew Chyla <cyba@gnome.pl>
* src/xml-io.c (xml_probe): Accept .gnumeric, .xml, .xml.gz not
......
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config) : Use
gnumeric_expr_entry_set_rangesel_from_dep.
2001-10-01 Zbigniew Chyla <cyba@gnome.pl>
* src/xml-io.c (xml_probe): Accept .gnumeric, .xml, .xml.gz not
......
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config) : Use
gnumeric_expr_entry_set_rangesel_from_dep.
2001-10-01 Zbigniew Chyla <cyba@gnome.pl>
* src/xml-io.c (xml_probe): Accept .gnumeric, .xml, .xml.gz not
......
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config) : Use
gnumeric_expr_entry_set_rangesel_from_dep.
2001-10-01 Zbigniew Chyla <cyba@gnome.pl>
* src/xml-io.c (xml_probe): Accept .gnumeric, .xml, .xml.gz not
......
2001-10-01 Jody Goldberg <jgoldberg@home.com>
* dialog-graph-guru.c (vector_state_fill) : Use
gnumeric_expr_entry_clear, gnumeric_expr_entry_set_rangesel_from_dep.
(cb_graph_guru_entry_changed) : flag changes.
(vector_state_new) : init the new flags and connect he changed signal,
and the gtk_object_data.
(vector_state_destroy) : clear the stored vector.
(graph_guru_init_data_page) : disable the debug spew.
(cb_graph_guru_focus) : use window::set_focus in place of
focus-{in,out} for each entry. This is still a stub.
(graph_guru_init) : connect cb_graph_guru_focus.
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* dialog-graph-guru.c (vector_state_fill) : Use gnm_graph_series_get_dimension.
......
......@@ -44,6 +44,8 @@ typedef struct
xmlChar *element;
int index;
gboolean is_optional, is_shared;
gboolean changed;
GnmGraphVector *vector;
GtkWidget *name_label;
GnumericExprEntry *entry;
......@@ -82,6 +84,7 @@ struct _GraphGuruState
int current_page, initial_page;
gboolean valid;
gboolean updating;
VectorState *current_vector;
gboolean is_columns;
xmlDoc *xml_doc;
......@@ -114,7 +117,7 @@ vector_state_fill (VectorState *vs, xmlNode *series)
/* clear beforehand to make error handling simpler */
vs->state->updating = TRUE;
gnumeric_expr_entry_set_rangesel_from_text (vs->entry,"");
gnumeric_expr_entry_clear (vs->entry);
gnumeric_expr_entry_set_flags (vs->entry,
GNUM_EE_ABS_COL|GNUM_EE_ABS_ROW, GNUM_EE_MASK);
vs->state->updating = FALSE;
......@@ -123,15 +126,15 @@ vector_state_fill (VectorState *vs, xmlNode *series)
if (dim != NULL) {
id = e_xml_get_integer_prop_by_name_with_default (dim, "ID", -1);
if (id >= 0) {
char *content = gnm_graph_vector_as_string (
gnm_graph_get_vector (vs->state->graph, id));
gnumeric_expr_entry_set_rangesel_from_text (
vs->entry, content);
vs->vector = gnm_graph_get_vector (vs->state->graph, id);
gnumeric_expr_entry_set_rangesel_from_dep (
vs->entry,
gnm_graph_vector_get_dependent (vs->vector));
gnumeric_expr_entry_set_flags (vs->entry,
GNUM_EE_ABS_COL|GNUM_EE_ABS_ROW, GNUM_EE_MASK);
g_free (content);
}
}
} else
vs->vector = NULL;
}
static void
......@@ -158,11 +161,11 @@ vector_state_init (VectorState *vs, xmlNode *descriptor)
gtk_widget_show (GTK_WIDGET (vs->entry));
}
static gboolean
cb_graph_guru_entry_focus_in (GtkWidget *ignored0, GdkEventFocus *ignored1, VectorState *vs)
static void
cb_graph_guru_entry_changed (GtkEditable *editable, VectorState *vs)
{
wbcg_set_entry (vs->state->wbcg, vs->entry);
return FALSE;
if (!vs->state->updating)
vs->changed = TRUE;
}
static VectorState *
......@@ -177,6 +180,8 @@ vector_state_new (GraphGuruState *state, gboolean shared, int indx)
vs->index = indx;
vs->element = NULL;
vs->is_shared = shared;
vs->changed = FALSE;
vs->vector = NULL;
table = GTK_TABLE (shared
? state->shared_series_details
......@@ -194,10 +199,11 @@ vector_state_new (GraphGuruState *state, gboolean shared, int indx)
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_EDITABLE (vs->entry));
/* FIXME : Do I really need focus-in ? is there something less draconian */
/* flag when things change so we'll know if we need to update the vector */
gtk_signal_connect (GTK_OBJECT (vs->entry),
"focus-in-event",
GTK_SIGNAL_FUNC (cb_graph_guru_entry_focus_in), vs);
"changed",
GTK_SIGNAL_FUNC (cb_graph_guru_entry_changed), vs);
gtk_object_set_data (GTK_OBJECT (vs->entry), "VectorState", vs);
return vs;
}
......@@ -205,6 +211,7 @@ vector_state_new (GraphGuruState *state, gboolean shared, int indx)
static void
vector_state_destroy (VectorState *vs, gboolean destroywidgets)
{
vs->vector = NULL;
if (vs->element) {
xmlFree (vs->element);
vs->element = NULL;
......@@ -437,7 +444,9 @@ graph_guru_init_data_page (GraphGuruState *s)
xmlNode *plot;
g_return_if_fail (s->xml_doc != NULL);
#if 0
xmlDocDump (stdout, s->xml_doc);
#endif
graph_guru_clear_sample (s);
......@@ -549,12 +558,10 @@ cb_series_entry_activate (GtkWidget *caller, GraphGuruState *state)
{
if (state->updating)
return;
puts (gtk_entry_get_text (GTK_ENTRY (caller)));
}
static void
cb_series_list_select (GtkWidget *list, GtkWidget *child, gpointer data)
{
puts ("foo");
}
static void
......@@ -562,12 +569,10 @@ cb_plot_entry_activate (GtkWidget *caller, GraphGuruState *state)
{
if (state->updating)
return;
puts (gtk_entry_get_text (GTK_ENTRY (caller)));
}
static void
cb_plot_list_select (GtkWidget *list, GtkWidget *child, gpointer data)
{
puts ("bar");
}
static GtkWidget *
......@@ -589,6 +594,42 @@ graph_guru_selector_init (GraphGuruState *s, char const *name, int i,
return w;
}
static void
cb_graph_guru_focus (GtkWindow *window, GtkWidget *focus, GraphGuruState *state)
{
VectorState *vs = state->current_vector;
if (vs != NULL && vs->changed) {
char const *str = gtk_entry_get_text (GTK_ENTRY (vs->entry));
state->current_vector = NULL;
vs->changed = FALSE;
printf ("parse (%s): %s\n", vs->element, str);
/* Are we adding a dimension that was not there previously ? */
if (*str) {
if (vs->vector != NULL) {
puts ("changing an existing");
} else {
puts ("Adding a new dimension");
}
} else if (vs->vector != NULL) {
puts ("removing an existing (check optional)");
} else {
puts ("should not happen");
}
}
if (focus != NULL) {
vs = gtk_object_get_data (GTK_OBJECT (focus), "VectorState");
if (vs != NULL) {
state->current_vector = vs;
vs->changed = FALSE;
wbcg_set_entry (vs->state->wbcg, vs->entry);
}
}
}
static gboolean
graph_guru_init (GraphGuruState *s)
{
......@@ -630,6 +671,9 @@ graph_guru_init (GraphGuruState *s)
gtk_signal_connect (GTK_OBJECT (s->dialog),
"key_press_event",
GTK_SIGNAL_FUNC (cb_graph_guru_key_press), s);
gtk_signal_connect (GTK_OBJECT (s->dialog),
"set-focus",
GTK_SIGNAL_FUNC (cb_graph_guru_focus), s);
return FALSE;
}
......@@ -665,6 +709,7 @@ dialog_graph_guru (WorkbookControlGUI *wbcg, GnmGraph *graph, int page)
state->current_page = -1;
state->current_plot = NULL;
state->current_series = NULL;
state->current_vector = NULL;
if (graph != NULL) {
g_return_if_fail (IS_GNUMERIC_GRAPH (graph));
......
......@@ -331,20 +331,17 @@ impl_string_vector_changed (PortableServer_Servant servant,
g_warning ("Gnumeric : string vector changed remotely (%p)", vector);
}
char *
gnm_graph_vector_as_string (GnmGraphVector const *vector)
void
gnm_graph_vector_from_string (GnmGraphVector const *vec, char const *str)
{
ParsePos pp;
g_return_val_if_fail (IS_GNUMERIC_GRAPH_VECTOR (vector), g_strdup ("ERROR"));
return expr_tree_as_string (vector->dep.expression,
parse_pos_init_dep (&pp, &vector->dep));
}
void
gnm_graph_vector_from_string (GnmGraphVector const *vec, char * str)
Dependent const *
gnm_graph_vector_get_dependent (GnmGraphVector const *vec)
{
g_return_val_if_fail (IS_GNUMERIC_GRAPH_VECTOR (vec), NULL);
return &vec->dep;
}
/******************************************************************************/
......
......@@ -39,8 +39,9 @@ extern char const * const gnm_graph_vector_type_name [];
#define IS_GNUMERIC_GRAPH_VECTOR(o) (GTK_CHECK_TYPE ((o), GNUMERIC_GRAPH_VECTOR_TYPE))
GtkType gnm_graph_vector_get_type (void);
char *gnm_graph_vector_as_string (GnmGraphVector const *vec);
void gnm_graph_vector_from_string (GnmGraphVector const *vec, char *);
Dependent const *gnm_graph_vector_get_dependent (GnmGraphVector const *v);
void gnm_graph_vector_from_string (GnmGraphVector const *v,
char const *str);
/* Some xml utilities */
xmlNode *gnm_graph_series_get_dimension (xmlNode *series, xmlChar const *element);
......
......@@ -820,14 +820,8 @@ sheet_widget_checkbox_user_config (SheetObject *so, SheetControlGUI *scg)
NULL);
state->expresion = gnumeric_expr_entry_new (wbcg);
gnumeric_expr_entry_set_scg (GNUMERIC_EXPR_ENTRY (state->expresion), scg);
if (swc->dep.expression != NULL) {
ParsePos pp;
char *text = expr_tree_as_string (swc->dep.expression,
parse_pos_init (&pp, NULL, so->sheet, 0, 0));
gnumeric_expr_entry_set_rangesel_from_text (
GNUMERIC_EXPR_ENTRY (state->expresion), text);
g_free (text);
}
gnumeric_expr_entry_set_rangesel_from_dep (
GNUMERIC_EXPR_ENTRY (state->expresion), &swc->dep);
state->label = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (state->label), swc->label);
......
2001-09-30 Jody Goldberg <jgoldberg@home.com>
* gnumeric-expr-entry.c (gnumeric_expr_entry_set_rangesel_from_dep) :
rename from gnumeric_expr_entry_set_rangesel_from_text and make it
more applicable. This gives us easier access to the parsed
expression.
(gnumeric_expr_entry_key_press_event) : Alt-Enter should be supported
in all entries, but only the main entry should get ctrl-enter
support.
2001-09-28 Jody Goldberg <jgoldberg@home.com>
* Makefile.am (libwidgets_a_SOURCES) : temporarily move gal's
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gnumeric-expr-entry.c: An entry widget specialized to handle expressions
* and ranges.
......@@ -8,16 +10,18 @@
#include <config.h>
#include "gnumeric-expr-entry.h"
#include "workbook-edit.h"
#include "workbook-control-gui-priv.h"
#include "sheet-control-gui.h"
#include "sheet-merge.h"
#include "parse-util.h"
#include "gui-util.h"
#include "ranges.h"
#include "value.h"
#include "sheet.h"
#include "commands.h"
#include <workbook-edit.h>
#include <workbook-control-gui-priv.h>
#include <sheet-control-gui.h>
#include <sheet-merge.h>
#include <parse-util.h>
#include <gui-util.h>
#include <ranges.h>
#include <value.h>
#include <expr.h>
#include <eval.h>
#include <sheet.h>
#include <commands.h>
#include <gal/util/e-util.h>
#include <gtk/gtkentry.h>
......@@ -167,15 +171,16 @@ gnumeric_expr_entry_key_press_event (GtkWidget *widget, GdkEventKey *event)
case GDK_KP_Enter:
case GDK_Return:
if (!wb_control_gui_is_editing (wbcg))
break;
/* Is this the right way to append a newline ?? */
if (state == GDK_MOD1_MASK) {
gtk_entry_append_text (entry, "\n");
return TRUE;
}
/* Ctrl-enter is only applicable for the main entry */
if (!wb_control_gui_is_editing (wbcg))
break;
if (state == GDK_CONTROL_MASK ||
state == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
EvalPos pos;
......@@ -357,9 +362,26 @@ gnumeric_expr_entry_set_scg (GnumericExprEntry *expr_entry,
}
/**
* gnumeric_expr_entry_set_rangesel_from_text
* gnumeric_expr_entry_clear :
* @gee : The expr_entry
*
* Clear flags and entry.
*/
void
gnumeric_expr_entry_clear (GnumericExprEntry *expr_entry)
{
g_return_if_fail (IS_GNUMERIC_EXPR_ENTRY (expr_entry));
/* We have nowhere to store the text while frozen. */
g_return_if_fail (expr_entry->freeze_count == 0);
reset_rangesel (expr_entry);
gtk_entry_set_text (GTK_ENTRY (expr_entry), "");
}
/**
* gnumeric_expr_entry_set_rangesel_from_dep
* @expr_entry: a #GnumericExprEntry
* @text: a string
* @dep: A dependent
*
* Sets the text of the entry, and removes saved information about earlier
* range selections.
......@@ -368,18 +390,25 @@ gnumeric_expr_entry_set_scg (GnumericExprEntry *expr_entry,
gnumeric_expr_entry_set_rangesel_from_range?
Should it parse the rangesel? */
void
gnumeric_expr_entry_set_rangesel_from_text (GnumericExprEntry *expr_entry,
char *text)
gnumeric_expr_entry_set_rangesel_from_dep (GnumericExprEntry *expr_entry,
Dependent const *dep)
{
g_return_if_fail (IS_GNUMERIC_EXPR_ENTRY (expr_entry));
g_return_if_fail (text != NULL);
g_return_if_fail (dep != NULL);
/* We have nowhere to store the text while frozen. */
g_return_if_fail (expr_entry->freeze_count == 0);
reset_rangesel (expr_entry);
if (dep->expression != NULL) {
ParsePos pp;
char *text = expr_tree_as_string (dep->expression,
parse_pos_init_dep (&pp, dep));
gtk_entry_set_text (GTK_ENTRY (expr_entry), text);
expr_entry->rangesel.text_end = strlen (text);
reset_rangesel (expr_entry);
gtk_entry_set_text (GTK_ENTRY (expr_entry), text);
expr_entry->rangesel.text_end = strlen (text);
g_free (text);
} else
gnumeric_expr_entry_clear (expr_entry);
}
static void
......
......@@ -39,8 +39,9 @@ void gnumeric_expr_entry_get_rangesel (GnumericExprEntry *expr_entry,
void gnumeric_expr_entry_rangesel_stopped (GnumericExprEntry *expr_entry,
gboolean clear_string);
void gnumeric_expr_entry_set_rangesel_from_text (GnumericExprEntry *expr_entry,
char *text);
void gnumeric_expr_entry_clear (GnumericExprEntry *gee);
void gnumeric_expr_entry_set_rangesel_from_dep (GnumericExprEntry *gee,
Dependent const *dep);
gboolean gnumeric_expr_entry_set_rangesel_from_range (GnumericExprEntry *expr_entry,
Range const *r, Sheet *sheet, int pos);
......
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