diff options
author | Jonathon Jongsma <jonathon@quotidian.org> | 2009-12-01 01:34:43 +0800 |
---|---|---|
committer | Jonathon Jongsma <jonathon@quotidian.org> | 2009-12-01 03:33:04 +0800 |
commit | c2ee0afbc85ce3ddf38ec07497c0cdae4f42a7fc (patch) | |
tree | e6430bf480afc3e4a220fdf713413c8df4a9da41 /e-util | |
parent | 495e9bf8001e2209a35e8991c07ec038576efdd4 (diff) | |
download | gsoc2013-evolution-c2ee0afbc85ce3ddf38ec07497c0cdae4f42a7fc.tar.gz gsoc2013-evolution-c2ee0afbc85ce3ddf38ec07497c0cdae4f42a7fc.tar.zst gsoc2013-evolution-c2ee0afbc85ce3ddf38ec07497c0cdae4f42a7fc.zip |
Rename EError to EAlert to match general use better
The EError mechanism is used both for error dialogs as well as basic alerts or
user prompts, so we should give it a more general name which matches this use.
This patch also cleans up a few includes of e-alert.h (formerly e-error.h) that
were not actually being used.
https://bugzilla.gnome.org/show_bug.cgi?id=602963
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/Makefile.am | 4 | ||||
-rw-r--r-- | e-util/e-alert.c (renamed from e-util/e-error.c) | 156 | ||||
-rw-r--r-- | e-util/e-alert.h | 66 | ||||
-rw-r--r-- | e-util/e-error.h | 66 | ||||
-rw-r--r-- | e-util/e-non-intrusive-error-dialog.h | 1 | ||||
-rw-r--r-- | e-util/e-util.c | 1 |
6 files changed, 147 insertions, 147 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am index c0b12d63c1..51fa43428e 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -22,7 +22,7 @@ eutilinclude_HEADERS = \ e-datetime-format.h \ e-dialog-utils.h \ e-dialog-widgets.h \ - e-error.h \ + e-alert.h \ e-event.h \ e-file-utils.h \ e-folder-map.h \ @@ -95,7 +95,7 @@ libeutil_la_SOURCES = \ e-datetime-format.c \ e-dialog-utils.c \ e-dialog-widgets.c \ - e-error.c \ + e-alert.c \ e-event.c \ e-file-utils.c \ e-folder-map.c \ diff --git a/e-util/e-error.c b/e-util/e-alert.c index 47d7548c70..cc7488744e 100644 --- a/e-util/e-error.c +++ b/e-util/e-alert.c @@ -35,35 +35,35 @@ #include "e-util.h" #include "e-util-private.h" -#include "e-error.h" +#include "e-alert.h" #define d(x) -struct _EError +struct _EAlert { gchar *tag; GPtrArray *args; }; void -e_error_free (EError *error) +e_alert_free (EAlert *alert) { - if (error == NULL) + if (alert == NULL) return; - g_free (error->tag); + g_free (alert->tag); /* arg strings will be freed automatically since we set a free func when * creating the ptr array */ - g_ptr_array_free (error->args, TRUE); + g_ptr_array_free (alert->args, TRUE); } -struct _e_error_button { - struct _e_error_button *next; +struct _e_alert_button { + struct _e_alert_button *next; const gchar *stock; const gchar *label; gint response; }; -struct _e_error { +struct _e_alert { guint32 flags; const gchar *id; gint type; @@ -73,24 +73,24 @@ struct _e_error { const gchar *secondary; const gchar *help_uri; gboolean scroll; - struct _e_error_button *buttons; + struct _e_alert_button *buttons; }; -struct _e_error_table { +struct _e_alert_table { const gchar *domain; const gchar *translation_domain; - GHashTable *errors; + GHashTable *alerts; }; -static GHashTable *error_table; +static GHashTable *alert_table; /* ********************************************************************** */ -static struct _e_error_button default_ok_button = { +static struct _e_alert_button default_ok_button = { NULL, "gtk-ok", NULL, GTK_RESPONSE_OK }; -static struct _e_error default_errors[] = { +static struct _e_alert default_alerts[] = { { GTK_DIALOG_MODAL, "error", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", "{1}", NULL, FALSE, &default_ok_button }, { GTK_DIALOG_MODAL, "error-primary", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", NULL, NULL, FALSE, &default_ok_button }, { GTK_DIALOG_MODAL, "warning", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", "{1}", NULL, FALSE, &default_ok_button }, @@ -170,9 +170,9 @@ ee_load(const gchar *path) { xmlDocPtr doc = NULL; xmlNodePtr root, error, scan; - struct _e_error *e; - struct _e_error_button *lastbutton; - struct _e_error_table *table; + struct _e_alert *e; + struct _e_alert_button *lastbutton; + struct _e_alert_table *table; gchar *tmp; d(printf("loading error file %s\n", path)); @@ -192,14 +192,14 @@ ee_load(const gchar *path) return; } - table = g_hash_table_lookup(error_table, tmp); + table = g_hash_table_lookup(alert_table, tmp); if (table == NULL) { gchar *tmp2; 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, (gpointer) table->domain, table); + table->alerts = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(alert_table, (gpointer) table->domain, table); tmp2 = (gchar *)xmlGetProp(root, (const guchar *)"translation-domain"); if (tmp2) { @@ -227,7 +227,7 @@ ee_load(const gchar *path) e->scroll = FALSE; xmlFree(tmp); - lastbutton = (struct _e_error_button *)&e->buttons; + lastbutton = (struct _e_alert_button *)&e->buttons; tmp = (gchar *)xmlGetProp(error, (const guchar *)"modal"); if (tmp) { @@ -277,7 +277,7 @@ ee_load(const gchar *path) xmlFree(tmp); } } else if (!strcmp((gchar *)scan->name, "button")) { - struct _e_error_button *b; + struct _e_alert_button *b; gchar *label = NULL; gchar *stock = NULL; @@ -312,7 +312,7 @@ ee_load(const gchar *path) } } - g_hash_table_insert(table->errors, (gpointer) e->id, e); + g_hash_table_insert(table->alerts, (gpointer) e->id, e); } } @@ -325,23 +325,23 @@ ee_load_tables(void) GDir *dir; const gchar *d; gchar *base; - struct _e_error_table *table; + struct _e_alert_table *table; gint i; - if (error_table != NULL) + if (alert_table != NULL) return; - error_table = g_hash_table_new(g_str_hash, g_str_equal); + alert_table = g_hash_table_new(g_str_hash, g_str_equal); - /* setup system error types */ + /* setup system alert types */ table = g_malloc0(sizeof(*table)); table->domain = "builtin"; - table->errors = g_hash_table_new(g_str_hash, g_str_equal); - for (i = 0; i < G_N_ELEMENTS (default_errors); i++) - g_hash_table_insert(table->errors, (gpointer) default_errors[i].id, &default_errors[i]); - g_hash_table_insert(error_table, (gpointer) table->domain, table); + table->alerts = g_hash_table_new(g_str_hash, g_str_equal); + for (i = 0; i < G_N_ELEMENTS (default_alerts); i++) + g_hash_table_insert(table->alerts, (gpointer) default_alerts[i].id, &default_alerts[i]); + g_hash_table_insert(alert_table, (gpointer) table->domain, table); - /* look for installed error tables */ + /* look for installed alert tables */ base = g_build_filename (EVOLUTION_PRIVDATADIR, "errors", NULL); dir = g_dir_open(base, 0, NULL); if (dir == NULL) { @@ -412,7 +412,7 @@ ee_build_label(GString *out, const gchar *fmt, GPtrArray *args, } static void -ee_response(GtkWidget *w, guint button, struct _e_error *e) +ee_response(GtkWidget *w, guint button, struct _e_alert *e) { if (button == GTK_RESPONSE_HELP) { g_signal_stop_emission_by_name(w, "response"); @@ -420,12 +420,12 @@ ee_response(GtkWidget *w, guint button, struct _e_error *e) } } -EError * -e_error_newv(const gchar *tag, const gchar *arg0, va_list ap) +EAlert * +e_alert_newv(const gchar *tag, const gchar *arg0, va_list ap) { gchar *tmp; GPtrArray *args; - EError *err = g_slice_new0 (EError); + EAlert *err = g_slice_new0 (EAlert); err->tag = g_strdup (tag); err->args = g_ptr_array_new_with_free_func (g_free); @@ -439,35 +439,35 @@ e_error_newv(const gchar *tag, const gchar *arg0, va_list ap) } /** - * e_error_new: - * @tag: error identifier - * @arg0: The first argument for the error formatter. The list must + * e_alert_new: + * @tag: alert identifier + * @arg0: The first argument for the alert formatter. The list must * be NULL terminated. * - * Creates a new EError. The @tag argument is used to determine - * which error to use, it is in the format domain:error-id. The NULL + * Creates a new EAlert. The @tag argument is used to determine + * which alert to use, it is in the format domain:alert-id. The NULL * terminated list of arguments, starting with @arg0 is used to fill - * out the error definition. + * out the alert definition. **/ -EError * -e_error_new(const gchar *tag, const gchar *arg0, ...) +EAlert * +e_alert_new(const gchar *tag, const gchar *arg0, ...) { - EError *e; + EAlert *e; va_list ap; va_start(ap, arg0); - e = e_error_newv(tag, arg0, ap); + e = e_alert_newv(tag, arg0, ap); va_end(ap); return e; } GtkWidget * -e_error_new_dialog(GtkWindow *parent, EError *error) +e_alert_new_dialog(GtkWindow *parent, EAlert *alert) { - struct _e_error_table *table; - struct _e_error *e; - struct _e_error_button *b; + struct _e_alert_table *table; + struct _e_alert *e; + struct _e_alert_button *b; GtkWidget *hbox, *w, *scroll=NULL; GtkWidget *action_area; GtkWidget *content_area; @@ -476,9 +476,9 @@ e_error_new_dialog(GtkWindow *parent, EError *error) GtkDialog *dialog; gchar *str, *perr=NULL, *serr=NULL; - g_return_val_if_fail (error != NULL, NULL); + g_return_val_if_fail (alert != NULL, NULL); - if (error_table == NULL) + if (alert_table == NULL) ee_load_tables(); dialog = (GtkDialog *)gtk_dialog_new(); @@ -498,17 +498,17 @@ e_error_new_dialog(GtkWindow *parent, EError *error) "Something called %s() with a NULL parent window. " "This is no longer legal, please fix it.", G_STRFUNC); - domain = alloca(strlen(error->tag)+1); - strcpy(domain, error->tag); + domain = alloca(strlen(alert->tag)+1); + strcpy(domain, alert->tag); id = strchr(domain, ':'); if (id) *id++ = 0; if ( id == NULL - || (table = g_hash_table_lookup(error_table, domain)) == NULL - || (e = g_hash_table_lookup(table->errors, id)) == NULL) { - /* setup a dummy error */ - str = g_strdup_printf(_("Internal error, unknown error '%s' requested"), error->tag); + || (table = g_hash_table_lookup(alert_table, domain)) == NULL + || (e = g_hash_table_lookup(table->alerts, id)) == NULL) { + /* setup a dummy alert */ + str = g_strdup_printf(_("Internal error, unknown error '%s' requested"), alert->tag); tmp = g_strdup_printf("<span weight=\"bold\">%s</span>", str); g_free(str); w = gtk_label_new(NULL); @@ -568,7 +568,7 @@ e_error_new_dialog(GtkWindow *parent, EError *error) out = g_string_new(""); if (e->title && *e->title) { - ee_build_label(out, e->title, error->args, FALSE); + ee_build_label(out, e->title, alert->args, FALSE); gtk_window_set_title((GtkWindow *)dialog, out->str); g_string_truncate(out, 0); } else @@ -576,19 +576,19 @@ e_error_new_dialog(GtkWindow *parent, EError *error) if (e->primary) { g_string_append(out, "<span weight=\"bold\" size=\"larger\">"); - ee_build_label(out, e->primary, error->args, TRUE); + ee_build_label(out, e->primary, alert->args, TRUE); g_string_append(out, "</span>\n\n"); oerr = g_string_new(""); - ee_build_label(oerr, e->primary, error->args, FALSE); + ee_build_label(oerr, e->primary, alert->args, FALSE); perr = g_strdup (oerr->str); g_string_free (oerr, TRUE); } else perr = g_strdup (gtk_window_get_title (GTK_WINDOW (dialog))); if (e->secondary) { - ee_build_label(out, e->secondary, error->args, TRUE); + ee_build_label(out, e->secondary, alert->args, TRUE); oerr = g_string_new(""); - ee_build_label(oerr, e->secondary, error->args, TRUE); + ee_build_label(oerr, e->secondary, alert->args, TRUE); serr = g_strdup (oerr->str); g_string_free (oerr, TRUE); } @@ -620,12 +620,12 @@ e_error_new_dialog(GtkWindow *parent, EError *error) } gint -e_error_run_dialog(GtkWindow *parent, EError *error) +e_alert_run_dialog(GtkWindow *parent, EAlert *alert) { GtkWidget *w; gint res; - w = e_error_new_dialog(parent, error); + w = e_alert_new_dialog(parent, alert); res = gtk_dialog_run((GtkDialog *)w); gtk_widget_destroy(w); @@ -634,7 +634,7 @@ e_error_run_dialog(GtkWindow *parent, EError *error) } /** - * e_error_dialog_count_buttons: + * e_alert_dialog_count_buttons: * @dialog: a #GtkDialog * * Counts the number of buttons in @dialog's action area. @@ -642,7 +642,7 @@ e_error_run_dialog(GtkWindow *parent, EError *error) * Returns: number of action area buttons **/ guint -e_error_dialog_count_buttons (GtkDialog *dialog) +e_alert_dialog_count_buttons (GtkDialog *dialog) { GtkWidget *container; GList *children, *iter; @@ -664,35 +664,35 @@ e_error_dialog_count_buttons (GtkDialog *dialog) } GtkWidget * -e_error_new_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...) +e_alert_new_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...) { GtkWidget *w; - EError *e; + EAlert *e; va_list ap; va_start(ap, arg0); - e = e_error_newv(tag, arg0, ap); + e = e_alert_newv(tag, arg0, ap); va_end(ap); - w = e_error_new_dialog (parent, e); - e_error_free (e); + w = e_alert_new_dialog (parent, e); + e_alert_free (e); return w; } gint -e_error_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...) +e_alert_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...) { - EError *e; + EAlert *e; va_list ap; gint response; va_start(ap, arg0); - e = e_error_newv(tag, arg0, ap); + e = e_alert_newv(tag, arg0, ap); va_end(ap); - response = e_error_run_dialog (parent, e); - e_error_free (e); + response = e_alert_run_dialog (parent, e); + e_alert_free (e); return response; } diff --git a/e-util/e-alert.h b/e-util/e-alert.h new file mode 100644 index 0000000000..d38f0a4c62 --- /dev/null +++ b/e-util/e-alert.h @@ -0,0 +1,66 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Michael Zucchi <notzed@ximian.com> + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef _E_ALERT_H +#define _E_ALERT_H + +#include <stdarg.h> +#include <gtk/gtk.h> + +/* + * Some standard alerts, if these are altered or added to, + * update devel-docs/misc/errors.txt + * + * Several more basic ones are needed. + */ + +#define E_ALERT_INFO "builtin:info" +#define E_ALERT_INFO_PRIMARY "builtin:info-primary" +#define E_ALERT_WARNING "builtin:warning" +#define E_ALERT_WARNING_PRIMARY "builtin:warning-primary" +#define E_ALERT_ERROR "builtin:error" +#define E_ALERT_ERROR_PRIMARY "builtin:error-primary" + +/* takes filename, returns OK if yes */ +#define E_ALERT_ASK_FILE_EXISTS_OVERWRITE "system:ask-save-file-exists-overwrite" +/* takes filename, reason */ +#define E_ALERT_NO_SAVE_FILE "system:no-save-file" +/* takes filename, reason */ +#define E_ALERT_NO_LOAD_FILE "system:no-save-file" + +typedef struct _EAlert EAlert; + +EAlert *e_alert_new(const gchar *tag, const gchar *arg0, ...); +EAlert *e_alert_newv(const gchar *tag, const gchar *arg0, va_list ap); + +void e_alert_free (EAlert *alert); + +/* Convenience functions for displaying the alert in a GtkDialog */ +GtkWidget *e_alert_new_dialog(GtkWindow *parent, EAlert *alert); +GtkWidget *e_alert_new_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...); + +gint e_alert_run_dialog(GtkWindow *parent, EAlert *alert); +gint e_alert_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...); + +guint e_alert_dialog_count_buttons (GtkDialog *dialog); + +#endif /* !_E_ALERT_H */ diff --git a/e-util/e-error.h b/e-util/e-error.h deleted file mode 100644 index 8068668a26..0000000000 --- a/e-util/e-error.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Michael Zucchi <notzed@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_ERROR_H -#define _E_ERROR_H - -#include <stdarg.h> -#include <gtk/gtk.h> - -/* - * 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_INFO "builtin:info" -#define E_ERROR_INFO_PRIMARY "builtin:info-primary" -#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" - -typedef struct _EError EError; - -EError *e_error_new(const gchar *tag, const gchar *arg0, ...); -EError *e_error_newv(const gchar *tag, const gchar *arg0, va_list ap); - -void e_error_free (EError *error); - -/* Convenience functions for displaying the error in a GtkDialog */ -GtkWidget *e_error_new_dialog(GtkWindow *parent, EError *error); -GtkWidget *e_error_new_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...); - -gint e_error_run_dialog(GtkWindow *parent, EError *error); -gint e_error_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...); - -guint e_error_dialog_count_buttons (GtkDialog *dialog); - -#endif /* !_E_ERROR_H */ diff --git a/e-util/e-non-intrusive-error-dialog.h b/e-util/e-non-intrusive-error-dialog.h index 4c38808ea2..2b03a7ec7c 100644 --- a/e-util/e-non-intrusive-error-dialog.h +++ b/e-util/e-non-intrusive-error-dialog.h @@ -23,7 +23,6 @@ #define __E_ERROR_DIALOG_H__ #include <glib-object.h> -#include "e-error.h" #include "e-icon-factory.h" #include "e-logger.h" diff --git a/e-util/e-util.c b/e-util/e-util.c index b5e9f101c4..ade2b38fbf 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -1426,6 +1426,7 @@ e_util_guess_mime_type (const gchar *filename, gboolean localfile) return mime_type; } +/* XXX: Should e-util/ really depend on filter/ ?? */ GSList * e_util_get_category_filter_options (void) { |