2005-08-23 [paul] 1.9.13cvs53
authorPaul Mangan <paul@claws-mail.org>
Tue, 23 Aug 2005 12:20:48 +0000 (12:20 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 23 Aug 2005 12:20:48 +0000 (12:20 +0000)
* src/addressbook.c
* src/editaddress.c
view all data of LDAP contacts
Patch by Colin

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/addressbook.c
src/editaddress.c

index 5243c02..2604031 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-23 [paul]      1.9.13cvs53
+
+       * src/addressbook.c
+       * src/editaddress.c
+               view all data of LDAP contacts
+               Patch by Colin
+
 2005-08-23 [paul]      1.9.13cvs52
 
        * src/addressbook.c
index 76eeb38..67e412a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.60.2.6 -r 1.60.2.7 src/filtering.c;  cvs diff -u -r 1.21.2.1 -r 1.21.2.2 src/filtering.h;  cvs diff -u -r 1.75.2.8 -r 1.75.2.9 src/matcher.c;  cvs diff -u -r 1.16.2.3 -r 1.16.2.4 src/matcher_parser_lex.l;  cvs diff -u -r 1.25.2.8 -r 1.25.2.9 src/matcher_parser_parse.y;  cvs diff -u -r 1.59.2.22 -r 1.59.2.23 src/prefs_filtering.c;  ) > 1.9.13cvs50.patchset
 ( cvs diff -u -r 1.207.2.57 -r 1.207.2.58 src/folderview.c;  cvs diff -u -r 1.52.2.11 -r 1.52.2.12 src/prefs_folder_item.c;  ) > 1.9.13cvs51.patchset
 ( cvs diff -u -r 1.60.2.26 -r 1.60.2.27 src/addressbook.c;  ) > 1.9.13cvs52.patchset
+( cvs diff -u -r 1.60.2.27 -r 1.60.2.28 src/addressbook.c;  cvs diff -u -r 1.14.2.9 -r 1.14.2.10 src/editaddress.c;  ) > 1.9.13cvs53.patchset
index c7a0727..a5eee9b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=52
+EXTRA_VERSION=53
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 592bd25..6615bdc 100644 (file)
@@ -213,8 +213,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,
@@ -317,10 +315,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);
@@ -409,7 +403,7 @@ static GtkItemFactoryEntry addressbook_entries[] =
        {N_("/_Book/New _Server"),      "<control><shift>S",    addressbook_new_ldap_cb,        0, NULL},
 #endif
        {N_("/_Book/---"),              NULL,           NULL, 0, "<Separator>"},
-       {N_("/_Book/_Edit book name"),  NULL,           addressbook_treenode_edit_cb,   0, NULL},
+       {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},
@@ -967,8 +961,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,
@@ -1122,6 +1114,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 );
@@ -1162,6 +1155,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;
@@ -1345,14 +1339,13 @@ static void addressbook_to_clicked(GtkButton *button, gpointer data)
 }
 
 static void addressbook_menubar_set_sensitive( gboolean sensitive ) {
-       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book name",   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, "/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, "/Edit/Paste Address",  sensitive ); */
 
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Address", sensitive );
        menu_set_sensitive( addrbook.menu_factory, "/Address/New Group",   sensitive );
@@ -1364,6 +1357,7 @@ static void addressbook_menubar_set_sensitive( gboolean 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;
@@ -1390,10 +1384,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 ) {
@@ -1402,6 +1396,7 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
                        iface = ds->interface;
                        if( iface->readOnly ) {
                                canEditTr = FALSE;
+                               canDelete = FALSE;
                        }
                        else {
                                canAdd = editAddress = TRUE;
@@ -1430,9 +1425,9 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
        menu_set_sensitive( addrbook.menu_factory, "/Address/Edit",   canEdit );
        menu_set_sensitive( addrbook.menu_factory, "/Address/Delete", canEdit );
        gtk_widget_set_sensitive( addrbook.edit_btn, canEdit );
-       gtk_widget_set_sensitive( addrbook.del_btn, canEdit );
+       gtk_widget_set_sensitive( addrbook.del_btn, canDelete );
 
-       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book name",      canEditTr );
+       menu_set_sensitive( addrbook.menu_factory, "/Book/Edit book",      canEditTr );
        menu_set_sensitive( addrbook.menu_factory, "/Book/Delete book",    canEditTr );
 
        /* Export data */
@@ -1565,6 +1560,7 @@ static void addressbook_list_menu_setup( void ) {
                        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 */
@@ -1584,19 +1580,21 @@ static void addressbook_list_menu_setup( void ) {
                        }
                        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;
                canBrowse = FALSE;
+               canDelete = canEdit;
        }
 
        /* Now go finalize menu items */
@@ -2061,6 +2059,7 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
 
        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 );
        }
