aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog22
-rw-r--r--shell/Evolution-Shell.idl13
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-shell-folder-creation-dialog.h2
-rw-r--r--shell/e-shell-folder-selection-dialog.c220
-rw-r--r--shell/e-shell-folder-selection-dialog.h73
-rw-r--r--shell/e-shell-view-menu.c74
-rw-r--r--shell/e-shell.c74
8 files changed, 478 insertions, 2 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 0b3897756a..5d2781f06f 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,27 @@
2000-06-10 Ettore Perazzoli <ettore@helixcode.com>
+ * e-shell.c (impl_Shell_user_select_folder): New, implementation
+ for `Shell:user_select_folder'.
+ (corba_class_init): Install it.
+ (folder_selection_dialog_clicked_cb): Callback for the folder
+ selection dialog.
+
+ * Evolution-Shell.idl: New method `Shell::user_select_folder'.
+ New interface `FolderSelectionListener'.
+
+ * glade/e-shell-folder-creation-dialog.glade: Make it larger.
+
+ * e-shell-folder-creation-dialog.h: Fix typo: #include
+ <gtk/gtkwindow.h>, not <gtk/gtkwidget.h>.
+
+ * e-shell-view-menu.c: Added "Go to folder..." command.
+ (commmand_goto_folder): Implementation for it.
+
+ * e-shell-folder-selection-dialog.c: New.
+ * e-shell-folder-selection-dialog.h: New.
+
+2000-06-10 Ettore Perazzoli <ettore@helixcode.com>
+
* e-local-folder.c (save_metadata): Don't set the description in
the XML file if null. Compute the physical path correctly.
diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl
index 4f3d18b169..9d1542ec26 100644
--- a/shell/Evolution-Shell.idl
+++ b/shell/Evolution-Shell.idl
@@ -13,10 +13,23 @@
module Evolution {
interface ShellComponent;
+ interface FolderSelectionListener;
+
interface Shell : Bonobo::Unknown {
exception NotFound {};
+ exception Busy {};
ShellComponent get_component_for_type (in string type)
raises (NotFound);
+
+ /* FIXME: Parent "transient_for" window. */
+ void user_select_folder (in FolderSelectionListener listener,
+ in string title,
+ in string default_folder)
+ raises (Busy);
+ };
+
+ interface FolderSelectionListener {
+ void selected (in string uri, in string physical_uri);
};
};
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 7788803994..4d605d5a15 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -53,6 +53,8 @@ evolution_SOURCES = \
e-shell-constants.h \
e-shell-folder-creation-dialog.c \
e-shell-folder-creation-dialog.h \
+ e-shell-folder-selection-dialog.c \
+ e-shell-folder-selection-dialog.h \
e-shell-folder-title-bar.c \
e-shell-folder-title-bar.h \
e-shell-utils.c \
diff --git a/shell/e-shell-folder-creation-dialog.h b/shell/e-shell-folder-creation-dialog.h
index 430898b6b0..ac7518f986 100644
--- a/shell/e-shell-folder-creation-dialog.h
+++ b/shell/e-shell-folder-creation-dialog.h
@@ -24,7 +24,7 @@
#ifndef E_SHELL_FOLDER_CREATION_DIALOG_H
#define E_SHELL_FOLDER_CREATION_DIALOG_H
-#include <gtk/gtkwidget.h>
+#include <gtk/gtkwindow.h>
#include "e-shell.h"
diff --git a/shell/e-shell-folder-selection-dialog.c b/shell/e-shell-folder-selection-dialog.c
new file mode 100644
index 0000000000..1864890081
--- /dev/null
+++ b/shell/e-shell-folder-selection-dialog.c
@@ -0,0 +1,220 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-shell-folder-selection-dialog.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libgnomeui/gnome-stock.h>
+#include <libgnome/gnome-i18n.h>
+
+#include "e-util/e-util.h"
+#include "widgets/misc/e-scroll-frame.h"
+
+#include "e-storage-set.h"
+#include "e-storage-set-view.h"
+
+#include "e-shell-folder-creation-dialog.h"
+
+#include "e-shell-folder-selection-dialog.h"
+
+
+#define PARENT_TYPE GNOME_TYPE_DIALOG
+static GnomeDialogClass *parent_class = NULL;
+
+struct _EShellFolderSelectionDialogPrivate {
+ EShell *shell;
+ GtkWidget *storage_set_view;
+};
+
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ EShellFolderSelectionDialog *folder_selection_dialog;
+ EShellFolderSelectionDialogPrivate *priv;
+
+ folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (object);
+ priv = folder_selection_dialog->priv;
+
+ g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+/* GnomeDialog methods. */
+
+static void
+impl_clicked (GnomeDialog *dialog,
+ int button_number)
+{
+ EShellFolderSelectionDialog *folder_selection_dialog;
+ EShellFolderSelectionDialogPrivate *priv;
+
+ folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (dialog);
+ priv = folder_selection_dialog->priv;
+
+ /* Check for the "Add..." button. */
+ if (button_number == 2) {
+ EStorageSetView *storage_set_view;
+ const char *default_parent_folder;
+
+#if 0
+ /* (FIXME: The stupid GnomeDialog defines the "clicked" signal as
+ GTK_RUN_LAST so this does not work. Grrr.) */
+ /* We don't want the user of the widget to handle this directly. */
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (dialog), "clicked");
+#endif
+
+ storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view);
+ default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view);
+
+ e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog),
+ default_parent_folder);
+ }
+}
+
+
+/* GTK+ type initialization. */
+
+static void
+class_init (EShellFolderSelectionDialogClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeDialogClass *dialog_class;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+ object_class = GTK_OBJECT_CLASS (klass);
+ dialog_class = GNOME_DIALOG_CLASS (klass);
+
+ object_class->destroy = impl_destroy;
+
+ dialog_class->clicked = impl_clicked;
+}
+
+static void
+init (EShellFolderSelectionDialog *shell_folder_selection_dialog)
+{
+ EShellFolderSelectionDialogPrivate *priv;
+
+ priv = g_new (EShellFolderSelectionDialogPrivate, 1);
+ priv->shell = NULL;
+ priv->storage_set_view = NULL;
+
+ shell_folder_selection_dialog->priv = priv;
+}
+
+
+void
+e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog,
+ EShell *shell,
+ const char *title,
+ const char *default_path)
+{
+ EShellFolderSelectionDialogPrivate *priv;
+ EStorageSet *storage_set;
+ GtkWidget *scroll_frame;
+
+ g_return_if_fail (folder_selection_dialog != NULL);
+ g_return_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog));
+ g_return_if_fail (shell != NULL);
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ priv = folder_selection_dialog->priv;
+
+ gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE);
+ gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title);
+
+ gnome_dialog_append_buttons (GNOME_DIALOG (folder_selection_dialog),
+ GNOME_STOCK_BUTTON_OK,
+ GNOME_STOCK_BUTTON_CANCEL,
+ _("New..."),
+ NULL);
+ gnome_dialog_set_default (GNOME_DIALOG (folder_selection_dialog), 0);
+
+ gtk_window_set_policy (GTK_WINDOW (folder_selection_dialog), TRUE, TRUE, FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300);
+
+ priv->shell = shell;
+ gtk_signal_connect_object_while_alive (GTK_OBJECT (shell), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (folder_selection_dialog));
+
+ storage_set = e_shell_get_storage_set (shell);
+
+ priv->storage_set_view = e_storage_set_new_view (storage_set);
+ GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS);
+
+ e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
+ default_path);
+
+ scroll_frame = e_scroll_frame_new (NULL, NULL);
+ e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll_frame),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (scroll_frame), priv->storage_set_view);
+
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (folder_selection_dialog)->vbox),
+ scroll_frame, TRUE, TRUE, 2);
+
+ gtk_widget_show (scroll_frame);
+ gtk_widget_show (priv->storage_set_view);
+}
+
+GtkWidget *
+e_shell_folder_selection_dialog_new (EShell *shell,
+ const char *title,
+ const char *default_path)
+{
+ EShellFolderSelectionDialog *folder_selection_dialog;
+
+ g_return_val_if_fail (shell != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ 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);
+
+ return GTK_WIDGET (folder_selection_dialog);
+}
+
+
+const char *
+e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog)
+{
+ EShellFolderSelectionDialogPrivate *priv;
+
+ g_return_val_if_fail (folder_selection_dialog != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL);
+
+ priv = folder_selection_dialog->priv;
+
+ return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view));
+}
+
+
+E_MAKE_TYPE (e_shell_folder_selection_dialog, "EShellFolderSelectionDialog", EShellFolderSelectionDialog,
+ class_init, init, PARENT_TYPE)
diff --git a/shell/e-shell-folder-selection-dialog.h b/shell/e-shell-folder-selection-dialog.h
new file mode 100644
index 0000000000..29d96e4c61
--- /dev/null
+++ b/shell/e-shell-folder-selection-dialog.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-shell-folder-selection-dialog.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef E_SHELL_FOLDER_SELECTION_DIALOG_H
+#define E_SHELL_FOLDER_SELECTION_DIALOG_H
+
+#include <libgnomeui/gnome-dialog.h>
+
+#include "e-shell.h"
+
+#ifdef cplusplus
+extern "C" {
+#pragma }
+#endif /* cplusplus */
+
+#define E_TYPE_SHELL_FOLDER_SELECTION_DIALOG (e_shell_folder_selection_dialog_get_type ())
+#define E_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialog))
+#define E_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialogClass))
+#define E_IS_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG))
+#define E_IS_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG))
+
+
+typedef struct _EShellFolderSelectionDialog EShellFolderSelectionDialog;
+typedef struct _EShellFolderSelectionDialogPrivate EShellFolderSelectionDialogPrivate;
+typedef struct _EShellFolderSelectionDialogClass EShellFolderSelectionDialogClass;
+
+struct _EShellFolderSelectionDialog {
+ GnomeDialog parent;
+
+ EShellFolderSelectionDialogPrivate *priv;
+};
+
+struct _EShellFolderSelectionDialogClass {
+ GnomeDialogClass parent_class;
+};
+
+
+GtkType e_shell_folder_selection_dialog_get_type (void);
+void e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog,
+ EShell *shell,
+ const char *title,
+ const char *default_path);
+GtkWidget *e_shell_folder_selection_dialog_new (EShell *shell,
+ const char *title,
+ const char *default_path);
+
+const char *e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog);
+
+#ifdef cplusplus
+}
+#endif /* cplusplus */
+
+#endif /* E_SHELL_FOLDER_SELECTION_DIALOG_H */
diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c
index 8dec015f8d..391a216823 100644
--- a/shell/e-shell-view-menu.c
+++ b/shell/e-shell-view-menu.c
@@ -27,6 +27,8 @@
#include <gnome.h>
#include "e-shell-folder-creation-dialog.h"
+#include "e-shell-folder-selection-dialog.h"
+
#include "e-shell-constants.h"
#include "e-shell-view-menu.h"
@@ -244,6 +246,69 @@ command_new_folder (BonoboUIHandler *uih,
}
+/* Going to a folder. */
+
+static void
+folder_selection_dialog_clicked_cb (GnomeDialog *dialog,
+ int button_number,
+ void *data)
+{
+ EShellFolderSelectionDialog *folder_selection_dialog;
+ EShellView *shell_view;
+
+ shell_view = E_SHELL_VIEW (data);
+ folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (dialog);
+
+ if (button_number != 0 /* OK */ && button_number != 1 /* Cancel */)
+ return;
+
+ if (button_number == 0 /* OK */) {
+ const char *path;
+
+ path = e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog);
+ if (path != NULL) {
+ char *uri;
+
+ uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
+ e_shell_view_display_uri (shell_view, uri);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+command_goto_folder (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
+{
+ GtkWidget *folder_selection_dialog;
+ 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);
+
+ gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "clicked",
+ GTK_SIGNAL_FUNC (folder_selection_dialog_clicked_cb), shell_view);
+
+ gtk_widget_show (folder_selection_dialog);
+}
+
+
/* Unimplemented commands. */
#define DEFINE_UNIMPLEMENTED(func) \
@@ -326,7 +391,14 @@ static GnomeUIInfo menu_file_open [] = {
static GnomeUIInfo menu_file [] = {
GNOMEUIINFO_SUBTREE_STOCK (N_("_New"), menu_file_new, GNOME_STOCK_MENU_NEW),
GNOMEUIINFO_SUBTREE_STOCK (N_("_Open"), menu_file_open, GNOME_STOCK_MENU_NEW),
- GNOMEUIINFO_ITEM_NONE (N_("Clos_e All Items"), N_("Closes all the open items"), command_close_open_items),
+
+ GNOMEUIINFO_ITEM_NONE (N_("Clos_e All Items"), N_("Closes all the open items"),
+ command_close_open_items),
+ GNOMEUIINFO_SEPARATOR,
+
+ GNOMEUIINFO_ITEM_NONE (N_("Go to folder..."), N_("Display a different folder"),
+ command_goto_folder),
+
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_EXIT_ITEM(command_quit, NULL),
diff --git a/shell/e-shell.c b/shell/e-shell.c
index fcaa592a32..7e5400d7e3 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -35,6 +35,8 @@
#include "e-corba-storage-registry.h"
#include "e-folder-type-registry.h"
#include "e-local-storage.h"
+#include "e-shell-constants.h"
+#include "e-shell-folder-selection-dialog.h"
#include "e-shell-view.h"
#include "e-shortcuts.h"
#include "e-storage-set.h"
@@ -84,6 +86,50 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+/* Callback for the folder selection dialog. */
+
+static void
+folder_selection_dialog_clicked_cb (GnomeDialog *dialog,
+ int button_number,
+ void *data)
+{
+ EShellFolderSelectionDialog *folder_selection_dialog;
+ Evolution_FolderSelectionListener listener;
+ EShell *shell;
+ EStorageSet *storage_set;
+ EFolder *folder;
+ CORBA_Environment ev;
+ const char *path;
+ char *uri;
+ const char *physical_uri;
+
+ folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (dialog);
+ shell = E_SHELL (data);
+ listener = gtk_object_get_data (GTK_OBJECT (dialog), "corba_listener");
+
+ storage_set = e_shell_get_storage_set (shell);
+ path = e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog),
+ folder = e_storage_set_get_folder (storage_set, path);
+
+ uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
+
+ if (folder == NULL) /* Uh? */
+ physical_uri = "";
+ else
+ physical_uri = e_folder_get_physical_uri (folder);
+
+ CORBA_exception_init (&ev);
+
+ Evolution_FolderSelectionListener_selected (listener, uri, physical_uri, &ev);
+
+ CORBA_Object_release (listener, &ev);
+
+ CORBA_exception_free (&ev);
+
+ g_free (uri);
+}
+
+
/* CORBA interface implementation. */
static POA_Evolution_Shell__vepv shell_vepv;
@@ -135,9 +181,36 @@ impl_Shell_get_component_for_type (PortableServer_Servant servant,
corba_component = bonobo_object_corba_objref (BONOBO_OBJECT (handler));
Bonobo_Unknown_ref (corba_component, ev);
+
return CORBA_Object_duplicate (corba_component, ev);
}
+static void
+impl_Shell_user_select_folder (PortableServer_Servant servant,
+ const Evolution_FolderSelectionListener listener,
+ const CORBA_char *title,
+ const CORBA_char *default_folder,
+ CORBA_Environment *ev)
+{
+ GtkWidget *folder_selection_dialog;
+ BonoboObject *bonobo_object;
+ Evolution_FolderSelectionListener listener_duplicate;
+ EShell *shell;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ shell = E_SHELL (bonobo_object);
+
+ folder_selection_dialog = e_shell_folder_selection_dialog_new (shell, title, default_folder);
+
+ listener_duplicate = CORBA_Object_duplicate (listener, ev);
+ gtk_object_set_data (GTK_OBJECT (folder_selection_dialog), "corba_listener", shell);
+
+ gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "clicked",
+ GTK_SIGNAL_FUNC (folder_selection_dialog_clicked_cb), shell);
+
+ gtk_widget_show (folder_selection_dialog);
+}
+
/* Initialization of the storages. */
@@ -295,6 +368,7 @@ corba_class_init (void)
epv = g_new0 (POA_Evolution_Shell__epv, 1);
epv->get_component_for_type = impl_Shell_get_component_for_type;
+ epv->user_select_folder = impl_Shell_user_select_folder;
vepv = &shell_vepv;
vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();