dialog-define-names.c 15.7 KB
Newer Older
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
Jody Goldberg's avatar
Jody Goldberg committed
2 3 4
/* vim: set sw=8: */
/*
 * dialog-define-name.c: Edit named regions.
Miguel de Icaza's avatar
Miguel de Icaza committed
5 6
 *
 * Author:
7
 * 	Jody Goldberg <jgoldberg@home.com>
Jody Goldberg's avatar
Jody Goldberg committed
8
 *	Michael Meeks <michael@imaginator.com>
9
 *	Chema Celorio <chema@celorio.com>
Jody Goldberg's avatar
Jody Goldberg committed
10
 */
Miguel de Icaza's avatar
Miguel de Icaza committed
11 12
#include <config.h>
#include <gnome.h>
Michael Meeks's avatar
Michael Meeks committed
13
#include <glade/glade.h>
Miguel de Icaza's avatar
Miguel de Icaza committed
14
#include "dialogs.h"
15
#include "expr.h"
16
#include "str.h"
17
#include "expr-name.h"
Jody Goldberg's avatar
Jody Goldberg committed
18
#include "sheet.h"
19
#include "workbook.h"
20
#include "workbook-control.h"
21
#include "workbook-edit.h"
22
#include "gnumeric-util.h"
Miguel de Icaza's avatar
Miguel de Icaza committed
23

24 25
#define LIST_KEY "name_list_data"

26 27 28 29 30
typedef enum {
	NAME_GURU_SCOPE_SHEET,
	NAME_GURU_SCOPE_WORKBOOK,
} NameGuruScope;

Michael Meeks's avatar
Michael Meeks committed
31 32
typedef struct {
	GladeXML  *gui;
33
	GtkWidget *dialog;
34 35 36
	GtkList   *list;
	GtkEntry  *name;
	GtkEntry  *value;
37
	GtkCombo  *scope;
Michael Meeks's avatar
Michael Meeks committed
38
	GList     *expr_names;
39
	NamedExpression *cur_name;
Jody Goldberg's avatar
Jody Goldberg committed
40

41 42 43 44
	GtkWidget *ok_button;
	GtkWidget *add_button;
	GtkWidget *close_button;
	GtkWidget *delete_button;
45
	GtkWidget *update_button;
46

47
	Sheet	  *sheet;
48 49
	Workbook  *wb;
	WorkbookControlGUI  *wbcg;
50 51

	gboolean updating;
52
} NameGuruState;
Michael Meeks's avatar
Michael Meeks committed
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110


/**
 * name_guru_warned_if_used:
 * @state: 
 * 
 * If the expresion that is about to be deleted is beeing used,
 * warn the user about it. Ask if we should procede or not
 * 
 * Return Value: TRUE if users confirms deletion, FALSE otherwise
 **/
static gboolean
name_guru_warn (NameGuruState *state)
{
	static gboolean warned = FALSE;
	if (!warned)
		g_warning ("Implement me !. name_guru_warned_if_used\n");
	warned = TRUE;

	return TRUE;
}

/**
 * name_guru_scope_change:
 * @state: 
 * @scope: 
 * 
 * Change the scope of state->cur_name. Ask the user if we want to procede with the 
 * change if we are going to invalidate expressions in the sheet.
 *
 * Return Value: FALSE, if the user cancels the scope change
 **/
static gboolean
name_guru_scope_change (NameGuruState *state, NameGuruScope scope)
{
	NamedExpression *expression;

	g_return_val_if_fail (state != NULL, FALSE);
	expression = state->cur_name;
	if (expression == NULL)
		return TRUE;
	
	/* get the current values for the expression */
	if (scope == NAME_GURU_SCOPE_WORKBOOK) {
		expr_name_sheet2wb (expression);
	}

	if (scope == NAME_GURU_SCOPE_SHEET) {
		if (!name_guru_warn (state))
			return FALSE;
		
		expr_name_wb2sheet (expression, state->sheet);
	}
	
	return TRUE;
}
			
