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


/**
 * name_guru_warned_if_used:
58 59
 * @state:
 *
60 61
 * If the expresion that is about to be deleted is beeing used,
 * warn the user about it. Ask if we should procede or not
62
 *
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
 * 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:
78 79 80 81
 * @state:
 * @scope:
 *
 * Change the scope of state->cur_name. Ask the user if we want to procede with the
82 83 84 85 86 87 88 89 90 91 92 93 94
 * 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;
95

96 97 98 99 100 101 102 103
	/* 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;
104

105 106
		expr_name_wb2sheet (expression, state->sheet);
	}
107

108 109
	return TRUE;
}
110

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
	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");
129

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

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

/**
 * name_guru_set_expr:
160
 * @state:
161
 * @expr_name: Expression to set in the entries, NULL to clear entries
162
 *
163 164 165 166 167 168 169
 * Set the entries in the dialog from an NamedExpression
 **/
static void
name_guru_set_expr (NameGuruState *state, NamedExpression *expr_name)
{
	g_return_if_fail (state != NULL);

170
	/* Don't recur.  */
171
	state->updating = TRUE;
172

173
	if (expr_name) {
174 175
		gchar *txt;

176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
		/* 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:
198 199
 * @state:
 *
200 201 202 203 204 205 206 207 208 209 210 211 212 213
 * 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:
214
 * @name:
215
 * @state:
216
 *
217
 * Given a name, it searches for it inside the list of Names
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
 * 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:
247 248 249
 * @state:
 * @update_entries:
 *
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
 * 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;
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
	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:
296 297 298
 * @dummy:
 * @state:
 *
299 300 301 302 303 304 305 306 307
 **/
static void
name_guru_update_sensitivity_cb (GtkWidget *dummy, NameGuruState *state)
{
	name_guru_update_sensitivity (state, FALSE);
}

/**
 * cb_name_guru_select_name:
308 309 310
 * @list:
 * @state:
 *
311 312
 * 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
/**
 * name_guru_scope_get:
374 375
 * @state:
 *
376
 * Get the selected Scope from the combo box
377 378
 *
 * Return Value:
379 380 381 382 383 384 385 386 387
 **/
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);
388

389 390 391 392 393 394 395 396 397
	if (strcmp (text, _("Workbook"))==0)
	    return NAME_GURU_SCOPE_WORKBOOK;
	else
	    return NAME_GURU_SCOPE_SHEET;
}


/**
 * cb_name_guru_remove:
398 399 400
 * @ignored:
 * @state:
 *
401 402
 * 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

/**
 * cb_name_guru_add:
426 427
 * @state:
 *
428
 * Update or add a NamedExpression from the values in the gtkentries.
429
 *
430 431
 * 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 451 452 453
	pp = parse_pos_init (&pos, state->wb, state->sheet, 0, 0);
	/*
	 * expr name uses 0,0 for now.  Figure out what to do with this
	 * eventually.
454 455
			     state->sheet->edit_pos.col,
			     state->sheet->edit_pos.row);
456
			     */
Jody Goldberg's avatar
Jody Goldberg committed
457 458 459 460 461

	expr_name = expr_name_lookup (pp, name);

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

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

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

487
	gtk_list_clear_items (state->list, 0, -1);
Jody Goldberg's avatar
Jody Goldberg committed
488
	name_guru_populate_list (state);
489
	gtk_widget_grab_focus (GTK_WIDGET (state->name));
490 491 492 493

	return TRUE;
}

Jody Goldberg's avatar
Jody Goldberg committed
494 495 496
static void
cb_name_guru_value_focus (GtkWidget *w, GdkEventFocus *ev, NameGuruState *state)
{
Jody Goldberg's avatar
Jody Goldberg committed
497
	GtkEntry *entry = GTK_ENTRY (w);
498

Jody Goldberg's avatar
Jody Goldberg committed
499
	if (entry == state->value) {
500 501
		workbook_set_entry (state->wbcg, state->value);
		workbook_edit_select_absolute (state->wbcg);
Jody Goldberg's avatar
Jody Goldberg committed
502
	} else
503
		workbook_set_entry (state->wbcg, NULL);
Jody Goldberg's avatar
Jody Goldberg committed
504 505
}

