2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / addrgather.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2002-2011 Match Grun and the Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 /*
21 * Dialog for gathering EMail addresses from mail folder.
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #include "defs.h"
29
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
33 #include <gtk/gtk.h>
34
35 #include "main.h"
36 #include "inc.h"
37 #include "mbox.h"
38 #include "filesel.h"
39 #include "foldersel.h"
40 #include "gtkutils.h"
41 #include "alertpanel.h"
42 #include "manage_window.h"
43 #include "folder.h"
44 #include "utils.h"
45 #include "prefs_common.h"
46
47 #include "addrharvest.h"
48 #include "addrindex.h"
49 #include "addrbook.h"
50
51 #define PAGE_FIELDS     0
52 #define PAGE_FINISH     1
53
54 #define NUM_FIELDS      6
55
56 #define FIELDS_N_COLS              2
57 #define FIELDS_COL_WIDTH_HEADER    100
58 #define FIELDS_COL_WIDTH_COUNT     140
59
60 #define MIN_FOLDER_SIZE 20
61 #define DFL_FOLDER_SIZE 50
62
63 typedef enum {
64         FIELD_COL_HEADER = 0,
65         FIELD_COL_COUNT  = 1
66 } AddrHarvest;
67
68 /*
69 * The dialog.
70 */
71 static struct _AddrHarvest {
72         GtkWidget *window;
73         GtkWidget *notebook;
74         GtkWidget *labelFolder;
75         GtkWidget *entryBook;
76         GtkWidget *checkHeader[ NUM_FIELDS ];
77         GtkWidget *spinbtnFolder;
78         GtkWidget *checkRecurse;
79         GtkWidget *btnOk;
80         GtkWidget *btnCancel;
81         GtkWidget *statusbar;
82         gint      status_cid;
83         gboolean  cancelled;
84         gboolean  done;
85         gchar     *folderPath;
86         GtkWidget *clistCount;
87 } addrgather_dlg;
88
89 static AddressIndex *_harv_addressIndex_;
90 static AddressBookFile *_harv_addressBook_;
91 static gchar *_harv_headerNames_[] = {
92         HEADER_FROM,
93         HEADER_REPLY_TO,
94         HEADER_SENDER,
95         HEADER_TO,
96         HEADER_CC,
97         HEADER_ERRORS_TO
98 };
99 static GList *_harv_messageList_;
100
101 static void addrgather_dlg_status_show( gchar *msg ) {
102         if( addrgather_dlg.statusbar != NULL ) {
103                 gtk_statusbar_pop( GTK_STATUSBAR(addrgather_dlg.statusbar),
104                         addrgather_dlg.status_cid );
105                 if( msg ) {
106                         gtk_statusbar_push(
107                                 GTK_STATUSBAR(addrgather_dlg.statusbar),
108                                 addrgather_dlg.status_cid, msg );
109                 }
110         }
111 }
112
113 static gint addrgather_dlg_delete_event(
114         GtkWidget *widget, GdkEventAny *event, gpointer data )
115 {
116         addrgather_dlg.cancelled = TRUE;
117         gtk_main_quit();
118         return TRUE;
119 }
120
121 static gboolean addrgather_dlg_key_pressed(
122         GtkWidget *widget, GdkEventKey *event, gpointer data )
123 {
124         if( event && event->keyval == GDK_KEY_Escape ) {
125                 addrgather_dlg.cancelled = TRUE;
126                 gtk_main_quit();
127         }
128         return FALSE;
129 }
130
131 static void addrgather_size_allocate(
132         GtkWidget *widget, GtkAllocation *allocation )
133 {
134         cm_return_if_fail( allocation != NULL );
135         
136         prefs_common.addrgather_width   = allocation->width;
137         prefs_common.addrgather_height  = allocation->height;
138 }
139
140 #define FMT_BUFSIZE 32
141
142 static gboolean addrgather_dlg_harvest() {
143         GtkCMCList *clist;
144         gchar *text[ FIELDS_N_COLS ];
145         AddressHarvester *harvester;
146         AddressBookFile *abf;
147         gchar *name;
148         gchar *newFile;
149         gchar str[ FMT_BUFSIZE ];
150         gint cnt;
151         gint i;
152         gint sz;
153
154         name = gtk_editable_get_chars( GTK_EDITABLE(addrgather_dlg.entryBook), 0, -1 );
155         if( name == NULL || strlen( name ) < 1 ) {
156                 addrgather_dlg_status_show(
157                         _( "Please specify name for address book." ) );
158                 g_free( name );
159                 return FALSE;
160         }
161
162         /* Create harvest helper */
163         harvester = addrharvest_create();
164         addrharvest_set_path( harvester, addrgather_dlg.folderPath );
165
166         for( i = 0; i < NUM_FIELDS; i++ ) {
167                 addrharvest_set_header( harvester, _harv_headerNames_[i],
168                 gtk_toggle_button_get_active(
169                         GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]) ) );
170         }
171         addrharvest_set_recurse( harvester,
172                 gtk_toggle_button_get_active(
173                         GTK_TOGGLE_BUTTON( addrgather_dlg.checkRecurse ) ) );
174
175         if( addrharvest_check_header( harvester ) == FALSE ) {
176                 addrgather_dlg_status_show(
177                         _( "Please select the mail headers to search." ) );
178                 addrharvest_free( harvester );
179                 g_free( name );
180                 return FALSE;
181         }
182
183         /* Go fer it */
184         addrgather_dlg_status_show( _( "Collecting addresses..." ) );
185         GTK_EVENTS_FLUSH();
186         sz = gtk_spin_button_get_value_as_int(
187                 GTK_SPIN_BUTTON( addrgather_dlg.spinbtnFolder ) );
188         addrharvest_set_folder_size( harvester, sz );
189
190         /* Create address book */
191         abf = addrbook_create_book();
192         addrbook_set_path( abf, _harv_addressIndex_->filePath );
193         newFile = addrbook_guess_next_file( abf );
194         addrbook_set_file( abf, newFile );
195         addrbook_set_name( abf, name );
196         g_free( newFile );
197         g_free( name );
198
199         /* Harvest addresses */
200         addrharvest_harvest(
201                 harvester, abf->addressCache, _harv_messageList_ );
202         addrbook_save_data( abf );
203         _harv_addressBook_ = abf;
204
205         /* Update summary count */
206         clist = GTK_CMCLIST(addrgather_dlg.clistCount);
207         gtk_cmclist_clear( clist );
208         for( i = 0; i < NUM_FIELDS; i++ ) {
209                 cnt = addrharvest_get_count( harvester, _harv_headerNames_[i] );
210                 if( cnt < 1 ) {
211                         strcpy( str, "-" );
212                 }
213                 else {
214                         sprintf( str, "%d", cnt );
215                 }
216                 text[ FIELD_COL_HEADER ] = _harv_headerNames_[i];
217                 text[ FIELD_COL_COUNT  ] = str;
218                 gtk_cmclist_append( clist, text );
219         }
220
221         addrharvest_free( harvester );
222
223         addrgather_dlg_status_show(_("Addresses collected successfully."));
224
225         /* Display summary page */
226         gtk_notebook_set_current_page(
227                 GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_FINISH );
228         addrgather_dlg.done = TRUE;
229         gtk_widget_set_sensitive( addrgather_dlg.btnCancel, FALSE );
230         gtk_widget_grab_default( addrgather_dlg.btnOk );
231
232         return TRUE;
233 }
234
235 static void addrgather_dlg_ok( GtkWidget *widget, gpointer data ) {
236         if(addrgather_dlg.done) {
237                 addrgather_dlg.done = FALSE;
238                 gtk_main_quit();
239                 return;
240         }
241         if( addrgather_dlg_harvest() ) {
242                 addrgather_dlg.cancelled = FALSE;
243         }
244 }
245
246 static void addrgather_dlg_cancel( GtkWidget *widget, gpointer data ) {
247         gtk_main_quit();
248 }
249
250 #define PACK_CHECK_BUTTON(box, checkbtn, label) \
251 { \
252         checkbtn = gtk_check_button_new_with_label(label); \
253         gtk_widget_show(checkbtn); \
254         gtk_box_pack_start(GTK_BOX(box), checkbtn, FALSE, TRUE, 0); \
255 }
256
257 /*
258  * Create notebook page for mail headers.
259  * Enter: pageNum Page number.
260  *        pageLbl Page label.
261  */
262 static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
263 {
264         GtkWidget *vbox;
265         GtkWidget *vboxf;
266         GtkWidget *hboxs;
267         GtkWidget *table;
268         GtkWidget *label;
269         GtkWidget *labelFolder;
270         GtkWidget *entryBook;
271         GtkWidget *frameHeader;
272         GtkWidget *checkHeader[NUM_FIELDS];
273         GtkWidget *spinbtnFolder;
274         GtkAdjustment *adjFolder;
275         GtkWidget *checkRecurse;
276         gint top;
277         gint i;
278         CLAWS_TIP_DECL();
279
280         /* Container */
281         vbox = gtk_vbox_new(FALSE, 6);
282         gtk_container_add(GTK_CONTAINER(addrgather_dlg.notebook), vbox);
283         gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
284
285         /* Notebook page */
286         label = gtk_label_new(pageLbl);
287         gtk_widget_show(label);
288         gtk_notebook_set_tab_label(GTK_NOTEBOOK(addrgather_dlg.notebook),
289                                    gtk_notebook_get_nth_page(GTK_NOTEBOOK(addrgather_dlg.notebook),
290                                                              pageNum), label);
291
292         /* Upper area - Field list */
293         table = gtk_table_new(4, 2, FALSE);
294         gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
295         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
296         gtk_table_set_col_spacings(GTK_TABLE(table), 4);
297
298         /* First row */
299         top = 0;
300         label = gtk_label_new(_("Current folder:"));
301         gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
302         gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
303
304         labelFolder = gtk_label_new("");
305         gtk_table_attach( GTK_TABLE(table), labelFolder, 1, 2, top, (top + 1),
306                 GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
307         gtk_misc_set_alignment( GTK_MISC(labelFolder), 0, 0.5 );
308
309         /* Second row */
310         top = 1;
311         label = gtk_label_new(_("Address book name:"));
312         gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
313         gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
314
315         entryBook = gtk_entry_new();
316         gtk_table_attach( GTK_TABLE(table), entryBook, 1, 2, top, (top + 1),
317                 GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
318
319         /* Third row */
320         top = 2;
321         label = gtk_label_new(_("Address book folder size:"));
322         gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
323         gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
324         CLAWS_SET_TIP(label,
325                         _("Maximum amount of entries per folder within the newly created address book"));
326
327         hboxs = gtk_hbox_new(FALSE, 8);
328         adjFolder = gtk_adjustment_new(DFL_FOLDER_SIZE, MIN_FOLDER_SIZE, G_MAXINT, 1, 10, 0);
329         spinbtnFolder = gtk_spin_button_new(GTK_ADJUSTMENT(adjFolder), 1, 0);
330         gtk_box_pack_start(GTK_BOX(hboxs), spinbtnFolder, FALSE, FALSE, 0);
331         gtk_widget_set_size_request(spinbtnFolder, 100, -1);
332         gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbtnFolder), TRUE);
333         gtk_table_attach(GTK_TABLE(table), hboxs, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
334         CLAWS_SET_TIP(spinbtnFolder,
335                         _("Maximum amount of entries per folder within the newly created address book"));
336
337         /* Fourth row */
338         top = 3;
339         frameHeader = gtk_frame_new(_("Process these mail header fields"));
340         gtk_widget_show(frameHeader);
341         gtk_table_attach(GTK_TABLE(table), frameHeader, 0, 2, top, (top + 4), GTK_FILL, 0, 0, 0);
342         gtk_frame_set_label_align(GTK_FRAME(frameHeader), 0.01, 0.5);
343
344         /* Check boxes */
345         vboxf = gtk_vbox_new(FALSE, 0);
346         gtk_widget_show(vboxf);
347         gtk_container_add(GTK_CONTAINER(frameHeader), vboxf);
348         gtk_container_set_border_width(GTK_CONTAINER(vboxf), 8);
349
350         for (i = 0; i < NUM_FIELDS; i++) {
351                 PACK_CHECK_BUTTON(vboxf, checkHeader[i],
352                         prefs_common_translated_header_name(_harv_headerNames_[i]));
353                 addrgather_dlg.checkHeader[i] = checkHeader[i];
354         }
355
356         /* Recurse folders */
357         top += 4;
358         checkRecurse = gtk_check_button_new_with_label( _("Include subfolders" ) );
359         gtk_table_attach( GTK_TABLE(table), checkRecurse, 0, 2, top, (top + 1),
360                         GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
361
362         addrgather_dlg.labelFolder   = labelFolder;
363         addrgather_dlg.entryBook     = entryBook;
364         addrgather_dlg.spinbtnFolder = spinbtnFolder;
365         addrgather_dlg.checkRecurse  = checkRecurse;
366 }
367
368 /*
369  * Create notebook page for summary counts.
370  * Enter: pageNum Page number.
371  *        pageLbl Page label.
372  */
373 static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
374         GtkWidget *label;
375         GtkWidget *vbox;
376         GtkWidget *clistSWin;
377         GtkWidget *clistCount;
378         gchar *titles[ FIELDS_N_COLS ];
379         gint i;
380
381         titles[ FIELD_COL_HEADER ] = _("Header Name");
382         titles[ FIELD_COL_COUNT  ] = _("Address Count");
383
384         vbox = gtk_vbox_new(FALSE, 8);
385         gtk_container_add( GTK_CONTAINER( addrgather_dlg.notebook ), vbox );
386         gtk_container_set_border_width( GTK_CONTAINER (vbox), 8 );
387
388         label = gtk_label_new( pageLbl );
389         gtk_widget_show( label );
390         gtk_notebook_set_tab_label(
391                 GTK_NOTEBOOK( addrgather_dlg.notebook ),
392                 gtk_notebook_get_nth_page( GTK_NOTEBOOK( addrgather_dlg.notebook ), pageNum ),
393                 label );
394
395         /* Summary count */
396         clistSWin = gtk_scrolled_window_new( NULL, NULL );
397         gtk_container_add( GTK_CONTAINER(vbox), clistSWin );
398         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clistSWin),
399                                        GTK_POLICY_AUTOMATIC,
400                                        GTK_POLICY_AUTOMATIC);
401
402         clistCount = gtk_cmclist_new_with_titles( FIELDS_N_COLS, titles );
403         gtk_container_add( GTK_CONTAINER(clistSWin), clistCount );
404         gtk_cmclist_set_selection_mode( GTK_CMCLIST(clistCount), GTK_SELECTION_BROWSE );
405         gtk_cmclist_set_column_width(
406                         GTK_CMCLIST(clistCount), FIELD_COL_HEADER, FIELDS_COL_WIDTH_HEADER );
407         gtk_cmclist_set_column_width(
408                         GTK_CMCLIST(clistCount), FIELD_COL_COUNT, FIELDS_COL_WIDTH_COUNT );
409
410         for( i = 0; i < FIELDS_N_COLS; i++ )
411                 gtkut_widget_set_can_focus(GTK_CMCLIST(clistCount)->column[i].button, FALSE);
412
413         addrgather_dlg.clistCount = clistCount;
414 }
415
416 /*
417  * Create notebook page for warning message.
418  * Enter: pageNum Page number.
419  *        pageLbl Page label.
420  */
421 static void addrgather_dlg_create(void)
422 {
423         GtkWidget *window;
424         GtkWidget *notebook;
425         GtkWidget *btnOk;
426         GtkWidget *btnCancel;
427         GtkWidget *statusbar;
428         GtkWidget *vbox;
429         GtkWidget *hbbox;
430         GtkWidget *hsbox;
431         static GdkGeometry geometry;
432         
433         window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "addrgather");
434         gtk_container_set_border_width(GTK_CONTAINER(window), 4);
435         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
436         gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
437         
438         g_signal_connect(G_OBJECT(window), "delete_event",
439                          G_CALLBACK(addrgather_dlg_delete_event), NULL);
440         g_signal_connect(G_OBJECT(window), "key_press_event",
441                          G_CALLBACK(addrgather_dlg_key_pressed), NULL);
442         g_signal_connect(G_OBJECT(window), "size_allocate",
443                          G_CALLBACK(addrgather_size_allocate), NULL);
444
445         vbox = gtk_vbox_new(FALSE, 6);
446         gtk_container_add(GTK_CONTAINER(window), vbox);
447
448         /* Notebook */
449         notebook = gtk_notebook_new();
450         gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
451         gtk_widget_show(notebook);
452         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
453         gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
454
455         /* Status line */
456         hsbox = gtk_hbox_new(FALSE, 0);
457         gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, 0);
458         statusbar = gtk_statusbar_new();
459         gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, 0);
460
461         /* Button panel */
462         gtkut_stock_button_set_create(&hbbox, &btnCancel, GTK_STOCK_CANCEL,
463                                       &btnOk, GTK_STOCK_OK,
464                                       NULL, NULL);
465         gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
466
467         /* Signal handlers */
468         g_signal_connect(G_OBJECT(btnOk), "clicked",
469                          G_CALLBACK(addrgather_dlg_ok), NULL);
470         g_signal_connect(G_OBJECT(btnCancel), "clicked",
471                          G_CALLBACK(addrgather_dlg_cancel), NULL);
472
473         if (!geometry.min_width) {
474                 geometry.min_width = 450;
475                 geometry.min_height = -1;
476         }
477
478         gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
479                                       GDK_HINT_MIN_SIZE);
480         gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.addrgather_width,
481                                     prefs_common.addrgather_height);
482
483         addrgather_dlg.window     = window;
484         addrgather_dlg.notebook   = notebook;
485         addrgather_dlg.btnOk      = btnOk;
486         addrgather_dlg.btnCancel  = btnCancel;
487         addrgather_dlg.statusbar  = statusbar;
488         addrgather_dlg.status_cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar),
489                                                                  "Collect Email Address Dialog");
490
491         /* Create notebook pages */
492         addrgather_page_fields(PAGE_FIELDS, _("Header Fields"));
493         addrgather_page_finish(PAGE_FINISH, _("Finish"));
494         gtk_widget_show_all(addrgather_dlg.window);
495 }
496
497 /*
498  * Harvest addresses main window.
499  * Enter: folderItem Source folder.
500  *        addrIndex  Address index.
501  *        sourceInd  Source indicator: FALSE - Folder, TRUE - Messages.
502  *        msgList    List of message numbers, or NULL to process folder.
503  * Return: Populated address book file, or NULL if none created.
504  */
505 AddressBookFile *addrgather_dlg_execute(FolderItem *folderItem, AddressIndex *addrIndex,
506                                         gboolean sourceInd, GList *msgList)
507 {
508         gint i;
509
510         _harv_addressIndex_ = addrIndex;
511         _harv_addressBook_ = NULL;
512         _harv_messageList_ = msgList;
513
514         /* Create dialog */
515         if (!addrgather_dlg.window)
516                 addrgather_dlg_create();
517         
518         addrgather_dlg.done = FALSE;
519
520         gtk_notebook_set_current_page(GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_FIELDS);
521         addrgather_dlg.folderPath = folder_item_get_path(folderItem);
522
523         /* Setup some default values */
524         gtk_label_set_text(GTK_LABEL(addrgather_dlg.labelFolder), folderItem->path);
525         gtk_entry_set_text(GTK_ENTRY(addrgather_dlg.entryBook), folderItem->path);
526
527         for (i = 0; i < NUM_FIELDS; i++) {
528                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
529                                              FALSE);
530                 if (g_utf8_collate(_harv_headerNames_[i], HEADER_FROM) == 0)
531                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
532                                                     TRUE);
533         }
534
535         gtk_widget_set_sensitive(addrgather_dlg.btnOk, TRUE);
536         gtk_widget_set_sensitive(addrgather_dlg.btnCancel, TRUE);
537         gtk_widget_grab_default(addrgather_dlg.btnOk);
538
539         /* Apply window title */
540         if (sourceInd) {
541                 gtk_window_set_title(GTK_WINDOW(addrgather_dlg.window),
542                                      _("Collect email addresses from selected messages"));
543                 gtk_widget_set_sensitive(addrgather_dlg.checkRecurse, FALSE);
544         } else {
545                 gtk_window_set_title(GTK_WINDOW(addrgather_dlg.window),
546                                      _("Collect email addresses from folder"));
547                 gtk_widget_set_sensitive(addrgather_dlg.checkRecurse, TRUE);
548         }
549         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkRecurse), FALSE);
550
551         addrgather_dlg_status_show("");
552         gtk_widget_show(addrgather_dlg.window);
553         gtk_window_set_modal(GTK_WINDOW(addrgather_dlg.window), TRUE);
554         gtk_widget_grab_focus(addrgather_dlg.entryBook);
555         manage_window_set_transient(GTK_WINDOW(addrgather_dlg.window));
556         gtk_main();
557
558         g_free(addrgather_dlg.folderPath);
559         addrgather_dlg.folderPath = NULL;
560         gtk_widget_hide(addrgather_dlg.window);
561         gtk_window_set_modal(GTK_WINDOW(addrgather_dlg.window), FALSE);
562         _harv_addressIndex_ = NULL;
563
564         if (addrgather_dlg.cancelled == TRUE)
565                 return NULL;
566
567         return _harv_addressBook_;
568 }
569
570 /*
571 * End of Source.
572 */
573
574