111 112 113
static void
cb_scope_changed (GtkEntry *entry, NameGuruState *state)
{
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
	NamedExpression *expression;

	if (state->updating)
		return;

	expression = state->cur_name;
	if (expression == NULL)
		return;

	if (!name_guru_scope_change (state,
				     (expression->sheet == NULL) ?
				     NAME_GURU_SCOPE_SHEET :
				     NAME_GURU_SCOPE_WORKBOOK))
		g_print ("Here we toggle the scope back to what it was\n"
			 "The user cancelled the scope change.\n");
	    
130 131 132 133 134
}

static void
name_guru_init_scope (NameGuruState *state)
{
135
	NamedExpression *expression;
136 137
	GList *list = NULL;

138 139 140
	expression  = state->cur_name;
	if (expression != NULL && expression->wb) {
		list = g_list_prepend (list, state->sheet->name_unquoted);
141 142 143
		list = g_list_prepend (list, _("Workbook"));
	} else {
		list = g_list_prepend (list, _("Workbook"));
144
		list = g_list_prepend (list, state->sheet->name_unquoted);
145 146 147
	}

	state->cur_name = NULL;
148
	state->updating = TRUE;
149 150
	gtk_combo_set_popdown_strings (state->scope, list);
	g_list_free (list);
151 152
	state->updating = FALSE;
	state->cur_name = expression;
153 154
}

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312

static void cb_name_guru_select_name (GtkWidget *list, NameGuruState *state);

/**
 * name_guru_set_expr:
 * @state: 
 * @expr_name: Expression to set in the entries, NULL to clear entries
 * 
 * Set the entries in the dialog from an NamedExpression
 **/
static void
name_guru_set_expr (NameGuruState *state, NamedExpression *expr_name)
{
	gchar *txt;

	g_return_if_fail (state != NULL);

	/* don't recurse */
	state->updating = TRUE;
					      
	if (expr_name) {
		/* Display the name */
		gtk_entry_set_text (state->name, expr_name->name->str);

		/* Display the value */
		txt = expr_name_value (expr_name);
		gtk_entry_set_text (state->value, txt);
		g_free (txt);
	} else {
		gtk_entry_set_text (state->name, "");
		gtk_entry_set_text (state->value, "");
	}

	/* unblock them */
	state->updating = FALSE;

	/* Init the scope combo box */
	name_guru_init_scope (state);

}

/**
 * name_guru_clear_selection:
 * @state: 
 * 
 * Clear the selection of the gtklist
 **/
static void
name_guru_clear_selection (NameGuruState *state)
{
	g_return_if_fail (state != NULL);

	state->updating = TRUE;
	gtk_list_unselect_all (state->list);
	state->updating = FALSE;
}

/**
 * name_guru_in_list:
 * @name: 
 * @state:
 * 
 * Given a name, it searches for it inside the list of Names
 * 
 * Return Value: TRUE if name is already defined, FALSE otherwise
 **/
static gboolean
name_guru_in_list (const gchar *name, NameGuruState *state)
{
	NamedExpression *expression;
	GList *list;

	g_return_val_if_fail (name != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);

	for (list = state->expr_names; list; list = list->next) {
		expression = (NamedExpression *) list->data;
		g_return_val_if_fail (expression != NULL, FALSE);
		g_return_val_if_fail (expression->name != NULL, FALSE);
		g_return_val_if_fail (expression->name->str != NULL, FALSE);
		if (strcasecmp (name, expression->name->str) == 0) {
			return TRUE;
		}
	}

	return FALSE;
}



/**
 * name_guru_update_sensitivity:
 * @state: 
 * @update_entries: 
 * 
 * Update the dialog widgets sensitivity
 **/
