aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-signature-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'e-util/e-signature-list.c')
-rw-r--r--e-util/e-signature-list.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/e-util/e-signature-list.c b/e-util/e-signature-list.c
index cbdf138a95..8acd9af451 100644
--- a/e-util/e-signature-list.c
+++ b/e-util/e-signature-list.c
@@ -61,7 +61,7 @@ GType
e_signature_list_get_type (void)
{
static GType type = 0;
-
+
if (!type) {
GTypeInfo type_info = {
sizeof (ESignatureListClass),
@@ -72,10 +72,10 @@ e_signature_list_get_type (void)
0,
(GInstanceInitFunc) e_signature_list_init,
};
-
+
type = g_type_register_static (E_TYPE_LIST, "ESignatureList", &type_info, 0);
}
-
+
return type;
}
@@ -84,13 +84,13 @@ static void
e_signature_list_class_init (ESignatureListClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
-
+
parent_class = g_type_class_ref (E_TYPE_LIST);
-
+
/* virtual method override */
object_class->dispose = e_signature_list_dispose;
object_class->finalize = e_signature_list_finalize;
-
+
/* signals */
signals[SIGNATURE_ADDED] =
g_signal_new ("signature-added",
@@ -131,14 +131,14 @@ static void
e_signature_list_dispose (GObject *object)
{
ESignatureList *list = (ESignatureList *) object;
-
+
if (list->priv->gconf) {
if (list->priv->notify_id != 0)
gconf_client_notify_remove (list->priv->gconf, list->priv->notify_id);
g_object_unref (list->priv->gconf);
list->priv->gconf = NULL;
}
-
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -146,9 +146,9 @@ static void
e_signature_list_finalize (GObject *object)
{
ESignatureList *list = (ESignatureList *) object;
-
+
g_free (list->priv);
-
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -156,13 +156,13 @@ static GSList *
add_autogen (ESignatureList *list, GSList *new_sigs)
{
ESignature *autogen;
-
+
autogen = e_signature_new ();
autogen->name = g_strdup ("Autogenerated");
autogen->autogen = TRUE;
-
+
e_list_append (E_LIST (list), autogen);
-
+
return g_slist_prepend (new_sigs, autogen);
}
@@ -178,9 +178,9 @@ gconf_signatures_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
EIterator *iter;
gboolean found;
char *uid;
-
+
old_sigs = e_list_duplicate (E_LIST (signature_list));
-
+
list = gconf_client_get_list (client, "/apps/evolution/mail/signatures", GCONF_VALUE_STRING, NULL);
for (l = list; l; l = l->next) {
found = FALSE;
@@ -196,16 +196,16 @@ gconf_signatures_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
e_iterator_delete (iter);
if (e_signature_set_from_xml (signature, l->data))
g_signal_emit (signature_list, signals[SIGNATURE_CHANGED], 0, signature);
-
+
have_autogen |= signature->autogen;
-
+
break;
}
}
-
+
g_object_unref (iter);
}
-
+
if (!found) {
/* Must be a new signature */
signature = e_signature_new_from_xml (l->data);
@@ -214,20 +214,20 @@ gconf_signatures_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
signature->uid = e_uid_new ();
resave = TRUE;
}
-
+
e_list_append (E_LIST (signature_list), signature);
new_sigs = g_slist_prepend (new_sigs, signature);
}
-
+
g_free (uid);
}
-
+
if (!have_autogen) {
new_sigs = add_autogen (signature_list, new_sigs);
have_autogen = TRUE;
resave = TRUE;
}
-
+
if (new_sigs != NULL) {
/* Now emit signals for each added signature. */
l = g_slist_reverse (new_sigs);
@@ -240,17 +240,17 @@ gconf_signatures_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry,
l = n;
}
}
-
+
/* Anything left in old_sigs must have been deleted */
for (iter = e_list_get_iterator (old_sigs); e_iterator_is_valid (iter); e_iterator_next (iter)) {
signature = (ESignature *) e_iterator_get (iter);
e_list_remove (E_LIST (signature_list), signature);
g_signal_emit (signature_list, signals[SIGNATURE_REMOVED], 0, signature);
}
-
+
g_object_unref (iter);
g_object_unref (old_sigs);
-
+
signature_list->priv->resave = resave;
}
@@ -258,9 +258,9 @@ static void *
copy_func (const void *data, void *closure)
{
GObject *object = (GObject *)data;
-
+
g_object_ref (object);
-
+
return object;
}
@@ -289,12 +289,12 @@ ESignatureList *
e_signature_list_new (GConfClient *gconf)
{
ESignatureList *signature_list;
-
+
g_return_val_if_fail (GCONF_IS_CLIENT (gconf), NULL);
-
+
signature_list = g_object_new (E_TYPE_SIGNATURE_LIST, NULL);
e_signature_list_construct (signature_list, gconf);
-
+
return signature_list;
}
@@ -302,29 +302,29 @@ void
e_signature_list_construct (ESignatureList *signature_list, GConfClient *gconf)
{
g_return_if_fail (GCONF_IS_CLIENT (gconf));
-
+
e_list_construct (E_LIST (signature_list), copy_func, free_func, NULL);
signature_list->priv->gconf = gconf;
g_object_ref (gconf);
-
+
gconf_client_add_dir (signature_list->priv->gconf,
"/apps/evolution/mail/signatures",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
+
signature_list->priv->notify_id =
gconf_client_notify_add (signature_list->priv->gconf,
"/apps/evolution/mail/signatures",
gconf_signatures_changed, signature_list,
NULL, NULL);
-
+
gconf_signatures_changed (signature_list->priv->gconf,
signature_list->priv->notify_id,
NULL, signature_list);
-
+
if (signature_list->priv->resave) {
e_signature_list_save (signature_list);
signature_list->priv->resave = FALSE;
- }
+ }
}
@@ -341,27 +341,27 @@ e_signature_list_save (ESignatureList *signature_list)
ESignature *signature;
EIterator *iter;
char *xmlbuf;
-
+
for (iter = e_list_get_iterator (E_LIST (signature_list));
e_iterator_is_valid (iter);
e_iterator_next (iter)) {
signature = (ESignature *) e_iterator_get (iter);
-
+
if ((xmlbuf = e_signature_to_xml (signature)))
list = g_slist_append (list, xmlbuf);
}
-
+
g_object_unref (iter);
-
+
gconf_client_set_list (signature_list->priv->gconf,
"/apps/evolution/mail/signatures",
GCONF_VALUE_STRING, list, NULL);
-
+
while (list) {
g_free (list->data);
list = g_slist_remove (list, list->data);
}
-
+
gconf_client_suggest_sync (signature_list->priv->gconf, NULL);
}
@@ -370,7 +370,7 @@ e_signature_list_save (ESignatureList *signature_list)
* e_signature_list_add:
* @signatures: signature list
* @signature: signature to add
- *
+ *
* Add an signature to the signature list. Will emit the signature-changed
* event.
**/
@@ -386,7 +386,7 @@ e_signature_list_add (ESignatureList *signatures, ESignature *signature)
* e_signature_list_change:
* @signatures: signature list
* @signature: signature to change
- *
+ *
* Signal that the details of an signature have changed.
**/
void
@@ -401,7 +401,7 @@ e_signature_list_change (ESignatureList *signatures, ESignature *signature)
* e_signature_list_remove:
* @signatures: signature list
* @signature: signature
- *
+ *
* Remove an signature from the signature list, and emit the
* signature-removed signal. If the signature was the default signature,
* then reset the default to the first signature.
@@ -422,13 +422,13 @@ e_signature_list_remove (ESignatureList *signatures, ESignature *signature)
* @signatures: signature list
* @type: Type of search.
* @key: Search key.
- *
+ *
* Perform a search of the signature list on a single key.
*
* @type must be set from one of the following search types:
* E_SIGNATURE_FIND_NAME - Find a signature by signature name.
* E_SIGNATURE_FIND_UID - Find a signature based on UID
- *
+ *
* Return value: The signature or NULL if it doesn't exist.
**/
const ESignature *
@@ -436,20 +436,20 @@ e_signature_list_find (ESignatureList *signatures, e_signature_find_t type, cons
{
const ESignature *signature = NULL;
EIterator *it;
-
+
/* this could use a callback for more flexibility ...
... but this makes the common cases easier */
-
+
if (!key)
return NULL;
-
+
for (it = e_list_get_iterator ((EList *) signatures);
e_iterator_is_valid (it);
e_iterator_next (it)) {
int found = 0;
-
+
signature = (const ESignature *) e_iterator_get (it);
-
+
switch (type) {
case E_SIGNATURE_FIND_NAME:
found = strcmp (signature->name, key) == 0;
@@ -458,14 +458,14 @@ e_signature_list_find (ESignatureList *signatures, e_signature_find_t type, cons
found = strcmp (signature->uid, key) == 0;
break;
}
-
+
if (found)
break;
-
+
signature = NULL;
}
-
+
g_object_unref (it);
-
+
return signature;
}