2005-10-18 [colin] 1.9.15cvs72
[claws.git] / src / addressbook.c
index 8ee706b5921b96bde45818e6b4f1942982322149..2140a570078f73253f6415f807ea5e9f81add1e1 100644 (file)
@@ -14,7 +14,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "expldifdlg.h"
 #include "browseldap.h"
 
+typedef enum
+{
+       COL_SOURCES     = 0,
+       N_INDEX_COLS    = 1
+} AddressIndexColumns;
+
 typedef enum
 {
        COL_NAME        = 0,
        COL_ADDRESS     = 1,
-       COL_REMARKS     = 2
-} AddressBookColumnPos;
+       COL_REMARKS     = 2,
+       N_LIST_COLS     = 3
+} AddressListColumns;
 
-#define N_COLS 3
 #define COL_NAME_WIDTH         164
 #define COL_ADDRESS_WIDTH      156
 
@@ -171,8 +177,10 @@ static void addressbook_to_clicked         (GtkButton      *button,
                                                 gpointer        data);
 static void addressbook_lup_clicked            (GtkButton      *button,
                                                 gpointer       data);
+static void addressbook_close_clicked          (GtkButton      *button,
+                                                gpointer       data);
 
-static gboolean addressbook_tree_selected      (GtkCTree       *ctree,
+static void addressbook_tree_selected  (GtkCTree       *ctree,
                                                 GtkCTreeNode   *node,
                                                 gint            column,
                                                 gpointer        data);
@@ -194,7 +202,6 @@ static void addressbook_person_expand_node  (GtkCTree       *ctree,
 static void addressbook_person_collapse_node   (GtkCTree       *ctree,
                                                 GList          *node,
                                                 gpointer       *data );
-static void addressbook_entry_gotfocus         (GtkWidget      *widget);
 
 #if 0
 static void addressbook_entry_changed          (GtkWidget      *widget);
@@ -212,8 +219,6 @@ static gboolean addressbook_tree_button_pressed     (GtkWidget      *ctree,
 static gboolean addressbook_tree_button_released(GtkWidget     *ctree,
                                                 GdkEventButton *event,
                                                 gpointer        data);
-static void addressbook_popup_close            (GtkMenuShell   *menu_shell,
-                                                gpointer        data);
 
 static void addressbook_new_folder_cb          (gpointer        data,
                                                 guint           action,
@@ -268,7 +273,8 @@ static void addressbook_new_ldap_cb         (gpointer        data,
                                                 GtkWidget      *widget);
 #endif
 
-static void addressbook_set_clist              (AddressObject  *obj);
+static void addressbook_set_clist              (AddressObject  *obj,
+                                                gboolean        refresh);
 
 static void addressbook_load_tree              (void);
 void addressbook_read_file                     (void);
@@ -296,7 +302,7 @@ static void addressbook_move_nodes_up               (GtkCTree       *ctree,
                                                GtkCTreeNode    *node);
 static GtkCTreeNode *addressbook_find_group_node (GtkCTreeNode *parent,
                                                   ItemGroup    *group);
-static gboolean key_pressed                    (GtkWidget      *widget,
+static gboolean addressbook_entry_key_pressed  (GtkWidget      *widget,
                                                 GdkEventKey    *event,
                                                 gpointer        data);
 static gint addressbook_treenode_compare_func  (GtkCList       *clist,
@@ -316,10 +322,6 @@ static void addressbook_folder_remove_one_person(GtkCTree *clist,
 static void addressbook_folder_remove_node     (GtkCTree *clist, 
                                                 GtkCTreeNode *node);
 
-#ifdef USE_LDAP
-static void addressbook_ldap_show_message      ( LdapServer *server );
-#endif
-
 /* LUT's and IF stuff */
 static void addressbook_free_treenode          ( gpointer data );
 AddressTypeControlItem *addrbookctl_lookup     (gint            ot);
@@ -348,7 +350,6 @@ static void addressbook_export_ldif_cb              ( void );
 static void addressbook_clip_cut_cb            ( void );
 static void addressbook_clip_copy_cb           ( void );
 static void addressbook_clip_paste_cb          ( void );
-static void addressbook_clip_paste_address_cb  ( void );
 static void addressbook_treenode_cut_cb                ( void );
 static void addressbook_treenode_copy_cb       ( void );
 static void addressbook_treenode_paste_cb      ( void );
@@ -358,6 +359,7 @@ static void addressbook_mail_to_cb          ( void );
 #ifdef USE_LDAP
 static void addressbook_browse_entry_cb                ( void );
 #endif
+static void addressbook_edit_clicked(GtkButton *button, gpointer data);
 
 static void addressbook_start_drag(GtkWidget *widget, gint button, 
                                   GdkEvent *event,
@@ -386,6 +388,7 @@ static void addressbook_drag_received_cb(GtkWidget        *widget,
                                        guint             info,
                                        guint             time,
                                        void             *pdata);
+static void addressbook_list_menu_setup( void );
 
 static GtkTargetEntry addressbook_drag_types[] =
 {
@@ -397,44 +400,42 @@ static GtkTargetList *addressbook_target_list = NULL;
 
 static GtkItemFactoryEntry addressbook_entries[] =
 {
-       {N_("/_File"),                  NULL,           NULL, 0, "<Branch>"},
-       {N_("/_File/New _Book"),        "<alt>B",       addressbook_new_book_cb,        0, NULL},
-       {N_("/_File/New _vCard"),       "<alt>D",       addressbook_new_vcard_cb,       0, NULL},
+       {N_("/_Book"),                  NULL,           NULL, 0, "<Branch>"},
+       {N_("/_Book/New _Book"),        "<control>B",   addressbook_new_book_cb,        0, NULL},
+       {N_("/_Book/New _Folder"),      "<control>R",   addressbook_new_folder_cb,      0, NULL},
+       {N_("/_Book/New _vCard"),       "<control><shift>D",    addressbook_new_vcard_cb,       0, NULL},
 #ifdef USE_JPILOT
-       {N_("/_File/New _JPilot"),      "<alt>J",       addressbook_new_jpilot_cb,      0, NULL},
+       {N_("/_Book/New _JPilot"),      "<control>J",   addressbook_new_jpilot_cb,      0, NULL},
 #endif
 #ifdef USE_LDAP
-       {N_("/_File/New _Server"),      "<alt>S",       addressbook_new_ldap_cb,        0, NULL},
+       {N_("/_Book/New _Server"),      "<control><shift>S",    addressbook_new_ldap_cb,        0, NULL},
 #endif
-       {N_("/_File/---"),              NULL,           NULL, 0, "<Separator>"},
-       {N_("/_File/_Edit"),            NULL,           addressbook_treenode_edit_cb,   0, NULL},
-       {N_("/_File/_Delete"),          NULL,           addressbook_treenode_delete_cb, 0, NULL},
-       {N_("/_File/---"),              NULL,           NULL, 0, "<Separator>"},
-       {N_("/_File/_Save"),            "<alt>S",       addressbook_file_save_cb,       0, NULL},
-       {N_("/_File/_Close"),           "<alt>W",       close_cb,                       0, NULL},
-       {N_("/_Edit"),                  NULL,           NULL, 0, "<Branch>"},
-       {N_("/_Edit/C_ut"),             "<ctl>X",       addressbook_clip_cut_cb,        0, NULL},
-       {N_("/_Edit/_Copy"),            "<ctl>C",       addressbook_clip_copy_cb,       0, NULL},
-       {N_("/_Edit/_Paste"),           "<ctl>V",       addressbook_clip_paste_cb,      0, NULL},
-       {N_("/_Edit/---"),              NULL,           NULL, 0, "<Separator>"},
-       {N_("/_Edit/Pa_ste Address"),   NULL,           addressbook_clip_paste_address_cb, 0, NULL},
-       {N_("/_Address"),               NULL,           NULL, 0, "<Branch>"},
-       {N_("/_Address/New _Address"),  "<alt>N",       addressbook_new_address_cb,     0, NULL},
-       {N_("/_Address/New _Group"),    "<alt>G",       addressbook_new_group_cb,       0, NULL},
-       {N_("/_Address/New _Folder"),   "<alt>R",       addressbook_new_folder_cb,      0, NULL},
+       {N_("/_Book/---"),              NULL,           NULL, 0, "<Separator>"},
+       {N_("/_Book/_Edit book"),       NULL,           addressbook_treenode_edit_cb,   0, NULL},
+       {N_("/_Book/_Delete book"),     NULL,           addressbook_treenode_delete_cb, 0, NULL},
+       {N_("/_Book/---"),              NULL,           NULL, 0, "<Separator>"},
+       {N_("/_Book/_Save"),            "<control>S",   addressbook_file_save_cb,       0, NULL},
+       {N_("/_Book/_Close"),           "<control>W",   close_cb,                       0, NULL},
+       {N_("/_Address"),                       NULL,           NULL, 0, "<Branch>"},
+       {N_("/_Address/C_ut"),          "<control>X",   addressbook_clip_cut_cb,        0, NULL},
+       {N_("/_Address/_Copy"),         "<control>C",   addressbook_clip_copy_cb,       0, NULL},
+       {N_("/_Address/_Paste"),        "<control>V",   addressbook_clip_paste_cb,      0, NULL},
+       {N_("/_Address/---"),           NULL,           NULL, 0, "<Separator>"},
+       {N_("/_Address/_Edit"),         "<control>Return",addressbook_edit_address_cb,    0, NULL},
+       {N_("/_Address/_Delete"),       "<control>D",   addressbook_delete_address_cb,  0, NULL},
        {N_("/_Address/---"),           NULL,           NULL, 0, "<Separator>"},
-       {N_("/_Address/_Edit"),         "<alt>Return",  addressbook_edit_address_cb,    0, NULL},
-       {N_("/_Address/_Delete"),       NULL,           addressbook_delete_address_cb,  0, NULL},
+       {N_("/_Address/New _Address"),  "<control>N",   addressbook_new_address_cb,     0, NULL},
+       {N_("/_Address/New _Group"),    "<control>G",   addressbook_new_group_cb,       0, NULL},
        {N_("/_Address/---"),           NULL,           NULL, 0, "<Separator>"},
        {N_("/_Address/_Mail To"),      NULL,           addressbook_mail_to_cb,         0, NULL},
-       {N_("/_Tools/---"),             NULL,           NULL, 0, "<Separator>"},
+       {N_("/_Tools"),                 NULL,           NULL, 0, "<Branch>"},
        {N_("/_Tools/Import _LDIF file..."), NULL,      addressbook_import_ldif_cb,     0, NULL},
        {N_("/_Tools/Import M_utt file..."), NULL,      addressbook_import_mutt_cb,     0, NULL},
        {N_("/_Tools/Import _Pine file..."), NULL,      addressbook_import_pine_cb,     0, NULL},
        {N_("/_Tools/---"),             NULL,           NULL, 0, "<Separator>"},
        {N_("/_Tools/Export _HTML..."), NULL,           addressbook_export_html_cb,     0, NULL},
        {N_("/_Tools/Export LDI_F..."), NULL,           addressbook_export_ldif_cb,     0, NULL},
-       {N_("/_Help"),                  NULL,           NULL, 0, "<LastBranch>"},
+       {N_("/_Help"),                  NULL,           NULL, 0, "<Branch>"},
        {N_("/_Help/_About"),           NULL,           about_show, 0, NULL}
 };
 
@@ -443,8 +444,6 @@ static GtkItemFactoryEntry addressbook_tree_popup_entries[] =
        {N_("/_Edit"),          NULL, addressbook_treenode_edit_cb,   0, NULL},
        {N_("/_Delete"),        NULL, addressbook_treenode_delete_cb, 0, NULL},
        {N_("/---"),            NULL, NULL, 0, "<Separator>"},
-       {N_("/New _Address"),   NULL, addressbook_new_address_cb,     0, NULL},
-       {N_("/New _Group"),     NULL, addressbook_new_group_cb,       0, NULL},
        {N_("/New _Folder"),    NULL, addressbook_new_folder_cb,      0, NULL},
        {N_("/---"),            NULL, NULL, 0, "<Separator>"},
        {N_("/C_ut"),           NULL, addressbook_treenode_cut_cb,    0, NULL},
@@ -459,13 +458,12 @@ static GtkItemFactoryEntry addressbook_list_popup_entries[] =
        {N_("/---"),            NULL, NULL, 0, "<Separator>"},
        {N_("/New _Address"),   NULL, addressbook_new_address_cb,    0, NULL},
        {N_("/New _Group"),     NULL, addressbook_new_group_cb,      0, NULL},
-       {N_("/New _Folder"),    NULL, addressbook_new_folder_cb,     0, NULL},
        {N_("/---"),            NULL, NULL, 0, "<Separator>"},
        {N_("/C_ut"),           NULL, addressbook_clip_cut_cb,       0, NULL},
        {N_("/_Copy"),          NULL, addressbook_clip_copy_cb,      0, NULL},
        {N_("/_Paste"),         NULL, addressbook_clip_paste_cb,     0, NULL},
        {N_("/---"),            NULL, NULL, 0, "<Separator>"},
-       {N_("/Pa_ste Address"), NULL, addressbook_clip_paste_address_cb, 0, NULL},
+/*     {N_("/Pa_ste Address"), NULL, addressbook_clip_paste_address_cb, 0, NULL},*/
        {N_("/_Mail To"),       NULL, addressbook_mail_to_cb,            0, NULL},
 #ifdef USE_LDAP
        {N_("/_Browse Entry"),  NULL, addressbook_browse_entry_cb,       0, NULL},
@@ -546,6 +544,43 @@ static gchar *addressbook_err2string( ErrMsgTableEntry lut[], gint code ) {
         return desc;
 }
 
+static gboolean lastCanLookup = FALSE;
+
+void addressbook_show_buttons(gboolean add_and_delete, gboolean lookup, gboolean mail_ops)
+{
+       if (add_and_delete) {
+               gtk_widget_show(addrbook.edit_btn);
+               gtk_widget_show(addrbook.del_btn);
+               gtk_widget_show(addrbook.reg_btn);
+       } else {
+               gtk_widget_hide(addrbook.edit_btn);
+               gtk_widget_hide(addrbook.del_btn);
+               gtk_widget_hide(addrbook.reg_btn);
+       }
+       
+       if (lookup) {
+               gtk_widget_show(addrbook.lup_btn);
+               gtk_widget_show(addrbook.entry);
+               gtk_widget_show(addrbook.label);
+       } else {
+               gtk_widget_hide(addrbook.lup_btn);
+               gtk_widget_hide(addrbook.entry);
+               gtk_widget_hide(addrbook.label);
+       }
+
+       lastCanLookup = lookup;
+
+       if (mail_ops) {
+               gtk_widget_show(addrbook.to_btn);
+               gtk_widget_show(addrbook.cc_btn);
+               gtk_widget_show(addrbook.bcc_btn);
+       } else {
+               gtk_widget_hide(addrbook.to_btn);
+               gtk_widget_hide(addrbook.cc_btn);
+               gtk_widget_hide(addrbook.bcc_btn);
+       }
+}
+
 void addressbook_open(Compose *target)
 {
        /* Initialize all static members */
@@ -562,7 +597,7 @@ void addressbook_open(Compose *target)
                addressbook_read_file();
                addressbook_create();
                addressbook_load_tree();
-               gtk_ctree_select(GTK_CTREE(addrbook.ctree),
+               gtk_sctree_select( GTK_SCTREE(addrbook.ctree),
                                 GTK_CTREE_NODE(GTK_CLIST(addrbook.ctree)->row_list));
        }
        else {
@@ -570,6 +605,7 @@ void addressbook_open(Compose *target)
        }
 
        gtk_widget_show_all(addrbook.window);
+       addressbook_show_buttons(target == NULL, lastCanLookup, target != NULL);
        addressbook_set_target_compose(target);
 }
 
@@ -611,13 +647,34 @@ void addressbook_refresh( void )
 {
        if (addrbook.window) {
                if (addrbook.treeSelected) {
-                       gtk_ctree_select(GTK_CTREE(addrbook.ctree),
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree),
                                         addrbook.treeSelected);
                }
        }
        addressbook_export_to_file();
 }
 
+static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+       if (event && event->keyval == GDK_Escape)
+               addressbook_close();
+       else if (event && event->keyval == GDK_Delete)
+               addressbook_del_clicked(NULL, NULL);
+       return FALSE;
+}
+
+/*!
+ *\brief       Save Gtk object size to prefs dataset
+ */
+static void addressbook_size_allocate_cb(GtkWidget *widget,
+                                        GtkAllocation *allocation)
+{
+       g_return_if_fail(allocation != NULL);
+
+       prefs_common.addressbookwin_width = allocation->width;
+       prefs_common.addressbookwin_height = allocation->height;
+}
+
 /*
 * Create the address book widgets. The address book contains two CTree widgets: the
 * address index tree on the left and the address list on the right.
@@ -652,11 +709,13 @@ static void addressbook_create(void)
        GtkWidget *hbbox;
        GtkWidget *hsbox;
        GtkWidget *del_btn;
+       GtkWidget *edit_btn;
        GtkWidget *reg_btn;
        GtkWidget *lup_btn;
        GtkWidget *to_btn;
        GtkWidget *cc_btn;
        GtkWidget *bcc_btn;
+       GtkWidget *close_btn;
        GtkWidget *tree_popup;
        GtkWidget *list_popup;
        GtkItemFactory *tree_factory;
@@ -665,26 +724,30 @@ static void addressbook_create(void)
        gint n_entries;
        GList *nodeIf;
 
-       gchar *titles[N_COLS];
-       gchar *dummy_titles[1];
+       gchar *index_titles[N_INDEX_COLS];
+       gchar *list_titles[N_LIST_COLS];
        gchar *text;
        gint i;
 
+       static GdkGeometry geometry;
+
        debug_print("Creating addressbook window...\n");
 
-       titles[COL_NAME]    = _("Name");
-       titles[COL_ADDRESS] = _("E-Mail address");
-       titles[COL_REMARKS] = _("Remarks");
-       dummy_titles[0]     = "";
+       index_titles[COL_SOURCES] = _("Sources");
+       list_titles[COL_NAME]    = _("Name");
+       list_titles[COL_ADDRESS] = _("E-Mail address");
+       list_titles[COL_REMARKS] = _("Remarks");
 
+       /* Address book window */
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(window), _("Address book"));
-       gtk_widget_set_size_request(window, ADDRESSBOOK_WIDTH, ADDRESSBOOK_HEIGHT);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
        gtk_widget_realize(window);
 
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(addressbook_close), NULL);
+       g_signal_connect(G_OBJECT(window), "size_allocate",
+                        G_CALLBACK(addressbook_size_allocate_cb), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                         G_CALLBACK(key_pressed), NULL);
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
@@ -692,6 +755,7 @@ static void addressbook_create(void)
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(window), vbox);
 
+       /* Menu bar */
        n_entries = sizeof(addressbook_entries) /
                sizeof(addressbook_entries[0]);
        menubar = menubar_create(window, addressbook_entries, n_entries,
@@ -699,7 +763,7 @@ static void addressbook_create(void)
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
        menu_factory = gtk_item_factory_from_widget(menubar);
 
-       vbox2 = gtk_vbox_new(FALSE, 4);
+       vbox2 = gtk_vbox_new(FALSE, BORDER_WIDTH);
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), BORDER_WIDTH);
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
 
@@ -710,7 +774,7 @@ static void addressbook_create(void)
        gtk_widget_set_size_request(ctree_swin, COL_FOLDER_WIDTH + 40, -1);
 
        /* Address index */
-       ctree = gtk_sctree_new_with_titles(1, 0, dummy_titles);
+       ctree = gtk_sctree_new_with_titles(N_INDEX_COLS, 0, index_titles);
        gtk_container_add(GTK_CONTAINER(ctree_swin), ctree);
        gtk_clist_set_selection_mode(GTK_CLIST(ctree), GTK_SELECTION_BROWSE);
        gtk_clist_set_column_width(GTK_CLIST(ctree), 0, COL_FOLDER_WIDTH);
@@ -755,7 +819,7 @@ static void addressbook_create(void)
        gtk_box_pack_start(GTK_BOX(clist_vbox), clist_swin, TRUE, TRUE, 0);
 
        /* Address list */
-       clist = gtk_sctree_new_with_titles(N_COLS, 0, titles);
+       clist = gtk_sctree_new_with_titles(N_LIST_COLS, 0, list_titles);
        gtk_container_add(GTK_CONTAINER(clist_swin), clist);
        gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED);
        gtk_ctree_set_line_style(GTK_CTREE(clist), GTK_CTREE_LINES_NONE);
@@ -768,7 +832,7 @@ static void addressbook_create(void)
        gtk_clist_set_compare_func(GTK_CLIST(clist),
                                   addressbook_list_compare_func);
 
-       for (i = 0; i < N_COLS; i++)
+       for (i = 0; i < N_LIST_COLS; i++)
                GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button,
                                       GTK_CAN_FOCUS);
 
@@ -793,16 +857,17 @@ static void addressbook_create(void)
        hbox = gtk_hbox_new(FALSE, 4);
        gtk_box_pack_start(GTK_BOX(clist_vbox), hbox, FALSE, FALSE, 0);
 
-       label = gtk_label_new(_("Name:"));
+       label = gtk_label_new(_("Lookup name:"));
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
        entry = gtk_entry_new();
        gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
 
        address_completion_register_entry(GTK_ENTRY(entry));
-       g_signal_connect(G_OBJECT(entry), "focus_in_event",
-                        G_CALLBACK(addressbook_entry_gotfocus), NULL);
 
+       g_signal_connect(G_OBJECT(entry), "key_press_event",
+                        G_CALLBACK(addressbook_entry_key_pressed),
+                        NULL);
 #if 0
        g_signal_connect(G_OBJECT(entry), "changed",
                         G_CALLBACK(addressbook_entry_changed), NULL);
@@ -822,19 +887,31 @@ static void addressbook_create(void)
        /* Button panel */
        hbbox = gtk_hbutton_box_new();
        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
-       gtk_box_set_spacing(GTK_BOX(hbbox), 2);
+       gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 2);
+       gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
 