static void
name_guru_update_sensitivity (NameGuruState *state, gboolean update_entries)
{
	gboolean selection;
	gboolean update;
	gboolean add;
	gboolean in_list = FALSE;
	const gchar *value;
	const gchar *name;

	g_return_if_fail (state->list != NULL);

	if (state->updating)
		return;
	
	name  = gtk_entry_get_text (state->name);
	value = gtk_entry_get_text (state->value);

	/** Add is active if :
	 *  - We have a name in the entry to add
	 *  - Either we don't have a current Name or if we have a current
	 *     name, the name is different than what we are going to add
	 **/
	add = (name != NULL &&
	       name[0] != '\0' &&
	       !(in_list = name_guru_in_list (name, state)));
	selection = (g_list_length (state->list->selection) > 0);
	update = (name && *name && !add);

	gtk_widget_set_sensitive (state->delete_button, selection && in_list);
	gtk_widget_set_sensitive (state->add_button,    add);
	gtk_widget_set_sensitive (state->update_button, update);

	if (!selection && update_entries)
		name_guru_set_expr (state, NULL);

	if (selection && !in_list)
		name_guru_clear_selection (state);
}



/**
 * name_guru_update_sensitivity_cb:
 * @dummy: 
 * @state: 
 * 
 **/
static void
name_guru_update_sensitivity_cb (GtkWidget *dummy, NameGuruState *state)
{
	name_guru_update_sensitivity (state, FALSE);
}

/**
 * cb_name_guru_select_name:
 * @list: 
 * @state: 
 * 
 * Set the expression from the selected row in the gtklist
 **/
313
static void
Jody Goldberg's avatar
Jody Goldberg committed
314
cb_name_guru_select_name (GtkWidget *list, NameGuruState *state)
315
{
Jody Goldberg's avatar
Jody Goldberg committed
316 317
	NamedExpression *expr_name;
	GList *sel = GTK_LIST(list)->selection;
318

319
	if (sel == NULL || state->updating)
320 321 322 323
		return;

	g_return_if_fail (sel->data != NULL);

Jody Goldberg's avatar
Jody Goldberg committed
324
	expr_name = gtk_object_get_data (GTK_OBJECT (sel->data), LIST_KEY);
325

326
	g_return_if_fail (expr_name != NULL);
Jody Goldberg's avatar
Jody Goldberg committed
327 328 329
	g_return_if_fail (expr_name->name != NULL);
	g_return_if_fail (expr_name->name->str != NULL);

330 331
	state->cur_name = expr_name;

332 333
	name_guru_set_expr (state, expr_name);
	name_guru_update_sensitivity (state, FALSE);
Jody Goldberg's avatar
Jody Goldberg committed
334

Michael Meeks's avatar
Michael Meeks committed
335 336
}

337

Michael Meeks's avatar
Michael Meeks committed
338
static void
Jody Goldberg's avatar
Jody Goldberg committed
339
name_guru_populate_list (NameGuruState *state)
Michael Meeks's avatar
Michael Meeks committed
340 341
{
	GList *names;
Jody Goldberg's avatar
Jody Goldberg committed
342
	GtkContainer *list;
Michael Meeks's avatar
Michael Meeks committed
343

344 345
	g_return_if_fail (state != NULL);
	g_return_if_fail (state->list != NULL);
Michael Meeks's avatar
Michael Meeks committed
346

347
	state->cur_name = NULL;
348 349
	if (state->expr_names != NULL)
		g_list_free (state->expr_names);
Michael Meeks's avatar
Michael Meeks committed
350

351
	state->expr_names = expr_name_list (state->wb, state->sheet, FALSE);
352

353
	list = GTK_CONTAINER (state->list);
354
	for (names = state->expr_names ; names != NULL ; names = g_list_next (names)) {
355
		NamedExpression *expr_name = names->data;
356 357 358 359 360 361 362 363 364
		GtkWidget *li;
		if (expr_name->sheet != NULL) {
			char *name = g_strdup_printf ("%s!%s",
						      expr_name->sheet->name_unquoted,
						      expr_name->name->str);
			li = gtk_list_item_new_with_label (name);
			g_free (name);
		} else
			li = gtk_list_item_new_with_label (expr_name->name->str);
365
		gtk_object_set_data (GTK_OBJECT (li), LIST_KEY, expr_name);
Jody Goldberg's avatar
Jody Goldberg committed
366
		gtk_container_add (list, li);
Michael Meeks's avatar
Michael Meeks committed
367
	}
Jody Goldberg's avatar
Jody Goldberg committed
368
	gtk_widget_show_all (GTK_WIDGET (state->list));
369
	name_guru_update_sensitivity (state, TRUE);
370 371
}

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
/**
 * name_guru_scope_get:
 * @state: 
 * 
 * Get the selected Scope from the combo box
 * 
 * Return Value: 
 **/
