Commit 3537beaf authored by Chyla Zbigniew's avatar Chyla Zbigniew

New. (error_info_new_printf): Use error_info_new_vprintf.

* src/error-info.[ch]
(error_info_new_vprintf): New.
(error_info_new_printf): Use error_info_new_vprintf.
(error_info_peek_message): Constified.

* src/command-context-priv.h (struct CommandContextClass): Added
error.error_info virtual.

* src/command-context.[ch] (gnumeric_error_error_info): New.

* src/io-context.[ch]
(gnumeric_io_error_system, gnumeric_io_error_read,
gnumeric_io_error_save): Use gnumeric_io_error_string.
(gnumeric_io_error_string): New.
(gnumeric_io_error_display): Renamed from
gnumeric_io_error_info_display. Use CommandContext's virtual -
gnumeric_error_error_info.
(gnumeric_io_error_info_clear, gnumeric_io_has_error_info): Removed.
s/gnumeric_io_clear_error/gnumeric_io_error_clear
s/gnumeric_io_error_info_push/gnumeric_io_error_push/
s/gnumeric_io_error_info_pop/gnumeric_io_error_pop/

* src/gnumeric-util.c
(ctree_insert_error_info): Automatically expand most nodes (don't expand
nodes with siblings).
(gnumeric_error_info_dialog_show_full): Renamed from
gnumeric_error_info_dialog_show. Display only a tree with error
details. Don't hardcode ctree column width, make ctree look nicer (no
lines, triangles as icons).
(gnumeric_error_info_dialog_show): New function, displays only main part
of the error and (optionally) "Show details" button. Use standard
gnome_message_box.

* src/plugin-util.c (gnumeric_fopen_error_info,
gnumeric_mmap_error_info): Use error_info_new_from_errno.
(gnumeric_open_error_info): Use error_info_new_from_errno,
added missing *ret_error.

