From: Melvin H. <mha...@us...> - 2003-08-19 09:05:04
|
Update of /cvsroot/libetpan/xetpan/src In directory sc8-pr-cvs1:/tmp/cvs-serv22328/src Modified Files: gtk-id-editor.c Log Message: - GtkIdEditor_ok_cb(): do not allow changes if an identity is currently used by a thread; really free deleted identities; update the new default mailboxes view; expunge deleted folders from the folders views - GtkIdEditor_transfer_changes(): changes to mailboxes are now taken into account - GtkIdEditor_add_mailboxes_page(): enable mailbox removal; add custom mailboxes list refreshing (displaying) - GtkIdEditor_mailboxes_add_done_cb(): enabled addition of new mailboxes - GtkIdEditor_mailboxes_remove_cb(): enabled removal of mailboxes - GtkIdEditor_mailboxes_refresh_cb(): new function to display the list of mailboxes Index: gtk-id-editor.c =================================================================== RCS file: /cvsroot/libetpan/xetpan/src/gtk-id-editor.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gtk-id-editor.c 29 Jul 2003 01:34:20 -0000 1.2 +++ gtk-id-editor.c 19 Aug 2003 09:05:01 -0000 1.3 @@ -102,7 +102,6 @@ XePGtkUtilsTree *sigtree; XePGtkUtilsTree *mtatree; clist *identity_list; - clist *mailbox_list; GtkWidget *label; GtkWidget *notebook; GtkWidget *id_name; @@ -248,10 +247,10 @@ GtkIdEditor_mailboxes_add_cb(XePGtkUtilsTree *idtree, void *aideditor); static void * -GtkIdEditor_mailboxes_remove_cb(XePGtkUtilsTree *idtree, void *aideditor); +GtkIdEditor_mailboxes_remove_cb(XePGtkUtilsTree *mbtree, void *aideditor); static void * -GtkIdEditor_mailboxes_to_top_cb(XePGtkUtilsTree *idtree, void *aideditor); +GtkIdEditor_mailboxes_to_top_cb(XePGtkUtilsTree *mbtree, void *aideditor); static void * GtkIdEditor_mailboxes_refresh_cb(XePGtkUtilsTree *idtree, void *aideditor); @@ -630,6 +629,27 @@ identities = a_Identity_list_get(); + for (iter = clist_begin(identities); iter; iter = iter->next) + { + identity = (XePIdentity *) iter->data; + if (a_Identity_is_busy(identity)) + { + char *msg; + msg = g_strdup_printf(_("Identity %s cannot be removed because it " + "is currently being used. Try later."), + identity->id); + a_GtkUtils_dialog_alert(_("Operation not permitted"), + ideditor->widget, XETPAN_INFO_MESSAGE, + msg, + _("You can check what operations are " + "currently running by opening the task " + "manager."), + XEP_GTKUTILS_OK, TRUE, TRUE, NULL, NULL); + g_free(msg); + return; + } + } + for (iter = clist_begin(identities); iter; iter = clist_delete(identities, iter)); @@ -646,9 +666,18 @@ identity = ID_TRIPLET_ORIG(triplet); clist_append(identities, identity); } + else + { + identity = ID_TRIPLET_ORIG(triplet); + a_Identity_free(identity); + } } GtkIdEditor_identities_free_copy(ideditor); - /* a_Conf_write(); */ + a_Foldersview_mailboxes_view_update(); + a_Foldersview_list_expunge(); + + a_Conf_write(); + GtkIdEditor_hide(ideditor); } @@ -788,16 +817,11 @@ if((to_change & XEP_IDEDITOR_MAILBOXES_CHANGED) && (*flags & XEP_IDEDITOR_MAILBOXES_CHANGED)) { -#if 0 - /* FolderRefs must be relinked if new folders were created that - * have the same refs. - */ - - list = a_Mailbox_list_new_copy(a_Identity_get_mailboxes(source)); - a_Identity_set_mailboxes(target, list); + list = a_Mailbox_list_clone(a_Identity_get_mailboxes(source)); + free(target->mailboxes); + target->mailboxes = list; *flags = *flags & ~XEP_IDEDITOR_MAILBOXES_CHANGED; -#endif } if ((to_change & XEP_IDEDITOR_MTAS_CHANGED) && @@ -991,8 +1015,6 @@ break; case XEP_IDEDITOR_MAILBOXES: - a_GtkUtils_tree_set_list(ideditor->mbtree, - a_Identity_get_mailboxes(identity_copy)); a_GtkUtils_tree_refresh(ideditor->mbtree); break; case XEP_IDEDITOR_MTAS: @@ -1197,7 +1219,9 @@ a_GtkUtils_tree_set_add_callback(mbtree, GtkIdEditor_mailboxes_add_cb, ideditor); - a_GtkUtils_tree_set_remove_callback(mbtree, NULL, NULL); + a_GtkUtils_tree_set_remove_callback(mbtree, + GtkIdEditor_mailboxes_remove_cb, + ideditor); a_GtkUtils_tree_set_edit_callback(mbtree, GtkIdEditor_mailboxes_edit_cb, ideditor); @@ -1205,6 +1229,9 @@ a_GtkUtils_tree_set_changed_callback(mbtree, GtkIdEditor_mailboxes_changed_cb, ideditor); + a_GtkUtils_tree_set_refresh_callback(mbtree, + GtkIdEditor_mailboxes_refresh_cb, + ideditor); ideditor->mbtree = mbtree; } @@ -1385,7 +1412,7 @@ return NULL; identity_copy = ID_TRIPLET_COPY(triplet); - a_Identity_free(identity_copy); + a_Identity_free_copy(identity_copy); ID_TRIPLET_COPY(triplet) = NULL; for (iter2 = iter->next; iter2; iter2 = iter2->next) @@ -1568,7 +1595,6 @@ (void **)&triplet, (void **) &iter); if (triplet == NULL || iter == NULL) { - printf("Not expanded...\n"); return NULL; } @@ -1617,6 +1643,8 @@ XePIdentity *identity_copy; int r = 0; + A_LOGGING_TRACE; + identities = a_Identity_list_get(); if (identities == NULL) return 0; @@ -1639,10 +1667,11 @@ { ID_TRIPLET_COPY(triplet) = identity_copy; ID_TRIPLET_ORIG(triplet) = identity; - if (clist_append(identity_list, triplet)) + ID_TRIPLET_FLAGS(triplet) = 0; + if (clist_append(identity_list, triplet)) { A_LOGGING_ERROR("malloc(): %s", strerror(errno)); - a_Identity_free(identity_copy); + a_Identity_free_copy(identity_copy); free(triplet); r = -1; } @@ -1650,7 +1679,7 @@ else { A_LOGGING_ERROR("malloc(): %s", strerror(errno)); - a_Identity_free(identity_copy); + a_Identity_free_copy(identity_copy); r = -1; } } @@ -1686,7 +1715,7 @@ identity_copy = ID_TRIPLET_COPY(triplet); if (identity_copy) { - a_Identity_free(identity_copy); + a_Identity_free_copy(identity_copy); } free(triplet); } @@ -2008,11 +2037,85 @@ GtkIdEditor_mailboxes_add_done_cb(XePGtkMbEditor *mbeditor, void *aideditor) { XePGtkIdEditor *ideditor = (XePGtkIdEditor *) aideditor; + XePUtilsTriplet *triplet; + XePGtkIdEditorPage page; + XePIdentity *identity_copy; + clistiter *iter; XePMailbox *mailbox; + if (GtkIdEditor_identity_get_selected(ideditor, &triplet, &page) != 0) + { + return; + } + + identity_copy = ID_TRIPLET_COPY(triplet); + + a_GtkUtils_tree_get_selected_data(ideditor->mbtree, NULL, NULL, NULL, + (void **)&iter, NULL); + mailbox = a_GtkMbEditor_get_mailbox(mbeditor); + clist_insert_after(identity_copy->mailboxes, iter, mailbox); + a_GtkUtils_tree_finalize_add(ideditor->mbtree, mailbox); +} + +static void * +GtkIdEditor_mailboxes_remove_cb(XePGtkUtilsTree *mbtree, void *aideditor) +{ + XePMailbox *mailbox; + clistiter *iter = NULL; + + a_GtkUtils_tree_get_selected_data(mbtree, NULL, NULL, NULL, + (void **)&iter, NULL); + + mailbox = (XePMailbox *) iter->data; + + mailbox->uid = -(mailbox->uid); /* Mark to be deleted */ + a_GtkUtils_tree_refresh(mbtree); + return NULL; +} + +static void * +GtkIdEditor_mailboxes_refresh_cb(XePGtkUtilsTree *mbtree, void *aideditor) +{ + XePGtkIdEditor *ideditor = (XePGtkIdEditor *) aideditor; + GtkWidget *id_treeview; + XePUtilsTriplet *triplet; + XePGtkIdEditorPage page; + GtkTreeStore *treestore; + clistiter *iter; + XePMailbox *mailbox; + GtkTreeIter treeiter; + XePIdentity *identity_copy; + + id_treeview = a_GtkUtils_tree_get_tree_view(ideditor->idtree); + + if (GtkIdEditor_identity_get_selected(ideditor, &triplet, &page) != 0) + { + return NULL; + } + + treestore = a_GtkUtils_tree_get_tree_store(mbtree); + + identity_copy = ID_TRIPLET_COPY(triplet); + + for (iter = clist_begin(identity_copy->mailboxes); iter; iter = iter->next) + { + mailbox = (XePMailbox *) iter->data; + if (mailbox->uid < 0) + continue; + gtk_tree_store_append(treestore, &treeiter, NULL); + gtk_tree_store_set(treestore, &treeiter, + TREE_DESCRIPTION_COL, mailbox->id, + TREE_TYPE_COL, 0, + TREE_WEIGHT_COL, PANGO_WEIGHT_NORMAL, + TREE_POINTER_COL, iter, + TREE_POINTER2_COL, NULL, + -1); + } + return NULL; + } static void * |