static NameGuruScope
name_guru_scope_get (NameGuruState *state)
{
	gchar *text;

	text = gtk_entry_get_text (GTK_ENTRY (state->scope->entry));

	g_return_val_if_fail (text != NULL, NAME_GURU_SCOPE_WORKBOOK);
	
	if (strcmp (text, _("Workbook"))==0)
	    return NAME_GURU_SCOPE_WORKBOOK;
	else
	    return NAME_GURU_SCOPE_SHEET;
}


/**
 * cb_name_guru_remove:
 * @ignored: 
 * @state: 
 * 
 * Remove the state->cur_name
 **/
403
static void
404
cb_name_guru_remove (GtkWidget *ignored, NameGuruState *state)
Michael Meeks's avatar
Michael Meeks committed
405
{
406 407
	g_return_if_fail (state != NULL);

408
	if (state->cur_name != NULL) {
409 410 411 412 413
		if (!name_guru_warn (state))
			return;
		state->expr_names = g_list_remove (state->expr_names, state->cur_name);
		expr_name_remove (state->cur_name);
		state->cur_name = NULL;
414

415 416 417 418
		gtk_list_clear_items (state->list, 0, -1);
		name_guru_populate_list (state);
	} else {
		g_warning ("Why is the delete button sensitive ? ...\n");
Jody Goldberg's avatar
Jody Goldberg committed
419
	}
420

421 422
}

423 424 425 426 427 428 429 430 431

/**
 * cb_name_guru_add:
 * @state: 
 * 
 * Update or add a NamedExpression from the values in the gtkentries.
 * 
 * Return Value: FALSE if the expression was invalid, TRUE otherwise
 **/
432
static gboolean
433
cb_name_guru_add (NameGuruState *state)
434
{
435
	NamedExpression *expr_name;
Jody Goldberg's avatar
Jody Goldberg committed
436
	ParsePos      pos, *pp;
437 438 439 440
	ExprTree *expr;
	const gchar *name;
	const gchar *value;
	gchar *error;
441 442 443 444 445 446 447 448

	g_return_val_if_fail (state != NULL, FALSE);

	value = gtk_entry_get_text (state->value);
	name  = gtk_entry_get_text (state->name);

	if (!name || (name[0] == '\0'))
		return TRUE;
449

450
	pp = parse_pos_init (&pos, state->wb, state->sheet,
451 452
			     state->sheet->edit_pos.col,
			     state->sheet->edit_pos.row);
Jody Goldberg's avatar
Jody Goldberg committed
453 454 455 456 457

	expr_name = expr_name_lookup (pp, name);

	expr = expr_parse_string (value, pp, NULL, &error);

Jody Goldberg's avatar
Jody Goldberg committed
458 459
	/* If the expression is invalid */
	if (expr == NULL) {
460
		gnumeric_notice (state->wbcg, GNOME_MESSAGE_BOX_ERROR, error);
461
		gtk_widget_grab_focus (GTK_WIDGET (state->value));
Jody Goldberg's avatar
Jody Goldberg committed
462 463
		return FALSE;
	} else if (expr_name) {
Jody Goldberg's avatar
Jody Goldberg committed
464
		if (!expr_name->builtin) {
465 466 467 468
			/* This means that the expresion was updated updated.
			 * FIXME: if the scope has been changed too, call scope
			 * chaned first. 
			 */
Jody Goldberg's avatar
Jody Goldberg committed
469 470
			expr_tree_unref (expr_name->t.expr_tree);
			expr_name->t.expr_tree = expr;
471
		} else 
472
			gnumeric_notice (state->wbcg, GNOME_MESSAGE_BOX_ERROR,
Morten Welinder's avatar
Morten Welinder committed
473
					 _("You cannot redefine a builtin name."));
474 475 476 477 478 479
	} else {
		if (name_guru_scope_get (state) == NAME_GURU_SCOPE_WORKBOOK)
			expr_name = expr_name_add (state->wb, NULL, name, expr, &error);
		else
			expr_name = expr_name_add (NULL, state->sheet, name, expr, &error);
	}
480

Jody Goldberg's avatar
Jody Goldberg committed
481
	g_return_val_if_fail (expr_name != NULL, FALSE);
482

483
	gtk_list_clear_items (state->list, 0, -1);
Jody Goldberg's avatar
Jody Goldberg committed
484
	name_guru_populate_list (state);
485
	gtk_widget_grab_focus (GTK_WIDGET (state->name));
486 487 488 489

	return TRUE;
}

