aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-04-28 14:37:26 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-04-28 14:37:26 +0800
commit4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675 (patch)
treef3efbe218556d095fe49ea91494b7b09265ca544 /widgets
parent8aeb46417a17826f24eb2c128c30d905f507e1d6 (diff)
downloadgsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar.gz
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar.bz2
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar.lz
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar.xz
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.tar.zst
gsoc2013-evolution-4e99c39bcf70a2b15d4bd6dbb609ef0aba8d9675.zip
holder for system errors.
2004-04-28 Not Zed <NotZed@Ximian.com> * e-system-errors.xml.in: holder for system errors. * test-error.c: helper to show an error message/test it. * e-error.[ch]: Api for disk-based, hig-compliant error messages and query boxes. svn path=/trunk/; revision=25650
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog9
-rw-r--r--widgets/misc/Makefile.am20
-rw-r--r--widgets/misc/e-error.c15
-rw-r--r--widgets/misc/e-error.h23
-rw-r--r--widgets/misc/e-system-errors.xml.in22
-rw-r--r--widgets/misc/test-error.c64
6 files changed, 141 insertions, 12 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 53fd3deaf6..899e901ab0 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,12 @@
+2004-04-28 Not Zed <NotZed@Ximian.com>
+
+ * e-system-errors.xml.in: holder for system errors.
+
+ * test-error.c: helper to show an error message/test it.
+
+ * e-error.[ch]: Api for disk-based, hig-compliant error messages
+ and query boxes.
+
2004-04-19 Jeffrey Stedfast <fejj@ximian.com>
* e-info-label.c (e_info_label_new): Updated to sue E_ICON_SIZE enums.
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 768f36cd9b..d1df5e467e 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -2,6 +2,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/a11y/widgets/ \
-DMAP_DIR=\""$(imagesdir)"\" \
+ -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
-DG_LOG_DOMAIN=__FILE__ \
$(SOURCE_SEL_CFLAGS)
@@ -24,6 +25,7 @@ widgetsinclude_HEADERS = \
e-combo-button.h \
e-dateedit.h \
e-dropdown-button.h \
+ e-error.h \
e-expander.h \
e-image-chooser.h \
e-info-label.h \
@@ -53,6 +55,7 @@ libemiscwidgets_la_SOURCES = \
e-combo-button.c \
e-dateedit.c \
e-dropdown-button.c \
+ e-error.c \
e-expander.c \
e-image-chooser.c \
e-info-label.c \
@@ -69,6 +72,11 @@ libemiscwidgets_la_SOURCES = \
MARSHAL_GENERATED = e-util-marshal.c e-util-marshal.h
@EVO_MARSHAL_RULE@
+error_in_files = e-system-errors.xml.in
+error_DATA = $(error_in_files:.xml.in=.xml)
+errordir = $(privdatadir)/errors
+@INTLTOOL_XML_RULE@
+
libemiscwidgets_la_LIBADD = $(top_builddir)/e-util/libeutil.la \
$(top_builddir)/a11y/widgets/libevolution-widgets-a11y.la \
$(SOURCE_SEL_LIBS)
@@ -83,6 +91,7 @@ noinst_PROGRAMS = \
test-calendar \
test-dateedit \
test-dropdown-button \
+ test-error \
test-multi-config-dialog \
test-source-option-menu \
test-source-selector \
@@ -135,7 +144,6 @@ test_title_bar_LDADD = \
./libemiscwidgets.la \
$(GNOME_FULL_LIBS)
-
# test-source-selector
test_source_selector_SOURCES = \
@@ -157,11 +165,19 @@ test_source_option_menu_LDADD = \
./libemiscwidgets.la \
$(SOURCE_SEL_LIBS)
+test_error_SOURCES = \
+ test-error.c
+
+test_error_LDADD = \
+ ./libemiscwidgets.la \
+ $(GNOME_FULL_LIBS)
+
-BUILT_SOURCES = $(MARSHAL_GENERATED)
+BUILT_SOURCES = $(MARSHAL_GENERATED) $(error_DATA)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
+ $(error_in_files) \
e-util-marshal.list \
ChangeLog.pre-1-4
diff --git a/widgets/misc/e-error.c b/widgets/misc/e-error.c
index f7cc9ee7bf..d60d301cab 100644
--- a/widgets/misc/e-error.c
+++ b/widgets/misc/e-error.c
@@ -214,10 +214,15 @@ ee_load(const char *path)
return;
}
- table = g_malloc0(sizeof(*table));
- table->domain = g_strdup(tmp);
+ table = g_hash_table_lookup(error_table, tmp);
+ if (table == NULL) {
+ table = g_malloc0(sizeof(*table));
+ table->domain = g_strdup(tmp);
+ table->errors = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_insert(error_table, table->domain, table);
+ } else
+ g_warning("Error file '%s', domain '%s' already used, merging", path, tmp);
g_free(tmp);
- table->errors = g_hash_table_new(g_str_hash, g_str_equal);
for (error = root->children;error;error = error->next) {
if (!strcmp(error->name, "error")) {
@@ -304,8 +309,6 @@ ee_load(const char *path)
}
xmlFreeDoc(doc);
-
- g_hash_table_insert(error_table, table->domain, table);
}
static void
@@ -324,7 +327,7 @@ ee_load_tables(void)
/* setup system error types */
table = g_malloc0(sizeof(*table));
- table->domain = "system";
+ table->domain = "builtin";
table->errors = g_hash_table_new(g_str_hash, g_str_equal);
for (i=0;i<sizeof(default_errors)/sizeof(default_errors[0]);i++)
g_hash_table_insert(table->errors, default_errors[i].id, &default_errors[i]);
diff --git a/widgets/misc/e-error.h b/widgets/misc/e-error.h
index 9da24e6004..2b0bded9bc 100644
--- a/widgets/misc/e-error.h
+++ b/widgets/misc/e-error.h
@@ -26,11 +26,26 @@
struct _GtkWindow;
-#define E_ERROR_WARNING "system:warning"
-#define E_ERROR_WARNING_PRIMARY "system:warning-primary"
-#define E_ERROR_ERROR "system:error"
-#define E_ERROR_ERROR_PRIMARY "system:error-primary"
+/*
+ * Some standard errors, if these are altered or added to,
+ * update devel-docs/misc/errors.txt
+ *
+ * Several more basic ones are needed.
+ */
+
+#define E_ERROR_WARNING "builtin:warning"
+#define E_ERROR_WARNING_PRIMARY "builtin:warning-primary"
+#define E_ERROR_ERROR "builtin:error"
+#define E_ERROR_ERROR_PRIMARY "builtin:error-primary"
+
+/* takes filename, returns OK if yes */
+#define E_ERROR_ASK_FILE_EXISTS_OVERWRITE "system:ask-save-file-exists-overwrite"
+/* takes filename, reason */
+#define E_ERROR_NO_SAVE_FILE "system:no-save-file"
+/* takes filename, reason */
+#define E_ERROR_NO_LOAD_FILE "system:no-save-file"
+/* Note that all errors returned are standard GtkDialoge's */
struct _GtkWidget *e_error_new(struct _GtkWindow *parent, const char *tag, const char *arg0, ...);
struct _GtkWidget *e_error_newv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap);
diff --git a/widgets/misc/e-system-errors.xml.in b/widgets/misc/e-system-errors.xml.in
new file mode 100644
index 0000000000..00175f91f1
--- /dev/null
+++ b/widgets/misc/e-system-errors.xml.in
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<error-list domain="system">
+
+ <error id="ask-save-file-exists-overwrite" type="error" default="GTK_RESPONSE_CANCEL">
+ <_title>Overwrite file?</_title>
+ <_primary>File exists &quot;{0}&quot;.</_primary>
+ <_secondary>Do you wish to overwrite it?</_secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button _label="_Overwrite" response="GTK_RESPONSE_OK"/>
+ </error>
+
+ <error id="no-save-file" type="error">
+ <_primary>Cannot save file &quot;{0}&quot;.</_primary>
+ <_secondary>Because &quot;{1}&quot;</_secondary>
+ </error>
+
+ <error id="no-load-file" type="error">
+ <_primary>Cannot open file &quot;{0}&quot;.</_primary>
+ <_secondary>Because &quot;{1}&quot;.</_secondary>
+ </error>
+
+</error-list>
diff --git a/widgets/misc/test-error.c b/widgets/misc/test-error.c
new file mode 100644
index 0000000000..38b9bfb6b0
--- /dev/null
+++ b/widgets/misc/test-error.c
@@ -0,0 +1,64 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * test-error.c
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Author: Michael Zucchi <notzed@ximian.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 Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libgnomeui/gnome-app.h>
+#include <libgnomeui/gnome-ui-init.h>
+#include "e-error.h"
+
+int
+main (int argc, char **argv)
+{
+ gnome_init ("test-error", "0.0", argc, argv);
+
+ argc--;
+ switch (argc) {
+ case 1:
+ e_error_run(NULL, argv[1], NULL);
+ break;
+ case 2:
+ e_error_run(NULL, argv[1], argv[2], NULL);
+ break;
+ case 3:
+ e_error_run(NULL, argv[1], argv[2], argv[3], NULL);
+ break;
+ case 4:
+ e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], NULL);
+ break;
+ case 5:
+ e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], argv[5], NULL);
+ break;
+ case 6:
+ e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], NULL);
+ break;
+ default:
+ printf("Error: too many or too few arguments\n");
+ printf("Usage:\n %s domain:error-id [ args ... ]\n", argv[0]);
+ }
+
+ return 0;
+}