talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 5771a0a7e2efd3bb4d48a9e23c24a9e4ff88e5da
parent deddd41a3220da4164b7c29cf0f05f01f7dbe954
Author: Holger Berndt <hb@claws-mail.org>
Date:   Sun, 10 May 2009 20:08:52 +0000

2009-05-10 [holger]	3.7.1cvs53

	* src/addr_compl.c
	* src/addr_compl.h
		Add a hook to make it possible for plugins to
		modify the address completion list

Diffstat:
MChangeLog | 7+++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/addr_compl.c | 42++++++++++++++++++------------------------
Msrc/addr_compl.h | 19+++++++++++++++++--
5 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +2009-05-10 [holger] 3.7.1cvs53 + + * src/addr_compl.c + * src/addr_compl.h + Add a hook to make it possible for plugins to + modify the address completion list + 2009-05-06 [paul] 3.7.1cvs52 * src/folder.c diff --git a/PATCHSETS b/PATCHSETS @@ -3792,3 +3792,4 @@ ( cvs diff -u -r 1.36.2.169 -r 1.36.2.170 src/common/utils.c; ) > 3.7.1cvs50.patchset ( cvs diff -u -r 1.36.2.170 -r 1.36.2.171 src/common/utils.c; ) > 3.7.1cvs51.patchset ( cvs diff -u -r 1.213.2.193 -r 1.213.2.194 src/folder.c; cvs diff -u -r 1.83.2.154 -r 1.83.2.155 src/mimeview.c; ) > 3.7.1cvs52.patchset +( cvs diff -u -r 1.27.2.45 -r 1.27.2.46 src/addr_compl.c; cvs diff -u -r 1.8.2.12 -r 1.8.2.13 src/addr_compl.h; ) > 3.7.1cvs53.patchset diff --git a/configure.ac b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=7 MICRO_VERSION=1 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=52 +EXTRA_VERSION=53 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/addr_compl.c b/src/addr_compl.c @@ -40,6 +40,7 @@ #include "utils.h" #include "prefs_common.h" #include "claws.h" +#include "hooks.h" #include <pthread.h> /*! @@ -69,18 +70,7 @@ enum { * addresses a little more (e.g. break up alfons@proteus.demon.nl into * something like alfons, proteus, demon, nl; and then completing on * any of those words). - */ - -/** - * address_entry - structure which refers to the original address entry in the - * address book . */ -typedef struct -{ - gchar *name; - gchar *address; - GList *grp_emails; -} address_entry; /** * completion_entry - structure used to complete addresses, with a reference @@ -230,7 +220,7 @@ static void free_all(void) * \param str Index string value. * \param ae Entry containing address data. */ -static void add_address1(const char *str, address_entry *ae) +void addr_compl_add_address1(const char *str, address_entry *ae) { completion_entry *ce1; ce1 = g_new0(completion_entry, 1), @@ -270,19 +260,19 @@ static gint add_address(const gchar *name, const gchar *address, cm_return_val_if_fail(ae != NULL, -1); ae->name = g_strdup(name); - ae->address = g_strdup(address); + ae->address = g_strdup(address); ae->grp_emails = grp_emails; g_address_list = g_list_prepend(g_address_list, ae); - add_address1(name, ae); + addr_compl_add_address1(name, ae); if (address != NULL && *address != '\0') - add_address1(address, ae); - + addr_compl_add_address1(address, ae); + if (nick != NULL && *nick != '\0') - add_address1(nick, ae); - + addr_compl_add_address1(nick, ae); + if ( alias != NULL && *alias != '\0') { - add_address1(alias, ae); + addr_compl_add_address1(alias, ae); } return 0; @@ -296,13 +286,17 @@ static void read_address_book(gchar *folderpath) { free_completion_list(); addrindex_load_completion( add_address, folderpath ); + + /* plugins may hook in here to modify/extend the completion list */ + hooks_invoke(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, &g_address_list); + g_address_list = g_list_reverse(g_address_list); g_completion_list = g_list_reverse(g_completion_list); /* merge the completion entry list into g_completion */ if (g_completion_list) { g_completion_add_items(g_completion, g_completion_list); if (debug_get_mode()) - debug_print("read %d items in %s\n", + debug_print("read %d items in %s\n", g_list_length(g_completion_list), folderpath?folderpath:"(null)"); } @@ -1681,11 +1675,11 @@ static gboolean addr_compl_selected(GtkTreeSelection *selector, * not using a time out would result in a crash. if this doesn't work * safely, maybe we should set variables when receiving button presses * in the tree view. */ - if (!window->destroying) { - window->destroying = TRUE; + if (!window->destroying) { + window->destroying = TRUE; g_idle_add((GSourceFunc) addr_compl_defer_select_destruct, data); - } - + } + return TRUE; } diff --git a/src/addr_compl.h b/src/addr_compl.h @@ -15,14 +15,27 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ - + #ifndef __ADDR_COMPL_H__ #define __ADDR_COMPL_H__ #include <gtk/gtk.h> +#define ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST "address_completion_build_address_list_hooklist" + +/** + * address_entry - structure which refers to the original address entry in the + * address book . + */ +typedef struct +{ + gchar *name; + gchar *address; + GList *grp_emails; +} address_entry; + gint start_address_completion (gchar *folderpath); guint complete_address (const gchar *str); guint complete_matches_found (const gchar *str); @@ -39,4 +52,6 @@ void address_completion_end (GtkWidget *mainwindow); void addrcompl_initialize ( void ); void addrcompl_teardown ( void ); +void addr_compl_add_address1(const char *str, address_entry *ae); + #endif /* __ADDR_COMPL_H__ */