From 5de7b60f7a19aad8186db52d82db3fe5e11e79d2 Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Fri, 16 Apr 2004 09:57:07 +0000 Subject: Work in progress, HIG'ing and de-coupling of errors. svn path=/trunk/; revision=25493 --- widgets/misc/e-error.c | 550 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 550 insertions(+) create mode 100644 widgets/misc/e-error.c (limited to 'widgets/misc/e-error.c') diff --git a/widgets/misc/e-error.c b/widgets/misc/e-error.c new file mode 100644 index 0000000000..f7cc9ee7bf --- /dev/null +++ b/widgets/misc/e-error.c @@ -0,0 +1,550 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * + * + * Authors: Michael Zucchi + * + * 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. + * + */ + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "e-error.h" + +#define d(x) 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; + struct _e_error_button *buttons; +}; + +struct _e_error_table { + char *domain; + GHashTable *errors; +}; + +static GHashTable *error_table; + +/* ********************************************************************** */ + +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}", &default_ok_button }, + { GTK_DIALOG_MODAL, "error-primary", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", NULL, &default_ok_button }, + { GTK_DIALOG_MODAL, "warning", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", "{1}", &default_ok_button }, + { GTK_DIALOG_MODAL, "warning-primary", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", 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;inext) { + const char *lang = l->data; + + for (scan = base;scan;scan=scan->next) { + if (!strcmp(scan->name, name)) { + char *xmllang = xmlGetProp(scan, "xml:lang"); + + if (xmllang) { + if (!strcmp(xmllang, lang)) { + xmlFree(xmllang); + return scan; + } + xmlFree(xmllang); + } else { + langc = scan; + if (strcmp(lang, "C") == 0) + return scan; + } + } + } + } + + return langc; +} + +/* + XML format: + + + <_title>Window Title? + <_primary>Primary error text.? + <_secondary>Secondary error text.? +