aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-05-18 12:44:13 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-05-18 12:44:13 +0800
commitd1551390ffa5d2b4b22f3cf085f30676885e8f0d (patch)
treecc0cc603423ab0fd20ace16ab0037216e00c44df /widgets/misc
parentf8921df01e239b4d77ce9b226c68fbd62cbffb9a (diff)
downloadgsoc2013-evolution-d1551390ffa5d2b4b22f3cf085f30676885e8f0d.tar.gz
gsoc2013-evolution-d1551390ffa5d2b4b22f3cf085f30676885e8f0d.tar.zst
gsoc2013-evolution-d1551390ffa5d2b4b22f3cf085f30676885e8f0d.zip
load the <help> tag if present. (ee_response): handle the help response
2004-05-18 Not Zed <NotZed@Ximian.com> * e-error.c (ee_load): load the <help> tag if present. (ee_response): handle the help response and swallow the signal. (e_error_newv): setup help button if we have a help uri. svn path=/trunk/; revision=25945
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/ChangeLog6
-rw-r--r--widgets/misc/e-error.c52
2 files changed, 45 insertions, 13 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 2fa8b0fbc8..d2d8abac2b 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,9 @@
+2004-05-18 Not Zed <NotZed@Ximian.com>
+
+ * e-error.c (ee_load): load the <help> tag if present.
+ (ee_response): handle the help response and swallow the signal.
+ (e_error_newv): setup help button if we have a help uri.
+
2004-05-17 Jeffrey Stedfast <fejj@novell.com>
* e-url-entry.c (init): Use E_ICON_SIZE_BUTTON for the icon size
diff --git a/widgets/misc/e-error.c b/widgets/misc/e-error.c
index 0d18da6a7b..2a2fd7426b 100644
--- a/widgets/misc/e-error.c
+++ b/widgets/misc/e-error.c
@@ -36,6 +36,7 @@
#include <gtk/gtkimage.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-url.h>
#include "e-error.h"
@@ -56,6 +57,7 @@ struct _e_error {
char *title;
char *primary;
char *secondary;
+ char *help_uri;
struct _e_error_button *buttons;
};
@@ -73,10 +75,10 @@ static struct _e_error_button default_ok_button = {
};
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 },
+ { 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 },
};
/* ********************************************************************** */
@@ -137,18 +139,16 @@ map_type(const char *name)
XML format:
<error id="error-id" type="info|warning|question|error"? response="default_response"? modal="true"? >
- <_title>Window Title</_title>?
- <_primary>Primary error text.</_primary>?
- <_secondary>Secondary error text.</_secondary>?
- <button stock="stock-button-id"? _label="button label"? response="response_id"? > *
+ <title>Window Title</title>?
+ <primary>Primary error text.</primary>?
+ <secondary>Secondary error text.</secondary>?
+ <help uri="help uri"/> ?
+ <button stock="stock-button-id"? label="button label"? response="response_id"? /> *
</error>
- Because we use intltool we need to do some weird shit to do with
- languages. title, primary and secondary will be expanded into
- per-language tags, specified using xml:lang property.
+ The tool e-error-tool is used to extract the translatable strings for
+ translation.
- The _label property will remain as plain english and we need to use
- gettext to extract it.
*/
static void
ee_load(const char *path)
@@ -232,6 +232,12 @@ ee_load(const char *path)
e->title = g_strdup(_(tmp));
xmlFree(tmp);
}
+ } else if (!strcmp(scan->name, "help")) {
+ tmp = xmlGetProp(scan, "uri");
+ if (tmp) {
+ e->help_uri = g_strdup(tmp);
+ xmlFree(tmp);
+ }
} else if (!strcmp(scan->name, "button")) {
struct _e_error_button *b;
@@ -355,6 +361,21 @@ ee_build_label(GString *out, const char *fmt, GPtrArray *args)
g_string_append(out, fmt);
}
+static void
+ee_response(GtkWidget *w, guint button, struct _e_error *e)
+{
+ GError *err = NULL;
+
+ if (button == GTK_RESPONSE_HELP) {
+ g_signal_stop_emission_by_name(w, "response");
+ gnome_url_show(e->help_uri, &err);
+ if (err) {
+ g_warning("Unable to run help uri: %s", err->message);
+ g_error_free(err);
+ }
+ }
+}
+
GtkWidget *
e_error_newv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap)
{
@@ -401,6 +422,11 @@ e_error_newv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap)
gtk_window_set_modal((GtkWindow *)dialog, TRUE);
gtk_window_set_destroy_with_parent((GtkWindow *)dialog, TRUE);
+ if (e->help_uri) {
+ w = gtk_dialog_add_button(dialog, GTK_STOCK_HELP, GTK_RESPONSE_HELP);
+ g_signal_connect(dialog, "response", G_CALLBACK(ee_response), e);
+ }
+
b = e->buttons;
if (b == NULL) {
gtk_dialog_add_button(dialog, GTK_STOCK_OK, GTK_RESPONSE_OK);