aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog43
-rw-r--r--shell/e-shell-folder-commands.c224
-rw-r--r--shell/e-shell-view-menu.c12
-rw-r--r--shell/e-shell-view.c34
-rw-r--r--shell/e-shell-view.h1
5 files changed, 302 insertions, 12 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index be1472609a..c7743ddcc8 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,48 @@
+2001-05-20 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-view-menu.c: Define the verb for "CopyFolder" as well.
+ (command_copy_folder): Implementation for the "CopyFolder" verb.
+
+ * e-shell-folder-commands.c: New struct `FolderCommandData'.
+ (folder_command_data_new): New function to allocate and initialize
+ it.
+ (folder_command_data_free): New function to free it.
+ (e_shell_command_move_folder): Pass a pointer to a filled-in
+ `FolderCommandData' struct to the callbacks instead of just
+ passing a pointer to the shell object.
+ (move_folder_selected_callback): Removed.
+ (move_folder_cancelled_callback): Removed.
+ (folder_selection_dialog_folder_selected_callback): New generic
+ callback for the folder selection dialog.
+ (folder_selection_dialog_cancelled_callback): New generic callback
+ for the folder selection dialog.
+ (connect_folder_selection_dialog_signals): New function to connect
+ these two handlers to a folder selection dialog.
+ (xfer_result_callback): New callback for the async xfer function.
+ (get_folder_name): New utility function.
+ (e_shell_command_copy_folder): Implement.
+
+2001-05-19 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-folder-commands.c
+ (e_shell_command_create_new_folder): Changed to use
+ `e_shell_view_get_current_path()' to get the default path, instead
+ of computing it itself.
+ (move_folder_cancelled_callback) (move_folder_selected_callback):
+ New, callbacks for the "cancelled" and "folder_selected" signals
+ on the folder selection dialog for the "Move folder" operation.
+ (e_shell_command_move_folder): Implemented.
+
+ * e-shell-view-menu.c (command_move_folder): New, implementation
+ for the "MoveFolder" verb.
+
+ * e-shell-view.c (e_shell_view_get_current_path): New.
+
2001-05-19 Ettore Perazzoli <ettore@ximian.com>
+ * e-shell-folder-selection-dialog.h: Rename @default_path to
+ @default_uri.
+
* e-shell.c (impl_Shell_selectUserFolder): Pass a NULL @caption to
`e_shell_folder_selection_dialog_new()'.
diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c
index 34cb2d0ac3..ab5c22ed0a 100644
--- a/shell/e-shell-folder-commands.c
+++ b/shell/e-shell-folder-commands.c
@@ -27,8 +27,157 @@
#include "e-shell-folder-commands.h"
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-util.h>
+
+#include <gtk/gtksignal.h>
+
#include "e-shell-constants.h"
#include "e-shell-folder-creation-dialog.h"
+#include "e-shell-folder-selection-dialog.h"
+
+
+/* Utility functions. */
+
+static const char *
+get_folder_name (EShell *shell,
+ const char *path)
+{
+ EStorageSet *storage_set;
+ EFolder *folder;
+
+ storage_set = e_shell_get_storage_set (shell);
+ folder = e_storage_set_get_folder (storage_set, path);
+
+ return e_folder_get_name (folder);
+}
+
+
+/* The data passed to the signals handled during the execution of the folder
+ commands. */
+
+enum _FolderCommand {
+ FOLDER_COMMAND_COPY,
+ FOLDER_COMMAND_MOVE
+};
+typedef enum _FolderCommand FolderCommand;
+
+struct _FolderCommandData {
+ EShell *shell;
+ EShellView *shell_view;
+ FolderCommand command;
+ char *source_path;
+ char *destination_path;
+};
+typedef struct _FolderCommandData FolderCommandData;
+
+static FolderCommandData *
+folder_command_data_new (EShell *shell,
+ EShellView *shell_view,
+ FolderCommand command,
+ const char *source_path,
+ const char *destination_path)
+{
+ FolderCommandData *new;
+
+ new = g_new (FolderCommandData, 1);
+ new->shell = shell;
+ new->shell_view = shell_view;
+ new->command = command;
+ new->source_path = g_strdup (source_path);
+ new->destination_path = g_strdup (destination_path);
+
+ return new;
+}
+
+static void
+folder_command_data_free (FolderCommandData *folder_command_data)
+{
+ g_free (folder_command_data->source_path);
+ g_free (folder_command_data->destination_path);
+
+ g_free (folder_command_data);
+}
+
+
+/* Callback for the storage result. */
+
+static void
+xfer_result_callback (EStorageSet *storage_set,
+ EStorageResult result,
+ void *data)
+{
+ FolderCommandData *folder_command_data;
+
+ folder_command_data = (FolderCommandData *) data;
+
+ /* FIXME do something. */
+
+ folder_command_data_free (folder_command_data);
+}
+
+
+/* The signals for the folder selection dialog. This used for the copy and
+ move commands. */
+
+static void
+folder_selection_dialog_folder_selected_callback (EShellFolderSelectionDialog *folder_selection_dialog,
+ const char *path,
+ void *data)
+{
+ FolderCommandData *folder_command_data;
+ EStorageSet *storage_set;
+ gboolean remove_source;
+
+ folder_command_data = (FolderCommandData *) data;
+
+ folder_command_data->destination_path = g_concat_dir_and_file (path,
+ g_basename (folder_command_data->source_path));
+
+ switch (folder_command_data->command) {
+ case FOLDER_COMMAND_COPY:
+ remove_source = FALSE;
+ break;
+ case FOLDER_COMMAND_MOVE:
+ remove_source = TRUE;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ storage_set = e_shell_get_storage_set (folder_command_data->shell);
+
+ e_storage_set_async_xfer_folder (storage_set,
+ folder_command_data->source_path,
+ folder_command_data->destination_path,
+ remove_source,
+ xfer_result_callback,
+ folder_command_data);
+
+ gtk_widget_destroy (GTK_WIDGET (folder_selection_dialog));
+}
+
+static void
+folder_selection_dialog_cancelled_callback (EShellFolderSelectionDialog *folder_selection_dialog,
+ void *data)
+{
+ folder_command_data_free ((FolderCommandData *) data);
+}
+
+static void
+connect_folder_selection_dialog_signals (EShellFolderSelectionDialog *folder_selection_dialog,
+ FolderCommandData *folder_command_data)
+{
+ g_assert (folder_command_data != NULL);
+
+ gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "folder_selected",
+ GTK_SIGNAL_FUNC (folder_selection_dialog_folder_selected_callback),
+ folder_command_data);
+
+ gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "cancelled",
+ GTK_SIGNAL_FUNC (folder_selection_dialog_cancelled_callback),
+ folder_command_data);
+}
/* Create new folder. */
@@ -37,21 +186,13 @@ void
e_shell_command_create_new_folder (EShell *shell,
EShellView *shell_view)
{
- const char *current_uri;
- const char *default_folder;
-
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (shell_view != NULL && E_IS_SHELL_VIEW (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;
-
- e_shell_show_folder_creation_dialog (shell, GTK_WINDOW (shell_view), default_folder,
+ /* FIXME: Should handle the result stuff. */
+ e_shell_show_folder_creation_dialog (shell, GTK_WINDOW (shell_view),
+ e_shell_view_get_current_path (shell_view),
NULL /* result_callback */,
NULL /* result_callback_data */);
}
@@ -77,11 +218,40 @@ void
e_shell_command_copy_folder (EShell *shell,
EShellView *shell_view)
{
+ GtkWidget *folder_selection_dialog;
+ FolderCommandData *data;
+ const char *current_path;
+ const char *current_uri;
+ char *caption;
+
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (shell_view != NULL && E_IS_SHELL_VIEW (shell_view));
- g_warning ("To be implemented");
+ current_path = e_shell_view_get_current_path (shell_view);
+
+ if (current_path == NULL) {
+ g_warning ("Called `e_shell_command_copy_folder()' without a valid displayed folder");
+ return;
+ }
+
+ caption = g_strdup_printf (_("Specify a folder to copy folder \"%s\" into:"),
+ get_folder_name (shell, current_path));
+
+ current_uri = e_shell_view_get_current_uri (shell_view);
+ folder_selection_dialog = e_shell_folder_selection_dialog_new (shell,
+ _("Copy folder"),
+ caption,
+ current_uri,
+ NULL);
+
+ g_free (caption);
+
+ data = folder_command_data_new (shell, shell_view, FOLDER_COMMAND_COPY, current_path, NULL);
+ connect_folder_selection_dialog_signals (E_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog),
+ data);
+
+ gtk_widget_show (folder_selection_dialog);
}
@@ -91,9 +261,39 @@ void
e_shell_command_move_folder (EShell *shell,
EShellView *shell_view)
{
+ GtkWidget *folder_selection_dialog;
+ FolderCommandData *data;
+ const char *current_path;
+ const char *current_uri;
+ char *caption;
+
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (shell_view != NULL && E_IS_SHELL_VIEW (shell_view));
+
+ current_path = e_shell_view_get_current_path (shell_view);
+ if (current_path == NULL) {
+ g_warning ("Called `e_shell_command_move_folder()' without a valid displayed folder");
+ return;
+ }
+
+ caption = g_strdup_printf (_("Specify a folder to move folder \"%s\" into:"),
+ get_folder_name (shell, current_path));
+
+ current_uri = e_shell_view_get_current_uri (shell_view);
+ folder_selection_dialog = e_shell_folder_selection_dialog_new (shell,
+ _("Move folder"),
+ caption,
+ current_uri,
+ NULL);
+
+ g_free (caption);
+
+ data = folder_command_data_new (shell, shell_view, FOLDER_COMMAND_MOVE, current_path, NULL);
+ connect_folder_selection_dialog_signals (E_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog),
+ data);
+
+ gtk_widget_show (folder_selection_dialog);
}
diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c
index 187348ae85..eb9059330b 100644
--- a/shell/e-shell-view-menu.c
+++ b/shell/e-shell-view-menu.c
@@ -360,6 +360,17 @@ command_move_folder (BonoboUIComponent *uih,
e_shell_command_move_folder (e_shell_view_get_shell (shell_view), shell_view);
}
+static void
+command_copy_folder (BonoboUIComponent *uih,
+ void *data,
+ const char *path)
+{
+ EShellView *shell_view;
+
+ shell_view = E_SHELL_VIEW (data);
+ e_shell_command_copy_folder (e_shell_view_get_shell (shell_view), shell_view);
+}
+
/* Going to a folder. */
@@ -532,6 +543,7 @@ BonoboUIVerb file_verbs [] = {
BonoboUIVerb folder_verbs [] = {
BONOBO_UI_VERB ("OpenFolderInNewWindow", command_open_folder_in_new_window),
BONOBO_UI_VERB ("MoveFolder", command_move_folder),
+ BONOBO_UI_VERB ("CopyFolder", command_copy_folder),
BONOBO_UI_VERB_END
};
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 8806b56ff4..73b7e3ba20 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -1770,6 +1770,14 @@ e_shell_view_get_appbar (EShellView *shell_view)
return shell_view->priv->appbar;
}
+/**
+ * e_shell_view_get_current_uri:
+ * @shell_view: A pointer to an EShellView object
+ *
+ * Get the URI currently displayed by this shell view.
+ *
+ * Return value:
+ **/
const char *
e_shell_view_get_current_uri (EShellView *shell_view)
{
@@ -1779,6 +1787,32 @@ e_shell_view_get_current_uri (EShellView *shell_view)
return shell_view->priv->uri;
}
+/**
+ * e_shell_view_get_current_path:
+ * @shell_view: A pointer to an EShellView object
+ *
+ * Get the path of the current displayed folder.
+ *
+ * Return value:
+ **/
+const char *
+e_shell_view_get_current_path (EShellView *shell_view)
+{
+ const char *current_uri;
+ const char *current_path;
+
+ current_uri = e_shell_view_get_current_uri (shell_view);
+ if (current_uri == NULL)
+ return NULL;
+
+ if (strncmp (current_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0)
+ current_path = current_uri + E_SHELL_URI_PREFIX_LEN;
+ else
+ current_path = NULL;
+
+ return current_path;
+}
+
static void
save_shortcut_bar_icon_modes (EShellView *shell_view)
{
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 3f94a0b2f8..8b4d35093d 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -89,6 +89,7 @@ BonoboUIComponent *e_shell_view_get_bonobo_ui_component (EShellView *shell_view
BonoboUIContainer *e_shell_view_get_bonobo_ui_container (EShellView *shell_view);
GtkWidget *e_shell_view_get_appbar (EShellView *shell_view);
const char *e_shell_view_get_current_uri (EShellView *shell_view);
+const char *e_shell_view_get_current_path (EShellView *shell_view);
gboolean e_shell_view_save_settings (EShellView *shell_view,
const char *prefix);