2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / addrgather.c
index 39f8a32ca4d0ec0989ce63d42a9f882f495b09ce..5bdaaa8b6495bf83575747095301a56d5748aecd 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002 Match Grun
+ * Copyright (C) 2002-2011 Match Grun and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 /*
 #include "defs.h"
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbbox.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkfilesel.h>
-#include <gtk/gtksignal.h>
-
-#include "intl.h"
+#include <gtk/gtk.h>
+
 #include "main.h"
 #include "inc.h"
 #include "mbox.h"
 #include "manage_window.h"
 #include "folder.h"
 #include "utils.h"
+#include "prefs_common.h"
 
 #include "addrharvest.h"
 #include "addrindex.h"
 #include "addrbook.h"
 
-#define PAGE_WARNING    0
-#define PAGE_FIELDS     1
-#define PAGE_FINISH     2
+#define PAGE_FIELDS     0
+#define PAGE_FINISH     1
 
 #define NUM_FIELDS      6
 
@@ -91,6 +81,7 @@ static struct _AddrHarvest {
        GtkWidget *statusbar;
        gint      status_cid;
        gboolean  cancelled;
+       gboolean  done;
        gchar     *folderPath;
        GtkWidget *clistCount;
 } addrgather_dlg;
@@ -107,7 +98,7 @@ static gchar *_harv_headerNames_[] = {
 };
 static GList *_harv_messageList_;
 
-void addrgather_dlg_status_show( gchar *msg ) {
+static void addrgather_dlg_status_show( gchar *msg ) {
        if( addrgather_dlg.statusbar != NULL ) {
                gtk_statusbar_pop( GTK_STATUSBAR(addrgather_dlg.statusbar),
                        addrgather_dlg.status_cid );
@@ -130,17 +121,26 @@ static gint addrgather_dlg_delete_event(
 static gboolean addrgather_dlg_key_pressed(
        GtkWidget *widget, GdkEventKey *event, gpointer data )
 {
-       if( event && event->keyval == GDK_Escape ) {
+       if( event && event->keyval == GDK_KEY_Escape ) {
                addrgather_dlg.cancelled = TRUE;
                gtk_main_quit();
        }
        return FALSE;
 }
 
+static void addrgather_size_allocate(
+       GtkWidget *widget, GtkAllocation *allocation )
+{
+       cm_return_if_fail( allocation != NULL );
+       
+       prefs_common.addrgather_width   = allocation->width;
+       prefs_common.addrgather_height  = allocation->height;
+}
+
 #define FMT_BUFSIZE 32
 
 static gboolean addrgather_dlg_harvest() {
-       GtkCList *clist;
+       GtkCMCList *clist;
        gchar *text[ FIELDS_N_COLS ];
        AddressHarvester *harvester;
        AddressBookFile *abf;
@@ -181,7 +181,8 @@ static gboolean addrgather_dlg_harvest() {
        }
 
        /* Go fer it */
-       addrgather_dlg_status_show( _( "Busy harvesting addresses..." ) );
+       addrgather_dlg_status_show( _( "Collecting addresses..." ) );
+       GTK_EVENTS_FLUSH();
        sz = gtk_spin_button_get_value_as_int(
                GTK_SPIN_BUTTON( addrgather_dlg.spinbtnFolder ) );
        addrharvest_set_folder_size( harvester, sz );
