diff options
-rw-r--r-- | doc/reference/shell/eshell-sections.txt | 3 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-signature-list.sgml | 19 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/eshell-unused.sgml | 10 | ||||
-rw-r--r-- | e-util/e-signature-list.c | 186 | ||||
-rw-r--r-- | e-util/e-signature-list.h | 85 | ||||
-rw-r--r-- | e-util/e-signature-utils.c | 14 | ||||
-rw-r--r-- | widgets/misc/e-signature-editor.c | 7 |
7 files changed, 188 insertions, 136 deletions
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index f5163458c9..07ee9b495d 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -1042,7 +1042,8 @@ e_signature_list_save e_signature_list_add e_signature_list_change e_signature_list_remove -e_signature_list_find +e_signature_list_find_by_name +e_signature_list_find_by_uid <SUBSECTION Standard> E_SIGNATURE_LIST E_IS_SIGNATURE_LIST diff --git a/doc/reference/shell/tmpl/e-signature-list.sgml b/doc/reference/shell/tmpl/e-signature-list.sgml index 1297695139..340e187726 100644 --- a/doc/reference/shell/tmpl/e-signature-list.sgml +++ b/doc/reference/shell/tmpl/e-signature-list.sgml @@ -55,7 +55,7 @@ Container for Signatures </para> -@gconf: +@client: @Returns: @@ -65,7 +65,7 @@ Container for Signatures </para> @signature_list: -@gconf: +@client: <!-- ##### FUNCTION e_signature_list_save ##### --> @@ -103,14 +103,23 @@ Container for Signatures @signature: -<!-- ##### FUNCTION e_signature_list_find ##### --> +<!-- ##### FUNCTION e_signature_list_find_by_name ##### --> <para> </para> @signature_list: -@type: -@key: +@signature_name: +@Returns: + + +<!-- ##### FUNCTION e_signature_list_find_by_uid ##### --> +<para> + +</para> + +@signature_list: +@signature_uid: @Returns: diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml index 1428d63fc2..e60ce1256a 100644 --- a/doc/reference/shell/tmpl/eshell-unused.sgml +++ b/doc/reference/shell/tmpl/eshell-unused.sgml @@ -439,3 +439,13 @@ e-shell-window.sgml @searchbar: @label_visible: +<!-- ##### FUNCTION e_signature_list_find ##### --> +<para> + +</para> + +@signature_list: +@type: +@key: +@Returns: + diff --git a/e-util/e-signature-list.c b/e-util/e-signature-list.c index bcc476bfc8..7a58e8fea4 100644 --- a/e-util/e-signature-list.c +++ b/e-util/e-signature-list.c @@ -21,15 +21,16 @@ * */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "e-signature-list.h" +#include <config.h> #include <string.h> #include <libedataserver/e-uid.h> -#include "e-signature-list.h" +#define E_SIGNATURE_LIST_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_SIGNATURE_LIST, ESignatureListPrivate)) struct _ESignatureListPrivate { GConfClient *gconf; @@ -46,80 +47,73 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -static void e_signature_list_finalize (GObject *object); -static void e_signature_list_dispose (GObject *object); - G_DEFINE_TYPE ( ESignatureList, e_signature_list, E_TYPE_LIST) static void -e_signature_list_class_init (ESignatureListClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - - object_class->dispose = e_signature_list_dispose; - object_class->finalize = e_signature_list_finalize; - - signals[SIGNATURE_ADDED] = - g_signal_new ("signature-added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_added), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); - signals[SIGNATURE_CHANGED] = - g_signal_new ("signature-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_changed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); - signals[SIGNATURE_REMOVED] = - g_signal_new ("signature-removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESignatureListClass, signature_removed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - E_TYPE_SIGNATURE); -} - -static void -e_signature_list_init (ESignatureList *list) -{ - list->priv = g_new0 (struct _ESignatureListPrivate, 1); -} - -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); + gconf_client_notify_remove ( + list->priv->gconf, list->priv->notify_id); g_object_unref (list->priv->gconf); list->priv->gconf = NULL; } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_signature_list_parent_class)->dispose (object); } static void -e_signature_list_finalize (GObject *object) +e_signature_list_class_init (ESignatureListClass *class) { - ESignatureList *list = (ESignatureList *) object; + GObjectClass *object_class; + + g_type_class_add_private (class, sizeof (ESignatureListPrivate)); - g_free (list->priv); + object_class = G_OBJECT_CLASS (class); + object_class->dispose = e_signature_list_dispose; - G_OBJECT_CLASS (e_signature_list_parent_class)->finalize (object); + signals[SIGNATURE_ADDED] = g_signal_new ( + "signature-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ESignatureListClass, signature_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_SIGNATURE); + + signals[SIGNATURE_CHANGED] = g_signal_new ( + "signature-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ESignatureListClass, signature_changed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_SIGNATURE); + + signals[SIGNATURE_REMOVED] = g_signal_new ( + "signature-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ESignatureListClass, signature_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_SIGNATURE); +} + +static void +e_signature_list_init (ESignatureList *signature_list) +{ + signature_list->priv = E_SIGNATURE_LIST_GET_PRIVATE (signature_list); } static GSList * @@ -398,51 +392,83 @@ e_signature_list_remove (ESignatureList *signature_list, ESignature *signature) } /** - * e_signature_list_find: - * @signature_list: signature list - * @type: Type of search. - * @key: Search key. + * e_signature_list_find_by_name: + * @signature_list: an #ESignatureList + * @name: the signature name to find * - * Perform a search of the signature list on a single key. + * Searches @signature_list for the given signature name. * - * @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 + * Returns: the matching signature or %NULL if it doesn't exist + **/ +ESignature * +e_signature_list_find_by_name (ESignatureList *signature_list, + const gchar *signature_name) +{ + ESignature *signature = NULL; + EIterator *it; + + g_return_val_if_fail (E_IS_SIGNATURE_LIST (signature_list), NULL); + + /* this could use a callback for more flexibility ... + ... but this makes the common cases easier */ + + if (signature_name == NULL) + return NULL; + + for (it = e_list_get_iterator (E_LIST (signature_list)); + e_iterator_is_valid (it); + e_iterator_next (it)) { + const gchar *value; + + /* XXX EIterator misuses const. */ + signature = (ESignature *) e_iterator_get (it); + value = e_signature_get_name (signature); + + if (g_strcmp0 (value, signature_name) == 0) + break; + + signature = NULL; + } + + g_object_unref (it); + + return signature; +} + +/** + * e_signature_list_find_by_uid: + * @signature_list: an #ESignatureList + * @name: the signature UID to find + * + * Searches @signature_list for the given signature UID. * - * Return value: The signature or NULL if it doesn't exist. + * Returns: the matching signature or %NULL if it doesn't exist **/ -const ESignature * -e_signature_list_find (ESignatureList *signature_list, - e_signature_find_t type, - const gchar *key) +ESignature * +e_signature_list_find_by_uid (ESignatureList *signature_list, + const gchar *signature_uid) { ESignature *signature = NULL; EIterator *it; + g_return_val_if_fail (E_IS_SIGNATURE_LIST (signature_list), NULL); + /* this could use a callback for more flexibility ... ... but this makes the common cases easier */ - if (!key) + if (signature_uid == NULL) return NULL; - for (it = e_list_get_iterator ((EList *) signature_list); + for (it = e_list_get_iterator (E_LIST (signature_list)); e_iterator_is_valid (it); e_iterator_next (it)) { const gchar *value = NULL; /* XXX EIterator misuses const. */ signature = (ESignature *) e_iterator_get (it); + value = e_signature_get_uid (signature); - switch (type) { - case E_SIGNATURE_FIND_NAME: - value = e_signature_get_name (signature); - break; - case E_SIGNATURE_FIND_UID: - value = e_signature_get_uid (signature); - break; - } - - if (g_strcmp0 (value, key) == 0) + if (g_strcmp0 (value, signature_uid) == 0) break; signature = NULL; diff --git a/e-util/e-signature-list.h b/e-util/e-signature-list.h index b662272180..f2c9df7865 100644 --- a/e-util/e-signature-list.h +++ b/e-util/e-signature-list.h @@ -21,55 +21,72 @@ * */ -#ifndef __E_SIGNATURE_LIST__ -#define __E_SIGNATURE_LIST__ +#ifndef E_SIGNATURE_LIST_H +#define E_SIGNATURE_LIST_H #include <libedataserver/e-list.h> #include <e-util/e-signature.h> #include <gconf/gconf-client.h> -#define E_TYPE_SIGNATURE_LIST (e_signature_list_get_type ()) -#define E_SIGNATURE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIGNATURE_LIST, ESignatureList)) -#define E_SIGNATURE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIGNATURE_LIST, ESignatureListClass)) -#define E_IS_SIGNATURE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIGNATURE_LIST)) -#define E_IS_SIGNATURE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIGNATURE_LIST)) +/* Standard GObject macros */ +#define E_TYPE_SIGNATURE_LIST \ + (e_signature_list_get_type ()) +#define E_SIGNATURE_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SIGNATURE_LIST, ESignatureList)) +#define E_SIGNATURE_LIST_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SIGNATURE_LIST, ESignatureListClass)) +#define E_IS_SIGNATURE_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SIGNATURE_LIST)) +#define E_IS_SIGNATURE_LIST_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_SIGNATURE_LIST)) +#define E_SIGNATURE_LIST_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SIGNATURE_LIST, ESignatureListClass)) + +G_BEGIN_DECLS typedef struct _ESignatureList ESignatureList; typedef struct _ESignatureListClass ESignatureListClass; - -/* search options for the find command */ -typedef enum { - E_SIGNATURE_FIND_NAME, - E_SIGNATURE_FIND_UID -} e_signature_find_t; +typedef struct _ESignatureListPrivate ESignatureListPrivate; struct _ESignatureList { - EList parent_object; - - struct _ESignatureListPrivate *priv; + EList parent; + ESignatureListPrivate *priv; }; struct _ESignatureListClass { EListClass parent_class; - /* signals */ - void (* signature_added) (ESignatureList *, ESignature *); - void (* signature_changed) (ESignatureList *, ESignature *); - void (* signature_removed) (ESignatureList *, ESignature *); + /* Signals */ + void (*signature_added) (ESignatureList *signature_list, + ESignature *signature); + void (*signature_changed) (ESignatureList *signature_list, + ESignature *signature); + void (*signature_removed) (ESignatureList *signature_list, + ESignature *signature); }; -GType e_signature_list_get_type (void); - -ESignatureList *e_signature_list_new (GConfClient *gconf); -void e_signature_list_construct (ESignatureList *signature_list, GConfClient *gconf); - -void e_signature_list_save (ESignatureList *signature_list); - -void e_signature_list_add (ESignatureList *signature_list, ESignature *signature); -void e_signature_list_change (ESignatureList *signature_list, ESignature *signature); -void e_signature_list_remove (ESignatureList *signature_list, ESignature *signature); - -const ESignature *e_signature_list_find (ESignatureList *signature_list, e_signature_find_t type, const gchar *key); - -#endif /* __E_SIGNATURE_LIST__ */ +GType e_signature_list_get_type (void); +ESignatureList *e_signature_list_new (GConfClient *client); +void e_signature_list_construct (ESignatureList *signature_list, + GConfClient *client); +void e_signature_list_save (ESignatureList *signature_list); +void e_signature_list_add (ESignatureList *signature_list, + ESignature *signature); +void e_signature_list_change (ESignatureList *signature_list, + ESignature *signature); +void e_signature_list_remove (ESignatureList *signature_list, + ESignature *signature); +ESignature * e_signature_list_find_by_name (ESignatureList *signature_list, + const gchar *signature_name); +ESignature * e_signature_list_find_by_uid (ESignatureList *signature_list, + const gchar *signature_uid); + +G_END_DECLS + +#endif /* E_SIGNATURE_LIST_H */ diff --git a/e-util/e-signature-utils.c b/e-util/e-signature-utils.c index d42d6f325d..8c190791d5 100644 --- a/e-util/e-signature-utils.c +++ b/e-util/e-signature-utils.c @@ -52,34 +52,24 @@ ESignature * e_get_signature_by_name (const gchar *name) { ESignatureList *signature_list; - const ESignature *signature; - e_signature_find_t find; g_return_val_if_fail (name != NULL, NULL); - find = E_SIGNATURE_FIND_NAME; signature_list = e_get_signature_list (); - signature = e_signature_list_find (signature_list, find, name); - /* XXX ESignatureList misuses const. */ - return (ESignature *) signature; + return e_signature_list_find_by_name (signature_list, name); } ESignature * e_get_signature_by_uid (const gchar *uid) { ESignatureList *signature_list; - const ESignature *signature; - e_signature_find_t find; g_return_val_if_fail (uid != NULL, NULL); - find = E_SIGNATURE_FIND_UID; signature_list = e_get_signature_list (); - signature = e_signature_list_find (signature_list, find, uid); - /* XXX ESignatureList misuses const. */ - return (ESignature *) signature; + return e_signature_list_find_by_uid (signature_list, uid); } gchar * diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c index effbf8bc30..68bd3a323f 100644 --- a/widgets/misc/e-signature-editor.c +++ b/widgets/misc/e-signature-editor.c @@ -175,10 +175,9 @@ action_save_and_close_cb (GtkAction *action, return; } - /* Don't overwrite an existing signature of the same name. - * XXX ESignatureList misuses const. */ - same_name = (ESignature *) e_signature_list_find ( - signature_list, E_SIGNATURE_FIND_NAME, signature_name); + /* Don't overwrite an existing signature of the same name. */ + same_name = + e_signature_list_find_by_name (signature_list, signature_name); if (same_name != NULL && !e_signature_is_equal (signature, same_name)) { e_alert_submit ( GTK_WIDGET (editor), |