Update the ::user_select_folder() interface so that it accepts both a

physical URI or an evolution: one for specifying the default folder.

svn path=/trunk/; revision=4508
This commit is contained in:
Ettore Perazzoli
2000-08-03 18:21:47 +00:00
parent f273b40d5e
commit 49fd4ffbc4
8 changed files with 208 additions and 13 deletions

View File

@ -1,3 +1,25 @@
2000-08-03 Ettore Perazzoli <ettore@helixcode.com>
* e-shell-view-menu.c (command_goto_folder): Just use the current
URI as the @default_uri parameter for
`e_shell_folder_selection_dialog_new()'.
* evolution-session.c (class_init): Call `corba_class_init()'.
* e-shell-folder-selection-dialog.c
(e_shell_folder_selection_dialog_new): @default_path renamed to
@default_uri.
(e_shell_folder_selection_dialog_construct): Likewise. If the
@default_uri is an `evolution:' one, use it as a path; if it is
different, assume it is a physical URI and consequently look for
the folder that has that physical URI and make it the default.
(set_default_folder): New helper function.
(e_shell_folder_selection_dialog_construct): Use it.
* e-storage-set.c (e_storage_set_get_path_for_physical_uri): New.
* e-storage.c (e_storage_get_path_for_physical_uri): New.
2000-07-27 Dan Winship <danw@helixcode.com>
* main.c (idle_cb): work with either gconf 0.5 or newer

View File

@ -33,8 +33,9 @@
#include "e-util/e-util.h"
#include "widgets/misc/e-scroll-frame.h"
#include "e-storage-set.h"
#include "e-shell-constants.h"
#include "e-storage-set-view.h"
#include "e-storage-set.h"
#include "e-shell-folder-creation-dialog.h"
@ -209,11 +210,46 @@ init (EShellFolderSelectionDialog *shell_folder_selection_dialog)
}
static void
set_default_folder (EShellFolderSelectionDialog *shell_folder_selection_dialog,
const char *default_uri)
{
EShellFolderSelectionDialogPrivate *priv;
char *default_path;
priv = shell_folder_selection_dialog->priv;
if (strncmp (default_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) {
/* `evolution:' URI. */
default_path = g_strdup (default_uri + E_SHELL_URI_PREFIX_LEN);
} else {
/* Physical URI. */
default_path = e_storage_set_get_path_for_physical_uri (priv->storage_set,
default_uri);
}
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
default_path);
g_free (default_path);
}
/**
* e_shell_folder_selection_dialog_construct:
* @folder_selection_dialog: A folder selection dialog widget
* @shell: The this folder selection dialog is for
* @title: Title of the window
* @default_uri: The URI of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Construct @folder_selection_dialog.
**/
void
e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog,
EShell *shell,
const char *title,
const char *default_path,
const char *default_uri,
const char *allowed_types[])
{
EShellFolderSelectionDialogPrivate *priv;
@ -258,8 +294,7 @@ e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_s
g_strdup (allowed_types[i]));
}
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
default_path);
set_default_folder (folder_selection_dialog, default_uri);
scroll_frame = e_scroll_frame_new (NULL, NULL);
e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll_frame),
@ -274,10 +309,23 @@ e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_s
gtk_widget_show (priv->storage_set_view);
}
/**
* e_shell_folder_selection_dialog_new:
* @shell: The this folder selection dialog is for
* @title: Title of the window
* @default_uri: The URI of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Create a new folder selection dialog widget. @default_uri can be either an
* `evolution:' URI or a physical URI (all the non-`evoluion:' URIs are
* considered to be physical URIs).
*
* Return value:
**/
GtkWidget *
e_shell_folder_selection_dialog_new (EShell *shell,
const char *title,
const char *default_path,
const char *default_uri,
const char *allowed_types[])
{
EShellFolderSelectionDialog *folder_selection_dialog;
@ -287,7 +335,7 @@ e_shell_folder_selection_dialog_new (EShell *shell,
folder_selection_dialog = gtk_type_new (e_shell_folder_selection_dialog_get_type ());
e_shell_folder_selection_dialog_construct (folder_selection_dialog, shell,
title, default_path, allowed_types);
title, default_uri, allowed_types);
return GTK_WIDGET (folder_selection_dialog);
}

View File

