From 68400be65ee2da2a7bcad35f306ba2846936e826 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 16 May 2005 06:10:22 +0000 Subject: added e-error.[ch], removed e-error-tool, and added e-system.error.xml 2005-05-16 Not Zed * Makefile.am: added e-error.[ch], removed e-error-tool, and added e-system.error.xml svn path=/trunk/; revision=29360 --- e-util/ChangeLog | 5 + e-util/Makefile.am | 21 +- e-util/e-error-tool.c | 134 ---------- e-util/e-error.c | 628 ++++++++++++++++++++++++++++++++++++++++++++++ e-util/e-error.h | 57 +++++ e-util/e-system.error.xml | 22 ++ 6 files changed, 721 insertions(+), 146 deletions(-) delete mode 100644 e-util/e-error-tool.c create mode 100644 e-util/e-error.c create mode 100644 e-util/e-error.h create mode 100644 e-util/e-system.error.xml diff --git a/e-util/ChangeLog b/e-util/ChangeLog index c2faeeb73b..5f5c407550 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,8 @@ +2005-05-16 Not Zed + + * Makefile.am: added e-error.[ch], removed e-error-tool, and added + e-system.error.xml + 2005-05-13 Not Zed * e-popup.c (emph_popup_factory): if we have a factory method diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 5ffedc9415..888cd47cd5 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -12,6 +12,7 @@ INCLUDES = \ -DEVOLUTION_ICONSDIR=\""$(imagesdir)"\" \ -DEVOLUTION_CATEGORY_ICONS=\""$(imagesdir)/categories"\" \ -DEVOLUTION_PLUGINDIR=\""$(plugindir)"\" \ + -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \ -DG_LOG_DOMAIN=\"e-utils\" \ $(GNOME_PILOT_CFLAGS) \ $(E_UTIL_CFLAGS) @@ -30,6 +31,7 @@ eutilinclude_HEADERS = \ e-corba-utils.h \ e-dialog-utils.h \ e-dialog-widgets.h \ + e-error.h \ e-event.h \ e-folder-map.h \ e-fsutils.h \ @@ -68,6 +70,7 @@ libeutil_la_SOURCES = \ e-corba-utils.c \ e-dialog-utils.c \ e-dialog-widgets.c \ + e-error.c \ e-event.c \ e-folder-map.c \ e-fsutils.c \ @@ -116,24 +119,18 @@ endif libeconduit_la_SOURCES = $(pilot_compile) -# e-error-tool - -e_error_tool_SOURCES = \ - e-error-tool.c - -e_error_tool_LDADD = \ - $(GNOME_FULL_LIBS) - -noinst_PROGRAMS = \ - e-error-tool +error_DATA = e-system.error +errordir = $(privdatadir)/errors +@EVO_PLUGIN_RULE@ EXTRA_DIST = \ + e-system.error.xml \ $(pilot_sources) \ ChangeLog.pre-1-4 \ e-util-marshal.list -BUILT_SOURCES = $(MARSHAL_GENERATED) +BUILT_SOURCES = $(MARSHAL_GENERATED) $(error_DATA) CLEANFILES = $(BUILT_SOURCES) -dist-hook: e-error-tool +dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/e-util/e-error-tool.c b/e-util/e-error-tool.c deleted file mode 100644 index 4544b8b158..0000000000 --- a/e-util/e-error-tool.c +++ /dev/null @@ -1,134 +0,0 @@ - -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -#include - -static void -dump_cstring(FILE *out, const char *tmp) -{ - const char *p; - int c; - - fprintf(out, "char *s = N_(\""); - p = tmp; - while ( (c = *p++) ) { - switch (c) { - case '\n': - fprintf(out, "\\n\"\n\t\""); - break; - case '\r': - fprintf(out, "\\r"); - break; - case '\t': - fprintf(out, "\\t"); - break; - case '"': - case '\\': - fprintf(out, "\\%c", c); - break; - default: - fputc(c, out); - } - } - - fprintf(out, "\");\n"); -} - -static void -extract_strings(FILE *out, const char *path) -{ - xmlDocPtr doc; - xmlNodePtr root, error, scan; - char *tmp, *domain; - - doc = xmlParseFile(path); - if (doc == NULL) { - g_warning("Error file '%s' not found", path); - return; - } - - root = xmlDocGetRootElement(doc); - if (root == NULL - || strcmp(root->name, "error-list") != 0 - || (domain = xmlGetProp(root, "domain")) == NULL) { - g_warning("Error file '%s' invalid format", path); - xmlFreeDoc(doc); - return; - } - - for (error = root->children;error;error = error->next) { - char *id; - - if (strcmp(error->name, "error") != 0) - continue; - - id = xmlGetProp(error, "id"); - if (id == NULL) { - g_warning("Error format invalid, missing error id"); - _exit(1); - } - - for (scan = error->children;scan;scan=scan->next) { - if (!strcmp(scan->name, "primary") - || !strcmp(scan->name, "secondary") - || !strcmp(scan->name, "title")) { - fprintf(out, "/* %s:%s %s */\n", domain, id, scan->name); - tmp = xmlNodeGetContent(scan); - if (tmp) { - dump_cstring(out, tmp); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "button")) { - tmp = xmlGetProp(scan, "label"); - if (tmp) { - dump_cstring(out, tmp); - xmlFree(tmp); - } - } - } - xmlFree(id); - } - - xmlFree(domain); - - xmlFreeDoc(doc); -} - -int main(int argc, char **argv) -{ - int i; - FILE *out; - - for (i=1;i + * + * Copyright 2004 Novell Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "e-error.h" + +#define d(x) + +struct _e_error_button { + struct _e_error_button *next; + char *stock; + char *label; + int response; +}; + +struct _e_error { + guint32 flags; + char *id; + int type; + int default_response; + char *title; + char *primary; + char *secondary; + char *help_uri; + struct _e_error_button *buttons; +}; + +struct _e_error_table { + char *domain; + char *translation_domain; + GHashTable *errors; +}; + +static GHashTable *error_table; +static GSList *ee_parent_list; + +/* ********************************************************************** */ + +static struct _e_error_button default_ok_button = { + NULL, "gtk-ok", NULL, GTK_RESPONSE_OK +}; + +static struct _e_error default_errors[] = { + { GTK_DIALOG_MODAL, "error", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", "{1}", NULL, &default_ok_button }, + { GTK_DIALOG_MODAL, "error-primary", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", NULL, NULL, &default_ok_button }, + { GTK_DIALOG_MODAL, "warning", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", "{1}", NULL, &default_ok_button }, + { GTK_DIALOG_MODAL, "warning-primary", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", NULL, NULL, &default_ok_button }, +}; + +/* ********************************************************************** */ + +static struct { + char *name; + int id; +} response_map[] = { + { "GTK_RESPONSE_REJECT", GTK_RESPONSE_REJECT }, + { "GTK_RESPONSE_ACCEPT", GTK_RESPONSE_ACCEPT }, + { "GTK_RESPONSE_OK", GTK_RESPONSE_OK }, + { "GTK_RESPONSE_CANCEL", GTK_RESPONSE_CANCEL }, + { "GTK_RESPONSE_CLOSE", GTK_RESPONSE_CLOSE }, + { "GTK_RESPONSE_YES", GTK_RESPONSE_YES }, + { "GTK_RESPONSE_NO", GTK_RESPONSE_NO }, + { "GTK_RESPONSE_APPLY", GTK_RESPONSE_APPLY }, + { "GTK_RESPONSE_HELP", GTK_RESPONSE_HELP }, +}; + +static int +map_response(const char *name) +{ + int i; + + for (i=0;i + Window Title? + Primary error text.? + Secondary error text.? + ? +