-       del_btn = gtk_button_new_with_label(_("Delete"));
+#if GTK_CHECK_VERSION(2, 6, 0)
+       edit_btn = gtk_button_new_from_stock(GTK_STOCK_EDIT);
+#else
+       edit_btn = gtk_button_new_from_stock(GTK_STOCK_PROPERTIES);
+#endif
+       GTK_WIDGET_SET_FLAGS(edit_btn, GTK_CAN_DEFAULT);
+       gtk_box_pack_start(GTK_BOX(hbbox), edit_btn, TRUE, TRUE, 0);
+       del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
        GTK_WIDGET_SET_FLAGS(del_btn, GTK_CAN_DEFAULT);
        gtk_box_pack_start(GTK_BOX(hbbox), del_btn, TRUE, TRUE, 0);
-       reg_btn = gtk_button_new_with_label(_("Add"));
+       reg_btn = gtk_button_new_from_stock(GTK_STOCK_NEW);
        GTK_WIDGET_SET_FLAGS(reg_btn, GTK_CAN_DEFAULT);
        gtk_box_pack_start(GTK_BOX(hbbox), reg_btn, TRUE, TRUE, 0);
-       lup_btn = gtk_button_new_with_label(_("Lookup"));
+
+
+       lup_btn = gtk_button_new_from_stock(GTK_STOCK_FIND);
        GTK_WIDGET_SET_FLAGS(lup_btn, GTK_CAN_DEFAULT);
