[genius] Sun Aug 17 14:39:15 2014 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Sun Aug 17 14:39:15 2014 Jiri (George) Lebl <jirka 5z com>
- Date: Sun, 17 Aug 2014 19:39:31 +0000 (UTC)
commit 39cc329e182a062750f91dab623f91b3db60b305
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Sun Aug 17 14:39:17 2014 -0500
Sun Aug 17 14:39:15 2014 Jiri (George) Lebl <jirka 5z com>
* src/graphing.c, src/gnome-genius.[ch]: When errors are given during
graphing, instead of forcing them into a box, which is in
retrospect really annoying, just display a warning label below the
graph window telling the user to look at the console. Also
if errors do go into a dialog, make sure that it is parented by the
graph window
ChangeLog | 9 ++
NEWS | 2 +
src/gnome-genius.c | 42 +++++++---
src/gnome-genius.h | 5 +-
src/graphing.c | 222 ++++++++++++++++++++++++++++------------------------
5 files changed, 163 insertions(+), 117 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4532654..c6f5262 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun Aug 17 14:39:15 2014 Jiri (George) Lebl <jirka 5z com>
+
+ * src/graphing.c, src/gnome-genius.[ch]: When errors are given during
+ graphing, instead of forcing them into a box, which is in
+ retrospect really annoying, just display a warning label below the
+ graph window telling the user to look at the console. Also
+ if errors do go into a dialog, make sure that it is parented by the
+ graph window
+
Fri Aug 15 17:38:41 2014 Jiri (George) Lebl <jirka 5z com>
* help/C/genius.xml: update the feedback info to be more within
diff --git a/NEWS b/NEWS
index 6222e7a..128d5e9 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Changes to 1.0.18
* New plotting functions: PlotCanvasFreeze/PlotCanvasThaw to improve flicker
if doing animations with genius, LinePlotDrawPoints function to draw just
points without the line
+* While plotting errors are no longer forced into a dialog, and presence
+ of errors is indicated in the graph window below the graph
* Allow setting color in LinePlotDrawLine with RGB vector.
* When the vector building notation is done with floats and the final
number is within 2^-20 times the step size of the goal,
diff --git a/src/gnome-genius.c b/src/gnome-genius.c
index a025bf6..6050a63 100644
--- a/src/gnome-genius.c
+++ b/src/gnome-genius.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2013 Jiri (George) Lebl
+ * Copyright (C) 1997-2014 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -92,6 +92,8 @@ GelCalcState curstate={
5 /* chop_when */
};
+long total_errors = 0;
+
#define MAX_CHOP 1000
static void check_events (void);
@@ -1048,7 +1050,8 @@ geniusbox (gboolean error,
const char *textbox_title,
gboolean bind_response,
gboolean wrap,
- const char *s)
+ const char *s,
+ GtkWidget *parent_win)
{
GtkWidget *mb;
/* if less than 10 lines */
@@ -1057,8 +1060,8 @@ geniusbox (gboolean error,
GtkMessageType type = GTK_MESSAGE_INFO;
if (error)
type = GTK_MESSAGE_ERROR;
- mb = gtk_message_dialog_new (genius_window ?
- GTK_WINDOW (genius_window) :
+ mb = gtk_message_dialog_new (parent_win ?
+ GTK_WINDOW (parent_win) :
NULL /* parent */,
0 /* flags */,
type,
@@ -1665,14 +1668,15 @@ full_answer (GtkWidget *menu_item, gpointer data)
_("Full Answer") /*textbox_title*/,
TRUE /*bind_response*/,
wrap /* wrap */,
- ve_sure_string (s));
+ ve_sure_string (s),
+ genius_window /* parent */);
gel_output_unref (out);
}
static void
-printout_error_num_and_reset(void)
+printout_error_num_and_reset(GtkWidget *parent)
{
if(genius_setup.error_box) {
if(errors) {
@@ -1686,7 +1690,8 @@ printout_error_num_and_reset(void)
NULL /*textbox_title*/,
TRUE /*bind_response*/,
FALSE /* wrap */,
- errors->str);
+ errors->str,
+ parent);
g_string_free(errors,TRUE);
errors=NULL;
}
@@ -1730,8 +1735,11 @@ geniuserror(const char *s)
char *file;
int line;
char *str;
- if(curstate.max_errors > 0 &&
- errors_printed++>=curstate.max_errors)
+
+ total_errors ++;
+
+ if (curstate.max_errors > 0 &&
+ errors_printed++ >= curstate.max_errors)
return;
gel_get_file_info(&file,&line);
@@ -1776,7 +1784,7 @@ geniuserror(const char *s)
}
void
-gel_printout_infos (void)
+gel_printout_infos_parent (GtkWidget *parent)
{
/* Print out the infos */
if (infos != NULL) {
@@ -1785,12 +1793,19 @@ gel_printout_infos (void)
NULL /*textbox_title*/,
TRUE /*bind_response*/,
FALSE /* wrap */,
- infos->str);
+ infos->str,
+ parent);
g_string_free (infos, TRUE);
infos = NULL;
}
- printout_error_num_and_reset ();
+ printout_error_num_and_reset (parent);
+}
+
+void
+gel_printout_infos (void)
+{
+ gel_printout_infos_parent (genius_window);
}
static void
@@ -4585,7 +4600,8 @@ fork_a_helper (void)
NULL /*textbox_title*/,
FALSE /*bind_response*/,
FALSE /*wrap*/,
- _("Can't execute genius-readline-helper-fifo!\n"));
+ _("Can't execute genius-readline-helper-fifo!\n"),
+ genius_window /* parent */);
gtk_dialog_run (GTK_DIALOG (d));
diff --git a/src/gnome-genius.h b/src/gnome-genius.h
index e15ec39..8f48249 100644
--- a/src/gnome-genius.h
+++ b/src/gnome-genius.h
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 2004-2009 Jiri (George) Lebl
+ * Copyright (C) 2004-2014 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -36,6 +36,7 @@ typedef struct {
extern GeniusSetup genius_setup;
extern GtkWidget *genius_window;
extern int gel_calc_running;
+extern long total_errors;
void genius_interrupt_calc (void);
@@ -45,6 +46,8 @@ void genius_unsetup_window_cursor (GtkWidget *win);
gboolean genius_ask_question (GtkWidget *parent, const char *question);
void genius_display_error (GtkWidget *parent, const char *err);
+void gel_printout_infos_parent (GtkWidget *parent);
+
/* same as GNOME */
#define GENIUS_PAD 8
#define GENIUS_PAD_SMALL 4
diff --git a/src/graphing.c b/src/graphing.c
index 964c424..372b2cd 100644
--- a/src/graphing.c
+++ b/src/graphing.c
@@ -55,6 +55,7 @@ static GtkWidget *plot_canvas = NULL;
static GtkWidget *plot_dialog = NULL;
static GtkWidget *plot_notebook = NULL;
static GtkWidget *function_notebook = NULL;
+static GtkWidget *errors_label_box = NULL;
static GtkWidget *solver_dialog = NULL;
gboolean solver_dialog_slopefield = TRUE;
@@ -1266,10 +1267,7 @@ plot_zoomin_cb (void)
{
if (plot_in_progress == 0) {
double len;
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
if (plot_mode == MODE_LINEPLOT ||
plot_mode == MODE_LINEPLOT_PARAMETRIC ||
@@ -1301,9 +1299,11 @@ plot_zoomin_cb (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
}
@@ -1312,10 +1312,7 @@ plot_zoomout_cb (void)
{
if (plot_in_progress == 0) {
double len;
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
if (plot_mode == MODE_LINEPLOT ||
plot_mode == MODE_LINEPLOT_PARAMETRIC ||
@@ -1347,9 +1344,11 @@ plot_zoomout_cb (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
}
@@ -1364,10 +1363,7 @@ plot_zoomfit_cb (void)
if (plot_in_progress == 0) {
double size;
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
if (plot_mode == MODE_LINEPLOT) {
size = plot_maxy - plot_miny;
@@ -1445,9 +1441,11 @@ plot_zoomfit_cb (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
}
@@ -1455,10 +1453,7 @@ static void
plot_resetzoom_cb (void)
{
if (plot_in_progress == 0) {
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
if (plot_mode == MODE_LINEPLOT ||
plot_mode == MODE_LINEPLOT_PARAMETRIC ||
@@ -1482,9 +1477,11 @@ plot_resetzoom_cb (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
}
@@ -1497,10 +1494,7 @@ lineplot_move_graph (double horiz, double vert)
plot_mode == MODE_LINEPLOT_SLOPEFIELD ||
plot_mode == MODE_LINEPLOT_VECTORFIELD)) {
double len;
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
len = plotx2 - plotx1;
plotx1 = plotx1 + horiz * len;
@@ -1515,9 +1509,11 @@ lineplot_move_graph (double horiz, double vert)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
}
@@ -1535,10 +1531,7 @@ dozoom_idle (gpointer data)
if (plot_in_progress == 0 && line_plot != NULL) {
double len;
- gboolean last_info = genius_setup.info_box;
- gboolean last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ long last_errnum = total_errors;
/* just click, so zoom in */
if (dozoom_just_click) {
@@ -1571,9 +1564,11 @@ dozoom_idle (gpointer data)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
}
return FALSE;
@@ -2078,6 +2073,8 @@ ensure_window (gboolean do_window_present)
gtk_window_present (GTK_WINDOW (graph_window));
else
gtk_widget_show (graph_window);
+
+ gtk_widget_hide (errors_label_box);
return;
}
@@ -2239,6 +2236,7 @@ ensure_window (gboolean do_window_present)
G_CALLBACK (clear_solutions_cb), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show_all (menubar);
plot_canvas = gtk_plot_canvas_new (WIDTH, HEIGHT, 1.0);
GTK_PLOT_CANVAS_UNSET_FLAGS (GTK_PLOT_CANVAS (plot_canvas),
@@ -2251,10 +2249,26 @@ ensure_window (gboolean do_window_present)
NULL);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (graph_window))),
GTK_WIDGET (plot_canvas), TRUE, TRUE, 0);
+ gtk_widget_show (plot_canvas);
+
+ errors_label_box = gtk_hbox_new (FALSE, GENIUS_PAD);
+ gtk_box_pack_start
+ (GTK_BOX (errors_label_box),
+ GTK_WIDGET (gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, 24)),
+ FALSE, FALSE, 0);
+ gtk_box_pack_start
+ (GTK_BOX (errors_label_box),
+ GTK_WIDGET (gtk_label_new (_("Errors during plotting (possibly harmless), see the
console."))),
+ FALSE, FALSE, 0);
+ gtk_widget_show_all (errors_label_box);
+ gtk_widget_hide (errors_label_box);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (graph_window))),
+ GTK_WIDGET (errors_label_box), FALSE, FALSE, GENIUS_PAD);
- gtk_widget_show_all (graph_window);
+
+ gtk_widget_show (graph_window);
}
@@ -2263,6 +2277,8 @@ clear_graph (void)
{
int i;
+ gtk_widget_hide (errors_label_box);
+
/* to avoid the costly removes */
g_slist_free (solutions_list);
solutions_list = NULL;
@@ -6365,17 +6381,13 @@ surface_from_dialog (void)
{
GelEFunc *func = { NULL };
double x1, x2, y1, y2, z1, z2;
- gboolean last_info;
- gboolean last_error;
+ long last_errnum;
char *error_to_print = NULL;
gboolean ex;
plot_mode = MODE_SURFACE;
- last_info = genius_setup.info_box;
- last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ last_errnum = total_errors;
ex = FALSE;
func = get_func_from_entry2 (surface_entry, surface_entry_status,
@@ -6478,9 +6490,11 @@ surface_from_dialog (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
return;
@@ -6490,9 +6504,11 @@ whack_copied_funcs:
func = NULL;
}
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
if (error_to_print != NULL) {
genius_display_error (plot_dialog, error_to_print);
@@ -6543,16 +6559,12 @@ plot_from_dialog_lineplot (void)
GelEFunc *func[MAXFUNC] = { NULL };
double x1, x2, y1, y2;
int i, j;
- gboolean last_info;
- gboolean last_error;
char *error_to_print = NULL;
+ long last_errnum;
plot_mode = MODE_LINEPLOT;
- last_info = genius_setup.info_box;
- last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ last_errnum = total_errors;
for (i = 0; i < MAXFUNC; i++) {
GelEFunc *f;
@@ -6633,9 +6645,11 @@ plot_from_dialog_lineplot (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
return;
@@ -6645,9 +6659,11 @@ whack_copied_funcs:
func[i] = NULL;
}
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
if (error_to_print != NULL) {
genius_display_error (plot_dialog, error_to_print);
@@ -6662,19 +6678,15 @@ plot_from_dialog_parametric (void)
GelEFunc *funcpy = NULL;
GelEFunc *funcpz = NULL;
double x1, x2, y1, y2;
- gboolean last_info;
- gboolean last_error;
char *error_to_print = NULL;
gboolean exx = FALSE;
gboolean exy = FALSE;
gboolean exz = FALSE;
+ long last_errnum;
plot_mode = MODE_LINEPLOT_PARAMETRIC;
- last_info = genius_setup.info_box;
- last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ last_errnum = total_errors;
funcpx = get_func_from_entry (parametric_entry_x,
parametric_status_x,
@@ -6773,9 +6785,11 @@ plot_from_dialog_parametric (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
return;
@@ -6787,9 +6801,11 @@ whack_copied_funcs:
d_freefunc (funcpz);
funcpz = NULL;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
if (error_to_print != NULL) {
genius_display_error (plot_dialog, error_to_print);
@@ -6802,17 +6818,13 @@ plot_from_dialog_slopefield (void)
{
GelEFunc *funcp = NULL;
double x1, x2, y1, y2;
- gboolean last_info;
- gboolean last_error;
char *error_to_print = NULL;
gboolean ex = FALSE;
+ long last_errnum;
plot_mode = MODE_LINEPLOT_SLOPEFIELD;
- last_info = genius_setup.info_box;
- last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ last_errnum = total_errors;
init_var_names ();
@@ -6878,9 +6890,11 @@ plot_from_dialog_slopefield (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
return;
@@ -6888,9 +6902,11 @@ whack_copied_funcs:
d_freefunc (funcp);
funcp = NULL;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
if (error_to_print != NULL) {
genius_display_error (plot_dialog, error_to_print);
@@ -6904,17 +6920,13 @@ plot_from_dialog_vectorfield (void)
GelEFunc *funcpx = NULL;
GelEFunc *funcpy = NULL;
double x1, x2, y1, y2;
- gboolean last_info;
- gboolean last_error;
char *error_to_print = NULL;
gboolean ex = FALSE;
+ long last_errnum;
plot_mode = MODE_LINEPLOT_VECTORFIELD;
- last_info = genius_setup.info_box;
- last_error = genius_setup.error_box;
- genius_setup.info_box = TRUE;
- genius_setup.error_box = TRUE;
+ last_errnum = total_errors;
vectorfield_normalize_arrow_length =
vectorfield_normalize_arrow_length_cb;
@@ -6985,9 +6997,11 @@ plot_from_dialog_vectorfield (void)
if (gel_interrupted)
gel_interrupted = FALSE;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
return;
@@ -6997,9 +7011,11 @@ whack_copied_funcs:
d_freefunc (funcpy);
funcpy = NULL;
- gel_printout_infos ();
- genius_setup.info_box = last_info;
- genius_setup.error_box = last_error;
+ gel_printout_infos_parent (graph_window);
+ if (last_errnum != total_errors &&
+ ! genius_setup.error_box) {
+ gtk_widget_show (errors_label_box);
+ }
if (error_to_print != NULL) {
genius_display_error (plot_dialog, error_to_print);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]