@@ -202,8 +203,8 @@ static gboolean addrgather_dlg_harvest() {
        _harv_addressBook_ = abf;
 
        /* Update summary count */
-       clist = GTK_CLIST(addrgather_dlg.clistCount);
-       gtk_clist_clear( clist );
+       clist = GTK_CMCLIST(addrgather_dlg.clistCount);
+       gtk_cmclist_clear( clist );
        for( i = 0; i < NUM_FIELDS; i++ ) {
                cnt = addrharvest_get_count( harvester, _harv_headerNames_[i] );
                if( cnt < 1 ) {
@@ -214,23 +215,29 @@ static gboolean addrgather_dlg_harvest() {
                }
                text[ FIELD_COL_HEADER ] = _harv_headerNames_[i];
                text[ FIELD_COL_COUNT  ] = str;
-               gtk_clist_append( clist, text );
+               gtk_cmclist_append( clist, text );
        }
 
        addrharvest_free( harvester );
 
-       addrgather_dlg_status_show( _("Addresses gathered successfully.") );
+       addrgather_dlg_status_show(_("Addresses collected successfully."));
 
        /* Display summary page */
-       gtk_notebook_set_page(
+       gtk_notebook_set_current_page(
                GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_FINISH );
-       gtk_widget_set_sensitive( addrgather_dlg.btnOk, FALSE );
-       gtk_widget_grab_default( addrgather_dlg.btnCancel );
+       addrgather_dlg.done = TRUE;
+       gtk_widget_set_sensitive( addrgather_dlg.btnCancel, FALSE );
+       gtk_widget_grab_default( addrgather_dlg.btnOk );
 
        return TRUE;
 }
 
 static void addrgather_dlg_ok( GtkWidget *widget, gpointer data ) {
+       if(addrgather_dlg.done) {
+               addrgather_dlg.done = FALSE;
+               gtk_main_quit();
+               return;
+       }
        if( addrgather_dlg_harvest() ) {
                addrgather_dlg.cancelled = FALSE;
        }
@@ -240,64 +247,11 @@ static void addrgather_dlg_cancel( GtkWidget *widget, gpointer data ) {
        gtk_main_quit();
 }
 
-#define PACK_CHECK_BUTTON(box, chkbtn, label) \
+#define PACK_CHECK_BUTTON(box, checkbtn, label) \
 { \
-       chkbtn = gtk_check_button_new_with_label(label); \
-       gtk_widget_show(chkbtn); \
-       gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \
-}
-
-/*
- * Create notebook page for warning message.
- * Enter: pageNum Page number.
- *        pageLbl Page label.
- */
-static void addrgather_page_warning( gint pageNum, gchar *pageLbl ) {
-       GtkWidget *vbox;
-       GtkWidget *table;
-       GtkWidget *label;
-       gint top;
-
-       vbox = gtk_vbox_new(FALSE, 8);
-       gtk_container_add( GTK_CONTAINER( addrgather_dlg.notebook ), vbox );
-       gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
-
-       label = gtk_label_new( pageLbl );
-       gtk_widget_show( label );
-       gtk_notebook_set_tab_label(
-               GTK_NOTEBOOK( addrgather_dlg.notebook ),
-               gtk_notebook_get_nth_page( GTK_NOTEBOOK( addrgather_dlg.notebook ), pageNum ),
-               label );
-
-       table = gtk_table_new(3, 2, FALSE);
-       gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
-       gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
-       gtk_table_set_row_spacings(GTK_TABLE(table), 8);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 8 );
-
-       /* First row */
-       top = 0;
-       label = gtk_label_new("");
-       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-
-       /* First row */
-       top++;
-       label = gtk_label_new( _("No folder or message was selected." ) );
-       gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
-       gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_LEFT );
-       gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
-
-       /* Second row */
-       top++;
-       label = gtk_label_new( _(
-                       "Please select a folder to process from the folder\n"
-                       "list. Alternatively, select one or messages from\n"
-                       "the message list." ) );
-
-       gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
-       gtk_label_set_justify( GTK_LABEL(label), GTK_JUSTIFY_LEFT );
-       gtk_misc_set_alignment( GTK_MISC(label), 0, 0.5 );
+       checkbtn = gtk_check_button_new_with_label(label); \
+       gtk_widget_show(checkbtn); \
+       gtk_box_pack_start(GTK_BOX(box), checkbtn, FALSE, TRUE, 0); \
 }
 
 /*
@@ -305,7 +259,8 @@ static void addrgather_page_warning( gint pageNum, gchar *pageLbl ) {
  * Enter: pageNum Page number.
  *        pageLbl Page label.
  */
-static void addrgather_page_fields( gint pageNum, gchar *pageLbl ) {
+static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
+{
        GtkWidget *vbox;
        GtkWidget *vboxf;
        GtkWidget *hboxs;
@@ -314,47 +269,46 @@ static void addrgather_page_fields( gint pageNum, gchar *pageLbl ) {
        GtkWidget *labelFolder;
        GtkWidget *entryBook;
        GtkWidget *frameHeader;
-       GtkWidget *checkHeader[ NUM_FIELDS ];
+       GtkWidget *checkHeader[NUM_FIELDS];
        GtkWidget *spinbtnFolder;
-       GtkObject *adjFolder;
+       GtkAdjustment *adjFolder;
        GtkWidget *checkRecurse;
        gint top;
        gint i;
+       CLAWS_TIP_DECL();
 
        /* Container */
-       vbox = gtk_vbox_new(FALSE, 8);
-       gtk_container_add( GTK_CONTAINER( addrgather_dlg.notebook ), vbox );
-       gtk_container_set_border_width( GTK_CONTAINER (vbox), 4 );
+       vbox = gtk_vbox_new(FALSE, 6);
+       gtk_container_add(GTK_CONTAINER(addrgather_dlg.notebook), vbox);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
 
        /* Notebook page */
-       label = gtk_label_new( pageLbl );
-       gtk_widget_show( label );
-       gtk_notebook_set_tab_label(
-               GTK_NOTEBOOK( addrgather_dlg.notebook ),
-               gtk_notebook_get_nth_page( GTK_NOTEBOOK( addrgather_dlg.notebook ), pageNum ),
-               label );
+       label = gtk_label_new(pageLbl);
+       gtk_widget_show(label);
+       gtk_notebook_set_tab_label(GTK_NOTEBOOK(addrgather_dlg.notebook),
+                                  gtk_notebook_get_nth_page(GTK_NOTEBOOK(addrgather_dlg.notebook),
+                                                            pageNum), label);
 
        /* Upper area - Field list */
-       table = gtk_table_new( 4, 2, FALSE);
-       gtk_box_pack_start( GTK_BOX(vbox), table, FALSE, FALSE, 0 );
-       gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
-       gtk_table_set_row_spacings( GTK_TABLE(table), 8 );
-       gtk_table_set_col_spacings( GTK_TABLE(table), 8 );
+       table = gtk_table_new(4, 2, FALSE);
+       gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
+       gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+       gtk_table_set_col_spacings(GTK_TABLE(table), 4);
 
        /* First row */
        top = 0;
-       label = gtk_label_new( _("Folder :") );
+       label = gtk_label_new(_("Current folder:"));
        gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
        gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
 
-       labelFolder = gtk_label_new( "" );
+       labelFolder = gtk_label_new("");
        gtk_table_attach( GTK_TABLE(table), labelFolder, 1, 2, top, (top + 1),
                GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
        gtk_misc_set_alignment( GTK_MISC(labelFolder), 0, 0.5 );
 
        /* Second row */
        top = 1;
-       label = gtk_label_new( _("Address Book :") );
+       label = gtk_label_new(_("Address book name:"));
        gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
        gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
 
@@ -364,40 +318,44 @@ static void addrgather_page_fields( gint pageNum, gchar *pageLbl ) {
 
        /* Third row */
        top = 2;
-       label = gtk_label_new( _("Folder Size :") );
+       label = gtk_label_new(_("Address book folder size:"));
        gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
        gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
-
-       hboxs = gtk_hbox_new( FALSE, 8 );
-       adjFolder =
-               gtk_adjustment_new( DFL_FOLDER_SIZE, MIN_FOLDER_SIZE, G_MAXINT, 1, 10, 100 );
-       spinbtnFolder = gtk_spin_button_new( GTK_ADJUSTMENT(adjFolder), 1, 0 );
-       gtk_box_pack_start( GTK_BOX(hboxs), spinbtnFolder, FALSE, FALSE, 0);
-       gtk_widget_set_usize( spinbtnFolder, 100, -1);
-       gtk_spin_button_set_numeric( GTK_SPIN_BUTTON(spinbtnFolder), TRUE );
-       gtk_table_attach( GTK_TABLE(table), hboxs, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0 );
+       CLAWS_SET_TIP(label,
+                       _("Maximum amount of entries per folder within the newly created address book"));
+
+       hboxs = gtk_hbox_new(FALSE, 8);
+       adjFolder = gtk_adjustment_new(DFL_FOLDER_SIZE, MIN_FOLDER_SIZE, G_MAXINT, 1, 10, 0);
+       spinbtnFolder = gtk_spin_button_new(GTK_ADJUSTMENT(adjFolder), 1, 0);
+       gtk_box_pack_start(GTK_BOX(hboxs), spinbtnFolder, FALSE, FALSE, 0);
+       gtk_widget_set_size_request(spinbtnFolder, 100, -1);
+       gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbtnFolder), TRUE);
+       gtk_table_attach(GTK_TABLE(table), hboxs, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
+       CLAWS_SET_TIP(spinbtnFolder,
+                       _("Maximum amount of entries per folder within the newly created address book"));
 
        /* Fourth row */
        top = 3;
-       frameHeader = gtk_frame_new( _("Process these mail header fields") );
-       gtk_widget_show( frameHeader );
-       gtk_table_attach( GTK_TABLE(table), frameHeader, 0, 2, top, (top + 4), GTK_FILL, 0, 0, 0 );
-       gtk_frame_set_label_align( GTK_FRAME(frameHeader), 0.01, 0.5 );
+       frameHeader = gtk_frame_new(_("Process these mail header fields"));
+       gtk_widget_show(frameHeader);
+       gtk_table_attach(GTK_TABLE(table), frameHeader, 0, 2, top, (top + 4), GTK_FILL, 0, 0, 0);
+       gtk_frame_set_label_align(GTK_FRAME(frameHeader), 0.01, 0.5);
 
        /* Check boxes */
-       vboxf = gtk_vbox_new( FALSE, 0 );
-       gtk_widget_show( vboxf );
-       gtk_container_add( GTK_CONTAINER( frameHeader ), vboxf );
-       gtk_container_set_border_width (GTK_CONTAINER( vboxf ), 8);
-
-       for( i = 0; i < NUM_FIELDS; i++ ) {
-               PACK_CHECK_BUTTON( vboxf, checkHeader[i], _harv_headerNames_[i] );
+       vboxf = gtk_vbox_new(FALSE, 0);
+       gtk_widget_show(vboxf);
+       gtk_container_add(GTK_CONTAINER(frameHeader), vboxf);
+       gtk_container_set_border_width(GTK_CONTAINER(vboxf), 8);
+
+       for (i = 0; i < NUM_FIELDS; i++) {
+               PACK_CHECK_BUTTON(vboxf, checkHeader[i],
+                       prefs_common_translated_header_name(_harv_headerNames_[i]));
                addrgather_dlg.checkHeader[i] = checkHeader[i];
        }
 
        /* Recurse folders */
        top += 4;
-       checkRecurse = gtk_check_button_new_with_label( _("Include sub-folders" ) );
+       checkRecurse = gtk_check_button_new_with_label( _("Include subfolders" ) );
        gtk_table_attach( GTK_TABLE(table), checkRecurse, 0, 2, top, (top + 1),
                        GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
 
@@ -441,16 +399,16 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
 
-       clistCount = gtk_clist_new_with_titles( FIELDS_N_COLS, titles );
+       clistCount = gtk_cmclist_new_with_titles( FIELDS_N_COLS, titles );
        gtk_container_add( GTK_CONTAINER(clistSWin), clistCount );
-       gtk_clist_set_selection_mode( GTK_CLIST(clistCount), GTK_SELECTION_BROWSE );
-       gtk_clist_set_column_width(
-                       GTK_CLIST(clistCount), FIELD_COL_HEADER, FIELDS_COL_WIDTH_HEADER );
-       gtk_clist_set_column_width(
-                       GTK_CLIST(clistCount), FIELD_COL_COUNT, FIELDS_COL_WIDTH_COUNT );
+       gtk_cmclist_set_selection_mode( GTK_CMCLIST(clistCount), GTK_SELECTION_BROWSE );
+       gtk_cmclist_set_column_width(
+                       GTK_CMCLIST(clistCount), FIELD_COL_HEADER, FIELDS_COL_WIDTH_HEADER );
+       gtk_cmclist_set_column_width(
+                       GTK_CMCLIST(clistCount), FIELD_COL_COUNT, FIELDS_COL_WIDTH_COUNT );
 
        for( i = 0; i < FIELDS_N_COLS; i++ )
-               GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clistCount)->column[i].button, GTK_CAN_FOCUS);
+               gtkut_widget_set_can_focus(GTK_CMCLIST(clistCount)->column[i].button, FALSE);
 
        addrgather_dlg.clistCount = clistCount;
 }
@@ -460,54 +418,51 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
  * Enter: pageNum Page number.
  *        pageLbl Page label.
  */
-static void addrgather_dlg_create( void ) {
+static void addrgather_dlg_create(void)
+{
        GtkWidget *window;
        GtkWidget *notebook;
        GtkWidget *btnOk;
        GtkWidget *btnCancel;
        GtkWidget *statusbar;
        GtkWidget *vbox;
-       GtkWidget *vnbox;
        GtkWidget *hbbox;
        GtkWidget *hsbox;
-
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
-       gtk_widget_set_usize( window, 380, -1 );
-       gtk_container_set_border_width(GTK_CONTAINER(window), 0);
-       gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER );
-       gtk_window_set_modal( GTK_WINDOW(window), TRUE );       
+       static GdkGeometry geometry;
+       
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "addrgather");
+       gtk_container_set_border_width(GTK_CONTAINER(window), 4);
+       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+       gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+       
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(addrgather_dlg_delete_event), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                         G_CALLBACK(addrgather_dlg_key_pressed), NULL);
+       g_signal_connect(G_OBJECT(window), "size_allocate",
+                        G_CALLBACK(addrgather_size_allocate), NULL);
 
-       vbox = gtk_vbox_new( FALSE, 8 );
-       gtk_container_add( GTK_CONTAINER(window), vbox );
-       gtk_container_set_border_width( GTK_CONTAINER(vbox), 0 );
-
-       vnbox = gtk_vbox_new(FALSE, 4);
-       gtk_container_set_border_width(GTK_CONTAINER(vnbox), 4);
-       gtk_widget_show(vnbox);
-       gtk_box_pack_start(GTK_BOX(vbox), vnbox, TRUE, TRUE, 0);
+       vbox = gtk_vbox_new(FALSE, 6);
+       gtk_container_add(GTK_CONTAINER(window), vbox);
 
        /* Notebook */
        notebook = gtk_notebook_new();
-       gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), FALSE );
+       gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
        gtk_widget_show(notebook);
-       gtk_box_pack_start(GTK_BOX(vnbox), notebook, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
 
        /* Status line */
-       hsbox = gtk_hbox_new( FALSE, 0 );
-       gtk_box_pack_end( GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH );
+       hsbox = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, 0);
        statusbar = gtk_statusbar_new();
-       gtk_box_pack_start( GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH );
+       gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, 0);
 
        /* Button panel */