-       gtk_box_pack_start(GTK_BOX(hbbox), lup_btn, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), lup_btn, TRUE, TRUE, 0);
 
+       g_signal_connect(G_OBJECT(edit_btn), "clicked",
+                        G_CALLBACK(addressbook_edit_clicked), NULL);
        g_signal_connect(G_OBJECT(del_btn), "clicked",
                         G_CALLBACK(addressbook_del_clicked), NULL);
        g_signal_connect(G_OBJECT(reg_btn), "clicked",
@@ -855,6 +932,10 @@ static void addressbook_create(void)
        GTK_WIDGET_SET_FLAGS(bcc_btn, GTK_CAN_DEFAULT);
        gtk_box_pack_start(GTK_BOX(hbbox), bcc_btn, TRUE, TRUE, 0);
 
+       close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+       GTK_WIDGET_SET_FLAGS(close_btn, GTK_CAN_DEFAULT);
+       gtk_box_pack_start(GTK_BOX(hbbox), close_btn, TRUE, TRUE, 0);
+
        g_signal_connect(G_OBJECT(to_btn), "clicked",
                         G_CALLBACK(addressbook_to_clicked),
                         GINT_TO_POINTER(COMPOSE_TO));
@@ -864,6 +945,8 @@ static void addressbook_create(void)
        g_signal_connect(G_OBJECT(bcc_btn), "clicked",
                         G_CALLBACK(addressbook_to_clicked),
                         GINT_TO_POINTER(COMPOSE_BCC));
+       g_signal_connect(G_OBJECT(close_btn), "clicked",
+                        G_CALLBACK(addressbook_close_clicked), NULL);
 
        /* Build icons for interface */
        stock_pixmap_gdk( window, STOCK_PIXMAP_INTERFACE,
@@ -885,7 +968,7 @@ static void addressbook_create(void)
                        AddressTypeControlItem *atci = adapter->atci;
                        text = atci->displayName;
                        adapter->treeNode =
-                               gtk_ctree_insert_node( GTK_CTREE(ctree),
+                               gtk_sctree_insert_node( GTK_CTREE(ctree),
                                        NULL, NULL, &text, FOLDER_SPACING,
                                        interfacexpm, interfacexpmmask,
                                        interfacexpm, interfacexpmmask,
@@ -904,8 +987,6 @@ static void addressbook_create(void)
                                       n_entries,
                                       "<AddressBookTree>", &tree_factory,
                                       NULL);
-       g_signal_connect(G_OBJECT(tree_popup), "selection_done",
-                        G_CALLBACK(addressbook_popup_close), NULL);
        n_entries = sizeof(addressbook_list_popup_entries) /
                sizeof(addressbook_list_popup_entries[0]);
        list_popup = menu_create_items(addressbook_list_popup_entries,
@@ -919,11 +1000,13 @@ static void addressbook_create(void)
        addrbook.ctree_swin
                         = ctree_swin;
        addrbook.clist   = clist;
+       addrbook.label   = label;
        addrbook.entry   = entry;
        addrbook.statusbar = statusbar;
        addrbook.status_cid = gtk_statusbar_get_context_id(
                        GTK_STATUSBAR(statusbar), "Addressbook Window" );
 
+       addrbook.edit_btn = edit_btn;
        addrbook.del_btn = del_btn;
        addrbook.reg_btn = reg_btn;
        addrbook.lup_btn = lup_btn;
@@ -939,9 +1022,18 @@ static void addressbook_create(void)
 
        addrbook.listSelected = NULL;
        address_completion_start(window);
-       gtk_widget_show_all(window);
-       gtk_widget_set_sensitive(addrbook.lup_btn, FALSE);
 
+       if (!geometry.min_height) {
+               geometry.min_width = ADDRESSBOOK_WIDTH;
+               geometry.min_height = ADDRESSBOOK_HEIGHT;
+       }
+
+       gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+                                     GDK_HINT_MIN_SIZE);
+       gtk_widget_set_size_request(window, prefs_common.addressbookwin_width,
+                                   prefs_common.addressbookwin_height);
+
+       gtk_widget_show_all(window);
 }
 
 /**
@@ -1029,6 +1121,11 @@ static void addressbook_button_set_sensitive(void)
        gtk_widget_set_sensitive(addrbook.bcc_btn, bcc_sens);
 }
 
+static void addressbook_edit_clicked(GtkButton *button, gpointer data)
+{
+       addressbook_edit_address_cb(NULL, 0, NULL);
+}
+
 /*
 * Delete one or more objects from address list.
 */
@@ -1054,6 +1151,7 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
 
        /* Test whether anything selected for deletion */
        nodeList = addrbook.listSelected;
+
        aio = gtk_ctree_node_get_row_data( clist, nodeList );
        if( aio == NULL) return;
        ds = addressbook_find_datasource( addrbook.treeSelected );
@@ -1094,6 +1192,7 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
        if( pobj->type == ADDR_DATASOURCE || pobj->type == ADDR_ITEM_FOLDER ) {
                /* Items inside folders */
                list = addrselect_get_list( _addressSelect_ );
+
                node = list;
                while( node ) {
                        item = node->data;
@@ -1116,7 +1215,7 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
                                ItemPerson *item = ( ItemPerson * ) aio;
                                addressbook_folder_remove_one_person( clist, item );
                                if (pobj->type == ADDR_ITEM_FOLDER)
-                                       addritem_folder_remove_person((ItemFolder *)pobj, item);
+                                       addritem_folder_remove_person(ADAPTER_FOLDER(pobj)->itemFolder, item);
                                item = addrbook_remove_person( abf, item );
                                if( item ) {
                                        addritem_free_item_person( item );
@@ -1135,9 +1234,10 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
                g_list_free( list );
                addressbook_list_select_clear();
                if( refreshList ) 
-                       gtk_ctree_select( ctree, addrbook.opened);
+                       gtk_sctree_select( GTK_SCTREE(ctree), addrbook.opened);
                addrbook_set_dirty(abf, TRUE);
                addressbook_export_to_file();
+               addressbook_list_menu_setup();
                return;
        }
        else if( pobj->type == ADDR_ITEM_GROUP ) {
@@ -1159,9 +1259,10 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
                }
                g_list_free( list );
                addressbook_list_select_clear();
-               gtk_ctree_select( ctree, addrbook.opened);
+               gtk_sctree_select( GTK_SCTREE(ctree), addrbook.opened);
                addrbook_set_dirty(abf, TRUE);
                addressbook_export_to_file();
+               addressbook_list_menu_setup();
                return;
        }
 
@@ -1260,7 +1361,17 @@ static void addressbook_to_clicked(GtkButton *button, gpointer data)
                }
                else if( aio->type == ADDR_ITEM_GROUP ) {
                        ItemGroup *group = ( ItemGroup * ) aio;
+                       AddressDataSource *ds = NULL;
+                       AddressBookFile *abf = NULL;
                        GList *nodeMail = group->listEMail;
+                       if (nodeMail == NULL) {
+                               if(addrbook.treeSelected ) {
+                                       ds = addressbook_find_datasource( addrbook.treeSelected );
+                                       abf = ds->rawDataSource;
+                                       if( abf != NULL )
+                                               nodeMail = addrbook_get_available_email_list( abf, group );
+                               }
+                       }
                        while( nodeMail ) {
                                ItemEMail *email = nodeMail->data;
 
@@ -1277,24 +1388,25 @@ static void addressbook_to_clicked(GtkButton *button, gpointer data)
 }
 
 static void addressbook_menubar_set_sensitive( gboolean sensitive ) {
-       menu_set_sensitive( addrbook.menu_factory, "/File/Edit",   sensitive );
-       menu_set_sensitive( addrbook.menu_factory, "/File/Delete", sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book",   sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Delete book", sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/New Folder",  sensitive );
 
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Cut",    sensitive );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Copy",   sensitive );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste",  sensitive );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address",  sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Cut",    sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Copy",   sensitive );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Paste",  sensitive );
 
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Address", sensitive );
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Group",   sensitive );
-       menu_set_sensitive( addrbook.menu_factory, "/Address/New Folder",  sensitive );
        menu_set_sensitive( addrbook.menu_factory, "/Address/Mail To",     sensitive );
        gtk_widget_set_sensitive( addrbook.reg_btn, sensitive );
+       gtk_widget_set_sensitive( addrbook.edit_btn, sensitive );
        gtk_widget_set_sensitive( addrbook.del_btn, sensitive );
 }
 
 static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode *node ) {
        gboolean canEdit = FALSE;
+       gboolean canDelete = TRUE;
        gboolean canAdd = FALSE;
        gboolean canEditTr = TRUE;
        gboolean editAddress = FALSE;
@@ -1321,10 +1433,10 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
                ds = ads->dataSource;
                iface = ds->interface;
                if( ! iface->readOnly ) {
-                       canAdd = canEdit = editAddress = TRUE;
+                       canAdd = canEdit = editAddress = canDelete = TRUE;
                }
                if( ! iface->haveLibrary ) {
-                       canAdd = canEdit = editAddress = canExport = FALSE;
+                       canAdd = canEdit = editAddress = canExport = canDelete = FALSE;
                }
        }
        else if( obj->type == ADDR_ITEM_FOLDER ) {
@@ -1333,6 +1445,7 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
                        iface = ds->interface;
                        if( iface->readOnly ) {
                                canEditTr = FALSE;
+                               canDelete = FALSE;
                        }
                        else {
                                canAdd = editAddress = TRUE;
@@ -1354,22 +1467,25 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
        /* Enable add */
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Address", editAddress );
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Group",   canAdd );
-       menu_set_sensitive( addrbook.menu_factory, "/Address/New Folder",  canAdd );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/New Folder",  canAdd );
        gtk_widget_set_sensitive( addrbook.reg_btn, editAddress );
 
        /* Enable edit */
        menu_set_sensitive( addrbook.menu_factory, "/Address/Edit",   canEdit );
-       menu_set_sensitive( addrbook.menu_factory, "/Address/Delete", canEdit );
-       gtk_widget_set_sensitive( addrbook.del_btn, canEdit );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Delete", canDelete );
+       gtk_widget_set_sensitive( addrbook.edit_btn, canEdit );
+       gtk_widget_set_sensitive( addrbook.del_btn, canDelete );
 
-       menu_set_sensitive( addrbook.menu_factory, "/File/Edit",      canEditTr );
-       menu_set_sensitive( addrbook.menu_factory, "/File/Delete",    canEditTr );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book",      canEditTr );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Delete book",    canEditTr );
 
        /* Export data */
        menu_set_sensitive( addrbook.menu_factory, "/Tools/Export HTML...", canExport );
        menu_set_sensitive( addrbook.menu_factory, "/Tools/Export LDIF...", canExport );
 }
 
+static void addressbook_list_menu_setup( void );
+
 /**
  * Address book tree callback function that responds to selection of tree
  * items.
@@ -1379,7 +1495,7 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
  * \param column Column number where selected occurred.
  * \param data   Pointer to user data.
  */
-static gboolean addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
+static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
                                      gint column, gpointer data)
 {
        AddressObject *obj = NULL;
@@ -1393,10 +1509,11 @@ static gboolean addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
        addressbook_status_show( "" );
        if( addrbook.entry != NULL ) gtk_entry_set_text(GTK_ENTRY(addrbook.entry), "");
 
-       if( addrbook.clist ) gtk_clist_clear( GTK_CLIST(addrbook.clist) );
        if( node ) obj = gtk_ctree_node_get_row_data( ctree, node );
-       if( obj == NULL ) return FALSE;
-
+       if( obj == NULL ) {
+               addressbook_set_clist(NULL, TRUE);
+               return;
+       }
        addrbook.opened = node;
 
        if( obj->type == ADDR_DATASOURCE ) {
@@ -1404,9 +1521,9 @@ static gboolean addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
                static gboolean tVal = TRUE;
 
                ads = ADAPTER_DSOURCE(obj);
-               if( ads == NULL ) return FALSE;
+               if( ads == NULL ) return;
                ds = ads->dataSource;
-               if( ds == NULL ) return FALSE;          
+               if( ds == NULL ) return;                
 
                if( addrindex_ds_get_modify_flag( ds ) ) {
                        addrindex_ds_read_data( ds );
@@ -1441,15 +1558,22 @@ static gboolean addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
        }
 
        /* Update address list */
-       addressbook_set_clist( obj );
+       g_signal_handlers_block_by_func
+               (G_OBJECT(ctree),
+                G_CALLBACK(addressbook_tree_selected), NULL);
+       addressbook_set_clist( obj, FALSE );
+       g_signal_handlers_unblock_by_func
+               (G_OBJECT(ctree),
+                G_CALLBACK(addressbook_tree_selected), NULL);
 
        /* Setup main menu selections */
        addressbook_menubar_set_sensitive( FALSE );
+       addressbook_list_menu_setup();
        addressbook_menuitem_set_sensitive( obj, node );
 
        addressbook_list_select_clear();
-       
-       return FALSE;
+       addressbook_list_menu_setup();
+       return;
 }
 
 /**
@@ -1486,13 +1610,13 @@ static void addressbook_list_menu_setup( void ) {
                iface = ds->interface;
                if( ! iface->readOnly ) {
                        menu_set_sensitive( addrbook.list_factory, "/New Address", TRUE );
-                       menu_set_sensitive( addrbook.list_factory, "/New Folder", TRUE );
                        menu_set_sensitive( addrbook.list_factory, "/New Group", TRUE );
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                        if( ! addrclip_is_empty( _clipBoard_ ) ) canPaste = TRUE;
                        if( ! addrselect_test_empty( _addressSelect_ ) ) canCut = TRUE;
                        if( obj ) canEdit = TRUE;
                }
+               canDelete = canEdit;
        }
        else if( pobj->type != ADDR_INTERFACE ) {
                /* Parent object is not an interface */
@@ -1507,21 +1631,21 @@ static void addressbook_list_menu_setup( void ) {
                        }
                        /* Folder */
                        if( pobj->type == ADDR_ITEM_FOLDER ) {
-                               menu_set_sensitive( addrbook.list_factory, "/New Folder", TRUE );
                                menu_set_sensitive( addrbook.list_factory, "/New Group", TRUE );
                                if( obj ) canEdit = TRUE;
                        }
                        if( ! addrclip_is_empty( _clipBoard_ ) ) canPaste = TRUE;
                        if( ! addrselect_test_empty( _addressSelect_ ) ) canCut = TRUE;
+                       canDelete = canEdit;
                }
                if( iface->type == ADDR_IF_LDAP ) {
                        if( obj ) canBrowse = TRUE;
+                       canEdit = TRUE;
+                       canDelete = FALSE;
                }
        }
        if( ! addrselect_test_empty( _addressSelect_ ) ) canCopy = TRUE;
 
