Commit 70e17e2a authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

move to gui_utils.c (error_in_entry) : move some code to

2002-01-27  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* dialog-analysis-tools.c (tools_destroy_warning) : move to gui_utils.c
	(error_in_entry) : move some code to gnumeric_notice_nonmodal
	* dialog-goal-seek.c : change gnumeric_notice to gnumeric_notice_nonmodal
	(dialog_goal_seek) : initialize state->warning_dialog
	* dialog-solver.c (solver_destroy_warning) : move to gui_utils.c
	(solver_notice) : move to gnumeric_notice_nonmodal

2002-01-27  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* src/gui_util.c (gnumeric_destroy_dialog) : new callback
	(gnumeric_notice_nonmodal) : save dialog ptr in reference
	* src/gui_util.h (gnumeric_notice_nonmodal) : change
	  parameters and return value
parent 5a343f12
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui_util.c (gnumeric_destroy_dialog) : new callback
(gnumeric_notice_nonmodal) : save dialog ptr in reference
* src/gui_util.h (gnumeric_notice_nonmodal) : change
parameters and return value
2002-01-27 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c :
......
......@@ -10,6 +10,7 @@ Andreas:
* Destroy outadated dialogs
* Port solver dialog to gnome2
* Make the solver information dialogs non-modal
* Make the goal-seek warnings non-modal
Jody:
* Initial port to gnome2.
......
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui_util.c (gnumeric_destroy_dialog) : new callback
(gnumeric_notice_nonmodal) : save dialog ptr in reference
* src/gui_util.h (gnumeric_notice_nonmodal) : change
parameters and return value
2002-01-27 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c :
......
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui_util.c (gnumeric_destroy_dialog) : new callback
(gnumeric_notice_nonmodal) : save dialog ptr in reference
* src/gui_util.h (gnumeric_notice_nonmodal) : change
parameters and return value
2002-01-27 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c :
......
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui_util.c (gnumeric_destroy_dialog) : new callback
(gnumeric_notice_nonmodal) : save dialog ptr in reference
* src/gui_util.h (gnumeric_notice_nonmodal) : change
parameters and return value
2002-01-27 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c :
......
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* dialog-analysis-tools.c (tools_destroy_warning) : move to gui_utils.c
(error_in_entry) : move some code to gnumeric_notice_nonmodal
* dialog-goal-seek.c : change gnumeric_notice to gnumeric_notice_nonmodal
(dialog_goal_seek) : initialize state->warning_dialog
* dialog-solver.c (solver_destroy_warning) : move to gui_utils.c
(solver_notice) : move to gnumeric_notice_nonmodal
2002-01-27 Andreas J. Guelzow <aguelzow@taliesin.ca>
* solver.glade : make gnome2 compatible
......
......@@ -283,25 +283,6 @@ gnumeric_expr_entry_parse_to_list (GnumericExprEntry *ee, Sheet *sheet)
return global_range_list_parse (sheet, str);
}
/**
* warning_destroy:
* @window:
* @state:
*
* Destroy the dialog and NULL the field in the state structure.
*
**/
static gboolean
tools_destroy_warning (GtkObject *w, GenericToolState *state)
{
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE);
state->warning_dialog = NULL;
return FALSE;
}
/**
* error_in_entry:
*
......@@ -314,13 +295,9 @@ tools_destroy_warning (GtkObject *w, GenericToolState *state)
static void
error_in_entry (GenericToolState *state, GtkWidget *entry, const char *err_str)
{
if (state->warning_dialog != NULL)
gtk_widget_destroy (state->warning_dialog);
state->warning_dialog = GTK_WIDGET (gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
GTK_MESSAGE_ERROR, err_str));
gtk_signal_connect (GTK_OBJECT (state->warning_dialog), "destroy",
GTK_SIGNAL_FUNC (tools_destroy_warning), state);
gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
&(state->warning_dialog),
GTK_MESSAGE_ERROR, err_str);
gtk_widget_grab_focus (entry);
gtk_entry_set_position (GTK_ENTRY (entry), 0);
......
......@@ -66,6 +66,7 @@ typedef struct {
Cell *change_cell;
Cell *old_cell;
Value *old_value;
GtkWidget *warning_dialog;
} GoalSeekState;
......@@ -346,12 +347,18 @@ cb_dialog_apply_clicked (GtkWidget *button, GoalSeekState *state)
Value *error_value, *target;
RangeRef const *r;
if (state->warning_dialog != NULL)
gtk_widget_destroy (state->warning_dialog);
/* set up source */
target = global_range_parse (state->sheet,
gtk_entry_get_text (GTK_ENTRY (state->set_cell_entry)));
if (target == NULL) {
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR,
_("You should introduce a valid cell name in 'Set Cell:'!"));
gnumeric_notice_nonmodal (GTK_WINDOW(state->dialog),
&(state->warning_dialog),
GTK_MESSAGE_ERROR,
_("You should introduce a valid cell "
"name in 'Set Cell:'!"));
focus_on_entry (GTK_WIDGET (state->set_cell_entry));
return;
}
......@@ -359,8 +366,11 @@ cb_dialog_apply_clicked (GtkWidget *button, GoalSeekState *state)
state->set_cell = sheet_cell_get (r->a.sheet, r->a.col, r->a.row);
value_release (target);
if (state->set_cell == NULL || !cell_has_expr (state->set_cell)) {
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR,
_("The cell named in 'Set Cell:' must contain a formula!"));
gnumeric_notice_nonmodal (GTK_WINDOW(state->dialog),
&(state->warning_dialog),
GTK_MESSAGE_ERROR,
_("The cell named in 'Set Cell:' "
"must contain a formula!"));
focus_on_entry (GTK_WIDGET (state->set_cell_entry));
return;
}
......@@ -369,9 +379,11 @@ cb_dialog_apply_clicked (GtkWidget *button, GoalSeekState *state)
target = global_range_parse (state->sheet,
gtk_entry_get_text (GTK_ENTRY (state->change_cell_entry)));
if (target == NULL) {
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR,
_("You should introduce a valid cell "
"name in 'By Changing Cell:'!"));
gnumeric_notice_nonmodal (GTK_WINDOW(state->dialog),
&(state->warning_dialog),
GTK_MESSAGE_ERROR,
_("You should introduce a valid cell "
"name in 'By Changing Cell:'!"));
focus_on_entry (GTK_WIDGET (state->change_cell_entry));
return;
}
......@@ -380,9 +392,11 @@ cb_dialog_apply_clicked (GtkWidget *button, GoalSeekState *state)
state->change_cell = sheet_cell_fetch (r->a.sheet, r->a.col, r->a.row);
value_release (target);
if (cell_has_expr (state->change_cell)) {
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR,
_("The cell named in 'By changing cell' "
"must not contain a formula."));
gnumeric_notice_nonmodal (GTK_WINDOW(state->dialog),
&(state->warning_dialog),
GTK_MESSAGE_ERROR,
_("The cell named in 'By changing cell' "
"must not contain a formula."));
focus_on_entry (GTK_WIDGET (state->change_cell_entry));
return;
}
......@@ -393,9 +407,11 @@ cb_dialog_apply_clicked (GtkWidget *button, GoalSeekState *state)
if (format != NULL)
target_value_format = format;
if (value == NULL){
gnumeric_notice (state->wbcg, GTK_MESSAGE_ERROR,
_("The value given in 'To Value:' "
"is not valid."));
gnumeric_notice_nonmodal (GTK_WINDOW(state->dialog),
&(state->warning_dialog),
GTK_MESSAGE_ERROR,
_("The value given in 'To Value:' "
"is not valid."));
focus_on_entry (GTK_WIDGET (state->to_value_entry));
return;
}
......@@ -652,6 +668,7 @@ dialog_goal_seek (WorkbookControlGUI *wbcg, Sheet *sheet)
state->wbcg = wbcg;
state->wb = wb_control_workbook (WORKBOOK_CONTROL (wbcg));
state->sheet = sheet;
state->warning_dialog = NULL;
if (dialog_init (state)) {
gnumeric_notice (wbcg, GTK_MESSAGE_ERROR,
......
......@@ -100,45 +100,6 @@ static const char *problem_type_group[] = {
0
};
/**
* warning_destroy:
* @window:
* @state:
*
* Destroy the dialog and NULL the field in the state structure.
*
**/
static gboolean
solver_destroy_warning (GtkObject *w, SolverState *state)
{
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (state != NULL, FALSE);
state->warning_dialog = NULL;
return FALSE;
}
/**
* :
* @state:
* @type:
* @str;
*
**/
static void
solver_notice (SolverState *state, GtkMessageType type, const char *str)
{
if (state->warning_dialog != NULL)
gtk_widget_destroy (state->warning_dialog);
state->warning_dialog = GTK_WIDGET (gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
type, str));
gtk_signal_connect (GTK_OBJECT (state->warning_dialog), "destroy",
GTK_SIGNAL_FUNC (solver_destroy_warning), state);
}
/**
* is_hom_row_or_col_ref:
* @Widget:
......@@ -851,7 +812,8 @@ cb_dialog_solve_clicked (GtkWidget *button, SolverState *state)
state->sheet, &opt_x, &sh_pr, &ilp);
workbook_recalc (state->sheet->workbook);
if (res == SOLVER_LP_OPTIMAL) {
solver_notice (state,
gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
&(state->warning_dialog),
GTK_MESSAGE_INFO,
_("Solver found an optimal solution. All "
"constraints and optimality conditions "
......@@ -867,7 +829,9 @@ cb_dialog_solve_clicked (GtkWidget *button, SolverState *state)
(_("Solver was not successful:"
" %i"), res);
}
solver_notice (state, GTK_MESSAGE_WARNING, str);
gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
&(state->warning_dialog),
GTK_MESSAGE_WARNING, str);
g_free (str);
}
......@@ -888,7 +852,9 @@ cb_dialog_solve_clicked (GtkWidget *button, SolverState *state)
str = g_strdup_printf
(_("Constraint `%s' is for a cell that "
"is not an input cell."), s);
solver_notice (state, GTK_MESSAGE_ERROR, str);
gnumeric_notice_nonmodal ((GtkWindow *) state->dialog,
&(state->warning_dialog),
GTK_MESSAGE_ERROR, str);
g_free (str);
}
......
......@@ -64,21 +64,47 @@ gnumeric_notice (WorkbookControlGUI *wbcg, GtkMessageType type, char const *str)
gnumeric_dialog_run (wbcg, GTK_DIALOG (dialog));
}
GtkWindow *
gnumeric_notice_nonmodal (GtkWindow *parent, GtkMessageType type, char const *str)
/**
* gnumeric_destroy_dialog:
* @window:
* @state:
*
* NULL the reference before.
* This is used to have small keyed-dialog style dialogs whose
* parent is just another dialog
*
**/
static gboolean
gnumeric_destroy_dialog (GtkObject *w, GtkWindow **ref)
{
g_return_val_if_fail (w != NULL, FALSE);
*ref = NULL;
return FALSE;
}
void
gnumeric_notice_nonmodal (GtkWindow *parent, GtkWidget **ref, GtkMessageType type, char const *str)
{
GtkWidget *dialog;
if (*ref != NULL)
gtk_widget_destroy (*ref);
dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, type,
GTK_BUTTONS_OK, str);
gtk_signal_connect_object (GTK_OBJECT (dialog), "response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (dialog));
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
GTK_SIGNAL_FUNC (gnumeric_destroy_dialog), ref);
gtk_widget_show (dialog);
*ref = dialog;
return GTK_WINDOW (dialog);
return;
}
......
......@@ -12,7 +12,8 @@ gboolean gnumeric_dialog_question_yes_no (WorkbookControlGUI *wbcg,
gboolean default_answer);
gboolean gnumeric_dialog_file_selection (WorkbookControlGUI *wbcg, GtkFileSelection *fsel);
void gnumeric_notice (WorkbookControlGUI *wbcg, GtkMessageType type, const char *str);
GtkWindow *gnumeric_notice_nonmodal (GtkWindow *parent, GtkMessageType type, char const *str);
void gnumeric_notice_nonmodal (GtkWindow *parent, GtkWidget **ref,
GtkMessageType type, char const *str);
void gnumeric_non_modal_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog);
gint gnumeric_dialog_run (WorkbookControlGUI *wbcg, GtkDialog *dialog);
......
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