From 0a6ebcf09b23bfc9d4ca42112a4f4ddb8d6c9df9 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 15 Sep 2004 19:18:33 +0000 Subject: If built with gtkfilechooser support, we need to add a checkbox in the 2004-09-09 Jeffrey Stedfast * mail-account-gui.c (mail_account_gui_new): If built with gtkfilechooser support, we need to add a checkbox in the chooser so that the user can select files or folders (allowing him to choose - otherwise they won't be able to setup certain types of accounts). Fixes bug #64974. svn path=/trunk/; revision=27271 --- mail/mail-account-gui.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'mail/mail-account-gui.c') diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 168a75ea7c..5de9dc8211 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -30,6 +30,7 @@ #include #include +#include #include @@ -44,6 +45,11 @@ #include #include #include +#ifdef USE_GTKFILECHOOSER +#include +#include +#include +#endif #include #include @@ -1753,10 +1759,49 @@ smime_encrypt_key_clear(GtkWidget *w, MailAccountGui *gui) } #endif +#ifdef USE_GTKFILECHOOSER +static void +select_file_toggled (GtkToggleButton *toggle, GtkFileChooser *chooser) +{ + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + + if (gtk_toggle_button_get_active (toggle)) + action = GTK_FILE_CHOOSER_ACTION_OPEN; + + gtk_file_chooser_set_action (chooser, action); +} + +static void +browse_clicked (GnomeFileEntry *fentry, MailAccountGui *gui) +{ + GtkWidget *check; + struct stat st; + char *path; + + if (GTK_IS_FILE_CHOOSER (fentry->fsw)) { + check = gtk_check_button_new_with_label (_("Select individual file")); + g_signal_connect (check, "toggled", G_CALLBACK (select_file_toggled), fentry->fsw); + gtk_widget_show (check); + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (fentry->fsw), check); + + path = gnome_file_entry_get_full_path (fentry, TRUE); + if (path && stat (path, &st) == 0 && S_ISREG (st.st_mode)) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); + else + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE); + gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (check)); + g_free (path); + } + + g_signal_handlers_disconnect_by_func (fentry, G_CALLBACK (fentry), gui); +} +#endif /* USE_GTKFILECHOOSER */ + MailAccountGui * mail_account_gui_new (EAccount *account, EMAccountPrefs *dialog) { MailAccountGui *gui; + GtkWidget *fileentry; g_object_ref (account); @@ -1765,6 +1810,15 @@ mail_account_gui_new (EAccount *account, EMAccountPrefs *dialog) gui->dialog = dialog; gui->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL, NULL); +#ifdef USE_GTKFILECHOOSER + /* KLUDGE: If this Evolution was built with GtkFileChooser support, the user + * won't be able to create some types of local accounts because GtkFileChooser + * must be set to allow selection of one or the other of file vs folder. + * However, some providers allow the selection of files *or* folders. */ + fileentry = glade_xml_get_widget (gui->xml, "source_path_entry"); + g_signal_connect_after (fileentry, "browse-clicked", G_CALLBACK (browse_clicked), gui); +#endif + /* Management */ gui->account_name = GTK_ENTRY (glade_xml_get_widget (gui->xml, "management_name")); gui->default_account = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "management_default")); -- cgit v1.2.3