aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-alert.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-08-29 22:44:16 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-08-29 23:22:28 +0800
commit4c05b9e925764a6035e3d0fcbfc1f0458d36f5d9 (patch)
treece1154c5d7487fbd566c5b68df90fb8259b4604e /e-util/e-alert.c
parente6c42ecc596fb16247e8d1d591a5d244a61d0e24 (diff)
downloadgsoc2013-evolution-4c05b9e925764a6035e3d0fcbfc1f0458d36f5d9.tar.gz
gsoc2013-evolution-4c05b9e925764a6035e3d0fcbfc1f0458d36f5d9.tar.zst
gsoc2013-evolution-4c05b9e925764a6035e3d0fcbfc1f0458d36f5d9.zip
Coding style and whitespace cleanup.
Diffstat (limited to 'e-util/e-alert.c')
-rw-r--r--e-util/e-alert.c164
1 files changed, 82 insertions, 82 deletions
diff --git a/e-util/e-alert.c b/e-util/e-alert.c
index 9ca0c02df3..aebee8326a 100644
--- a/e-util/e-alert.c
+++ b/e-util/e-alert.c
@@ -101,12 +101,12 @@ static struct {
};
static gint
-map_response(const gchar *name)
+map_response (const gchar *name)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (response_map); i++)
- if (!strcmp(name, response_map[i].name))
+ if (!strcmp (name, response_map[i].name))
return response_map[i].id;
return 0;
@@ -123,13 +123,13 @@ static struct {
};
static gint
-map_type(const gchar *name)
+map_type (const gchar *name)
{
gint i;
if (name) {
for (i = 0; i < G_N_ELEMENTS (type_map); i++)
- if (!strcmp(name, type_map[i].name))
+ if (!strcmp (name, type_map[i].name))
return i;
}
@@ -176,7 +176,7 @@ struct _EAlertPrivate
*/
static void
-e_alert_load(const gchar *path)
+e_alert_load (const gchar *path)
{
xmlDocPtr doc = NULL;
xmlNodePtr root, error, scan;
@@ -193,38 +193,38 @@ e_alert_load(const gchar *path)
return;
}
- root = xmlDocGetRootElement(doc);
+ root = xmlDocGetRootElement (doc);
if (root == NULL
|| strcmp((gchar *)root->name, "error-list") != 0
|| (tmp = (gchar *)xmlGetProp(root, (const guchar *)"domain")) == NULL) {
g_warning("Error file '%s' invalid format", path);
- xmlFreeDoc(doc);
+ xmlFreeDoc (doc);
return;
}
- table = g_hash_table_lookup(alert_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->alerts = g_hash_table_new(g_str_hash, g_str_equal);
- g_hash_table_insert(alert_table, (gpointer) table->domain, table);
+ table = g_malloc0 (sizeof (*table));
+ table->domain = g_strdup (tmp);
+ 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) {
- table->translation_domain = g_strdup(tmp2);
- xmlFree(tmp2);
+ table->translation_domain = g_strdup (tmp2);
+ xmlFree (tmp2);
tmp2 = (gchar *)xmlGetProp(root, (const guchar *)"translation-localedir");
if (tmp2) {
- bindtextdomain(table->translation_domain, tmp2);
- xmlFree(tmp2);
+ bindtextdomain (table->translation_domain, tmp2);
+ xmlFree (tmp2);
}
}
} else
g_warning("Error file '%s', domain '%s' already used, merging", path, tmp);
- xmlFree(tmp);
+ xmlFree (tmp);
for (error = root->children;error;error = error->next) {
if (!strcmp((gchar *)error->name, "error")) {
@@ -232,89 +232,89 @@ e_alert_load(const gchar *path)
if (tmp == NULL)
continue;
- e = g_malloc0(sizeof(*e));
- e->id = g_strdup(tmp);
+ e = g_malloc0 (sizeof (*e));
+ e->id = g_strdup (tmp);
e->scroll = FALSE;
- xmlFree(tmp);
+ xmlFree (tmp);
lastbutton = (struct _e_alert_button *)&e->buttons;
tmp = (gchar *)xmlGetProp(error, (const guchar *)"modal");
if (tmp) {
if (!strcmp(tmp, "true"))
e->flags |= GTK_DIALOG_MODAL;
- xmlFree(tmp);
+ xmlFree (tmp);
}
tmp = (gchar *)xmlGetProp(error, (const guchar *)"type");
- e->type = map_type(tmp);
+ e->type = map_type (tmp);
if (tmp)
- xmlFree(tmp);
+ xmlFree (tmp);
tmp = (gchar *)xmlGetProp(error, (const guchar *)"default");
if (tmp) {
- e->default_response = map_response(tmp);
- xmlFree(tmp);
+ e->default_response = map_response (tmp);
+ xmlFree (tmp);
}
tmp = (gchar *)xmlGetProp(error, (const guchar *)"scroll");
if (tmp) {
if (!strcmp(tmp, "yes"))
e->scroll = TRUE;
- xmlFree(tmp);
+ xmlFree (tmp);
}
for (scan = error->children;scan;scan=scan->next) {
if (!strcmp((gchar *)scan->name, "primary")) {
- if ((tmp = (gchar *)xmlNodeGetContent(scan))) {
- e->primary = g_strdup(dgettext(table->translation_domain, tmp));
- xmlFree(tmp);
+ if ((tmp = (gchar *)xmlNodeGetContent (scan))) {
+ e->primary = g_strdup (dgettext (table->translation_domain, tmp));
+ xmlFree (tmp);
}
} else if (!strcmp((gchar *)scan->name, "secondary")) {
- if ((tmp = (gchar *)xmlNodeGetContent(scan))) {
- e->secondary = g_strdup(dgettext(table->translation_domain, tmp));
- xmlFree(tmp);
+ if ((tmp = (gchar *)xmlNodeGetContent (scan))) {
+ e->secondary = g_strdup (dgettext (table->translation_domain, tmp));
+ xmlFree (tmp);
}
} else if (!strcmp((gchar *)scan->name, "title")) {
- if ((tmp = (gchar *)xmlNodeGetContent(scan))) {
- e->title = g_strdup(dgettext(table->translation_domain, tmp));
- xmlFree(tmp);
+ if ((tmp = (gchar *)xmlNodeGetContent (scan))) {
+ e->title = g_strdup (dgettext (table->translation_domain, tmp));
+ xmlFree (tmp);
}
} else if (!strcmp((gchar *)scan->name, "help")) {
tmp = (gchar *)xmlGetProp(scan, (const guchar *)"uri");
if (tmp) {
- e->help_uri = g_strdup(tmp);
- xmlFree(tmp);
+ e->help_uri = g_strdup (tmp);
+ xmlFree (tmp);
}
} else if (!strcmp((gchar *)scan->name, "button")) {
struct _e_alert_button *b;
gchar *label = NULL;
gchar *stock = NULL;
- b = g_malloc0(sizeof(*b));
+ b = g_malloc0 (sizeof (*b));
tmp = (gchar *)xmlGetProp(scan, (const guchar *)"stock");
if (tmp) {
- stock = g_strdup(tmp);
+ stock = g_strdup (tmp);
b->stock = stock;
- xmlFree(tmp);
+ xmlFree (tmp);
}
tmp = (gchar *)xmlGetProp(scan, (const guchar *)"label");
if (tmp) {
- label = g_strdup(dgettext(table->translation_domain, tmp));
+ label = g_strdup (dgettext (table->translation_domain, tmp));
b->label = label;
- xmlFree(tmp);
+ xmlFree (tmp);
}
tmp = (gchar *)xmlGetProp(scan, (const guchar *)"response");
if (tmp) {
- b->response = map_response(tmp);
- xmlFree(tmp);
+ b->response = map_response (tmp);
+ xmlFree (tmp);
}
if (stock == NULL && label == NULL) {
g_warning("Error file '%s': missing button details in error '%s'", path, e->id);
- g_free(stock);
- g_free(label);
- g_free(b);
+ g_free (stock);
+ g_free (label);
+ g_free (b);
} else {
lastbutton->next = b;
lastbutton = b;
@@ -322,15 +322,15 @@ e_alert_load(const gchar *path)
}
}
- g_hash_table_insert(table->alerts, (gpointer) e->id, e);
+ g_hash_table_insert (table->alerts, (gpointer) e->id, e);
}
}
- xmlFreeDoc(doc);
+ xmlFreeDoc (doc);
}
static void
-e_alert_load_tables(void)
+e_alert_load_tables (void)
{
GDir *dir;
const gchar *d;
@@ -341,38 +341,38 @@ e_alert_load_tables(void)
if (alert_table != NULL)
return;
- alert_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 alert types */
- table = g_malloc0(sizeof(*table));
+ table = g_malloc0 (sizeof (*table));
table->domain = "builtin";
- table->alerts = g_hash_table_new(g_str_hash, g_str_equal);
+ 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);
+ g_hash_table_insert (alert_table, (gpointer) table->domain, table);
/* look for installed alert tables */
base = g_build_filename (EVOLUTION_PRIVDATADIR, "errors", NULL);
- dir = g_dir_open(base, 0, NULL);
+ dir = g_dir_open (base, 0, NULL);
if (dir == NULL) {
g_free (base);
return;
}
- while ((d = g_dir_read_name(dir))) {
+ while ((d = g_dir_read_name (dir))) {
gchar *path;
if (d[0] == '.')
continue;
- path = g_build_filename(base, d, NULL);
- e_alert_load(path);
- g_free(path);
+ path = g_build_filename (base, d, NULL);
+ e_alert_load (path);
+ g_free (path);
}
- g_dir_close(dir);
+ g_dir_close (dir);
g_free (base);
}
@@ -445,18 +445,18 @@ e_alert_constructed (GObject *obj)
g_return_if_fail (alert_table);
g_return_if_fail (alert->priv->tag);
- domain = g_alloca(strlen(alert->priv->tag)+1);
- strcpy(domain, alert->priv->tag);
- id = strchr(domain, ':');
+ domain = g_alloca (strlen (alert->priv->tag)+1);
+ strcpy (domain, alert->priv->tag);
+ id = strchr (domain, ':');
if (id)
*id++ = 0;
- table = g_hash_table_lookup(alert_table, domain);
+ table = g_hash_table_lookup (alert_table, domain);
g_return_if_fail (table);
- alert->priv->definition = g_hash_table_lookup(table->alerts, id);
+ alert->priv->definition = g_hash_table_lookup (table->alerts, id);
- g_warn_if_fail(alert->priv->definition);
+ g_warn_if_fail (alert->priv->definition);
}
@@ -514,35 +514,35 @@ e_alert_init (EAlert *self)
* Returns: a new #EAlert
**/
EAlert *
-e_alert_new(const gchar *tag, ...)
+e_alert_new (const gchar *tag, ...)
{
EAlert *e;
va_list ap;
- va_start(ap, tag);
- e = e_alert_new_valist(tag, ap);
- va_end(ap);
+ va_start (ap, tag);
+ e = e_alert_new_valist (tag, ap);
+ va_end (ap);
return e;
}
EAlert *
-e_alert_new_valist(const gchar *tag, va_list ap)
+e_alert_new_valist (const gchar *tag, va_list ap)
{
gchar *tmp;
GPtrArray *args = g_ptr_array_new_with_free_func (g_free);
tmp = va_arg (ap, gchar *);
while (tmp) {
- g_ptr_array_add(args, g_strdup (tmp));
- tmp = va_arg(ap, gchar *);
+ g_ptr_array_add (args, g_strdup (tmp));
+ tmp = va_arg (ap, gchar *);
}
return e_alert_new_array (tag, args);
}
EAlert *
-e_alert_new_array(const gchar *tag, GPtrArray *args)
+e_alert_new_array (const gchar *tag, GPtrArray *args)
{
return g_object_new (E_TYPE_ALERT, "tag", tag, "args", args, NULL);
}
@@ -568,21 +568,21 @@ e_alert_format_string (GString *out,
gint id;
while (fmt
- && (newstart = strchr(fmt, '{'))
- && (end = strchr(newstart+1, '}'))) {
- g_string_append_len(out, fmt, newstart-fmt);
- id = atoi(newstart+1);
+ && (newstart = strchr (fmt, '{'))
+ && (end = strchr (newstart+1, '}'))) {
+ g_string_append_len (out, fmt, newstart-fmt);
+ id = atoi (newstart+1);
if (id < args->len) {
if (escape_args)
- e_alert_append_text_escaped(out, args->pdata[id]);
+ e_alert_append_text_escaped (out, args->pdata[id]);
else
- g_string_append(out, args->pdata[id]);
+ g_string_append (out, args->pdata[id]);
} else
g_warning("Error references argument %d not supplied by caller", id);
fmt = end+1;
}
- g_string_append(out, fmt);
+ g_string_append (out, fmt);
}
guint32
@@ -647,7 +647,7 @@ e_alert_get_primary_text (EAlert *alert,
g_free (title);
}
else {
- g_string_append_printf(
+ g_string_append_printf (
formatted,
_("Internal error, unknown error '%s' requested"),
alert->priv->tag);