* src/workbook-control-gui.c (wbcg_error_error_info): New
(implementation of CommandContext's virtual).
(workbook_control_gui_ctor_class): Use it here.

* src/workbook-view.c (wb_view_save_as, wb_view_save,
wb_view_open_custom): Don't use removed gnumeric_io_has_error_info.
parent 36e082dd
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* src/error-info.[ch]
(error_info_new_vprintf): New.
(error_info_new_printf): Use error_info_new_vprintf.
(error_info_peek_message): Constified.
* src/command-context-priv.h (struct CommandContextClass): Added
error.error_info virtual.
* src/command-context.[ch] (gnumeric_error_error_info): New.
* src/io-context.[ch]
(gnumeric_io_error_system, gnumeric_io_error_read,
gnumeric_io_error_save): Use gnumeric_io_error_string.
(gnumeric_io_error_string): New.
(gnumeric_io_error_display): Renamed from
gnumeric_io_error_info_display. Use CommandContext's virtual -
gnumeric_error_error_info.
(gnumeric_io_error_info_clear, gnumeric_io_has_error_info): Removed.
s/gnumeric_io_clear_error/gnumeric_io_error_clear
s/gnumeric_io_error_info_push/gnumeric_io_error_push/
s/gnumeric_io_error_info_pop/gnumeric_io_error_pop/
* src/gnumeric-util.c
(ctree_insert_error_info): Automatically expand most nodes (don't expand
nodes with siblings).
(gnumeric_error_info_dialog_show_full): Renamed from
gnumeric_error_info_dialog_show. Display only a tree with error
details. Don't hardcode ctree column width, make ctree look nicer (no
lines, triangles as icons).
(gnumeric_error_info_dialog_show): New function, displays only main part
of the error and (optionally) "Show details" button. Use standard
gnome_message_box.
* src/plugin-util.c (gnumeric_fopen_error_info,
gnumeric_mmap_error_info): Use error_info_new_from_errno.
(gnumeric_open_error_info): Use error_info_new_from_errno,
added missing *ret_error.
* src/workbook-control-gui.c (wbcg_error_error_info): New
(implementation of CommandContext's virtual).
(workbook_control_gui_ctor_class): Use it here.
* src/workbook-view.c (wb_view_save_as, wb_view_save,
wb_view_open_custom): Don't use removed gnumeric_io_has_error_info.
2001-07-14 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_handle_motion) : adjust
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* src/error-info.[ch]
(error_info_new_vprintf): New.
(error_info_new_printf): Use error_info_new_vprintf.
(error_info_peek_message): Constified.
* src/command-context-priv.h (struct CommandContextClass): Added
error.error_info virtual.
* src/command-context.[ch] (gnumeric_error_error_info): New.
* src/io-context.[ch]
(gnumeric_io_error_system, gnumeric_io_error_read,
gnumeric_io_error_save): Use gnumeric_io_error_string.
(gnumeric_io_error_string): New.
(gnumeric_io_error_display): Renamed from
gnumeric_io_error_info_display. Use CommandContext's virtual -
gnumeric_error_error_info.
(gnumeric_io_error_info_clear, gnumeric_io_has_error_info): Removed.
s/gnumeric_io_clear_error/gnumeric_io_error_clear
s/gnumeric_io_error_info_push/gnumeric_io_error_push/
s/gnumeric_io_error_info_pop/gnumeric_io_error_pop/
* src/gnumeric-util.c
(ctree_insert_error_info): Automatically expand most nodes (don't expand
nodes with siblings).
(gnumeric_error_info_dialog_show_full): Renamed from
gnumeric_error_info_dialog_show. Display only a tree with error
details. Don't hardcode ctree column width, make ctree look nicer (no
lines, triangles as icons).
(gnumeric_error_info_dialog_show): New function, displays only main part
of the error and (optionally) "Show details" button. Use standard
gnome_message_box.
* src/plugin-util.c (gnumeric_fopen_error_info,
gnumeric_mmap_error_info): Use error_info_new_from_errno.
(gnumeric_open_error_info): Use error_info_new_from_errno,
added missing *ret_error.
* src/workbook-control-gui.c (wbcg_error_error_info): New
(implementation of CommandContext's virtual).
(workbook_control_gui_ctor_class): Use it here.
* src/workbook-view.c (wb_view_save_as, wb_view_save,
wb_view_open_custom): Don't use removed gnumeric_io_has_error_info.
2001-07-14 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_handle_motion) : adjust
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* src/error-info.[ch]
(error_info_new_vprintf): New.
(error_info_new_printf): Use error_info_new_vprintf.
(error_info_peek_message): Constified.
* src/command-context-priv.h (struct CommandContextClass): Added
error.error_info virtual.
* src/command-context.[ch] (gnumeric_error_error_info): New.
* src/io-context.[ch]
(gnumeric_io_error_system, gnumeric_io_error_read,
gnumeric_io_error_save): Use gnumeric_io_error_string.
(gnumeric_io_error_string): New.
(gnumeric_io_error_display): Renamed from
gnumeric_io_error_info_display. Use CommandContext's virtual -
gnumeric_error_error_info.
(gnumeric_io_error_info_clear, gnumeric_io_has_error_info): Removed.
s/gnumeric_io_clear_error/gnumeric_io_error_clear
s/gnumeric_io_error_info_push/gnumeric_io_error_push/
s/gnumeric_io_error_info_pop/gnumeric_io_error_pop/
* src/gnumeric-util.c
(ctree_insert_error_info): Automatically expand most nodes (don't expand
nodes with siblings).
(gnumeric_error_info_dialog_show_full): Renamed from
gnumeric_error_info_dialog_show. Display only a tree with error
details. Don't hardcode ctree column width, make ctree look nicer (no
lines, triangles as icons).
(gnumeric_error_info_dialog_show): New function, displays only main part
of the error and (optionally) "Show details" button. Use standard
gnome_message_box.
* src/plugin-util.c (gnumeric_fopen_error_info,
gnumeric_mmap_error_info): Use error_info_new_from_errno.
(gnumeric_open_error_info): Use error_info_new_from_errno,
added missing *ret_error.
* src/workbook-control-gui.c (wbcg_error_error_info): New
(implementation of CommandContext's virtual).
(workbook_control_gui_ctor_class): Use it here.
* src/workbook-view.c (wb_view_save_as, wb_view_save,
wb_view_open_custom): Don't use removed gnumeric_io_has_error_info.
2001-07-14 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_handle_motion) : adjust
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* src/error-info.[ch]
(error_info_new_vprintf): New.
(error_info_new_printf): Use error_info_new_vprintf.
(error_info_peek_message): Constified.
* src/command-context-priv.h (struct CommandContextClass): Added
error.error_info virtual.
* src/command-context.[ch] (gnumeric_error_error_info): New.
* src/io-context.[ch]
(gnumeric_io_error_system, gnumeric_io_error_read,
gnumeric_io_error_save): Use gnumeric_io_error_string.
(gnumeric_io_error_string): New.
(gnumeric_io_error_display): Renamed from
gnumeric_io_error_info_display. Use CommandContext's virtual -
gnumeric_error_error_info.
(gnumeric_io_error_info_clear, gnumeric_io_has_error_info): Removed.
s/gnumeric_io_clear_error/gnumeric_io_error_clear
s/gnumeric_io_error_info_push/gnumeric_io_error_push/
s/gnumeric_io_error_info_pop/gnumeric_io_error_pop/
* src/gnumeric-util.c
(ctree_insert_error_info): Automatically expand most nodes (don't expand
nodes with siblings).
(gnumeric_error_info_dialog_show_full): Renamed from
gnumeric_error_info_dialog_show. Display only a tree with error
details. Don't hardcode ctree column width, make ctree look nicer (no
lines, triangles as icons).
(gnumeric_error_info_dialog_show): New function, displays only main part
of the error and (optionally) "Show details" button. Use standard
gnome_message_box.
* src/plugin-util.c (gnumeric_fopen_error_info,
gnumeric_mmap_error_info): Use error_info_new_from_errno.
(gnumeric_open_error_info): Use error_info_new_from_errno,
added missing *ret_error.
* src/workbook-control-gui.c (wbcg_error_error_info): New
(implementation of CommandContext's virtual).
(workbook_control_gui_ctor_class): Use it here.
* src/workbook-view.c (wb_view_save_as, wb_view_save,
wb_view_open_custom): Don't use removed gnumeric_io_has_error_info.
2001-07-14 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_handle_motion) : adjust
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* lotus.c (lotus_read): Use gnumeric_io_error_string.
2001-06-28 Jody Goldberg <jgoldberg@home>
* Release 0.67
......
......@@ -312,8 +312,7 @@ lotus_read (IOContext *io_context, Workbook *wb, const char *filename)
}
if (!read_workbook (wb, f)) {
gnumeric_io_error_info_set (io_context,
error_info_new_str (_("Error while reading lotus workbook.")));
gnumeric_io_error_string (io_context, _("Error while reading lotus workbook."));
}
fclose (f);
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* pln.c (pln_file_open): Use gnumeric_io_error_string.
2001-06-28 Jody Goldberg <jgoldberg@home>
* Release 0.67
......
......@@ -927,8 +927,7 @@ pln_file_open (GnumFileOpener const *fo, IOContext *io_context,
munmap((char *)data, len);
} else {
gnumeric_io_error_info_set (io_context,
error_info_new_str (_("Unable to mmap the file")));
gnumeric_io_error_string (io_context, _("Unable to mmap the file"));
}
close(fd);
}
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* python-loader.c (gnumeric_plugin_loader_python_func_file_open,
gnumeric_plugin_loader_python_func_file_save): Use gnumeric_io_error_string.
2001-06-29 Zbigniew Chyla <cyba@gnome.pl>
* py-gnumeric.c (create_python_interpreter): Call PySys_SetArgv after
......
......@@ -320,7 +320,7 @@ gnumeric_plugin_loader_python_func_file_open (GnumFileOpener const *fo, PluginSe
Py_DECREF (open_result);
workbook_sheet_attach (wb_view_workbook (wb_view), sheet, NULL);
} else {
gnumeric_io_error_info_set (io_context, error_info_new_str (convert_python_exception_to_string ()));
gnumeric_io_error_string (io_context, convert_python_exception_to_string ());
clear_python_error_if_needed ();
sheet_destroy (sheet);
}
......@@ -421,7 +421,7 @@ gnumeric_plugin_loader_python_func_file_save (GnumFileSaver const *fs, PluginSer
if (save_result != NULL) {
Py_DECREF (save_result);
} else {
gnumeric_io_error_info_set (io_context, error_info_new_str (convert_python_exception_to_string ()));
gnumeric_io_error_string (io_context, convert_python_exception_to_string ());
clear_python_error_if_needed ();
}
}
......
2001-07-14 Zbigniew Chyla <cyba@gnome.pl>
* xml-sax-read.c (xml_sax_file_open): Use gnumeric_io_error_string.
2001-06-28 Jody Goldberg <jgoldberg@home>
* Release 0.67
......
......@@ -1912,9 +1912,7 @@ xml_sax_file_open (GnumFileOpener const *fo, IOContext *io_context,
*/
ctxt = xmlCreateFileParserCtxt (filename);
if (ctxt == NULL) {
gnumeric_io_error_info_set (io_context,
error_info_new_str (
_("xmlCreateFileParserCtxt () failed.")));
gnumeric_io_error_string (io_context, _("xmlCreateFileParserCtxt () failed."));
return;
}
ctxt->sax = &xmlSaxSAXParser;
......@@ -1923,9 +1921,7 @@ xml_sax_file_open (GnumFileOpener const *fo, IOContext *io_context,
xmlParseDocument (ctxt);
if (!ctxt->wellFormed)
gnumeric_io_error_info_set (io_context,
error_info_new_str (
_("XML document not well formed!")));
gnumeric_io_error_string (io_context, _("XML document not well formed!"));
else
workbook_queue_all_recalc (state.wb);
......
......@@ -2,6 +2,7 @@
#define GNUMERIC_COMMAND_CONTEXT_PRIV_H
#include "command-context.h"
#include "error-info.h"
#include <gtk/gtkobject.h>
struct _CommandContext {
......@@ -23,6 +24,7 @@ typedef struct {
char const *cmd, Range const *array);
void (*invalid) (CommandContext *ctxt,
char const *msg, char const *val);
void (*error_info) (CommandContext *ctxt, ErrorInfo *error);
} error;
} CommandContextClass;
......
......@@ -95,6 +95,15 @@ gnumeric_error_splits_array (CommandContext *context,
CC_CLASS (context)->error.splits_array (context, cmd, array);
}
void
gnumeric_error_error_info (CommandContext *context, ErrorInfo *error)
{
g_return_if_fail (IS_COMMAND_CONTEXT (context));
CC_CLASS (context)->error.error_info (context, error);
}
void
gnumeric_progress_set (CommandContext *context, gfloat f)
{
......
......@@ -2,6 +2,7 @@
#define GNUMERIC_COMMAND_CONTEXT_H
#include "gnumeric.h"
#include "error-info.h"
#include <gtk/gtkobject.h>
#define COMMAND_CONTEXT_TYPE (command_context_get_type ())
......@@ -23,6 +24,7 @@ void gnumeric_error_invalid (CommandContext *context,
char const *msg, char const *val);
void gnumeric_error_splits_array (CommandContext *context,
char const *cmd, Range const *array);
void gnumeric_error_error_info (CommandContext *context, ErrorInfo *error);
void gnumeric_progress_set (CommandContext *context, gfloat f);
void gnumeric_progress_message_set (CommandContext *context, gchar const *msg);
......
......@@ -28,22 +28,29 @@ error_info_new_str (const gchar *msg)
return error;
}
ErrorInfo *
error_info_new_vprintf (const gchar *msg_format, va_list args)
{
ErrorInfo *error;
error = g_new (ErrorInfo, 1);
error->msg = g_strdup_vprintf (msg_format, args);
error->details = NULL;
return error;
}
ErrorInfo *
error_info_new_printf (const gchar *msg_format, ...)
{
ErrorInfo *error;
va_list args;
gchar *msg_str;
va_start (args, msg_format);
msg_str = g_strdup_vprintf (msg_format, args);
error = error_info_new_vprintf (msg_format, args);
va_end (args);
error = g_new (ErrorInfo, 1);
error->msg = msg_str;
error->details = NULL;
return error;
}
......@@ -178,7 +185,7 @@ error_info_print (ErrorInfo *error)
error_info_print_with_offset (error, 0);
}
gchar *
const gchar *
error_info_peek_message (ErrorInfo *error)
{
g_return_val_if_fail (error != NULL, NULL);
......
......@@ -5,17 +5,18 @@
typedef struct _ErrorInfo ErrorInfo;
ErrorInfo *error_info_new_str (const gchar *msg);
ErrorInfo *error_info_new_printf (const gchar *msg_format, ...) G_GNUC_PRINTF (1, 2);
ErrorInfo *error_info_new_str_with_details (const gchar *msg, ErrorInfo *details);
ErrorInfo *error_info_new_str_with_details_list (const gchar *msg, GList *details);
ErrorInfo *error_info_new_from_error_list (GList *errors);
ErrorInfo *error_info_new_from_errno (void);
void error_info_add_details (ErrorInfo *error, ErrorInfo *details);
void error_info_add_details_list (ErrorInfo *error, GList *details);
void error_info_free (ErrorInfo *error);
void error_info_print (ErrorInfo *error);
gchar *error_info_peek_message (ErrorInfo *error);
GList *error_info_peek_details (ErrorInfo *error);
ErrorInfo *error_info_new_str (const gchar *msg);
ErrorInfo *error_info_new_printf (const gchar *msg_format, ...) G_GNUC_PRINTF (1, 2);
ErrorInfo *error_info_new_vprintf (const gchar *msg_format, va_list args);
ErrorInfo *error_info_new_str_with_details (const gchar *msg, ErrorInfo *details);
ErrorInfo *error_info_new_str_with_details_list (const gchar *msg, GList *details);
ErrorInfo *error_info_new_from_error_list (GList *errors);
ErrorInfo *error_info_new_from_errno (void);
void error_info_add_details (ErrorInfo *error, ErrorInfo *details);
void error_info_add_details_list (ErrorInfo *error, GList *details);
void error_info_free (ErrorInfo *error);
void error_info_print (ErrorInfo *error);
const gchar *error_info_peek_message (ErrorInfo *error);
GList *error_info_peek_details (ErrorInfo *error);
#endif /* GNUMERIC_ERROR_INFO_H */
......@@ -36,9 +36,9 @@ gnumeric_dialog_question_yes_no (WorkbookControlGUI *wbcg,
GNOME_STOCK_BUTTON_NO,
NULL);
if (default_answer) {
default_button = (GtkWidget *) (GNOME_DIALOG (dialog)->buttons)->data;
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->data;
} else {
default_button = (GtkWidget *) (GNOME_DIALOG (dialog)->buttons)->next->data;
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->next->data;
}
gtk_widget_grab_focus (default_button);
......@@ -264,43 +264,43 @@ gnumeric_dialog_show (WorkbookControlGUI *wbcg, GnomeDialog *dialog,
gtk_widget_show(GTK_WIDGET(dialog));
}
#define ERROR_INFO_DIALOG_EXPANDED_LEVELS 1
static GtkCTreeNode *
ctree_insert_error_info (GtkCTree *ctree, GtkCTreeNode *parent, GtkCTreeNode *sibling, gint level, ErrorInfo *error)
ctree_insert_error_info (GtkCTree *ctree, GtkCTreeNode *parent,
GtkCTreeNode *sibling, ErrorInfo *error,
gboolean expand)
{
GtkCTreeNode *my_node, *last_child_node;
gchar *message;
gboolean child_expand;
GList *details_list, *l;
message = error_info_peek_message (error);
message = (gchar *) error_info_peek_message (error);
if (message == NULL) {
message = _("Unknown error");
message = _("Multiple errors");
}
details_list = error_info_peek_details (error);
my_node = gtk_ctree_insert_node (ctree, parent, sibling, &message, 0, NULL, NULL, NULL, NULL, details_list == NULL, level < ERROR_INFO_DIALOG_EXPANDED_LEVELS);
my_node = gtk_ctree_insert_node (ctree, parent, sibling, &message, 0, NULL, NULL, NULL, NULL, details_list == NULL, expand);
child_expand = details_list == NULL || details_list->next == NULL;
last_child_node = NULL;
for (l = details_list; l != NULL; l = l->next) {
ErrorInfo *detail_error;
ErrorInfo *detail_error = l->data;
detail_error = (ErrorInfo *) l->data;
last_child_node = ctree_insert_error_info (ctree, my_node, last_child_node, level + 1, detail_error);
last_child_node = ctree_insert_error_info (ctree, my_node, last_child_node,
detail_error, child_expand);
}
return my_node;
}
/**
* gnumeric_error_info_dialog_show
* gnumeric_error_info_dialog_show_full
*
*/
void
gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
static void
gnumeric_error_info_dialog_show_full (WorkbookControlGUI *wbcg, ErrorInfo *error)
{
gchar *message;
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *label_message;
GtkWidget *scrolled_window, *ctree;
GtkCTreeNode *main_ctree_node;
GtkWidget *dialog_action_area;
......@@ -308,29 +308,20 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
g_return_if_fail (error != NULL);
message = error_info_peek_message (error);
if (message == NULL) {
message = _("Unknown error");
}
dialog = gnome_dialog_new (_("Gnumeric error message"), NULL);
gtk_widget_set_usize (dialog, 500, 300);
dialog = gnome_dialog_new (_("Detailed error message"), NULL);
gtk_widget_set_usize (dialog, 600, 300);
gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, TRUE, FALSE);
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
label_message = gtk_label_new (message);
gtk_label_set_line_wrap (GTK_LABEL (label_message), TRUE);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), label_message, gtk_label_new (_("Message")));
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
ctree = gtk_ctree_new (1, 0);
gtk_clist_set_column_width (GTK_CLIST (ctree), 0, 1000);
main_ctree_node = ctree_insert_error_info (GTK_CTREE (ctree), NULL, NULL, 0, error);
gtk_ctree_set_line_style (GTK_CTREE (ctree), GTK_CTREE_LINES_NONE);
gtk_ctree_set_expander_style (GTK_CTREE (ctree), GTK_CTREE_EXPANDER_TRIANGLE);
main_ctree_node = ctree_insert_error_info (GTK_CTREE (ctree), NULL, NULL, error, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE);
gtk_container_add (GTK_CONTAINER (scrolled_window), ctree);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, gtk_label_new (_("Details")));
gtk_widget_show_all (GTK_WIDGET (scrolled_window));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), scrolled_window, TRUE, TRUE, 0);
dialog_action_area = GNOME_DIALOG (dialog)->action_area;
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area), GTK_BUTTONBOX_END);
......@@ -340,12 +331,57 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
button_close = GTK_WIDGET (g_list_last (GNOME_DIALOG (dialog)->buttons)->data);
GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT);
gtk_widget_show_all (GTK_WIDGET (notebook));
gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
gnumeric_dialog_run (wbcg, GNOME_DIALOG (dialog));
}
/**
* gnumeric_error_info_dialog_show
*
*/
void
gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
{
GString *str;
GList *details;
gboolean has_extra_details;
GtkWidget *dialog, *default_button;
str = g_string_new (error_info_peek_message (error));
details = error_info_peek_details (error);
if (g_list_length (details) == 1) {
ErrorInfo *details_error = details->data;
const gchar *s;
s = error_info_peek_message (details_error);
if (s != NULL) {
g_string_append (str, "\n\n");
g_string_append (str, s);
}
has_extra_details = error_info_peek_details (details_error) != NULL;
} else {
has_extra_details = details != NULL;
}
if (has_extra_details) {
dialog = gnome_message_box_new (
str->str, GNOME_MESSAGE_BOX_ERROR,
_("Show details"), GNOME_STOCK_BUTTON_CLOSE, NULL);
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->next->data;
} else {
dialog = gnome_message_box_new (
str->str, GNOME_MESSAGE_BOX_ERROR,
GNOME_STOCK_BUTTON_CLOSE, NULL);
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->data;
}
g_string_free (str, TRUE);
gtk_widget_grab_focus (default_button);
if (gnumeric_dialog_run (wbcg, GNOME_DIALOG (dialog)) == 0 &&
has_extra_details) {
gnumeric_error_info_dialog_show_full (wbcg, error);
}
}
/**
* gnumeric_set_transient
* @wbcg : The calling window
......
......@@ -36,9 +36,9 @@ gnumeric_dialog_question_yes_no (WorkbookControlGUI *wbcg,
GNOME_STOCK_BUTTON_NO,
NULL);
if (default_answer) {
default_button = (GtkWidget *) (GNOME_DIALOG (dialog)->buttons)->data;
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->data;
} else {
default_button = (GtkWidget *) (GNOME_DIALOG (dialog)->buttons)->next->data;
default_button = (GtkWidget *) GNOME_DIALOG (dialog)->buttons->next->data;
}
gtk_widget_grab_focus (default_button);
......@@ -264,43 +264,43 @@ gnumeric_dialog_show (WorkbookControlGUI *wbcg, GnomeDialog *dialog,
gtk_widget_show(GTK_WIDGET(dialog));
}
#define ERROR_INFO_DIALOG_EXPANDED_LEVELS 1
static GtkCTreeNode *
ctree_insert_error_info (GtkCTree *ctree, GtkCTreeNode *parent, GtkCTreeNode *sibling, gint level, ErrorInfo *error)
ctree_insert_error_info (GtkCTree *ctree, GtkCTreeNode *parent,
GtkCTreeNode *sibling, ErrorInfo *error,
gboolean expand)
{
GtkCTreeNode *my_node, *last_child_node;
gchar *message;
gboolean child_expand;
GList *details_list, *l;
message = error_info_peek_message (error);
message = (gchar *) error_info_peek_message (error);
if (message == NULL) {
message = _("Unknown error");
message = _("Multiple errors");
}
details_list = error_info_peek_details (error);
my_node = gtk_ctree_insert_node (ctree, parent, sibling, &message, 0, NULL, NULL, NULL, NULL, details_list == NULL, level < ERROR_INFO_DIALOG_EXPANDED_LEVELS);
my_node = gtk_ctree_insert_node (ctree, parent, sibling, &message, 0, NULL, NULL, NULL, NULL, details_list == NULL, expand);
child_expand = details_list == NULL || details_list->next == NULL;
last_child_node = NULL;
for (l = details_list; l != NULL; l = l->next) {
ErrorInfo *detail_error;
ErrorInfo *detail_error = l->data;
detail_error = (ErrorInfo *) l->data;
last_child_node = ctree_insert_error_info (ctree, my_node, last_child_node, level + 1, detail_error);
last_child_node = ctree_insert_error_info (ctree, my_node, last_child_node,
detail_error, child_expand);
}
return my_node;
}
/**
* gnumeric_error_info_dialog_show
* gnumeric_error_info_dialog_show_full
*
*/
void
gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
static void
gnumeric_error_info_dialog_show_full (WorkbookControlGUI *wbcg, ErrorInfo *error)
{
gchar *message;
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *label_message;
GtkWidget *scrolled_window, *ctree;
GtkCTreeNode *main_ctree_node;
GtkWidget *dialog_action_area;
......@@ -308,29 +308,20 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
g_return_if_fail (error != NULL);
message = error_info_peek_message (error);
if (message == NULL) {
message = _("Unknown error");
}
dialog = gnome_dialog_new (_("Gnumeric error message"), NULL);
gtk_widget_set_usize (dialog, 500, 300);
dialog = gnome_dialog_new (_("Detailed error message"), NULL);
gtk_widget_set_usize (dialog, 600, 300);
gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, TRUE, FALSE);
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), notebook, TRUE, TRUE, 0);
label_message = gtk_label_new (message);
gtk_label_set_line_wrap (GTK_LABEL (label_message), TRUE);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), label_message, gtk_label_new (_("Message")));
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
ctree = gtk_ctree_new (1, 0);
gtk_clist_set_column_width (GTK_CLIST (ctree), 0, 1000);
main_ctree_node = ctree_insert_error_info (GTK_CTREE (ctree), NULL, NULL, 0, error);
gtk_ctree_set_line_style (GTK_CTREE (ctree), GTK_CTREE_LINES_NONE);
gtk_ctree_set_expander_style (GTK_CTREE (ctree), GTK_CTREE_EXPANDER_TRIANGLE);
main_ctree_node = ctree_insert_error_info (GTK_CTREE (ctree), NULL, NULL, error, TRUE);
gtk_clist_set_column_auto_resize (GTK_CLIST (ctree), 0, TRUE);
gtk_container_add (GTK_CONTAINER (scrolled_window), ctree);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, gtk_label_new (_("Details")));
gtk_widget_show_all (GTK_WIDGET (scrolled_window));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), scrolled_window, TRUE, TRUE, 0);
dialog_action_area = GNOME_DIALOG (dialog)->action_area;
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area), GTK_BUTTONBOX_END);
......@@ -340,12 +331,57 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
button_close = GTK_WIDGET (g_list_last (GNOME_DIALOG (dialog)->buttons)->data);
GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT);
gtk_widget_show_all (GTK_WIDGET (notebook));
gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE);
gnumeric_dialog_run (wbcg, GNOME_DIALOG (dialog));
}
/**
* gnumeric_error_info_dialog_show
*
*/
void
gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
{
GString *str;
GList *details;
gboolean has_extra_details;
GtkWidget *dialog, *default_button;
str = g_string_new (error_info_peek_message (error));
details = error_info_peek_details (error);
if (g_list_length (details) == 1) {
ErrorInfo *details_error = details->data;
const gchar *s;