Jody Goldberg's avatar
Jody Goldberg committed
490 491 492
static void
cb_name_guru_value_focus (GtkWidget *w, GdkEventFocus *ev, NameGuruState *state)
{
Jody Goldberg's avatar
Jody Goldberg committed
493
	GtkEntry *entry = GTK_ENTRY (w);
494

Jody Goldberg's avatar
Jody Goldberg committed
495
	if (entry == state->value) {
496 497
		workbook_set_entry (state->wbcg, state->value);
		workbook_edit_select_absolute (state->wbcg);
Jody Goldberg's avatar
Jody Goldberg committed
498
	} else
499
		workbook_set_entry (state->wbcg, NULL);
Jody Goldberg's avatar
Jody Goldberg committed
500 501
}

502
static void
503
cb_name_guru_clicked (GtkWidget *button, NameGuruState *state)
504
{
505 506 507
	if (state->dialog == NULL)
		return;

508
	workbook_set_entry (state->wbcg, NULL);
509
	
510
	if (button == state->delete_button) {
511
		cb_name_guru_remove (NULL, state);
512 513 514
		return;
	}

515 516 517 518 519
	if (button == state->add_button ||
	    button == state->update_button ||
	    button == state->ok_button) {
		/* If adding the name failed, do not exit */
		if (!cb_name_guru_add (state)) {
Jody Goldberg's avatar
Jody Goldberg committed
520
			return;
521 522
		}
	}
523

524
	if (button == state->close_button || button == state->ok_button) {
525
		gtk_widget_destroy (state->dialog);
526 527 528
		return;
	}
	
529 530
}

531 532
static GtkWidget *
name_guru_init_button (NameGuruState *state, char const *name)
533
{
534
	GtkWidget *tmp = glade_xml_get_widget (state->gui, name);
535 536 537

	g_return_val_if_fail (tmp != NULL, NULL);
	
538 539 540 541
	gtk_signal_connect (GTK_OBJECT (tmp), "clicked",
			    GTK_SIGNAL_FUNC (cb_name_guru_clicked),
			    state);
	return tmp;
542 543
}

544 545
static gboolean
cb_name_guru_destroy (GtkObject *w, NameGuruState *state)
546
{
547 548 549
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);

550
	workbook_edit_detach_guru (state->wbcg);
551 552 553 554 555 556

	if (state->gui != NULL) {
		gtk_object_unref (GTK_OBJECT (state->gui));
		state->gui = NULL;
	}

557
	workbook_finish_editing (state->wbcg, FALSE);
558 559 560 561

	state->dialog = NULL;

	g_free (state);
562

563
	return FALSE;
564 565
}