@@ -2137,7 +2136,7 @@ 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, "/Book/Edit book name",          canEdit );
+       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 );
@@ -2158,19 +2157,11 @@ static gboolean addressbook_tree_button_released(GtkWidget *ctree,
                                                 gpointer data)
 {
        gtk_sctree_select( GTK_SCTREE(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_sctree_select( GTK_SCTREE(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)
 {
@@ -2683,7 +2674,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;
@@ -2691,6 +2682,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;
@@ -3895,6 +3887,7 @@ 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 );
index 694102f..2d6f23b 100644 (file)
@@ -80,6 +80,7 @@ static struct _PersonEdit_dlg {
        gint rowIndEMail;
        gint rowIndAttrib;
        gboolean editNew;
+       gboolean read_only;
 
 } personeditdlg;
 
@@ -224,9 +225,11 @@ static void edit_person_email_list_selected( GtkCList *clist, gint row, gint col
                        gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_alias), ADDRITEM_NAME(email) );
                if( email->remarks )
                        gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_remarks), email->remarks );
-               gtk_widget_set_sensitive(personeditdlg.email_del, TRUE);
-               gtk_widget_set_sensitive(personeditdlg.email_up, row > 0);
-               gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, row + 1) != NULL);
+               if (!personeditdlg.read_only) {
+                       gtk_widget_set_sensitive(personeditdlg.email_del, TRUE);
+                       gtk_widget_set_sensitive(personeditdlg.email_up, row > 0);
+                       gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, row + 1) != NULL);
+               }
        } else {
                gtk_widget_set_sensitive(personeditdlg.email_del, FALSE);
                gtk_widget_set_sensitive(personeditdlg.email_up, FALSE);
@@ -243,8 +246,10 @@ static void edit_person_email_move( gint dir ) {
        if( email ) {
                gtk_clist_row_move( clist, personeditdlg.rowIndEMail, row );
                personeditdlg.rowIndEMail = row;
-               gtk_widget_set_sensitive(personeditdlg.email_up, row > 0);
-               gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, row + 1) != NULL);
+               if (!personeditdlg.read_only) {
+                       gtk_widget_set_sensitive(personeditdlg.email_up, row > 0);
+                       gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, row + 1) != NULL);
+               }
        } else {
                gtk_widget_set_sensitive(personeditdlg.email_up, FALSE);
                gtk_widget_set_sensitive(personeditdlg.email_down, FALSE);
@@ -278,9 +283,11 @@ static void edit_person_email_delete( gpointer data ) {
        if( ! email ) {
                personeditdlg.rowIndEMail = -1 + row;
        }
-       gtk_widget_set_sensitive(personeditdlg.email_del, gtk_clist_get_row_data(clist, 0) != NULL);
-       gtk_widget_set_sensitive(personeditdlg.email_up, gtk_clist_get_row_data(clist, personeditdlg.rowIndEMail + 1) != NULL);
-       gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, personeditdlg.rowIndEMail - 1) != NULL);
+       if (!personeditdlg.read_only) {
+               gtk_widget_set_sensitive(personeditdlg.email_del, gtk_clist_get_row_data(clist, 0) != NULL);
+               gtk_widget_set_sensitive(personeditdlg.email_up, gtk_clist_get_row_data(clist, personeditdlg.rowIndEMail + 1) != NULL);
+               gtk_widget_set_sensitive(personeditdlg.email_down, gtk_clist_get_row_data(clist, personeditdlg.rowIndEMail - 1) != NULL);
+       }
        edit_person_status_show( NULL );
 }
 
