2004-09-28 [colin] 0.9.12cvs110
authorColin Leroy <colin@colino.net>
Tue, 28 Sep 2004 09:55:18 +0000 (09:55 +0000)
committerColin Leroy <colin@colino.net>
Tue, 28 Sep 2004 09:55:18 +0000 (09:55 +0000)
* src/folderview.c
Add contextual Empty trash menu
* src/mainwindow.c
Revert cvs109 which was useless

ChangeLog.claws
PATCHSETS
configure.ac
src/folderview.c
src/mainwindow.c

index fab413b..d1fe60b 100644 (file)
@@ -1,3 +1,10 @@
+2004-09-28 [colin]     0.9.12cvs110
+
+       * src/folderview.c
+               Add contextual Empty trash menu
+       * src/mainwindow.c
+               Revert cvs109 which was useless
+
 2004-09-28 [colin]     0.9.12cvs109
 
        * src/mainwindow.c
index afe9bf2..e9842a1 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -92,3 +92,4 @@
 ( cvs diff -u -r 1.71 -r 1.73 src/addressbook.c; ) > 0.9.12cvs107.patchset
 ( cvs diff -u -r 1.73 -r 1.74 src/addressbook.c; ) > 0.9.12cvs108.patchset
 ( cvs diff -u -r 1.306 -r 1.307 src/mainwindow.c; ) > 0.9.12cvs109.patchset
+( cvs diff -u -r 1.246 -r 1.247 src/folderview.c; cvs diff -u -r 1.307 -r 1.308 src/mainwindow.c; ) > 0.9.12cvs110.patchset
index 80b29d7..17d894d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=109
+EXTRA_VERSION=110
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 719a4bd..205129d 100644 (file)
@@ -178,6 +178,10 @@ static void mark_all_read_cb            (FolderView    *folderview,
                                          guint           action,
                                          GtkWidget      *widget);
 
+static void folderview_empty_trash_cb  (FolderView     *folderview,
+                                        guint           action,
+                                        GtkWidget      *widget);
+
 static void folderview_search_cb       (FolderView     *folderview,
                                         guint           action,
                                         GtkWidget      *widget);
@@ -232,9 +236,15 @@ static GtkItemFactoryEntry folderview_common_popup_entries[] =
        {N_("/Mark all _read"),         NULL, mark_all_read_cb, 0, NULL},
        {N_("/_Search folder..."),      NULL, folderview_search_cb, 0, NULL},
        {N_("/_Properties..."),         NULL, folderview_property_cb, 0, NULL},
-       {N_("/_Processing..."),         NULL, folderview_processing_cb, 0, NULL},
+       {N_("/Pr_ocessing..."),         NULL, folderview_processing_cb, 0, NULL},
 };
 
+static GtkItemFactoryEntry folder_view_trash_popup_entries[] = {
+       {N_("/---"),                    NULL, NULL, 0, "<Separator>"},
+       {N_("/Empty trash..."),         NULL, folderview_empty_trash_cb, 0, NULL},
+};
+
+
 GtkTargetEntry folderview_drag_types[] =
 {
        {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
@@ -1376,6 +1386,15 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
        if (fpopup->set_sensitivity != NULL)
                fpopup->set_sensitivity(fpopup_factory, item);
 
+       if (item == folder->trash &&
+           gtk_item_factory_get_item(fpopup_factory, "/Empty trash...") == NULL) {
+               gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[0], folderview, 1);
+               gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[1], folderview, 1);
+       } else {
+               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[0]);
+               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[1]);
+       }
+       
 #define SET_SENS(name, sens) \
        menu_set_sensitive(fpopup_factory, name, sens)
 
@@ -1384,7 +1403,8 @@ static void folderview_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                 folderview->selected == folderview->opened);
        SET_SENS("/Properties...", TRUE);
        SET_SENS("/Processing...", item->node->parent != NULL);
-
+       if (item == folder->trash)
+               SET_SENS("/Empty trash...", folder_item_get_msg_list(item) != NULL);
 #undef SET_SENS
 
        popup = gtk_item_factory_get_widget(fpopup_factory, fpopup->path);
@@ -1641,6 +1661,38 @@ void folderview_create_folder_node(FolderView *folderview, FolderItem *item)
        gtk_clist_thaw(GTK_CLIST(ctree));
 }
 
+static void folderview_empty_trash_cb(FolderView *folderview, guint action,
+                                     GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       GSList *mlist = NULL;
+       GSList *cur = NULL;
+       if (!folderview->selected) return;
+       
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+       if (item != item->folder->trash) return;
+       
+       if (prefs_common.ask_on_clean) {
+               if (alertpanel(_("Empty trash"),
+                              _("Empty all messages in trash?"),
+                              _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+                       return;
+       }
+       
+       mlist = folder_item_get_msg_list(item);
+       
+       for (cur = mlist ; cur != NULL ; cur = cur->next) {
+               MsgInfo * msginfo = (MsgInfo *) cur->data;
+               partial_mark_for_delete(msginfo);
+               procmsg_msginfo_free(msginfo);
+       }
+
+       folder_item_remove_all_msg(item);
+}
+
 static void folderview_search_cb(FolderView *folderview, guint action,
                                 GtkWidget *widget)
 {
index e940db7..17acb0b 100644 (file)
@@ -1552,7 +1552,7 @@ void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
 {
        GList *list;
-       guint has_trash = 0;
+       guint has_trash;
        Folder *folder;
 
        for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {