From: Alfons Hoogervorst Date: Fri, 20 Apr 2001 23:24:31 +0000 (+0000) Subject: sync with cvs 4.64cvs4 X-Git-Tag: custom-headers~11 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=6cd5dcde2646b13437babaa7138fa463f99cf7c1 sync with cvs 4.64cvs4 --- diff --git a/ChangeLog.claws b/ChangeLog.claws new file mode 100644 index 000000000..be53c29a8 --- /dev/null +++ b/ChangeLog.claws @@ -0,0 +1,3 @@ +2001-04-21 + * sync with recent sylpheed cvs. Untested though. [alfons] + diff --git a/src/Makefile.am b/src/Makefile.am index 572f6d06c..ceaed97bf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -70,7 +70,8 @@ sylpheed_SOURCES = \ passphrase.c passphrase.h \ select-keys.c select-keys.h \ manual.c manual.h \ - addr_compl.c addr_compl.h + addr_compl.c addr_compl.h \ + export.c export.h EXTRA_DIST = \ pixmaps/clip.xpm \ diff --git a/src/addressbook.c b/src/addressbook.c index 40ecc846c..6d23e24e9 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -780,7 +780,11 @@ static void addressbook_list_selected(GtkCList *clist, gint row, gint column, GList *cur; if (event && event->type == GDK_2BUTTON_PRESS) { - addressbook_edit_address_cb(NULL, 0, NULL); + if (prefs_common.add_address_by_click && + addrbook.target_compose) + addressbook_to_clicked(NULL, NULL); + else + addressbook_edit_address_cb(NULL, 0, NULL); return; } diff --git a/src/export.c b/src/export.c new file mode 100644 index 000000000..09c640ac1 --- /dev/null +++ b/src/export.c @@ -0,0 +1,231 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2001 Hiroyuki Yamamoto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "defs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "intl.h" +#include "main.h" +#include "inc.h" +#include "mbox.h" +#include "filesel.h" +#include "foldersel.h" +#include "gtkutils.h" +#include "manage_window.h" +#include "folder.h" + +static GtkWidget *window; +static GtkWidget *src_entry; +static GtkWidget *file_entry; +static GtkWidget *src_button; +static GtkWidget *file_button; +static GtkWidget *ok_button; +static GtkWidget *cancel_button; +static gboolean export_ack; + +static void export_create(void); +static void export_ok_cb(GtkWidget *widget, gpointer data); +static void export_cancel_cb(GtkWidget *widget, gpointer data); +static void export_srcsel_cb(GtkWidget *widget, gpointer data); +static void export_filesel_cb(GtkWidget *widget, gpointer data); +static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data); + +gint export_mbox(FolderItem *default_src) +{ + gint ok = 0; + + if (!window) + export_create(); + else + gtk_widget_show(window); + + if (default_src && default_src->path) + gtk_entry_set_text(GTK_ENTRY(src_entry), default_src->path); + else + gtk_entry_set_text(GTK_ENTRY(src_entry), ""); + gtk_entry_set_text(GTK_ENTRY(file_entry), ""); + gtk_widget_grab_focus(file_entry); + + manage_window_set_transient(GTK_WINDOW(window)); + + gtk_main(); + + if (export_ack) { + gchar *srcdir, *mbox; + FolderItem *src; + + srcdir = gtk_entry_get_text(GTK_ENTRY(src_entry)); + mbox = gtk_entry_get_text(GTK_ENTRY(file_entry)); + + if (mbox && *mbox) { + src = folder_find_item_from_path(srcdir); + if (!src) + g_warning("Can't find the folder.\n"); + else + ok = export_to_mbox(src, mbox); + } + } + + gtk_widget_hide(window); + + return ok; +} + +static void export_create(void) +{ + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *desc_label; + GtkWidget *table; + GtkWidget *file_label; + GtkWidget *src_label; + GtkWidget *confirm_area; + + window = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_window_set_title(GTK_WINDOW(window), _("Export")); + gtk_container_set_border_width(GTK_CONTAINER(window), 5); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_window_set_modal(GTK_WINDOW(window), TRUE); + gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE); + gtk_signal_connect(GTK_OBJECT(window), "delete_event", + GTK_SIGNAL_FUNC(export_cancel_cb), NULL); + gtk_signal_connect(GTK_OBJECT(window), "key_press_event", + GTK_SIGNAL_FUNC(key_pressed), NULL); + gtk_signal_connect(GTK_OBJECT(window), "focus_in_event", + GTK_SIGNAL_FUNC(manage_window_focus_in), NULL); + gtk_signal_connect(GTK_OBJECT(window), "focus_out_event", + GTK_SIGNAL_FUNC(manage_window_focus_out), NULL); + + vbox = gtk_vbox_new(FALSE, 4); + gtk_container_add(GTK_CONTAINER(window), vbox); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); + + desc_label = gtk_label_new + (_("Specify target folder and mbox file.")); + gtk_box_pack_start(GTK_BOX(hbox), desc_label, FALSE, FALSE, 0); + + table = gtk_table_new(2, 3, FALSE); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(table), 8); + gtk_table_set_row_spacings(GTK_TABLE(table), 8); + gtk_table_set_col_spacings(GTK_TABLE(table), 8); + gtk_widget_set_usize(table, 420, -1); + + src_label = gtk_label_new(_("Source dir:")); + gtk_table_attach(GTK_TABLE(table), src_label, 0, 1, 0, 1, + GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0); + gtk_misc_set_alignment(GTK_MISC(src_label), 1, 0.5); + + file_label = gtk_label_new(_("Exporting file:")); + gtk_table_attach(GTK_TABLE(table), file_label, 0, 1, 1, 2, + GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0); + gtk_misc_set_alignment(GTK_MISC(file_label), 1, 0.5); + + src_entry = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(table), src_entry, 1, 2, 0, 1, + GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); + + file_entry = gtk_entry_new(); + gtk_table_attach(GTK_TABLE(table), file_entry, 1, 2, 1, 2, + GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); + + src_button = gtk_button_new_with_label(_(" Select... ")); + gtk_table_attach(GTK_TABLE(table), src_button, 2, 3, 0, 1, + 0, 0, 0, 0); + gtk_signal_connect(GTK_OBJECT(src_button), "clicked", + GTK_SIGNAL_FUNC(export_srcsel_cb), NULL); + + file_button = gtk_button_new_with_label(_(" Select... ")); + gtk_table_attach(GTK_TABLE(table), file_button, 2, 3, 1, 2, + 0, 0, 0, 0); + gtk_signal_connect(GTK_OBJECT(file_button), "clicked", + GTK_SIGNAL_FUNC(export_filesel_cb), NULL); + + gtkut_button_set_create(&confirm_area, + &ok_button, _("OK"), + &cancel_button, _("Cancel"), + NULL, NULL); + gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0); + gtk_widget_grab_default(ok_button); + + gtk_signal_connect(GTK_OBJECT(ok_button), "clicked", + GTK_SIGNAL_FUNC(export_ok_cb), NULL); + gtk_signal_connect(GTK_OBJECT(cancel_button), "clicked", + GTK_SIGNAL_FUNC(export_cancel_cb), NULL); + + gtk_widget_show_all(window); +} + +static void export_ok_cb(GtkWidget *widget, gpointer data) +{ + export_ack = TRUE; + if (gtk_main_level() > 1) + gtk_main_quit(); +} + +static void export_cancel_cb(GtkWidget *widget, gpointer data) +{ + export_ack = FALSE; + if (gtk_main_level() > 1) + gtk_main_quit(); +} + +static void export_filesel_cb(GtkWidget *widget, gpointer data) +{ + gchar *filename; + + filename = filesel_select_file(_("Select exporting file"), NULL); + if (filename) + gtk_entry_set_text(GTK_ENTRY(file_entry), filename); +} + +static void export_srcsel_cb(GtkWidget *widget, gpointer data) +{ + FolderItem *src; + + src = foldersel_folder_sel(NULL); + if (src && src->path) + gtk_entry_set_text(GTK_ENTRY(src_entry), src->path); +} + +static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + if (event && event->keyval == GDK_Escape) + export_cancel_cb(NULL, NULL); +} diff --git a/src/export.h b/src/export.h new file mode 100644 index 000000000..34d73a065 --- /dev/null +++ b/src/export.h @@ -0,0 +1,29 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2001 Hiroyuki Yamamoto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EXPORT_H__ +#define __EXPORT_H__ + +#include + +#include "folder.h" + +gint export_mbox(FolderItem *default_src); + +#endif /* __EXPORT_H__ */ diff --git a/src/import.c b/src/import.c index aee97880d..d51830588 100644 --- a/src/import.c +++ b/src/import.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999,2000 Hiroyuki Yamamoto + * Copyright (C) 1999-2001 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,7 +64,7 @@ static void import_filesel_cb(GtkWidget *widget, gpointer data); static void import_destsel_cb(GtkWidget *widget, gpointer data); static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data); -gint import_mbox(void) +gint import_mbox(FolderItem *default_dest) { gint ok = 0; @@ -73,6 +73,13 @@ gint import_mbox(void) else gtk_widget_show(window); + gtk_entry_set_text(GTK_ENTRY(file_entry), ""); + if (default_dest && default_dest->path) + gtk_entry_set_text(GTK_ENTRY(dest_entry), default_dest->path); + else + gtk_entry_set_text(GTK_ENTRY(dest_entry), ""); + gtk_widget_grab_focus(file_entry); + manage_window_set_transient(GTK_WINDOW(window)); gtk_main(); @@ -107,6 +114,8 @@ gint import_mbox(void) static void import_create(void) { GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *desc_label; GtkWidget *table; GtkWidget *file_label; GtkWidget *dest_label; @@ -114,11 +123,10 @@ static void import_create(void) window = gtk_window_new(GTK_WINDOW_DIALOG); gtk_window_set_title(GTK_WINDOW(window), _("Import")); - gtk_widget_set_usize(window, 450, -1); - gtk_container_set_border_width(GTK_CONTAINER(window), 4); + gtk_container_set_border_width(GTK_CONTAINER(window), 5); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(window), TRUE); - gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); + gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(import_cancel_cb), NULL); gtk_signal_connect(GTK_OBJECT(window), "key_press_event", @@ -128,14 +136,23 @@ static void import_create(void) gtk_signal_connect(GTK_OBJECT(window), "focus_out_event", GTK_SIGNAL_FUNC(manage_window_focus_out), NULL); - vbox = gtk_vbox_new(FALSE, 8); + vbox = gtk_vbox_new(FALSE, 4); gtk_container_add(GTK_CONTAINER(window), vbox); + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); + + desc_label = gtk_label_new + (_("Specify target mbox file and destination folder.")); + gtk_box_pack_start(GTK_BOX(hbox), desc_label, FALSE, FALSE, 0); + table = gtk_table_new(2, 3, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(table), 8); - gtk_table_set_row_spacings(GTK_TABLE(table), 12); + gtk_table_set_row_spacings(GTK_TABLE(table), 8); gtk_table_set_col_spacings(GTK_TABLE(table), 8); + gtk_widget_set_usize(table, 420, -1); file_label = gtk_label_new(_("Importing file:")); gtk_table_attach(GTK_TABLE(table), file_label, 0, 1, 0, 1, @@ -185,13 +202,15 @@ static void import_create(void) static void import_ok_cb(GtkWidget *widget, gpointer data) { import_ack = TRUE; - gtk_main_quit(); + if (gtk_main_level() > 1) + gtk_main_quit(); } static void import_cancel_cb(GtkWidget *widget, gpointer data) { import_ack = FALSE; - gtk_main_quit(); + if (gtk_main_level() > 1) + gtk_main_quit(); } static void import_filesel_cb(GtkWidget *widget, gpointer data) diff --git a/src/import.h b/src/import.h index 20dfe47c1..64d8421f6 100644 --- a/src/import.h +++ b/src/import.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999,2000 Hiroyuki Yamamoto + * Copyright (C) 1999-2001 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ #include -gint import_mbox(void); +#include "folder.h" + +gint import_mbox(FolderItem *default_dest); #endif /* __IMPORT_H__ */ diff --git a/src/mainwindow.c b/src/mainwindow.c index 79892c193..8835e6f42 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -54,6 +54,7 @@ #include "compose.h" #include "procmsg.h" #include "import.h" +#include "export.h" #include "prefs_common.h" #include "prefs_filter.h" #include "prefs_account.h" @@ -157,6 +158,9 @@ static void delete_folder_cb (MainWindow *mainwin, static void import_mbox_cb (MainWindow *mainwin, guint action, GtkWidget *widget); +static void export_mbox_cb (MainWindow *mainwin, + guint action, + GtkWidget *widget); static void empty_trash_cb (MainWindow *mainwin, guint action, GtkWidget *widget); @@ -335,6 +339,7 @@ static GtkItemFactoryEntry mainwin_entries[] = {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL}, {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL}, {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL}, + {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL}, {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL}, {N_("/_File/---"), NULL, NULL, 0, ""}, {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL}, @@ -1616,7 +1621,13 @@ static void delete_folder_cb(MainWindow *mainwin, guint action, static void import_mbox_cb(MainWindow *mainwin, guint action, GtkWidget *widget) { - import_mbox(); + import_mbox(mainwin->summaryview->folder_item); +} + +static void export_mbox_cb(MainWindow *mainwin, guint action, + GtkWidget *widget) +{ + export_mbox(mainwin->summaryview->folder_item); } static void empty_trash_cb(MainWindow *mainwin, guint action, diff --git a/src/mbox.c b/src/mbox.c index 051ee5e66..6513beb6e 100644 --- a/src/mbox.c +++ b/src/mbox.c @@ -367,9 +367,9 @@ void empty_mbox(const gchar *mbox) } /* read all messages in SRC, and store them into one MBOX file. */ -gint export_mbox(FolderItem *src, const gchar *mbox) +gint export_to_mbox(FolderItem *src, const gchar *mbox) { - GSList *mlist = NULL; + GSList *mlist; GSList *cur; MsgInfo *msginfo; FILE *msg_fp; @@ -383,14 +383,13 @@ gint export_mbox(FolderItem *src, const gchar *mbox) debug_print(_("Exporting messages from %s into %s...\n"), src->path, mbox); - mlist = src->folder->get_msg_list(src->folder, src, TRUE); - if (!mlist) return 0; - if ((mbox_fp = fopen(mbox, "w")) == NULL) { FILE_OP_ERROR(mbox, "fopen"); return -1; } + mlist = src->folder->get_msg_list(src->folder, src, TRUE); + for (cur = mlist; cur != NULL; cur = cur->next) { msginfo = (MsgInfo *)cur->data; diff --git a/src/mbox.h b/src/mbox.h index 969b07129..3b210f0a4 100644 --- a/src/mbox.h +++ b/src/mbox.h @@ -41,7 +41,7 @@ gint copy_mbox (const gchar *src, const gchar *dest); void empty_mbox (const gchar *mbox); -gint export_mbox (FolderItem *src, +gint export_to_mbox (FolderItem *src, const gchar *mbox); #endif /* __MBOX_H__ */ diff --git a/src/prefs_common.c b/src/prefs_common.c index 1cb986552..ee7630e79 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -140,6 +140,7 @@ static struct Interface { GtkWidget *checkbtn_confonexit; GtkWidget *checkbtn_cleanonexit; GtkWidget *checkbtn_askonclean; + GtkWidget *checkbtn_addaddrbyclick; } interface; static struct Other { @@ -454,6 +455,9 @@ static PrefParam param[] = { {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL, &interface.checkbtn_immedexec, prefs_set_data_from_toggle, prefs_set_toggle}, + {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click, + P_BOOL, &interface.checkbtn_addaddrbyclick, + prefs_set_data_from_toggle, prefs_set_toggle}, {"confirm_on_exit", "TRUE", &prefs_common.confirm_on_exit, P_BOOL, &interface.checkbtn_confonexit, @@ -1418,6 +1422,7 @@ static void prefs_interface_create(void) GtkWidget *checkbtn_openunread; GtkWidget *checkbtn_openinbox; GtkWidget *checkbtn_immedexec; + GtkWidget *checkbtn_addaddrbyclick; GtkWidget *label; GtkWidget *frame_exit; @@ -1468,6 +1473,10 @@ static void prefs_interface_create(void) gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + PACK_CHECK_BUTTON + (vbox2, checkbtn_addaddrbyclick, + _("Add address to destination when double-clicked")); + PACK_FRAME (vbox1, frame_exit, _("On exit")); vbox_exit = gtk_vbox_new (FALSE, VSPACING_NARROW); @@ -1488,13 +1497,14 @@ static void prefs_interface_create(void) _("Ask before emptying")); SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean); - interface.checkbtn_emacs = checkbtn_emacs; - interface.checkbtn_openunread = checkbtn_openunread; - interface.checkbtn_openinbox = checkbtn_openinbox; - interface.checkbtn_immedexec = checkbtn_immedexec; - interface.checkbtn_confonexit = checkbtn_confonexit; - interface.checkbtn_cleanonexit = checkbtn_cleanonexit; - interface.checkbtn_askonclean = checkbtn_askonclean; + interface.checkbtn_emacs = checkbtn_emacs; + interface.checkbtn_openunread = checkbtn_openunread; + interface.checkbtn_openinbox = checkbtn_openinbox; + interface.checkbtn_immedexec = checkbtn_immedexec; + interface.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick; + interface.checkbtn_confonexit = checkbtn_confonexit; + interface.checkbtn_cleanonexit = checkbtn_cleanonexit; + interface.checkbtn_askonclean = checkbtn_askonclean; } static void prefs_other_create(void) diff --git a/src/prefs_common.h b/src/prefs_common.h index 4fb0db4ac..2cb7e3b27 100644 --- a/src/prefs_common.h +++ b/src/prefs_common.h @@ -155,6 +155,7 @@ struct _PrefsCommon gboolean open_unread_on_enter; gboolean open_inbox_on_inc; gboolean immediate_exec; + gboolean add_address_by_click; gboolean confirm_on_exit; gboolean clean_on_exit; diff --git a/src/summaryview.c b/src/summaryview.c index 9afef154c..d308f99b0 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -556,8 +556,11 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item, STATUSBAR_POP(summaryview->mainwin); is_refresh = (item == summaryview->folder_item) ? TRUE : FALSE; - if (is_refresh) + if (is_refresh) { prev_msgnum = summary_get_current_msgnum(summaryview); + if (prev_msgnum < 1) + is_refresh = FALSE; + } #if 0 /* process the marks if any */