-       canDelete = canEdit;
-
        /* Disable edit or browse if more than one row selected */
        if( GTK_CLIST(clist)->selection && GTK_CLIST(clist)->selection->next ) {
                canEdit = FALSE;
@@ -1535,14 +1659,14 @@ static void addressbook_list_menu_setup( void ) {
        menu_set_sensitive( addrbook.list_factory, "/Cut",           canCut );
        menu_set_sensitive( addrbook.list_factory, "/Copy",          canCopy );
        menu_set_sensitive( addrbook.list_factory, "/Paste",         canPaste );
-       menu_set_sensitive( addrbook.list_factory, "/Paste Address", canPaste );
+/*     menu_set_sensitive( addrbook.list_factory, "/Paste Address", canPaste );*/
 
        menu_set_sensitive( addrbook.list_factory, "/Mail To",       canCopy );
 
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Cut",           canCut );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Copy",          canCopy );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste",         canPaste );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Cut",           canCut );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Copy",          canCopy );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Paste",         canPaste );
+/*     menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );*/
 
        menu_set_sensitive( addrbook.tree_factory, "/Cut",             canCut );
        menu_set_sensitive( addrbook.tree_factory, "/Copy",            canCopy );
@@ -1552,6 +1676,7 @@ static void addressbook_list_menu_setup( void ) {
        menu_set_sensitive( addrbook.menu_factory, "/Address/Delete",  canDelete );
        menu_set_sensitive( addrbook.menu_factory, "/Address/Mail To", canCopy );
 
+       gtk_widget_set_sensitive( addrbook.edit_btn, canEdit );
        gtk_widget_set_sensitive( addrbook.del_btn, canDelete );
 
 #ifdef USE_LDAP
@@ -1684,10 +1809,11 @@ static void addressbook_clip_paste_cb( void ) {
        }
 
        /* Display items pasted */
-       gtk_ctree_select( ctree, addrbook.opened );
+       gtk_sctree_select( GTK_SCTREE(ctree), addrbook.opened );
 
 }
 