-       gtkut_button_set_create( &hbbox, &btnOk, _("OK"),
-               &btnCancel, _("Cancel"), NULL, NULL );
-       gtk_box_pack_end( GTK_BOX(vbox), hbbox, FALSE, FALSE, 0 );
-       gtk_container_set_border_width( GTK_CONTAINER(hbbox), 0 );
+       gtkut_stock_button_set_create(&hbbox, &btnCancel, GTK_STOCK_CANCEL,
+                                     &btnOk, GTK_STOCK_OK,
+                                     NULL, NULL);
+       gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
 
        /* Signal handlers */
        g_signal_connect(G_OBJECT(btnOk), "clicked",
@@ -515,20 +470,28 @@ static void addrgather_dlg_create( void ) {
        g_signal_connect(G_OBJECT(btnCancel), "clicked",
                         G_CALLBACK(addrgather_dlg_cancel), NULL);
 
-       gtk_widget_show_all( vbox );
+       if (!geometry.min_width) {
+               geometry.min_width = 450;
+               geometry.min_height = -1;
+       }
+
+       gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+                                     GDK_HINT_MIN_SIZE);
+       gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.addrgather_width,
+                                   prefs_common.addrgather_height);
+
        addrgather_dlg.window     = window;
        addrgather_dlg.notebook   = notebook;
        addrgather_dlg.btnOk      = btnOk;
        addrgather_dlg.btnCancel  = btnCancel;
        addrgather_dlg.statusbar  = statusbar;
