aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/em-folder-selector.c40
-rw-r--r--mail/em-folder-tree-model.c2
-rw-r--r--mail/em-folder-tree.c42
-rw-r--r--mail/em-folder-tree.h2
5 files changed, 67 insertions, 30 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index a1034d9934..1cc5c95a6f 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,14 @@
+2003-12-04 Jeffrey Stedfast <fejj@ximian.com>
+
+ Fixes bug #51605.
+
+ * em-folder-selector.c (emfs_response): Handle creating a new
+ folder (pop up a create-folder-selector dialog).
+
+ * em-folder-tree.c (emft_popup_new_folder_response): Moved all the
+ logic into em_folder_tree_create_folder().
+ (em_folder_tree_create_folder): New function to create a folder.
+
2003-12-04 Radek Doulik <rodo@ximian.com>
* em-folder-view.c: set junk toolbar buttons pixmaps
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index 543925b1a1..5e2697ddf8 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -57,7 +57,6 @@ static void em_folder_selector_class_init (EMFolderSelectorClass *klass);
static void em_folder_selector_init (EMFolderSelector *emfs);
static void em_folder_selector_destroy (GtkObject *obj);
static void em_folder_selector_finalize (GObject *obj);
-static void em_folder_selector_response (GtkDialog *dialog, int response);
static GtkDialogClass *parent_class = NULL;
@@ -92,14 +91,11 @@ em_folder_selector_class_init (EMFolderSelectorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
- GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
parent_class = g_type_class_ref (GTK_TYPE_DIALOG);
object_class->finalize = em_folder_selector_finalize;
gtk_object_class->destroy = em_folder_selector_destroy;
-
- dialog_class->response = em_folder_selector_response;
}
static void
@@ -127,15 +123,31 @@ em_folder_selector_finalize (GObject *obj)
}
static void
-em_folder_selector_response (GtkDialog *dialog, int response)
+emfs_response (GtkWidget *dialog, int response, EMFolderSelector *emfs)
{
- EMFolderSelector *emfs = (EMFolderSelector *) dialog;
+ EMFolderTreeModel *model;
+ const char *path, *uri;
+ EMFolderTree *emft;
+
+ if (response != EM_FOLDER_SELECTOR_RESPONSE_NEW)
+ return;
- switch (response) {
- case EM_FOLDER_SELECTOR_RESPONSE_NEW:
- /* FIXME: implement me */
- break;
+ model = em_folder_tree_get_model (emfs->emft);
+ emft = (EMFolderTree *) em_folder_tree_new_with_model (model);
+ dialog = em_folder_selector_create_new (emft, 0, _("Create New Folder"), _("Specify where to create the folder:"));
+ gtk_window_set_transient_for ((GtkWindow *) dialog, (GtkWindow *) emfs);
+
+ if (gtk_dialog_run ((GtkDialog *) dialog) == GTK_RESPONSE_OK) {
+ uri = em_folder_selector_get_selected_uri ((EMFolderSelector *) dialog);
+ path = em_folder_selector_get_selected_path ((EMFolderSelector *) dialog);
+
+ if (em_folder_tree_create_folder (emfs->emft, path, uri))
+ em_folder_tree_set_selected (emfs->emft, uri);
}
+
+ gtk_widget_destroy (dialog);
+
+ g_signal_stop_emission_by_name (emfs, "response");
}
static void
@@ -178,8 +190,10 @@ em_folder_selector_construct (EMFolderSelector *emfs, EMFolderTree *emft, guint3
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (emfs)->vbox), 6);
emfs->flags = flags;
- if (flags & EM_FOLDER_SELECTOR_CAN_CREATE)
- gtk_dialog_add_buttons (GTK_DIALOG (emfs), GTK_STOCK_NEW, EM_FOLDER_SELECTOR_RESPONSE_NEW, NULL);
+ if (flags & EM_FOLDER_SELECTOR_CAN_CREATE) {
+ gtk_dialog_add_button (GTK_DIALOG (emfs), GTK_STOCK_NEW, EM_FOLDER_SELECTOR_RESPONSE_NEW);
+ g_signal_connect (emfs, "response", G_CALLBACK (emfs_response), emfs);
+ }
gtk_dialog_add_buttons (GTK_DIALOG (emfs), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
@@ -188,7 +202,7 @@ em_folder_selector_construct (EMFolderSelector *emfs, EMFolderTree *emft, guint3
gtk_dialog_set_default_response (GTK_DIALOG (emfs), GTK_RESPONSE_OK);
emfs->emft = emft;
- gtk_widget_show ((GtkWidget *) emfs->emft);
+ gtk_widget_show ((GtkWidget *) emft);
g_signal_connect (emfs->emft, "folder-selected", G_CALLBACK (folder_selected_cb), emfs);
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index ecaa095f6f..cb82f7df7e 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -1139,7 +1139,7 @@ em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gb
static void
expanded_save (gpointer key, gpointer value, FILE *fp)
{
- /* FIXME: don't save nodes that don't exist in the tree anymore... */
+ /* FIXME: don't save stale entries */
if (!GPOINTER_TO_INT (value))
return;
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index d2f25793e4..409fc5881d 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -1000,25 +1000,18 @@ emft_popup_move (GtkWidget *item, EMFolderTree *emft)
NULL, emft_popup_copy_folder_selected, cfd);
}
-static void
-emft_popup_new_folder_response (EMFolderSelector *emfs, int response, EMFolderTree *emft)
+
+gboolean
+em_folder_tree_create_folder (EMFolderTree *emft, const char *path, const char *uri)
{
- /* FIXME: ugh, kludge-a-licious: EMFolderSelector uses EMFolderTree so we can poke emfs->emft internals */
- struct _EMFolderTreePrivate *priv = emfs->emft->priv;
+ struct _EMFolderTreePrivate *priv = emft->priv;
struct _EMFolderTreeModelStoreInfo *si;
- const char *uri, *parent, *path, *full_name;
+ const char *parent, *full_name;
char *name, *namebuf = NULL;
GtkWidget *dialog;
CamelStore *store;
CamelException ex;
- if (response != GTK_RESPONSE_OK) {
- gtk_widget_destroy ((GtkWidget *) emfs);
- return;
- }
-
- uri = em_folder_selector_get_selected_uri (emfs);
- path = em_folder_selector_get_selected_path (emfs);
d(printf ("Creating folder: %s (%s)\n", path, uri));
camel_exception_init (&ex);
@@ -1056,19 +1049,36 @@ emft_popup_new_folder_response (EMFolderSelector *emfs, int response, EMFolderTr
g_free (namebuf);
- gtk_widget_destroy ((GtkWidget *) emfs);
-
- return;
+ return TRUE;
exception:
- dialog = gtk_message_dialog_new ((GtkWindow *) emfs, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new ((GtkWindow *) emft, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s"), ex.desc);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
camel_exception_clear (&ex);
g_free (namebuf);
gtk_widget_show (dialog);
+
+ return FALSE;
+}
+
+static void
+emft_popup_new_folder_response (EMFolderSelector *emfs, int response, EMFolderTree *emft)
+{
+ const char *uri, *path;
+
+ if (response != GTK_RESPONSE_OK) {
+ gtk_widget_destroy ((GtkWidget *) emfs);
+ return;
+ }
+
+ uri = em_folder_selector_get_selected_uri (emfs);
+ path = em_folder_selector_get_selected_path (emfs);
+
+ if (em_folder_tree_create_folder (emfs->emft, path, uri))
+ gtk_widget_destroy ((GtkWidget *) emfs);
}
static void
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index c532f24314..ec4e9301d9 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -71,6 +71,8 @@ const char *em_folder_tree_get_selected_path (EMFolderTree *emft);
EMFolderTreeModel *em_folder_tree_get_model (EMFolderTree *emft);
+gboolean em_folder_tree_create_folder (EMFolderTree *emft, const char *path, const char *uri);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */