aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-selector.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-11-20 06:28:25 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-11-20 06:28:25 +0800
commita69101987e5bda77882d32a049f93fefad16985e (patch)
treea46560bbb165003a7723f06b779ce2bb88b12f92 /mail/em-folder-selector.c
parentdc497cb36bd6b3b00752195bfc6cfebfb11a1a7a (diff)
downloadgsoc2013-evolution-a69101987e5bda77882d32a049f93fefad16985e.tar.gz
gsoc2013-evolution-a69101987e5bda77882d32a049f93fefad16985e.tar.zst
gsoc2013-evolution-a69101987e5bda77882d32a049f93fefad16985e.zip
Emit the response signal with the RESPONSE_NEW value.
2003-11-19 Jeffrey Stedfast <fejj@ximian.com> * em-folder-selector.c (emfs_create_name_activate): Emit the response signal with the RESPONSE_NEW value. (emfs_create_name_changed): Sanity check the entry text and set OK sensitivity. (folder_selected_cb): If there is an entry widget, then call name_changed() to decide sensitivity, else set OK to be sensitive. svn path=/trunk/; revision=23453
Diffstat (limited to 'mail/em-folder-selector.c')
-rw-r--r--mail/em-folder-selector.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index a670222c5e..4a2ac4f2af 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -41,6 +41,8 @@
#include <gtk/gtkstock.h>
#include <camel/camel-url.h>
+#include <camel/camel-store.h>
+#include <camel/camel-session.h>
#include "em-folder-tree.h"
#include "em-folder-selector.h"
@@ -48,6 +50,9 @@
#define d(x) x
+extern CamelSession *session;
+
+
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);
@@ -133,12 +138,29 @@ em_folder_selector_response (GtkDialog *dialog, int response)
}
}
-
+static void
+emfs_create_name_changed (GtkEntry *entry, EMFolderSelector *emfs)
+{
+ const char *path, *text = NULL;
+ gboolean active;
+
+ if (emfs->name_entry->text_length > 0)
+ text = gtk_entry_get_text (emfs->name_entry);
+
+ path = em_folder_tree_get_selected_path (emfs->emft);
+
+ active = text && path && !strchr (text, '/');
+
+ gtk_dialog_set_response_sensitive ((GtkDialog *) emfs, GTK_RESPONSE_OK, active);
+}
static void
folder_selected_cb (EMFolderTree *emft, const char *path, const char *uri, EMFolderSelector *emfs)
{
- gtk_dialog_set_response_sensitive (GTK_DIALOG (emfs), GTK_RESPONSE_OK, TRUE);
+ if (emfs->name_entry)
+ emfs_create_name_changed (emfs->name_entry, emfs);
+ else
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (emfs), GTK_RESPONSE_OK, TRUE);
}
void
@@ -203,22 +225,11 @@ em_folder_selector_new (EMFolderTree *emft, guint32 flags, const char *title, co
return (GtkWidget *) emfs;
}
-static void
-emfs_create_name_changed (GtkEntry *entry, EMFolderSelector *emfs)
-{
- gboolean active;
-
- /* FIXME: need to port this... */
- active = /* folder does not exist && */ emfs->name_entry->text_length > 0;
-
- gtk_dialog_set_response_sensitive ((GtkDialog *) emfs, GTK_RESPONSE_OK, active);
-}
static void
emfs_create_name_activate (GtkEntry *entry, EMFolderSelector *emfs)
{
- /* FIXME: create the folder... */
- printf ("entry activated, woop\n");
+ g_signal_emit_by_name (emfs, "response", 0, EM_FOLDER_SELECTOR_RESPONSE_NEW);
}
GtkWidget *
@@ -227,11 +238,15 @@ em_folder_selector_create_new (EMFolderTree *emft, guint32 flags, const char *ti
EMFolderSelector *emfs;
GtkWidget *hbox, *w;
+ /* remove the CREATE flag if it is there since that's the
+ * whole purpose of this dialog */
+ flags &= ~EM_FOLDER_SELECTOR_CAN_CREATE;
+
emfs = g_object_new (em_folder_selector_get_type (), NULL);
em_folder_selector_construct (emfs, emft, flags, title, text);
hbox = gtk_hbox_new (FALSE, 0);
- w = gtk_label_new_with_mnemonic (_("Folder _name"));
+ w = gtk_label_new_with_mnemonic (_("Folder _name:"));
gtk_box_pack_start ((GtkBox *) hbox, w, FALSE, FALSE, 6);
emfs->name_entry = (GtkEntry *) gtk_entry_new ();
g_signal_connect (emfs->name_entry, "changed", G_CALLBACK (emfs_create_name_changed), emfs);