506
static void
507
cb_name_guru_clicked (GtkWidget *button, NameGuruState *state)
508
{
509 510 511
	if (state->dialog == NULL)
		return;

512
	workbook_set_entry (state->wbcg, NULL);
513

514
	if (button == state->delete_button) {
515
		cb_name_guru_remove (NULL, state);
516 517 518
		return;
	}

519 520 521 522 523
	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
524
			return;
525 526
		}
	}
527

528
	if (button == state->close_button || button == state->ok_button) {
529
		gtk_widget_destroy (state->dialog);
530 531
		return;
	}
532

533 534
}

535 536
static GtkWidget *
name_guru_init_button (NameGuruState *state, char const *name)
537
{
538
	GtkWidget *tmp = glade_xml_get_widget (state->gui, name);
539 540

	g_return_val_if_fail (tmp != NULL, NULL);
541

542 543 544 545
	gtk_signal_connect (GTK_OBJECT (tmp), "clicked",
			    GTK_SIGNAL_FUNC (cb_name_guru_clicked),
			    state);
	return tmp;
546 547
}

548 549
static gboolean
cb_name_guru_destroy (GtkObject *w, NameGuruState *state)
550
{
551 552 553
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);

554
	workbook_edit_detach_guru (state->wbcg);
555 556 557 558 559 560

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

561
	workbook_finish_editing (state->wbcg, FALSE);
562 563 564 565

	state->dialog = NULL;

	g_free (state);
566

567
	return FALSE;
568 569
}

570
static gboolean
571
name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
572
{
573 574 575 576 577 578
	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");
579 580 581
        if (state->gui == NULL)
                return TRUE;

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

	/* 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);
595

596 597 598
	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");
599
	state->delete_button = name_guru_init_button (state, "delete_button");
600
	state->update_button = name_guru_init_button (state, "update_button");
601 602

	gtk_signal_connect (GTK_OBJECT (state->list), "selection_changed",
603
			    GTK_SIGNAL_FUNC (cb_name_guru_select_name), state);
Jody Goldberg's avatar
Jody Goldberg committed
604 605 606 607
	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);
608
	gtk_signal_connect (GTK_OBJECT (state->dialog), "destroy",
Jody Goldberg's avatar
Jody Goldberg committed
609
			    GTK_SIGNAL_FUNC (cb_name_guru_destroy), state);
610 611
	gtk_signal_connect (GTK_OBJECT (state->name), "changed",
			    GTK_SIGNAL_FUNC (name_guru_update_sensitivity_cb), state);
612 613 614
	/* We need to connect 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.
615 616 617
	 */
	gtk_signal_connect_after (GTK_OBJECT (state->value), "changed",
				  GTK_SIGNAL_FUNC (name_guru_update_sensitivity_cb), state);
618

Jody Goldberg's avatar
Jody Goldberg committed
619 620 621 622
 	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_EDITABLE(state->name));
 	gnumeric_editable_enters (GTK_WINDOW (state->dialog),
				  GTK_EDITABLE (state->value));
623 624
	gnumeric_combo_enters (GTK_WINDOW (state->dialog),
			       state->scope);
625
	gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
626

627
	workbook_edit_attach_guru (state->wbcg, state->dialog);
628 629

	return FALSE;
Michael Meeks's avatar
Michael Meeks committed
630 631
}

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

643
	g_return_if_fail (wbcg != NULL);
Michael Meeks's avatar
Michael Meeks committed
644

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

Jody Goldberg's avatar
Jody Goldberg committed
653
	name_guru_populate_list (state);
654
	gtk_widget_show (state->dialog);
Miguel de Icaza's avatar
Miguel de Icaza committed
655
}