+#if 0
 /**
  * Paste clipboard email addresses only into address list widget.
  */
@@ -1749,9 +1875,10 @@ static void addressbook_clip_paste_address_cb( void ) {
 
        /* Display items pasted */
        if( cnt > 0 ) {
-               gtk_ctree_select( ctree, addrbook.opened );
+               gtk_sctree_select( GTK_SCTREE(ctree), addrbook.opened );
        }
 }
+#endif
 
 /**
  * Add current treenode object to clipboard. Note that widget only allows
@@ -1903,7 +2030,7 @@ static void addressbook_list_row_selected( GtkCTree *clist,
 
        aio = gtk_ctree_node_get_row_data( clist, node );
        if( aio ) {
-               printf( "list select: %d : '%s'\n", aio->type, aio->name );
+               /* printf( "list select: %d : '%s'\n", aio->type, aio->name ); */
                addressbook_list_select_add( aio, ds );
        }
 
@@ -1924,10 +2051,6 @@ static void addressbook_list_row_unselected( GtkCTree *ctree,
        }
 }
 
-static void addressbook_entry_gotfocus( GtkWidget *widget ) {
-       gtk_editable_select_region( GTK_EDITABLE(addrbook.entry), 0, -1 );
-}
-
 /* from gdkevents.c */
 #define DOUBLE_CLICK_TIME 250
 