@ -308,21 +308,16 @@ command_goto_folder (BonoboUIHandler *uih,
EShellView *shell_view;
EShell *shell;
const char *current_uri;
const char *default_folder;
shell_view = E_SHELL_VIEW (data);
shell = e_shell_view_get_shell (shell_view);
current_uri = e_shell_view_get_current_uri (shell_view);
if (strncmp (current_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0)
default_folder = current_uri + E_SHELL_URI_PREFIX_LEN;
else
default_folder = NULL;
folder_selection_dialog = e_shell_folder_selection_dialog_new (shell,
_("Go to folder..."),
default_folder, NULL);
current_uri,
NULL);
gtk_window_set_transient_for (GTK_WINDOW (folder_selection_dialog), GTK_WINDOW (shell_view));

View File

@ -523,5 +523,53 @@ e_storage_set_get_folder_type_registry (EStorageSet *storage_set)
return storage_set->priv->folder_type_registry;
}
/* Utility functions. */
/**
* e_storage_set_get_path_for_physical_uri:
* @storage_set: A storage set
* @physical_uri: A physical URI
*
* Retrieve the path of the folder whose physical URI matches @physical_uri.
*
* Return value:
**/
char *
e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set,
const char *physical_uri)
{
EStorageSetPrivate *priv;
GList *p;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
g_return_val_if_fail (physical_uri != NULL, NULL);
priv = storage_set->priv;
for (p = priv->storages; p != NULL; p = p->next) {
EStorage *storage;
char *storage_path;
storage = E_STORAGE (p->data);
storage_path = e_storage_get_path_for_physical_uri (storage, physical_uri);
if (storage_path != NULL) {
char *storage_set_path;
storage_set_path = g_strconcat (G_DIR_SEPARATOR_S,
e_storage_get_name (storage),
storage_path,
NULL);
g_free (storage_path);
return storage_set_path;
}
}
return NULL;
}
E_MAKE_TYPE (e_storage_set, "EStorageSet", EStorageSet, class_init, init, PARENT_TYPE)

View File

@ -100,6 +100,11 @@ void e_storage_set_async_remove_folder (EStorageSet *storage
EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set);
/* Utility functions. */
char *e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set,
const char *physical_uri);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -436,6 +436,76 @@ e_storage_result_to_string (EStorageResult result)
}
/* Utility functions. */
struct _GetPathForPhysicalUriForeachData {
const char *physical_uri;
char *retval;
};
typedef struct _GetPathForPhysicalUriForeachData GetPathForPhysicalUriForeachData;
static void
get_path_for_physical_uri_foreach (void *key,
void *value,
void *data)
{
GetPathForPhysicalUriForeachData *foreach_data;
const char *physical_uri;
Folder *folder;
foreach_data = (GetPathForPhysicalUriForeachData *) data;
if (foreach_data->retval != NULL)
return;
folder = (Folder *) value;
if (folder->e_folder == NULL)
return;
physical_uri = e_folder_get_physical_uri (folder->e_folder);
if (strcmp (foreach_data->physical_uri, physical_uri) == 0) {
const char *path;
path = (const char *) key;
foreach_data->retval = g_strdup (path);
}
}
/**
* e_storage_get_path_for_physical_uri:
* @storage: A storage
* @physical_uri: A physical URI
*
* Look for the folder having the specified @physical_uri.
*
* Return value: The path of the folder having the specified @physical_uri in
* @storage. If such a folder does not exist, just return NULL. The return
* value must be freed by the caller.
**/
char *
e_storage_get_path_for_physical_uri (EStorage *storage,
const char *physical_uri)
{
GetPathForPhysicalUriForeachData foreach_data;
EStoragePrivate *priv;
g_return_val_if_fail (storage != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE (storage), NULL);
g_return_val_if_fail (physical_uri != NULL, NULL);
priv = storage->priv;
foreach_data.physical_uri = physical_uri;
foreach_data.retval = NULL;
g_hash_table_foreach (priv->path_to_folder, get_path_for_physical_uri_foreach, &foreach_data);
return foreach_data.retval;
}
/* Protected functions. */
/* These functions are used by subclasses to add and remove folders from the
state stored in the storage object. */

View File

@ -119,6 +119,11 @@ void e_storage_async_remove_folder (EStorage *storage,
const char *e_storage_result_to_string (EStorageResult result);
/* Utility functions. */
char *e_storage_get_path_for_physical_uri (EStorage *storage,
const char *physical_uri);
/* Protected. C++ anyone? */
gboolean e_storage_new_folder (EStorage *storage, const char *path, EFolder *folder);
gboolean e_storage_removed_folder (EStorage *storage, const char *path);

View File

@ -144,6 +144,8 @@ class_init (EvolutionSessionClass *klass)
gtk_marshal_NONE__STRING,
GTK_TYPE_NONE, 1,
GTK_TYPE_STRING);
corba_class_init ();
}
static void