aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-08-04 02:21:47 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-08-04 02:21:47 +0800
commit49fd4ffbc41c4270efcc28d108b5a66d8773e178 (patch)
tree0c3ee5b15690e5214cf14bcac364cd435e66334a
parentf273b40d5edeb4da6408c265097c44d70ae861eb (diff)
downloadgsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar.gz
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar.bz2
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar.lz
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar.xz
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.tar.zst
gsoc2013-evolution-49fd4ffbc41c4270efcc28d108b5a66d8773e178.zip
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
-rw-r--r--shell/ChangeLog22
-rw-r--r--shell/e-shell-folder-selection-dialog.c60
-rw-r--r--shell/e-shell-view-menu.c9
-rw-r--r--shell/e-storage-set.c48
-rw-r--r--shell/e-storage-set.h5
-rw-r--r--shell/e-storage.c70
-rw-r--r--shell/e-storage.h5
-rw-r--r--shell/evolution-session.c2
8 files changed, 208 insertions, 13 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 3909397ab7..4cb12baad9 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -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
diff --git a/shell/e-shell-folder-selection-dialog.c b/shell/e-shell-folder-selection-dialog.c
index 95cc1d2141..60aa36d9bd 100644
--- a/shell/e-shell-folder-selection-dialog.c
+++ b/shell/e-shell-folder-selection-dialog.c
@@ -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);
}
diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c
index 905d1d834b..996697d023 100644
--- a/shell/e-shell-view-menu.c
+++ b/shell/e-shell-view-menu.c
@@ -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));
diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c
index 81f97f055c..3a1fbb9b65 100644
--- a/shell/e-storage-set.c
+++ b/shell/e-storage-set.c
@@ -524,4 +524,52 @@ e_storage_set_get_folder_type_registry (EStorageSet *storage_set)
}
+/* 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)
diff --git a/shell/e-storage-set.h b/shell/e-storage-set.h
index 7731b5cafc..cc0d34811a 100644
--- a/shell/e-storage-set.h
+++ b/shell/e-storage-set.h
@@ -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 */
diff --git a/shell/e-storage.c b/shell/e-storage.c
index 8963f85759..eb03cb36a0 100644
--- a/shell/e-storage.c
+++ b/shell/e-storage.c
@@ -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. */
diff --git a/shell/e-storage.h b/shell/e-storage.h
index 5422d6a9b4..7b140bda22 100644
--- a/shell/e-storage.h
+++ b/shell/e-storage.h
@@ -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);
diff --git a/shell/evolution-session.c b/shell/evolution-session.c
index 0bc09f1ebe..1e0acb36b4 100644
--- a/shell/evolution-session.c
+++ b/shell/evolution-session.c
@@ -144,6 +144,8 @@ class_init (EvolutionSessionClass *klass)
gtk_marshal_NONE__STRING,
GTK_TYPE_NONE, 1,
GTK_TYPE_STRING);
+
+ corba_class_init ();
}
static void