@@ -1990,13 +2113,11 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
        addressbook_menubar_set_sensitive( FALSE );
 
        if( gtk_clist_get_selection_info( clist, event->x, event->y, &row, &column ) ) {
-               gtk_clist_select_row( clist, row, column );
                gtkut_clist_set_focus_row(clist, row);
                obj = gtk_clist_get_row_data( clist, row );
        }
 
        menu_set_insensitive_all(GTK_MENU_SHELL(addrbook.tree_popup));
-       gtk_widget_set_sensitive( addrbook.lup_btn, FALSE );
 
        if( obj == NULL ) return FALSE;
 
@@ -2014,9 +2135,7 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
                        canTreePaste = FALSE;
                }
                else {
-                       menu_set_sensitive( addrbook.tree_factory, "/New Address", TRUE );
                        menu_set_sensitive( addrbook.tree_factory, "/New Folder", TRUE );
-                       menu_set_sensitive( addrbook.tree_factory, "/New Group", TRUE );
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                }
                canTreeCopy = TRUE;
@@ -2032,9 +2151,7 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
                        canEdit = TRUE;
                        canDelete = TRUE;
                        canTreeCut = TRUE;
-                       menu_set_sensitive( addrbook.tree_factory, "/New Address", TRUE );
                        menu_set_sensitive( addrbook.tree_factory, "/New Folder", TRUE );
-                       menu_set_sensitive( addrbook.tree_factory, "/New Group", TRUE );
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                }
                canTreeCopy = TRUE;
@@ -2051,7 +2168,7 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
                if( ! iface->readOnly ) {
                        canEdit = TRUE;
                        canDelete = TRUE;
-                       menu_set_sensitive( addrbook.tree_factory, "/New Address", TRUE );
+                       menu_set_sensitive( addrbook.list_factory, "/New Address", TRUE );
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                }
        }
@@ -2072,15 +2189,14 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
        menu_set_sensitive( addrbook.tree_factory, "/Copy",   canTreeCopy );
        menu_set_sensitive( addrbook.tree_factory, "/Paste",  canTreePaste );
 
-       menu_set_sensitive( addrbook.menu_factory, "/File/Edit",          canEdit );
-       menu_set_sensitive( addrbook.menu_factory, "/File/Delete",        canEdit );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Cut",           canCut );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Copy",          canCopy );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste",         canPaste );
-       menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );
-
-       gtk_widget_set_sensitive( addrbook.lup_btn, canLookup );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book",          canEdit );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Delete book",        canEdit );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Cut",           canCut );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Copy",          canCopy );
+       menu_set_sensitive( addrbook.menu_factory, "/Address/Paste",         canPaste );
+/*     menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );*/
 
+       addressbook_show_buttons(addrbook.target_compose == NULL, canLookup, addrbook.target_compose != NULL);
        if( event->button == 3 ) {
                gtk_menu_popup(GTK_MENU(addrbook.tree_popup), NULL, NULL, NULL, NULL,
                               event->button, event->time);
@@ -2093,20 +2209,10 @@ static gboolean addressbook_tree_button_released(GtkWidget *ctree,
                                                 GdkEventButton *event,
                                                 gpointer data)
 {
-       gtk_ctree_select(GTK_CTREE(addrbook.ctree), addrbook.opened);
        gtkut_ctree_set_focus_row(GTK_CTREE(addrbook.ctree), addrbook.opened);
        return FALSE;
 }
 
-static void addressbook_popup_close(GtkMenuShell *menu_shell, gpointer data)
-{
-       if (!addrbook.opened) return;
-
-       gtk_ctree_select(GTK_CTREE(addrbook.ctree), addrbook.opened);
-       gtkut_ctree_set_focus_row(GTK_CTREE(addrbook.ctree),
-                                 addrbook.opened);
-}
-
 static void addressbook_new_folder_cb(gpointer data, guint action,
                                      GtkWidget *widget)
 {
@@ -2142,7 +2248,7 @@ static void addressbook_new_folder_cb(gpointer data, guint action,
                        addrbook.treeSelected, ds, folder, ADDR_ITEM_FOLDER );
                gtk_ctree_expand( ctree, addrbook.treeSelected );
                if( addrbook.treeSelected == addrbook.opened )
-                       addressbook_set_clist(obj);
+                       addressbook_set_clist(obj, TRUE);
        }
 
 }
@@ -2181,7 +2287,7 @@ static void addressbook_new_group_cb(gpointer data, guint action,
                nn = addressbook_node_add_group( addrbook.treeSelected, ds, group );
                gtk_ctree_expand( ctree, addrbook.treeSelected );
                if( addrbook.treeSelected == addrbook.opened )
-                       addressbook_set_clist(obj);
+                       addressbook_set_clist(obj, TRUE);
        }
 
 }
@@ -2198,7 +2304,7 @@ static void addressbook_change_node_name(GtkCTreeNode *node, const gchar *name)
        gtk_ctree_get_node_info(ctree, node, text, &spacing,
                                &pix_cl, &mask_cl, &pix_op, &mask_op,
                                &is_leaf, &expanded);
-       gtk_ctree_set_node_info(ctree, node, name, spacing,
+       gtk_sctree_set_node_info(ctree, node, name, spacing,
                                pix_cl, mask_cl, pix_op, mask_op,
                                is_leaf, expanded);
 }
@@ -2306,7 +2412,7 @@ static void addressbook_treenode_edit_cb(gpointer data, guint action,
                addressbook_change_node_name( node, name );
                gtk_sctree_sort_node(ctree, parentNode);
                gtk_ctree_expand( ctree, node );
-               gtk_ctree_select( ctree, node );
+               gtk_sctree_select( GTK_SCTREE( ctree), node );
        }
 }
 
@@ -2509,7 +2615,7 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
                ItemPerson *person = addressbook_edit_person( abf, folder, NULL, FALSE );
                if( person ) {
                        if (addrbook.treeSelected == addrbook.opened) {
-                               gtk_ctree_select( GTK_CTREE(addrbook.ctree), addrbook.opened );
+                               gtk_sctree_select( GTK_SCTREE(addrbook.ctree), addrbook.opened );
                        }
                }
        }
@@ -2520,7 +2626,7 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
                if (addrbook.treeSelected == addrbook.opened) {
                        /* Change node name in tree. */
                        addressbook_change_node_name( addrbook.treeSelected, ADDRITEM_NAME(group) );
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), addrbook.opened );
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), addrbook.opened );
                }
        }
 }