@@ -423,7 +430,7 @@ static void edit_person_load_attrib( ItemPerson *person ) {
 
 static void edit_person_attrib_list_selected( GtkCList *clist, gint row, gint column, GdkEvent *event, gpointer data ) {
        UserAttribute *attrib = gtk_clist_get_row_data( clist, row );
-       if( attrib ) {
+       if( attrib && !personeditdlg.read_only) {
                gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atname), attrib->name );
                gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atvalue), attrib->value );
                gtk_widget_set_sensitive(personeditdlg.attrib_del, TRUE);
@@ -452,7 +459,8 @@ static void edit_person_attrib_delete( gpointer data ) {
                personeditdlg.rowIndAttrib = -1 + row;
        } 
        
-       gtk_widget_set_sensitive(personeditdlg.attrib_del, gtk_clist_get_row_data(clist, 0) != NULL);
+       if (!personeditdlg.read_only)
+               gtk_widget_set_sensitive(personeditdlg.attrib_del, gtk_clist_get_row_data(clist, 0) != NULL);
        
        edit_person_status_show( NULL );
 }
@@ -665,6 +673,9 @@ static void edit_person_entry_email_changed (GtkWidget *entry, gpointer data)
 {
        gboolean non_empty = gtk_clist_get_row_data(GTK_CLIST(personeditdlg.clist_email), 0) != NULL;
 
+       if (personeditdlg.read_only)
+               return;
+
        if (gtk_entry_get_text(GTK_ENTRY(personeditdlg.entry_email)) == NULL
        ||  strlen(gtk_entry_get_text(GTK_ENTRY(personeditdlg.entry_email))) == 0) {
                gtk_widget_set_sensitive(personeditdlg.email_add,FALSE);
@@ -860,6 +871,9 @@ static void edit_person_entry_att_changed (GtkWidget *entry, gpointer data)
 {
        gboolean non_empty = gtk_clist_get_row_data(GTK_CLIST(personeditdlg.clist_attrib), 0) != NULL;
 
+       if (personeditdlg.read_only)
+               return;
+
        if (gtk_entry_get_text(GTK_ENTRY(personeditdlg.entry_atname)) == NULL
        ||  strlen(gtk_entry_get_text(GTK_ENTRY(personeditdlg.entry_atname))) == 0) {
                gtk_widget_set_sensitive(personeditdlg.attrib_add,FALSE);
@@ -1064,6 +1078,27 @@ static GList *edit_person_build_attrib_list() {
        return listAttrib;
 }
 
+static void update_sensitivity(void)
+{
+       gtk_widget_set_sensitive(personeditdlg.entry_name,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_first,   !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_last,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_nick,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_email,   !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_alias,   !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_remarks, !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.email_up,      !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.email_down,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.email_del,     !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.email_mod,     !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.email_add,     !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_atname,  !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.entry_atvalue, !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.attrib_add,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.attrib_del,    !personeditdlg.read_only);
+       gtk_widget_set_sensitive(personeditdlg.attrib_mod,    !personeditdlg.read_only);
+}
+
 /*
 * Edit person.
 * Enter: abf    Address book.
@@ -1083,6 +1118,10 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent, I
                addressbook_edit_person_create(&cancelled);
        gtk_widget_grab_focus(personeditdlg.ok_btn);
        gtk_widget_grab_focus(personeditdlg.entry_name);
+       
+       personeditdlg.read_only = (abf == NULL);
+       update_sensitivity();
+
        gtk_widget_show(personeditdlg.window);
        manage_window_set_transient(GTK_WINDOW(personeditdlg.window));
 
@@ -1144,7 +1183,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent, I
        }
 
        cn = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_name), 0, -1 );
-       if( person ) {
+       if( person && abf ) {
                /* Update email/attribute list for existing person */
                addrbook_update_address_list( abf, person, listEMail );
                addrbook_update_attrib_list( abf, person, listAttrib );
@@ -1155,7 +1194,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent, I
                        /* Wasting our time */
                        if( listEMail == NULL && listAttrib == NULL ) cancelled = TRUE;
                }
-               if( ! cancelled ) {
+               if( ! cancelled && abf ) {
                        person = addrbook_add_address_list( abf, parent, listEMail );
                        addrbook_add_attrib_list( abf, person, listAttrib );
                }