-       addrgather_dlg.status_cid = gtk_statusbar_get_context_id(
-               GTK_STATUSBAR(statusbar), "Harvest E-Mail Address Dialog" );
+       addrgather_dlg.status_cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar),
+                                                                "Collect Email Address Dialog");
 
        /* Create notebook pages */
-       addrgather_page_warning( PAGE_WARNING, _( "Warning" ) );
-       addrgather_page_fields( PAGE_FIELDS, _( "Header Fields" ) );
-       addrgather_page_finish( PAGE_FINISH, _( "Finish" ) );
-       gtk_widget_show_all( addrgather_dlg.window );
+       addrgather_page_fields(PAGE_FIELDS, _("Header Fields"));
+       addrgather_page_finish(PAGE_FINISH, _("Finish"));
+       gtk_widget_show_all(addrgather_dlg.window);
 }
 
 /*
@@ -539,11 +502,9 @@ static void addrgather_dlg_create( void ) {
  *        msgList    List of message numbers, or NULL to process folder.
  * Return: Populated address book file, or NULL if none created.
  */
-AddressBookFile *addrgather_dlg_execute(
-       FolderItem *folderItem, AddressIndex *addrIndex, gboolean sourceInd,
-       GList *msgList )
+AddressBookFile *addrgather_dlg_execute(FolderItem *folderItem, AddressIndex *addrIndex,
+                                       gboolean sourceInd, GList *msgList)
 {
-       gboolean errFlag;
        gint i;
 
        _harv_addressIndex_ = addrIndex;
@@ -551,78 +512,57 @@ AddressBookFile *addrgather_dlg_execute(
        _harv_messageList_ = msgList;
 
        /* Create dialog */
-       if( ! addrgather_dlg.window ) {
+       if (!addrgather_dlg.window)
                addrgather_dlg_create();
+       
+       addrgather_dlg.done = FALSE;
+
+       gtk_notebook_set_current_page(GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_FIELDS);
+       addrgather_dlg.folderPath = folder_item_get_path(folderItem);
+
+       /* Setup some default values */
+       gtk_label_set_text(GTK_LABEL(addrgather_dlg.labelFolder), folderItem->path);
+       gtk_entry_set_text(GTK_ENTRY(addrgather_dlg.entryBook), folderItem->path);
+
+       for (i = 0; i < NUM_FIELDS; i++) {
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
+                                            FALSE);
+               if (g_utf8_collate(_harv_headerNames_[i], HEADER_FROM) == 0)
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
+                                                   TRUE);
        }
 
-       errFlag = TRUE;
-       if( folderItem && folderItem->path ) {
-               gtk_notebook_set_page(
-                       GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_FIELDS );
-               addrgather_dlg.folderPath = folder_item_get_path( folderItem );
-
-               /* Setup some default values */
-               gtk_label_set_text(
-                       GTK_LABEL(addrgather_dlg.labelFolder), folderItem->path );
-               gtk_entry_set_text(
-                       GTK_ENTRY(addrgather_dlg.entryBook), folderItem->path );
-
-               for( i = 0; i < NUM_FIELDS; i++ ) {
-                       gtk_toggle_button_set_active(
-                               GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
-                               FALSE );
-                       if( g_utf8_collate( _harv_headerNames_[i], HEADER_FROM ) == 0 ) {
-                               gtk_toggle_button_set_active(
-                                       GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
-                                       TRUE );
-                       }
-               }
-
-               gtk_widget_set_sensitive( addrgather_dlg.btnOk, TRUE );
-               gtk_widget_grab_default( addrgather_dlg.btnOk );
-               errFlag = FALSE;
-       }
+       gtk_widget_set_sensitive(addrgather_dlg.btnOk, TRUE);
+       gtk_widget_set_sensitive(addrgather_dlg.btnCancel, TRUE);
+       gtk_widget_grab_default(addrgather_dlg.btnOk);
 
        /* Apply window title */
-       if( sourceInd ) {
-               gtk_window_set_title( GTK_WINDOW(addrgather_dlg.window),
-                       _("Harvest E-Mail Addresses - from Selected Messages") );
-               gtk_widget_set_sensitive( addrgather_dlg.checkRecurse, FALSE );
-               if( msgList == NULL ) {
-                       errFlag = TRUE;
-               }
-       }
-       else {
-               gtk_window_set_title( GTK_WINDOW(addrgather_dlg.window),
-                       _("Harvest E-Mail Addresses - from Folder") );
-               gtk_widget_set_sensitive( addrgather_dlg.checkRecurse, TRUE );
+       if (sourceInd) {
+               gtk_window_set_title(GTK_WINDOW(addrgather_dlg.window),
+                                    _("Collect email addresses from selected messages"));
+               gtk_widget_set_sensitive(addrgather_dlg.checkRecurse, FALSE);
+       } else {
+               gtk_window_set_title(GTK_WINDOW(addrgather_dlg.window),
+                                    _("Collect email addresses from folder"));
+               gtk_widget_set_sensitive(addrgather_dlg.checkRecurse, TRUE);
        }
-       gtk_toggle_button_set_active(
-               GTK_TOGGLE_BUTTON( addrgather_dlg.checkRecurse ), FALSE );
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkRecurse), FALSE);
 