@@ -2619,7 +2725,7 @@ static void addressbook_edit_address_cb( gpointer data, guint action, GtkWidget
        if( ds == NULL ) return;
 
        abf = addressbook_get_book_file();
-       if( abf == NULL ) return;
+       
        if( obj->type == ADDR_ITEM_EMAIL ) {
                ItemEMail *email = ( ItemEMail * ) obj;
                if( email == NULL ) return;
@@ -2627,6 +2733,7 @@ static void addressbook_edit_address_cb( gpointer data, guint action, GtkWidget
                        /* Edit parent group */
                        AdapterGroup *adapter = ADAPTER_GROUP(pobj);
                        ItemGroup *itemGrp = adapter->itemGroup;
+                       if( abf == NULL ) return;
                        if( addressbook_edit_group( abf, NULL, itemGrp ) == NULL ) return;
                        name = ADDRITEM_NAME(itemGrp);
                        node = addrbook.treeSelected;
@@ -2665,7 +2772,7 @@ static void addressbook_edit_address_cb( gpointer data, guint action, GtkWidget
        if( node == NULL ) return;
        addressbook_change_node_name( node, name );
        gtk_sctree_sort_node( ctree, parentNode );
-       gtk_ctree_select( ctree, addrbook.opened ); 
+       gtk_sctree_select( GTK_SCTREE(ctree), addrbook.opened ); 
 }
 
 static void addressbook_delete_address_cb(gpointer data, guint action,
@@ -2716,7 +2823,7 @@ static void addressbook_load_group( GtkCTree *clist, ItemGroup *itemGroup ) {
        AddressTypeControlItem *atci = addrbookctl_lookup( ADDR_ITEM_EMAIL );
        for( ; items != NULL; items = g_list_next( items ) ) {
                GtkCTreeNode *nodeEMail = NULL;
-               gchar *text[N_COLS];
+               gchar *text[N_LIST_COLS];
                ItemEMail *email = items->data;
                ItemPerson *person;
                gchar *str = NULL;
@@ -2733,7 +2840,7 @@ static void addressbook_load_group( GtkCTree *clist, ItemGroup *itemGroup ) {
                }
                text[COL_ADDRESS] = email->address;
                text[COL_REMARKS] = email->remarks;
-               nodeEMail = gtk_ctree_insert_node(
+               nodeEMail = gtk_sctree_insert_node(
                                clist, NULL, NULL,
                                text, FOLDER_SPACING,
                                atci->iconXpm, atci->maskXpm,
@@ -2752,7 +2859,7 @@ static void addressbook_folder_load_one_person(
 {
        GtkCTreeNode *nodePerson = NULL;
        GtkCTreeNode *nodeEMail = NULL;
-       gchar *text[N_COLS];
+       gchar *text[N_LIST_COLS];
        gboolean flgFirst = TRUE, haveAddr = FALSE;
        GList *node;
 
@@ -2778,7 +2885,7 @@ static void addressbook_folder_load_one_person(
                        else {
                                text[COL_NAME] = ADDRITEM_NAME(person);
                        }
-                       nodePerson = gtk_ctree_insert_node(
+                       nodePerson = gtk_sctree_insert_node(
                                        clist, NULL, NULL,
                                        text, FOLDER_SPACING,
                                        atci->iconXpm, atci->maskXpm,
@@ -2791,7 +2898,7 @@ static void addressbook_folder_load_one_person(
                else {
                        /* Subsequent email is a child node of person */
                        text[COL_NAME] = ADDRITEM_NAME(email);
-                       nodeEMail = gtk_ctree_insert_node(
+                       nodeEMail = gtk_sctree_insert_node(
                                        clist, nodePerson, NULL,
                                        text, FOLDER_SPACING,
                                        atciMail->iconXpm, atciMail->maskXpm,
@@ -2807,7 +2914,7 @@ static void addressbook_folder_load_one_person(
                text[COL_NAME] = ADDRITEM_NAME(person);
                text[COL_ADDRESS] = NULL;
                text[COL_REMARKS] = NULL;
-               nodePerson = gtk_ctree_insert_node(
+               nodePerson = gtk_sctree_insert_node(
                                clist, NULL, NULL,
                                text, FOLDER_SPACING,
                                atci->iconXpm, atci->maskXpm,
@@ -2859,9 +2966,10 @@ static void addressbook_folder_refresh_one_person( GtkCTree *clist, ItemPerson *
        if( node )
                addressbook_folder_remove_node( clist, node );
        addressbook_folder_load_one_person( clist, person, atci, atciMail );
+       gtk_sctree_sort_node( clist, NULL );
        node = gtk_ctree_find_by_row_data( clist, NULL, person );
        if( node ) {
-               gtk_ctree_select( clist, node );
+               gtk_sctree_select( GTK_SCTREE(clist), node );
                if (!gtk_ctree_node_is_visible( clist, node ) ) 
                        gtk_ctree_node_moveto( clist, node, 0, 0, 0 );
        }
@@ -2888,13 +2996,13 @@ static void addressbook_folder_load_group( GtkCTree *clist, ItemFolder *itemFold
        items = addritem_folder_get_group_list( itemFolder );
        for( ; items != NULL; items = g_list_next( items ) ) {
                GtkCTreeNode *nodeGroup = NULL;
-               gchar *text[N_COLS];
+               gchar *text[N_LIST_COLS];
                ItemGroup *group = items->data;
                if( group == NULL ) continue;
                text[COL_NAME] = ADDRITEM_NAME(group);
                text[COL_ADDRESS] = NULL;
                text[COL_REMARKS] = NULL;
-               nodeGroup = gtk_ctree_insert_node(clist, NULL, NULL,
+               nodeGroup = gtk_sctree_insert_node(clist, NULL, NULL,
                                      text, FOLDER_SPACING,
                                      atci->iconXpm, atci->maskXpm,
                                      atci->iconXpmOpen, atci->maskXpmOpen,
@@ -3026,12 +3134,17 @@ static AddressDataSource *addressbook_find_datasource( GtkCTreeNode *node ) {
  * Load address list widget with children of specified object.
  * \param obj Parent object to be loaded.
  */
-static void addressbook_set_clist( AddressObject *obj ) {
+static void addressbook_set_clist( AddressObject *obj, gboolean refresh ) {
        GtkCTree *ctreelist = GTK_CTREE(addrbook.clist);
        GtkCList *clist = GTK_CLIST(addrbook.clist);
        AddressDataSource *ds = NULL;
        AdapterDSource *ads = NULL;
+       static AddressObject *last_obj = NULL;
 
+       if (obj == last_obj && !refresh)
+               return;
+
+       last_obj = obj;
        if( obj == NULL ) {
                gtk_clist_clear(clist);
                return;
@@ -3242,13 +3355,15 @@ static gboolean addressbook_convert( AddressIndex *addrIndex ) {
        }
        if( errFlag ) {
                debug_print( "Error\n%s\n", msg );
-               alertpanel_with_type( _( "Addressbook conversion error" ), msg, GTK_STOCK_CLOSE, 
-                                     NULL, NULL, NULL, ALERT_ERROR );
+               alertpanel_full(_("Addressbook conversion error"), msg,
+                               GTK_STOCK_CLOSE, NULL, NULL, FALSE,
+                               NULL, ALERT_ERROR, G_ALERTDEFAULT);
        }
        else if( msg ) {
                debug_print( "Warning\n%s\n", msg );
-               alertpanel_with_type( _( "Addressbook conversion" ), msg, GTK_STOCK_CLOSE, 
-                                     NULL, NULL, NULL, ALERT_WARNING );
+               alertpanel_full(_("Addressbook conversion error"), msg,
+                               GTK_STOCK_CLOSE, NULL, NULL, FALSE,
+                               NULL, ALERT_WARNING, G_ALERTDEFAULT);
        }
 
        return retVal;
@@ -3284,10 +3399,10 @@ void addressbook_read_file( void ) {
                /* Error reading address book */
                debug_print( "Could not read address index.\n" );
                addrindex_print_index( addrIndex, stdout );
-               alertpanel_with_type( _( "Addressbook Error" ),
-                           _( "Could not read address index" ),
-                           GTK_STOCK_CLOSE, NULL, NULL, NULL,
-                           ALERT_ERROR);
+               alertpanel_full(_("Addressbook Error"),
+                               _("Could not read address index"),
+                               GTK_STOCK_CLOSE, NULL, NULL, FALSE,
+                               NULL, ALERT_ERROR, G_ALERTDEFAULT);
        }
        debug_print( "done.\n" );
 }
@@ -3329,7 +3444,7 @@ static GtkCTreeNode *addressbook_add_object(GtkCTreeNode *node,
                        /* Add object to tree */
                        gchar **name;
                        name = &obj->name;
-                       added = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
+                       added = gtk_sctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
                                atci->iconXpm, atci->maskXpm, atci->iconXpmOpen, atci->maskXpmOpen,
                                atci->treeLeaf, atci->treeExpand );
                        gtk_ctree_node_set_row_data_full( ctree, added, obj,
@@ -3371,7 +3486,7 @@ static GtkCTreeNode *addressbook_node_add_group(
        ADDRESS_OBJECT_NAME(adapter) = g_strdup( ADDRITEM_NAME(itemGroup) );
        adapter->itemGroup = itemGroup;
 
-       newNode = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
+       newNode = gtk_sctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
                        atci->iconXpm, atci->maskXpm, atci->iconXpm, atci->maskXpm,
                        atci->treeLeaf, atci->treeExpand );
        gtk_ctree_node_set_row_data_full( ctree, newNode, adapter,
@@ -3424,7 +3539,7 @@ static GtkCTreeNode *addressbook_node_add_folder(
                adapter->itemFolder = itemFolder;
 
                name = ADDRITEM_NAME(itemFolder);
-               newNode = gtk_ctree_insert_node( ctree, node, NULL, &name, FOLDER_SPACING,
+               newNode = gtk_sctree_insert_node( ctree, node, NULL, &name, FOLDER_SPACING,
                                atci->iconXpm, atci->maskXpm, atci->iconXpm, atci->maskXpm,
                                atci->treeLeaf, atci->treeExpand );
                if( newNode ) {
@@ -3466,10 +3581,10 @@ void addressbook_export_to_file( void ) {
        }
 }
 
-static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+static gboolean addressbook_entry_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-       if (event && event->keyval == GDK_Escape)
-               addressbook_close();
+       if (event && event->keyval == GDK_Return)
+               addressbook_lup_clicked(NULL, NULL);
        return FALSE;
 }
 
@@ -3533,7 +3648,7 @@ static void addressbook_new_book_cb( gpointer data, guint action, GtkWidget *wid
        if( ads ) {
                newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
                if( newNode ) {
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), newNode );
                        addrbook.treeSelected = newNode;
                }
        }
@@ -3550,7 +3665,7 @@ static void addressbook_new_vcard_cb( gpointer data, guint action, GtkWidget *wi
        if( ads ) {
                newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
                if( newNode ) {
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), newNode );
                        addrbook.treeSelected = newNode;
                }
        }
@@ -3571,7 +3686,7 @@ static void addressbook_new_jpilot_cb( gpointer data, guint action, GtkWidget *w
        if( ads ) {
                newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
                if( newNode ) {
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), newNode );
                        addrbook.treeSelected = newNode;
                }
        }
@@ -3593,7 +3708,7 @@ static void addressbook_new_ldap_cb( gpointer data, guint action, GtkWidget *wid
        if( ads ) {
                newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
                if( newNode ) {
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), newNode );
                        addrbook.treeSelected = newNode;
                }
        }
@@ -3637,7 +3752,7 @@ static void addressbook_refresh_current( void ) {
        ctree = GTK_CTREE(addrbook.ctree);
        obj = gtk_ctree_node_get_row_data( ctree, addrbook.treeSelected );
        if( obj == NULL ) return;
-       addressbook_set_clist( obj );
+       addressbook_set_clist( obj, TRUE );
 }
 
 /**
@@ -3766,7 +3881,7 @@ static void addressbook_perform_search(
        nNode = addressbook_node_add_folder( pNode, ds, folder, aoType );
        gtk_ctree_expand( ctree, pNode );
        if( nNode ) {
-               gtk_ctree_select( ctree, nNode );
+               gtk_sctree_select( GTK_SCTREE(ctree), nNode );
                addrbook.treeSelected = nNode;
        }
 
@@ -3828,11 +3943,16 @@ static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
                parentNode = node;
        }
        addressbook_perform_search( ds, searchTerm, parentNode );
+       
        gtk_widget_grab_focus( addrbook.entry );
 
        g_free( searchTerm );
 }
 
+static void addressbook_close_clicked( GtkButton *button, gpointer data ) {
+       addressbook_close();
+}
+
 #ifdef USE_LDAP
 /**
  * Browse address entry for highlighted entry.
@@ -3956,7 +4076,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        atci->maskXpm = bookxpmmask;
        atci->iconXpmOpen = bookxpm;
        atci->maskXpmOpen = bookxpmmask;
-       atci->menuCommand = "/File/New Book";
+       atci->menuCommand = "/Book/New Book";
        g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
        _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
 
@@ -4036,7 +4156,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        atci->maskXpm = vcardxpmmask;
        atci->iconXpmOpen = vcardxpm;
        atci->maskXpmOpen = vcardxpmmask;
-       atci->menuCommand = "/File/New vCard";
+       atci->menuCommand = "/Book/New vCard";
        g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
        _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
 
@@ -4052,7 +4172,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        atci->maskXpm = jpilotxpmmask;
        atci->iconXpmOpen = jpilotxpm;
        atci->maskXpmOpen = jpilotxpmmask;
-       atci->menuCommand = "/File/New JPilot";
+       atci->menuCommand = "/Book/New JPilot";
        g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
        _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
 
@@ -4084,7 +4204,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        atci->maskXpm = ldapxpmmask;
        atci->iconXpmOpen = ldapxpm;
        atci->maskXpmOpen = ldapxpmmask;
-       atci->menuCommand = "/File/New Server";
+       atci->menuCommand = "/Book/New Server";
        g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
        _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
 
@@ -4324,8 +4444,7 @@ static void addressbook_import_ldif_cb( void ) {
                                        adapter->treeNode,
                                        ADDRESS_OBJECT(ads) );
                                if( newNode ) {
-                                       gtk_ctree_select(
-                                               GTK_CTREE(addrbook.ctree),
+                                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree),
                                                newNode );
                                        addrbook.treeSelected = newNode;
                                }
@@ -4362,8 +4481,7 @@ static void addressbook_import_mutt_cb( void ) {
                                        adapter->treeNode,
                                        ADDRESS_OBJECT(ads) );
                                if( newNode ) {
-                                       gtk_ctree_select(
-                                               GTK_CTREE(addrbook.ctree),
+                                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree),
                                                newNode );
                                        addrbook.treeSelected = newNode;
                                }
@@ -4400,8 +4518,7 @@ static void addressbook_import_pine_cb( void ) {
                                        adapter->treeNode,
                                        ADDRESS_OBJECT(ads) );
                                if( newNode ) {
-                                       gtk_ctree_select(
-                                               GTK_CTREE(addrbook.ctree),
+                                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree),
                                                newNode );
                                        addrbook.treeSelected = newNode;
                                }
@@ -4638,7 +4755,7 @@ static gboolean addressbook_drag_motion_cb(GtkWidget      *widget,
                g_signal_handlers_block_by_func
                        (G_OBJECT(widget),
                         G_CALLBACK(addressbook_tree_selected), NULL);
-               gtk_ctree_select(GTK_CTREE(widget), node);
+               gtk_sctree_select( GTK_SCTREE(widget), node);
                g_signal_handlers_unblock_by_func
                        (G_OBJECT(widget),
                         G_CALLBACK(addressbook_tree_selected), NULL);
@@ -4661,7 +4778,7 @@ static void addressbook_drag_leave_cb(GtkWidget      *widget,
                g_signal_handlers_block_by_func
                        (G_OBJECT(widget),
                         G_CALLBACK(addressbook_tree_selected), NULL);
-               gtk_ctree_select(GTK_CTREE(widget), addrbook.treeSelected);
+               gtk_sctree_select( GTK_SCTREE(widget), addrbook.treeSelected);
                g_signal_handlers_unblock_by_func
                        (G_OBJECT(widget),
                         G_CALLBACK(addressbook_tree_selected), NULL);
@@ -4714,7 +4831,6 @@ static void addressbook_drag_received_cb(GtkWidget        *widget,
                            ds->type == ADDR_IF_LDAP) 
                                goto free_list;         
                        afolder = addrindex_ds_get_root_folder( ds );
-                       
                } else {
                        goto free_list;
                }
@@ -4725,12 +4841,19 @@ static void addressbook_drag_received_cb(GtkWidget        *widget,
                        AddressBookFile *obook = dragged_ab;
                        AddressBookFile *abook = addressbook_get_book_file_for_node(node);
                        for (cur = dragged_persons; cur; cur = cur->next) {
+                               AddrBookBase *adbase = ( AddrBookBase * ) ds ? ds->rawDataSource : NULL;
+                               AddressCache *cache = (adbase) ? adbase->addressCache : NULL;
+
                                person = (ItemPerson *)cur->data;
                                addritem_folder_remove_person(ofolder, person);
-                               addritem_folder_add_person(afolder, person);
+                               if (cache) {
+                                       addrcache_folder_add_person(cache, afolder, person);
+                               } else {
+                                       addritem_folder_add_person(afolder, person);
+                               }
                        }
                        addressbook_list_select_clear();
-                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), addrbook.opened);
+                       gtk_sctree_select( GTK_SCTREE(addrbook.ctree), addrbook.opened);
                                                        
                        if (abook) {
                                addrbook_set_dirty(abook, TRUE);