566
static gboolean
567
name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
568
{
569 570 571 572 573 574
	Workbook *wb = wb_control_workbook (WORKBOOK_CONTROL (wbcg));

	state->wbcg  = wbcg;
	state->wb   = wb;
	state->sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
	state->gui = gnumeric_glade_xml_new (state->wbcg, "names.glade");
575 576 577
        if (state->gui == NULL)
                return TRUE;

578
	state->dialog = glade_xml_get_widget (state->gui, "NameGuru");
579 580
	state->name  = GTK_ENTRY (glade_xml_get_widget (state->gui, "name"));
	state->value = GTK_ENTRY (glade_xml_get_widget (state->gui, "value"));
581
	state->scope = GTK_COMBO (glade_xml_get_widget (state->gui, "scope_combo"));
582 583
	state->list  = GTK_LIST  (glade_xml_get_widget (state->gui, "name_list"));
	state->expr_names = NULL;
584
	state->cur_name   = NULL;
585
	state->updating   = FALSE;
586 587 588 589 590

	/* Init the scope combo box */
	name_guru_init_scope (state);
	gtk_signal_connect (GTK_OBJECT (state->scope->entry), "changed",
			    GTK_SIGNAL_FUNC (cb_scope_changed), state);
591

592 593 594
	state->ok_button     = name_guru_init_button (state, "ok_button");
	state->close_button  = name_guru_init_button (state, "close_button");
	state->add_button    = name_guru_init_button (state, "add_button");
595
	state->delete_button = name_guru_init_button (state, "delete_button");
596
	state->update_button = name_guru_init_button (state, "update_button");
597 598

	gtk_signal_connect (GTK_OBJECT (state->list), "selection_changed",
599
			    GTK_SIGNAL_FUNC (cb_name_guru_select_name), state);
Jody Goldberg's avatar
Jody Goldberg committed
600 601 602 603
	gtk_signal_connect (GTK_OBJECT (state->name), "focus-in-event",
			    GTK_SIGNAL_FUNC (cb_name_guru_value_focus), state);
	gtk_signal_connect (GTK_OBJECT (state->value), "focus-in-event",
			    GTK_SIGNAL_FUNC (cb_name_guru_value_focus), state);
604
	gtk_signal_connect (GTK_OBJECT (state->dialog), "destroy",
Jody Goldberg's avatar
Jody Goldberg committed
605
			    GTK_SIGNAL_FUNC (cb_name_guru_destroy), state);
606 607 608 609 610 611 612 613
	gtk_signal_connect (GTK_OBJECT (state->name), "changed",
			    GTK_SIGNAL_FUNC (name_guru_update_sensitivity_cb), state);
	/* We need to conect after because this is an expresion, and it will be changed
	 * by the mouse selecting a range, update after the entry is updated with the
	 * new text
	 */
	gtk_signal_connect_after (GTK_OBJECT (state->value), "changed",
				  GTK_SIGNAL_FUNC (name_guru_update_sensitivity_cb), state);
614

Jody Goldberg's avatar
Jody Goldberg committed
615 616 617 618
 	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_EDITABLE(state->name));
 	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_EDITABLE (state->value));
619 620
	gnumeric_combo_enters (GTK_WINDOW (state->dialog),
			       state->scope);
621
	gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
622

623
	workbook_edit_attach_guru (state->wbcg, state->dialog);
624 625

	return FALSE;
Michael Meeks's avatar
Michael Meeks committed
626 627
}

628 629 630 631 632 633
/**
 * dialog_define_names:
 * @wbcg: 
 * 
 * Create and show the define names dialog.
 **/
Miguel de Icaza's avatar
Miguel de Icaza committed
634
void
635
dialog_define_names (WorkbookControlGUI *wbcg)
Miguel de Icaza's avatar
Miguel de Icaza committed
636
{
637
	NameGuruState *state;
Michael Meeks's avatar
Michael Meeks committed
638

639
	g_return_if_fail (wbcg != NULL);
Michael Meeks's avatar
Michael Meeks committed
640

641
	state = g_new (NameGuruState, 1);
642
	if (name_guru_init (state, wbcg)) {
643 644
		gnumeric_notice (wbcg, GNOME_MESSAGE_BOX_ERROR,
				 _("Could not create the Name Guru."));
645
		g_free (state);
Michael Meeks's avatar
Michael Meeks committed
646 647 648
		return;
	}

Jody Goldberg's avatar
Jody Goldberg committed
649
	name_guru_populate_list (state);
650
	gtk_widget_show (state->dialog);
Miguel de Icaza's avatar
Miguel de Icaza committed
651
}
652