This commit was manufactured by cvs2svn to create branch 'gtk2'.
authorClaws Mail Team <theteam@claws-mail.org>
Mon, 26 Apr 2004 16:06:48 +0000 (16:06 +0000)
committerClaws Mail Team <theteam@claws-mail.org>
Mon, 26 Apr 2004 16:06:48 +0000 (16:06 +0000)
Cherrypick from master 2004-04-26 16:06:47 UTC reboot '0.9.10claws52':
    m4/.cvsignore
    src/gtk/inputdialog.c
    src/gtk/inputdialog.h
    src/imap_gtk.c
    src/imap_gtk.h
    src/mh_gtk.c
    src/mh_gtk.h
    src/news_gtk.h

m4/.cvsignore [new file with mode: 0644]
src/gtk/inputdialog.c [new file with mode: 0644]
src/gtk/inputdialog.h [new file with mode: 0644]
src/imap_gtk.c [new file with mode: 0644]
src/imap_gtk.h [new file with mode: 0644]
src/mh_gtk.c [new file with mode: 0644]
src/mh_gtk.h [new file with mode: 0644]
src/news_gtk.h [new file with mode: 0644]

diff --git a/m4/.cvsignore b/m4/.cvsignore
new file mode 100644 (file)
index 0000000..4b3dd95
--- /dev/null
@@ -0,0 +1,21 @@
+Makefile
+Makefile.in
+codeset.m4
+gettext.m4
+glibc21.m4
+iconv.m4
+intdiv0.m4
+inttypes_h.m4
+inttypes.m4
+inttypes-pri.m4
+isc-posix.m4
+lcmessage.m4
+lib-ld.m4
+lib-link.m4
+lib-prefix.m4
+nls.m4
+po.m4
+progtest.m4
+stdint_h.m4
+uintmax_t.m4
+ulongulong.m4
diff --git a/src/gtk/inputdialog.c b/src/gtk/inputdialog.c
new file mode 100644 (file)
index 0000000..3111c70
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 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 <glib.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkcombo.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbbox.h>
+
+#include "intl.h"
+#include "inputdialog.h"
+#include "manage_window.h"
+#include "gtkutils.h"
+#include "utils.h"
+
+#define INPUT_DIALOG_WIDTH     420
+
+typedef enum
+{
+       INPUT_DIALOG_NORMAL,
+       INPUT_DIALOG_INVISIBLE,
+       INPUT_DIALOG_COMBO
+} InputDialogType;
+
+static gboolean ack;
+static gboolean fin;
+
+static InputDialogType type;
+
+static GtkWidget *dialog;
+static GtkWidget *msg_label;
+static GtkWidget *entry;
+static GtkWidget *combo;
+static GtkWidget *ok_button;
+
+static void input_dialog_create        (void);
+static gchar *input_dialog_open        (const gchar    *title,
+                                const gchar    *message,
+                                const gchar    *default_string);
+static void input_dialog_set   (const gchar    *title,
+                                const gchar    *message,
+                                const gchar    *default_string);
+
+static void ok_clicked         (GtkWidget      *widget,
+                                gpointer        data);
+static void cancel_clicked     (GtkWidget      *widget,
+                                gpointer        data);
+static gint delete_event       (GtkWidget      *widget,
+                                GdkEventAny    *event,
+                                gpointer        data);
+static void key_pressed                (GtkWidget      *widget,
+                                GdkEventKey    *event,
+                                gpointer        data);
+static void entry_activated    (GtkEditable    *editable);
+static void combo_activated    (GtkEditable    *editable);
+
+
+gchar *input_dialog(const gchar *title, const gchar *message,
+                   const gchar *default_string)
+{
+       if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
+
+       if (!dialog)
+               input_dialog_create();
+
+       type = INPUT_DIALOG_NORMAL;
+       gtk_widget_hide(combo);
+       gtk_widget_show(entry);
+       gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE);
+
+       return input_dialog_open(title, message, default_string);
+}
+
+gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
+                                  const gchar *default_string)
+{
+       if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
+
+       if (!dialog)
+               input_dialog_create();
+
+       type = INPUT_DIALOG_INVISIBLE;
+       gtk_widget_hide(combo);
+       gtk_widget_show(entry);
+       gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+
+       return input_dialog_open(title, message, default_string);
+}
+
+gchar *input_dialog_combo(const gchar *title, const gchar *message,
+                         const gchar *default_string, GList *list,
+                         gboolean case_sensitive)
+{
+       if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
+
+       if (!dialog)
+               input_dialog_create();
+
+       type = INPUT_DIALOG_COMBO;
+       gtk_widget_hide(entry);
+       gtk_widget_show(combo);
+
+       if (!list) {
+               GList empty_list;
+
+               empty_list.data = (gpointer)"";
+               empty_list.next = NULL;
+               empty_list.prev = NULL;
+               gtk_combo_set_popdown_strings(GTK_COMBO(combo), &empty_list);
+       } else
+               gtk_combo_set_popdown_strings(GTK_COMBO(combo), list);
+
+       gtk_combo_set_case_sensitive(GTK_COMBO(combo), case_sensitive);
+
+       return input_dialog_open(title, message, default_string);
+}
+
+gchar *input_dialog_query_password(const gchar *server, const gchar *user)
+{
+       gchar *message;
+       gchar *pass;
+
+       message = g_strdup_printf(_("Input password for %s on %s:"),
+                                 user, server);
+       pass = input_dialog_with_invisible(_("Input password"), message, NULL);
+       g_free(message);
+
+       return pass;
+}
+
+static void input_dialog_create(void)
+{
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       GtkWidget *confirm_area;
+       GtkWidget *cancel_button;
+
+       dialog = gtk_dialog_new();
+       gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, FALSE);
+       gtk_widget_set_usize(dialog, INPUT_DIALOG_WIDTH, -1);
+       gtk_container_set_border_width
+               (GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 5);
+       gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
+                          GTK_SIGNAL_FUNC(delete_event), NULL);
+       gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event",
+                          GTK_SIGNAL_FUNC(key_pressed), NULL);
+       MANAGE_WINDOW_SIGNALS_CONNECT(dialog);
+
+       gtk_widget_realize(dialog);
+
+       vbox = gtk_vbox_new(FALSE, 8);
+       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
+
+       hbox = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+       msg_label = gtk_label_new("");
+       gtk_box_pack_start(GTK_BOX(hbox), msg_label, FALSE, FALSE, 0);
+       gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_LEFT);
+
+       entry = gtk_entry_new();
+       gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
+       gtk_signal_connect(GTK_OBJECT(entry), "activate",
+                          GTK_SIGNAL_FUNC(entry_activated), NULL);
+
+       combo = gtk_combo_new();
+       gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
+       gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "activate",
+                          GTK_SIGNAL_FUNC(combo_activated), NULL);
+
+       gtkut_button_set_create(&confirm_area,
+                               &ok_button,     _("OK"),
+                               &cancel_button, _("Cancel"),
+                               NULL, NULL);
+       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+                         confirm_area);
+       gtk_widget_grab_default(ok_button);
+
+       gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
+                          GTK_SIGNAL_FUNC(ok_clicked), NULL);
+       gtk_signal_connect(GTK_OBJECT(cancel_button), "clicked",
+                          GTK_SIGNAL_FUNC(cancel_clicked), NULL);
+
+
+       gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
+}
+
+static gchar *input_dialog_open(const gchar *title, const gchar *message,
+                               const gchar *default_string)
+{
+       gchar *str;
+
+       if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
+
+       if (!dialog)
+               input_dialog_create();
+
+       input_dialog_set(title, message, default_string);
+       gtk_widget_show(dialog);
+       gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       manage_window_set_transient(GTK_WINDOW(dialog));
+
+       ack = fin = FALSE;
+
+       while (fin == FALSE)
+               gtk_main_iteration();
+
+       manage_window_focus_out(dialog, NULL, NULL);
+       gtk_widget_hide(dialog);
+
+       if (ack) {
+               GtkEditable *editable;
+
+               if (type == INPUT_DIALOG_COMBO)
+                       editable = GTK_EDITABLE(GTK_COMBO(combo)->entry);
+               else
+                       editable = GTK_EDITABLE(entry);
+
+               str = gtk_editable_get_chars(editable, 0, -1);
+               if (str && *str == '\0') {
+                       g_free(str);
+                       str = NULL;
+               }
+       } else
+               str = NULL;
+
+       GTK_EVENTS_FLUSH();
+
+       debug_print("return string = %s\n", str ? str : "(none)");
+       return str;
+}
+
+static void input_dialog_set(const gchar *title, const gchar *message,
+                            const gchar *default_string)
+{
+       GtkWidget *entry_;
+
+       if (type == INPUT_DIALOG_COMBO)
+               entry_ = GTK_COMBO(combo)->entry;
+       else
+               entry_ = entry;
+
+       gtk_window_set_title(GTK_WINDOW(dialog), title);
+       gtk_label_set_text(GTK_LABEL(msg_label), message);
+       if (default_string && *default_string) {
+               gtk_entry_set_text(GTK_ENTRY(entry_), default_string);
+               gtk_entry_set_position(GTK_ENTRY(entry_), 0);
+               gtk_entry_select_region(GTK_ENTRY(entry_), 0, -1);
+       } else
+               gtk_entry_set_text(GTK_ENTRY(entry_), "");
+
+       gtk_widget_grab_focus(ok_button);
+       gtk_widget_grab_focus(entry_);
+}
+
+static void ok_clicked(GtkWidget *widget, gpointer data)
+{
+       ack = TRUE;
+       fin = TRUE;
+}
+
+static void cancel_clicked(GtkWidget *widget, gpointer data)
+{
+       ack = FALSE;
+       fin = TRUE;
+}
+
+static gint delete_event(GtkWidget *widget, GdkEventAny *event, gpointer data)
+{
+       ack = FALSE;
+       fin = TRUE;
+
+       return TRUE;
+}
+
+static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+       if (event && event->keyval == GDK_Escape) {
+               ack = FALSE;
+               fin = TRUE;
+       }
+}
+
+static void entry_activated(GtkEditable *editable)
+{
+       ack = TRUE;
+       fin = TRUE;
+}
+
+static void combo_activated(GtkEditable *editable)
+{
+       ack = TRUE;
+       fin = TRUE;
+}
diff --git a/src/gtk/inputdialog.h b/src/gtk/inputdialog.h
new file mode 100644 (file)
index 0000000..0e9175a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 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 __INPUTDIALOG_H__
+#define __INPUTDIALOG_H__
+
+#include <glib.h>
+
+gchar *input_dialog                    (const gchar    *title,
+                                        const gchar    *message,
+                                        const gchar    *default_string);
+gchar *input_dialog_with_invisible     (const gchar    *title,
+                                        const gchar    *message,
+                                        const gchar    *default_string);
+gchar *input_dialog_combo              (const gchar    *title,
+                                        const gchar    *message,
+                                        const gchar    *default_string,
+                                        GList          *list,
+                                        gboolean        case_sensitive);
+gchar *input_dialog_query_password     (const gchar    *server,
+                                        const gchar    *user);
+
+#endif /* __INPUTDIALOG_H__ */
diff --git a/src/imap_gtk.c b/src/imap_gtk.c
new file mode 100644 (file)
index 0000000..e73cbda
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto & the Sylpheed-Claws Team
+ *
+ * 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 <glib.h>
+
+#include <gtk/gtk.h>
+
+#include "intl.h"
+#include "utils.h"
+#include "folder.h"
+#include "folderview.h"
+#include "menu.h"
+#include "account.h"
+#include "alertpanel.h"
+#include "foldersel.h"
+#include "inputdialog.h"
+#include "imap.h"
+#include "inc.h"
+
+static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void rename_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void remove_server_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
+
+static GtkItemFactoryEntry imap_popup_entries[] =
+{
+       {N_("/Create _new folder..."),   NULL, new_folder_cb,    0, NULL},
+       {N_("/_Rename folder..."),       NULL, rename_folder_cb, 0, NULL},
+       {N_("/M_ove folder..."),         NULL, move_folder_cb,   0, NULL},
+       {N_("/_Delete folder"),          NULL, delete_folder_cb, 0, NULL},
+       {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
+       {N_("/Down_load messages"),      NULL, download_cb,      0, NULL},
+       {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
+       {N_("/_Check for new messages"), NULL, update_tree_cb,   0, NULL},
+       {N_("/R_ebuild folder tree"),    NULL, update_tree_cb,   1, NULL},
+       {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
+       {N_("/Remove _IMAP4 account"),   NULL, remove_server_cb, 0, NULL},
+       {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
+};
+
+static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+
+static FolderViewPopup imap_popup =
+{
+       "imap",
+       "<IMAPFolder>",
+       NULL,
+       set_sensitivity
+};
+
+void imap_gtk_init(void)
+{
+       guint i, n_entries;
+
+       n_entries = sizeof(imap_popup_entries) /
+               sizeof(imap_popup_entries[0]);
+       for (i = 0; i < n_entries; i++)
+               imap_popup.entries = g_slist_append(imap_popup.entries, &imap_popup_entries[i]);
+
+       folderview_register_popup(&imap_popup);
+}
+
+static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+{
+#define SET_SENS(name, sens) \
+       menu_set_sensitive(factory, name, sens)
+
+       SET_SENS("/Create new folder...",   TRUE);
+       SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Move folder...",         item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Delete folder",          item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+
+       SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
+       SET_SENS("/Rebuild folder tree",    folder_item_parent(item) == NULL);
+
+       SET_SENS("/Remove IMAP4 account",   folder_item_parent(item) == NULL);
+
+#undef SET_SENS
+}
+
+static void new_folder_cb(FolderView *folderview, guint action,
+                         GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       FolderItem *new_item;
+       gchar *new_folder;
+       gchar *name;
+       gchar *p;
+
+       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);
+       g_return_if_fail(item->folder->account != NULL);
+
+       new_folder = input_dialog
+               (_("New folder"),
+                _("Input the name of new folder:\n"
+                  "(if you want to create a folder to store subfolders,\n"
+                  " append `/' at the end of the name)"),
+                _("NewFolder"));
+       if (!new_folder) return;
+       AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
+
+       p = strchr(new_folder, G_DIR_SEPARATOR);
+       if (p && *(p + 1) != '\0') {
+               alertpanel_error(_("`%c' can't be included in folder name."),
+                                G_DIR_SEPARATOR);
+               return;
+       }
+
+       name = trim_string(new_folder, 32);
+       AUTORELEASE_STR(name, {g_free(name); return;});
+
+       /* find whether the directory already exists */
+       if (folder_find_child_item_by_name(item, new_folder)) {
+               alertpanel_error(_("The folder `%s' already exists."), name);
+               return;
+       }
+
+       new_item = folder_create_folder(item, new_folder);
+       if (!new_item) {
+               alertpanel_error(_("Can't create the folder `%s'."), name);
+               return;
+       }
+       folder_write_list();
+}
+
+static void rename_folder_cb(FolderView *folderview, guint action,
+                            GtkWidget *widget)
+{
+       FolderItem *item;
+       gchar *new_folder;
+       gchar *name;
+       gchar *message;
+       gchar *old_path;
+       gchar *old_id;
+       gchar *new_id;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->path != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       name = trim_string(item->name, 32);
+       message = g_strdup_printf(_("Input new name for `%s':"), name);
+       new_folder = input_dialog(_("Rename folder"), message,
+                                 g_basename(item->path));
+       g_free(message);
+       g_free(name);
+       if (!new_folder) return;
+       AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
+
+/*
+       TODO: check new name for IMAP namespace separator
+       if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
+               alertpanel_error(_("`%c' can't be included in folder name."),
+                                G_DIR_SEPARATOR);
+               return;
+       }
+*/
+       if (folder_find_child_item_by_name(folder_item_parent(item), new_folder)) {
+               name = trim_string(new_folder, 32);
+               alertpanel_error(_("The folder `%s' already exists."), name);
+               g_free(name);
+               return;
+       }
+
+       Xstrdup_a(old_path, item->path, {g_free(new_folder); return;});
+
+       old_id = folder_item_get_identifier(item);
+       
+       if (folder_item_rename(item, new_folder) < 0) {
+               alertpanel_error(_("The folder could not be renamed.\n"
+                                  "The new folder name is not allowed."));
+               g_free(old_id);
+               return;
+       }
+
+       /* if (FOLDER_TYPE(item->folder) == F_MH)
+               prefs_filtering_rename_path(old_path, item->path); */
+       new_id = folder_item_get_identifier(item);
+       prefs_filtering_rename_path(old_id, new_id);
+
+       g_free(old_id);
+       g_free(new_id);
+
+       folder_item_prefs_save_config(item);
+       folder_write_list();
+}
+
+static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget)
+{
+       FolderItem *from_folder = NULL, *to_folder = NULL;
+
+       from_folder = folderview_get_selected(folderview);
+       if (!from_folder || from_folder->folder->klass != imap_get_class())
+               return;
+
+       to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL);
+       if (!to_folder)
+               return;
+       
+       folderview_move_folder(folderview, from_folder, to_folder);
+}
+
+static void remove_server_cb(FolderView *folderview, guint action, GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       PrefsAccount *account;
+       gchar *name;
+       gchar *message;
+       AlertValue avalue;
+
+       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);
+       g_return_if_fail(item->folder->account != NULL);
+
+       name = trim_string(item->folder->name, 32);
+       message = g_strdup_printf(_("Really delete IMAP4 account `%s'?"), name);
+       avalue = alertpanel(_("Delete IMAP4 account"), message,
+                           _("Yes"), _("+No"), NULL);
+       g_free(message);
+       g_free(name);
+
+       if (avalue != G_ALERTDEFAULT) return;
+
+       if (folderview->opened == folderview->selected ||
+           gtk_ctree_is_ancestor(ctree,
+                                 folderview->selected,
+                                 folderview->opened)) {
+               summary_clear_all(folderview->summaryview);
+               folderview->opened = NULL;
+       }
+
+       account = item->folder->account;
+       folderview_unselect(folderview);
+       summary_clear_all(folderview->summaryview);
+       folder_destroy(item->folder);
+       account_destroy(account);
+       account_set_menu();
+       main_window_reflect_prefs_all();
+       folder_write_list();
+}
+
+static void delete_folder_cb(FolderView *folderview, guint action,
+                            GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       gchar *message, *name;
+       AlertValue avalue;
+       gchar *old_path;
+       gchar *old_id;
+
+       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->path != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       name = trim_string(item->name, 32);
+       AUTORELEASE_STR(name, {g_free(name); return;});
+       message = g_strdup_printf
+               (_("All folder(s) and message(s) under `%s' will be deleted.\n"
+                  "Do you really want to delete?"), name);
+       avalue = alertpanel(_("Delete folder"), message,
+                           _("Yes"), _("+No"), NULL);
+       g_free(message);
+       if (avalue != G_ALERTDEFAULT) return;
+
+       Xstrdup_a(old_path, item->path, return);
+       old_id = folder_item_get_identifier(item);
+
+       if (folderview->opened == folderview->selected ||
+           gtk_ctree_is_ancestor(ctree,
+                                 folderview->selected,
+                                 folderview->opened)) {
+               summary_clear_all(folderview->summaryview);
+               folderview->opened = NULL;
+       }
+
+       if (item->folder->klass->remove_folder(item->folder, item) < 0) {
+               alertpanel_error(_("Can't remove the folder `%s'."), name);
+               if (folderview->opened == folderview->selected)
+                       summary_show(folderview->summaryview,
+                                    folderview->summaryview->folder_item);
+               g_free(old_id);
+               return;
+       }
+
+       folder_write_list();
+
+       prefs_filtering_delete_path(old_id);
+       g_free(old_id);
+
+}
+
+static void update_tree_cb(FolderView *folderview, guint action,
+                          GtkWidget *widget)
+{
+       FolderItem *item;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+
+       summary_show(folderview->summaryview, NULL);
+
+       g_return_if_fail(item->folder != NULL);
+
+       if (action == 0)
+               folderview_check_new(item->folder);
+       else
+               folderview_rescan_tree(item->folder);
+}
+
+static void download_cb(FolderView *folderview, guint action,
+                       GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       MainWindow *mainwin = folderview->mainwin;
+       FolderItem *item;
+
+       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 0
+       if (!prefs_common.online_mode) {
+               if (alertpanel(_("Offline"),
+                              _("You are offline. Go online?"),
+                              _("Yes"), _("No"), NULL) == G_ALERTDEFAULT)
+                       main_window_toggle_online(folderview->mainwin, TRUE);
+               else
+                       return;
+       }
+#endif
+       main_window_cursor_wait(mainwin);
+       inc_lock();
+       main_window_lock(mainwin);
+       gtk_widget_set_sensitive(folderview->ctree, FALSE);
+       main_window_progress_on(mainwin);
+       GTK_EVENTS_FLUSH();
+       if (folder_item_fetch_all_msg(item) < 0) {
+               gchar *name;
+
+               name = trim_string(item->name, 32);
+               alertpanel_error(_("Error occurred while downloading messages in `%s'."), name);
+               g_free(name);
+       }
+       folder_set_ui_func(item->folder, NULL, NULL);
+       main_window_progress_off(mainwin);
+       gtk_widget_set_sensitive(folderview->ctree, TRUE);
+       main_window_unlock(mainwin);
+       inc_unlock();
+       main_window_cursor_normal(mainwin);
+}
diff --git a/src/imap_gtk.h b/src/imap_gtk.h
new file mode 100644 (file)
index 0000000..957714b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto & the Sylpheed-Claws Team
+ *
+ * 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 IMAP_GTK_H
+#define IMAP_GTK_H
+
+void imap_gtk_init(void);
+
+#endif /* IMAP_GTK_H */
diff --git a/src/mh_gtk.c b/src/mh_gtk.c
new file mode 100644 (file)
index 0000000..907904c
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto & the Sylpheed-Claws Team
+ *
+ * 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 <glib.h>
+
+#include <gtk/gtk.h>
+
+#include "intl.h"
+#include "utils.h"
+#include "folder.h"
+#include "folderview.h"
+#include "menu.h"
+#include "account.h"
+#include "alertpanel.h"
+#include "inputdialog.h"
+#include "mh.h"
+#include "foldersel.h"
+
+static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void rename_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void remove_mailbox_cb(FolderView *folderview, guint action, GtkWidget *widget);
+
+static GtkItemFactoryEntry mh_popup_entries[] =
+{
+       {N_("/Create _new folder..."),   NULL, new_folder_cb,     0, NULL},
+       {N_("/_Rename folder..."),       NULL, rename_folder_cb,  0, NULL},
+       {N_("/M_ove folder..."),         NULL, move_folder_cb,    0, NULL},
+       {N_("/_Delete folder"),          NULL, delete_folder_cb,  0, NULL},
+       {N_("/---"),                     NULL, NULL,              0, "<Separator>"},
+       {N_("/_Check for new messages"), NULL, update_tree_cb,    0, NULL},
+       {N_("/R_ebuild folder tree"),    NULL, update_tree_cb,    1, NULL},
+       {N_("/---"),                     NULL, NULL,              0, "<Separator>"},
+       {N_("/Remove _mailbox"),         NULL, remove_mailbox_cb, 0, NULL},
+       {N_("/---"),                     NULL, NULL,              0, "<Separator>"},
+};
+
+static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+
+static FolderViewPopup mh_popup =
+{
+       "mh",
+       "<MHFolder>",
+       NULL,
+       set_sensitivity
+};
+
+void mh_gtk_init(void)
+{
+       guint i, n_entries;
+
+       n_entries = sizeof(mh_popup_entries) /
+               sizeof(mh_popup_entries[0]);
+       for (i = 0; i < n_entries; i++)
+               mh_popup.entries = g_slist_append(mh_popup.entries, &mh_popup_entries[i]);
+
+       folderview_register_popup(&mh_popup);
+}
+
+static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+{
+#define SET_SENS(name, sens) \
+       menu_set_sensitive(factory, name, sens)
+
+       SET_SENS("/Create new folder...",   TRUE);
+       SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Move folder...",         item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("/Delete folder",          item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+
+       SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
+       SET_SENS("/Rebuild folder tree",    folder_item_parent(item) == NULL);
+
+       SET_SENS("/Remove mailbox",         folder_item_parent(item) == NULL);
+
+#undef SET_SENS
+}
+
+static void new_folder_cb(FolderView *folderview, guint action,
+                         GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       FolderItem *new_item;
+       gchar *new_folder;
+       gchar *name;
+       gchar *p;
+
+       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);
+
+       new_folder = input_dialog(_("New folder"),
+                                 _("Input the name of new folder:"),
+                                 _("NewFolder"));
+       if (!new_folder) return;
+       AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
+
+       p = strchr(new_folder, G_DIR_SEPARATOR);
+       if (p) {
+               alertpanel_error(_("`%c' can't be included in folder name."),
+                                G_DIR_SEPARATOR);
+               return;
+       }
+
+       name = trim_string(new_folder, 32);
+       AUTORELEASE_STR(name, {g_free(name); return;});
+
+       /* find whether the directory already exists */
+       if (folder_find_child_item_by_name(item, new_folder)) {
+               alertpanel_error(_("The folder `%s' already exists."), name);
+               return;
+       }
+
+       new_item = folder_create_folder(item, new_folder);
+       if (!new_item) {
+               alertpanel_error(_("Can't create the folder `%s'."), name);
+               return;
+       }
+
+       folder_write_list();
+}
+
+static void delete_folder_cb(FolderView *folderview, guint action,
+                            GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+       gchar *message, *name;
+       AlertValue avalue;
+       gchar *old_path;
+       gchar *old_id;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->path != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       name = trim_string(item->name, 32);
+       AUTORELEASE_STR(name, {g_free(name); return;});
+       message = g_strdup_printf
+               (_("All folder(s) and message(s) under `%s' will be deleted.\n"
+                  "Do you really want to delete?"), name);
+       avalue = alertpanel(_("Delete folder"), message,
+                           _("Yes"), _("+No"), NULL);
+       g_free(message);
+       if (avalue != G_ALERTDEFAULT) return;
+
+       Xstrdup_a(old_path, item->path, return);
+       old_id = folder_item_get_identifier(item);
+
+       if (folderview->opened == folderview->selected ||
+           gtk_ctree_is_ancestor(ctree,
+                                 folderview->selected,
+                                 folderview->opened)) {
+               summary_clear_all(folderview->summaryview);
+               folderview->opened = NULL;
+       }
+
+       if (item->folder->klass->remove_folder(item->folder, item) < 0) {
+               alertpanel_error(_("Can't remove the folder `%s'."), name);
+               if (folderview->opened == folderview->selected)
+                       summary_show(folderview->summaryview,
+                                    folderview->summaryview->folder_item);
+               g_free(old_id);
+               return;
+       }
+
+       folder_write_list();
+
+       prefs_filtering_delete_path(old_id);
+       g_free(old_id);
+
+}
+
+static void rename_folder_cb(FolderView *folderview, guint action,
+                            GtkWidget *widget)
+{
+       FolderItem *item;
+       gchar *new_folder;
+       gchar *name;
+       gchar *message;
+       gchar *old_path;
+       gchar *old_id;
+       gchar *new_id;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->path != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       name = trim_string(item->name, 32);
+       message = g_strdup_printf(_("Input new name for `%s':"), name);
+       new_folder = input_dialog(_("Rename folder"), message,
+                                 g_basename(item->path));
+       g_free(message);
+       g_free(name);
+       if (!new_folder) return;
+       AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
+
+       if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
+               alertpanel_error(_("`%c' can't be included in folder name."),
+                                G_DIR_SEPARATOR);
+               return;
+       }
+
+       if (folder_find_child_item_by_name(folder_item_parent(item), new_folder)) {
+               name = trim_string(new_folder, 32);
+               alertpanel_error(_("The folder `%s' already exists."), name);
+               g_free(name);
+               return;
+       }
+
+       Xstrdup_a(old_path, item->path, {g_free(new_folder); return;});
+
+       old_id = folder_item_get_identifier(item);
+       
+       if (folder_item_rename(item, new_folder) < 0) {
+               alertpanel_error(_("The folder could not be renamed.\n"
+                                  "The new folder name is not allowed."));
+               g_free(old_id);
+               return;
+       }
+
+       /* if (FOLDER_TYPE(item->folder) == F_MH)
+               prefs_filtering_rename_path(old_path, item->path); */
+       new_id = folder_item_get_identifier(item);
+       prefs_filtering_rename_path(old_id, new_id);
+
+       g_free(old_id);
+       g_free(new_id);
+
+       folder_item_prefs_save_config(item);
+       folder_write_list();
+}
+
+static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget)
+{
+       FolderItem *from_folder = NULL, *to_folder = NULL;
+
+       from_folder = folderview_get_selected(folderview);
+       if (!from_folder || from_folder->folder->klass != mh_get_class())
+               return;
+
+       to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL);
+       if (!to_folder)
+               return;
+       
+       folderview_move_folder(folderview, from_folder, to_folder);
+}
+
+static void update_tree_cb(FolderView *folderview, guint action,
+                          GtkWidget *widget)
+{
+       FolderItem *item;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+
+       summary_show(folderview->summaryview, NULL);
+
+       g_return_if_fail(item->folder != NULL);
+
+       if (action == 0)
+               folderview_check_new(item->folder);
+       else
+               folderview_rescan_tree(item->folder);
+}
+
+static void remove_mailbox_cb(FolderView *folderview, guint action,
+                             GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       GtkCTreeNode *node;
+       FolderItem *item;
+       gchar *name;
+       gchar *message;
+       AlertValue avalue;
+
+       item = folderview_get_selected(folderview);
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+       if (folder_item_parent(item)) return;
+
+       name = trim_string(item->folder->name, 32);
+       message = g_strdup_printf
+               (_("Really remove the mailbox `%s' ?\n"
+                  "(The messages are NOT deleted from the disk)"), name);
+       avalue = alertpanel(_("Remove mailbox"), message,
+                           _("Yes"), _("+No"), NULL);
+       g_free(message);
+       g_free(name);
+       if (avalue != G_ALERTDEFAULT) return;
+
+       folderview_unselect(folderview);
+       summary_clear_all(folderview->summaryview);
+
+       folder_destroy(item->folder);
+}
+
diff --git a/src/mh_gtk.h b/src/mh_gtk.h
new file mode 100644 (file)
index 0000000..f017201
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto & the Sylpheed-Claws Team
+ *
+ * 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 MH_GTK_H
+#define MH_GTK_H
+
+void mh_gtk_init(void);
+
+#endif /* MH_GTK_H */
diff --git a/src/news_gtk.h b/src/news_gtk.h
new file mode 100644 (file)
index 0000000..8cbf08b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2004 Hiroyuki Yamamoto & the Sylpheed-Claws Team
+ *
+ * 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 NEWS_GTK_H
+#define NEWS_GTK_H
+
+void news_gtk_init(void);
+
+#endif /* NEWS_GTK_H */