-       addrgather_dlg_status_show( "" );
-       gtk_widget_show( addrgather_dlg.window );
-
-       if( errFlag ) {
-               gtk_notebook_set_page(
-                       GTK_NOTEBOOK(addrgather_dlg.notebook), PAGE_WARNING );
-               gtk_widget_set_sensitive( addrgather_dlg.btnOk, FALSE );
-               gtk_widget_grab_default( addrgather_dlg.btnCancel );
-       }
-       else {
-               gtk_widget_grab_focus( addrgather_dlg.entryBook );
-       }
-       manage_window_set_transient( GTK_WINDOW(addrgather_dlg.window) );
+       addrgather_dlg_status_show("");
+       gtk_widget_show(addrgather_dlg.window);
+       gtk_window_set_modal(GTK_WINDOW(addrgather_dlg.window), TRUE);
+       gtk_widget_grab_focus(addrgather_dlg.entryBook);
+       manage_window_set_transient(GTK_WINDOW(addrgather_dlg.window));
        gtk_main();
 
-       if( ! errFlag ) {
-               g_free( addrgather_dlg.folderPath );
-               addrgather_dlg.folderPath = NULL;
-       }
-       gtk_widget_hide( addrgather_dlg.window );
+       g_free(addrgather_dlg.folderPath);
+       addrgather_dlg.folderPath = NULL;
+       gtk_widget_hide(addrgather_dlg.window);
+       gtk_window_set_modal(GTK_WINDOW(addrgather_dlg.window), FALSE);
        _harv_addressIndex_ = NULL;
 
-       if( addrgather_dlg.cancelled == TRUE ) return NULL;
+       if (addrgather_dlg.cancelled == TRUE)
+               return NULL;
 
        return _harv_addressBook_;
 }