diff options
author | Iain Holmes <iain@src.gnome.org> | 2001-09-29 02:58:17 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2001-09-29 02:58:17 +0800 |
commit | e6ab5554d4fe16cc816d8751b0206291ffeeccc5 (patch) | |
tree | 8b6ea8acb7336b8e37db01bae9cd3ae10969753e /shell/e-shell-folder-creation-dialog.c | |
parent | 03dcbdb743e9fd4d8490f60830545a88e58776ef (diff) | |
download | gsoc2013-evolution-e6ab5554d4fe16cc816d8751b0206291ffeeccc5.tar.gz gsoc2013-evolution-e6ab5554d4fe16cc816d8751b0206291ffeeccc5.tar.zst gsoc2013-evolution-e6ab5554d4fe16cc816d8751b0206291ffeeccc5.zip |
Allow callers to set the default type of folder to be created.
svn path=/trunk/; revision=13220
Diffstat (limited to 'shell/e-shell-folder-creation-dialog.c')
-rw-r--r-- | shell/e-shell-folder-creation-dialog.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/shell/e-shell-folder-creation-dialog.c b/shell/e-shell-folder-creation-dialog.c index 59d6468338..4f0878efc2 100644 --- a/shell/e-shell-folder-creation-dialog.c +++ b/shell/e-shell-folder-creation-dialog.c @@ -374,7 +374,8 @@ type_with_display_name_compare_func (const void *a, const void *b) static GList * add_folder_types (GtkWidget *dialog, GladeXML *gui, - EShell *shell) + EShell *shell, + const char *default_type) { EFolderTypeRegistry *folder_type_registry; GtkWidget *folder_type_option_menu; @@ -438,7 +439,7 @@ add_folder_types (GtkWidget *dialog, gtk_object_set_data_full (GTK_OBJECT (menu_item), "folder_type", g_strdup (type->type), g_free); - if (strcmp (type->type, "mail") == 0) + if (strcmp (type->type, default_type ? default_type : "mail") == 0) default_item = i; i ++; @@ -457,6 +458,28 @@ add_folder_types (GtkWidget *dialog, return folder_types; } +static const char * +get_type_from_parent_path (EShell *shell, + const char *path) +{ + EFolder *folder; + const char *folder_type; + EStorageSet *set; + + set = e_shell_get_storage_set (shell); + folder = e_storage_set_get_folder (set, path); + if (folder == NULL) { + return NULL; + } + + folder_type = e_folder_get_type_string (folder); + if (folder_type == NULL) { + return NULL; + } else { + return folder_type; + } +} + /* FIXME: Currently this is modal. I think it's OK, but if people think it is not, we should change it to non-modal and make sure only one of these is @@ -465,6 +488,7 @@ void e_shell_show_folder_creation_dialog (EShell *shell, GtkWindow *parent_window, const char *default_parent_folder, + const char *default_type, EShellFolderCreationDialogCallback result_callback, void *result_callback_data) { @@ -490,7 +514,14 @@ e_shell_show_folder_creation_dialog (EShell *shell, setup_folder_name_entry (dialog, gui, shell); storage_set_view = add_storage_set_view (dialog, gui, shell, default_parent_folder); - folder_types = add_folder_types (dialog, gui, shell); + if (default_type == NULL) { + char *dt; + + dt = get_type_from_parent_path (shell, default_parent_folder); + folder_types = add_folder_types (dialog, gui, shell, dt); + } else { + folder_types = add_folder_types (dialog, gui, shell, default_type); + } dialog_data = g_new (DialogData, 1); dialog_data->dialog = dialog; |