aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-02-11 06:21:35 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-02-11 06:21:35 +0800
commit5597ba679c773ac8ad159c31c070dd7f034b99ff (patch)
treeaf0bf0502016286e17f4243df510708ae1f01738 /shell
parent945c3f43e7a055ef8263c2982d6b87819c2a36e9 (diff)
downloadgsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar.gz
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar.bz2
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar.lz
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar.xz
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.tar.zst
gsoc2013-evolution-5597ba679c773ac8ad159c31c070dd7f034b99ff.zip
Remove dead files
2004-02-10 JP Rosevear <jpr@ximian.com> * Remove dead files svn path=/trunk/; revision=24692
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog4
-rw-r--r--shell/e-shell-folder-commands.c653
-rw-r--r--shell/e-shell-folder-commands.h42
-rw-r--r--shell/e-shortcuts-view-model.c341
-rw-r--r--shell/e-shortcuts-view-model.h66
-rw-r--r--shell/e-shortcuts-view.c800
-rw-r--r--shell/e-shortcuts-view.h74
-rw-r--r--shell/e-shortcuts.c1289
-rw-r--r--shell/e-shortcuts.h167
-rw-r--r--shell/evolution-folder-selector-button.c455
-rw-r--r--shell/evolution-shell-client.c139
-rw-r--r--shell/evolution-storage.c1349
12 files changed, 4 insertions, 5375 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index c1bd5806b4..3a5bd55c91 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,7 @@
+2004-02-10 JP Rosevear <jpr@ximian.com>
+
+ * Remove dead files
+
2004-02-06 JP Rosevear <jpr@ximian.com>
* importer/intelligent.c (get_intelligent_importers): use base
diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c
deleted file mode 100644
index 02be16cd5f..0000000000
--- a/shell/e-shell-folder-commands.c
+++ /dev/null
@@ -1,653 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shell-folder-commands.h
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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 "e-shell-folder-commands.h"
-
-#include "e-util/e-dialog-utils.h"
-#include "e-util/e-request.h"
-
-#include "e-shell-constants.h"
-#include "e-shell-folder-creation-dialog.h"
-#include "e-shell-folder-selection-dialog.h"
-#include "e-shell-utils.h"
-
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-util.h>
-
-#include <gtk/gtkentry.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkstock.h>
-
-#include <string.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);
-}
-
-static int
-get_folder_unread (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_unread_count (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;
-
- if (result != E_STORAGE_OK) {
- const char *fmt;
-
- if (folder_command_data->command == FOLDER_COMMAND_COPY)
- fmt = _("Cannot copy folder: %s");
- else
- fmt = _("Cannot move folder: %s");
-
- e_notice (folder_command_data->shell_view, GTK_MESSAGE_ERROR,
- fmt, e_storage_result_to_string (result));
- }
-
- 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;
- char *base_name;
- gboolean remove_source;
-
- folder_command_data = (FolderCommandData *) data;
-
- base_name = g_path_get_basename (folder_command_data->source_path);
- folder_command_data->destination_path = g_build_filename (path, base_name, NULL);
- g_free (base_name);
-
- 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 ();
- return;
- }
-
- if (strcmp (folder_command_data->destination_path,
- folder_command_data->source_path) == 0) {
- const char *msg;
-
- if (remove_source)
- msg = _("Cannot move a folder over itself.");
- else
- msg = _("Cannot copy a folder over itself.");
-
- e_notice (folder_selection_dialog, GTK_MESSAGE_ERROR, msg);
- return;
- }
-
- if (remove_source) {
- int source_len;
-
- source_len = strlen (folder_command_data->source_path);
- if (strncmp (folder_command_data->destination_path,
- folder_command_data->source_path,
- source_len) == 0) {
- e_notice (folder_selection_dialog, GTK_MESSAGE_ERROR,
- _("Cannot move a folder into one of its descendants."));
- return;
- }
- }
-
- 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);
-
- g_signal_connect (folder_selection_dialog, "folder_selected",
- G_CALLBACK (folder_selection_dialog_folder_selected_callback),
- folder_command_data);
-
- g_signal_connect (folder_selection_dialog, "cancelled",
- G_CALLBACK (folder_selection_dialog_cancelled_callback),
- folder_command_data);
-}
-
-
-/* Create new folder. */
-
-void
-e_shell_command_create_new_folder (EShell *shell,
- EShellView *shell_view,
- const char *parent_folder_path)
-{
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL || parent_folder_path != NULL);
- g_return_if_fail (shell_view != NULL && E_IS_SHELL_VIEW (shell_view));
- g_return_if_fail (parent_folder_path != NULL || g_path_is_absolute (parent_folder_path));
-
- if (parent_folder_path == NULL)
- parent_folder_path = e_shell_view_get_current_path (shell_view);
-
- /* 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 /* Default type. Take it from parent */,
- NULL /* result_callback */,
- NULL /* result_callback_data */);
-}
-
-
-/* Open folder in other window. */
-
-void
-e_shell_command_open_folder_in_other_window (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- EShellView *view;
- char *uri;
-
- 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));
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- uri = g_strconcat (E_SHELL_URI_PREFIX, folder_path, NULL);
- view = e_shell_create_view (shell, uri, shell_view);
- g_free (uri);
-
- gtk_widget_show (GTK_WIDGET (view));
-}
-
-
-/* Copy folder. */
-
-void
-e_shell_command_copy_folder (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- GtkWidget *folder_selection_dialog;
- FolderCommandData *data;
- char *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_return_if_fail (folder_path == NULL || g_path_is_absolute (folder_path));
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- if (folder_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, folder_path));
-
- uri = g_strconcat (E_SHELL_URI_PREFIX, folder_path, NULL);
- folder_selection_dialog = e_shell_folder_selection_dialog_new (shell, _("Copy Folder"),
- caption, uri, NULL, TRUE);
-
- g_free (caption);
- g_free (uri);
-
- data = folder_command_data_new (shell, shell_view, FOLDER_COMMAND_COPY, folder_path, NULL);
- connect_folder_selection_dialog_signals (E_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog),
- data);
-
- gtk_widget_show (folder_selection_dialog);
-}
-
-
-/* Move folder. */
-
-void
-e_shell_command_move_folder (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- GtkWidget *folder_selection_dialog;
- FolderCommandData *data;
- char *uri;
- char *caption;
-
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL);
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- g_return_if_fail (folder_path == NULL || g_path_is_absolute (folder_path));
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- if (folder_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, folder_path));
-
- uri = g_strconcat (E_SHELL_URI_PREFIX, folder_path, NULL);
- folder_selection_dialog = e_shell_folder_selection_dialog_new (shell, _("Move Folder"),
- caption, uri, NULL, TRUE);
-
- g_free (caption);
- g_free (uri);
-
- data = folder_command_data_new (shell, shell_view, FOLDER_COMMAND_MOVE, folder_path, NULL);
- connect_folder_selection_dialog_signals (E_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog),
- data);
-
- gtk_widget_show (folder_selection_dialog);
-}
-
-static void
-delete_cb (EStorageSet *storage_set,
- EStorageResult result,
- void *data)
-{
- EShellView *shell_view;
-
- shell_view = E_SHELL_VIEW (data);
-
- if (result != E_STORAGE_OK)
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("Cannot delete folder:\n%s"), e_storage_result_to_string (result));
-}
-
-static GtkResponseType
-delete_dialog (EShellView *shell_view, const char *folder_name)
-{
- GtkWidget *dialog;
- GtkResponseType response;
- char *title;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (shell_view),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("Really delete folder \"%s\"?"), folder_name);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE, GTK_RESPONSE_OK);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
-
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 6);
-
- title = g_strdup_printf (_("Delete \"%s\""), folder_name);
- gtk_window_set_title (GTK_WINDOW (dialog), title);
- g_free (title);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return response;
-}
-
-void
-e_shell_command_delete_folder (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- EStorageSet *storage_set;
-
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL || folder_path != NULL);
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- g_return_if_fail (folder_path != NULL || g_path_is_absolute (folder_path));
-
- storage_set = e_shell_get_storage_set (shell);
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- if (delete_dialog (shell_view, get_folder_name (shell, folder_path)) == GTK_RESPONSE_OK)
- e_storage_set_async_remove_folder (storage_set, folder_path, delete_cb, shell_view);
-}
-
-
-struct _RenameCallbackData {
- EShellView *shell_view;
- char *new_path;
-};
-typedef struct _RenameCallbackData RenameCallbackData;
-
-static RenameCallbackData *
-rename_callback_data_new (EShellView *shell_view,
- const char *new_path)
-{
- RenameCallbackData *callback_data;
-
- callback_data = g_new (RenameCallbackData, 1);
-
- g_object_ref (shell_view);
- callback_data->shell_view = shell_view;
-
- callback_data->new_path = g_strdup (new_path);
-
- return callback_data;
-}
-
-static void
-rename_callback_data_free (RenameCallbackData *callback_data)
-{
- g_object_unref (callback_data->shell_view);
- g_free (callback_data->new_path);
-
- g_free (callback_data);
-}
-
-static void
-rename_cb (EStorageSet *storage_set, EStorageResult result, void *data)
-{
- RenameCallbackData *callback_data;
-
- callback_data = (RenameCallbackData *) data;
-
- if (result != E_STORAGE_OK) {
- e_notice (callback_data->shell_view, GTK_MESSAGE_ERROR,
- _("Cannot rename folder:\n%s"), e_storage_result_to_string (result));
- } else {
- EFolder *folder;
- EShell *shell;
- EStorageSet *storage_set;
-
- shell = e_shell_view_get_shell (callback_data->shell_view);
- storage_set = e_shell_get_storage_set (shell);
- folder = e_storage_set_get_folder (storage_set, callback_data->new_path);
-
- if (folder != NULL) {
- char *base_name = g_path_get_basename (callback_data->new_path);
-
- e_folder_set_name (folder, base_name);
- g_free (base_name);
- }
- }
-
- rename_callback_data_free (callback_data);
-}
-
-void
-e_shell_command_rename_folder (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- EStorageSet *storage_set;
- EFolder *folder;
- RenameCallbackData *callback_data;
- const char *old_name;
- char *prompt;
- gboolean done;
-
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
-
- storage_set = e_shell_get_storage_set (shell);
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- folder = e_storage_set_get_folder (storage_set, folder_path);
- g_return_if_fail (folder != NULL);
-
- old_name = e_folder_get_name (folder);
- prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), old_name);
-
- done = FALSE;
- while (! done) {
- const char *reason;
- char *new_name;
-
- new_name = e_request_string (GTK_WINDOW (shell_view), _("Rename Folder"), prompt, old_name);
-
- if (new_name == NULL || strcmp (old_name, new_name) == 0) {
- done = TRUE;
- } else if (! e_shell_folder_name_is_valid (new_name, &reason)) {
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("The specified folder name is not valid: %s"), reason);
- } else {
- char *old_base_path = g_path_get_dirname (folder_path);
- char *new_path = g_build_filename (old_base_path, new_name, NULL);
-
- if (e_storage_set_get_folder (storage_set, new_path) != NULL) {
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("A folder named \"%s\" already exists. Please use a different name."),
- new_name);
- } else {
- callback_data = rename_callback_data_new (shell_view, new_path);
- e_storage_set_async_xfer_folder (storage_set, folder_path, new_path, TRUE,
- rename_cb, callback_data);
- done = TRUE;
- }
-
- g_free (old_base_path);
- g_free (new_path);
- }
- }
-
- g_free (prompt);
-}
-
-
-static void
-remove_shared_cb (EStorageSet *storage_set,
- EStorageResult result,
- void *data)
-{
- EShellView *shell_view;
-
- shell_view = E_SHELL_VIEW (data);
-
- if (result == E_STORAGE_NOTIMPLEMENTED ||
- result == E_STORAGE_UNSUPPORTEDOPERATION)
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("Selected folder does not belong to another user"));
- else if (result != E_STORAGE_OK)
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("Cannot remove folder:\n%s"), e_storage_result_to_string (result));
-}
-
-void
-e_shell_command_remove_shared_folder (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- EStorageSet *storage_set;
-
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL || folder_path != NULL);
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- g_return_if_fail (folder_path != NULL || g_path_is_absolute (folder_path));
-
- storage_set = e_shell_get_storage_set (shell);
-
- if (folder_path == NULL)
- folder_path = e_shell_view_get_current_path (shell_view);
-
- e_storage_set_async_remove_shared_folder (storage_set, folder_path,
- remove_shared_cb, shell_view);
-}
-
-
-void
-e_shell_command_add_to_shortcut_bar (EShell *shell,
- EShellView *shell_view,
- const char *folder_path)
-{
- EShortcuts *shortcuts;
- EStorageSet *storage_set;
- EFolder *folder;
- char *uri;
- const char *path;
- int group_num;
- int unread_count;
-
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL);
- g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- g_return_if_fail (folder_path == NULL || g_path_is_absolute (folder_path));
-
- shortcuts = e_shell_get_shortcuts (shell);
- group_num = e_shell_view_get_current_shortcuts_group_num (shell_view);
-
- if (folder_path == NULL) {
- uri = g_strdup (e_shell_view_get_current_uri (shell_view));
- path = e_shell_view_get_current_path (shell_view);
- } else {
- uri = g_strconcat (E_SHELL_URI_PREFIX, folder_path, NULL);
- path = folder_path;
- }
-
- unread_count = get_folder_unread (shell, path);
- storage_set = e_shell_get_storage_set (shell);
- folder = e_storage_set_get_folder (storage_set, path);
-
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, uri, NULL,
- unread_count,
- e_folder_get_type_string (folder),
- e_folder_get_custom_icon_name (folder));
-
- g_free (uri);
-}
diff --git a/shell/e-shell-folder-commands.h b/shell/e-shell-folder-commands.h
deleted file mode 100644
index 72b7ba0b0e..0000000000
--- a/shell/e-shell-folder-commands.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shell-folder-commands.h
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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_COMMANDS_H
-#define E_SHELL_FOLDER_COMMANDS_H
-
-#include "e-shell.h"
-#include "e-shell-view.h"
-
-void e_shell_command_open_folder_in_other_window (EShell *shell, EShellView *shell_view, const char *folder_path);
-
-void e_shell_command_create_new_folder (EShell *shell, EShellView *shell_view, const char *parent_folder_path);
-
-void e_shell_command_copy_folder (EShell *shell, EShellView *shell_view, const char *folder_path);
-void e_shell_command_move_folder (EShell *shell, EShellView *shell_view, const char *folder_path);
-void e_shell_command_delete_folder (EShell *shell, EShellView *shell_view, const char *folder_path);
-void e_shell_command_rename_folder (EShell *shell, EShellView *shell_view, const char *folder_path);
-
-void e_shell_command_remove_shared_folder (EShell *shell, EShellView *shell_view, const char *folder_path);
-
-void e_shell_command_add_to_shortcut_bar (EShell *shell, EShellView *shell_view, const char *folder_path);
-
-#endif
diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c
deleted file mode 100644
index e7fb8c23fb..0000000000
--- a/shell/e-shortcuts-view-model.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts-view-model.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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
- */
-
-/* FIXME. This really sucks. We are using the model/view approach in the
- dumbest possible way. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-shortcuts-view-model.h"
-
-#include "e-icon-factory.h"
-
-#include <glib.h>
-#include <gtk/gtksignal.h>
-#include <libgnome/gnome-i18n.h>
-
-#include <gal/util/e-util.h>
-
-
-#define PARENT_TYPE e_shortcut_model_get_type ()
-static EShortcutModelClass *parent_class = NULL;
-
-struct _EShortcutsViewModelPrivate {
- EShortcuts *shortcuts;
-};
-
-
-/* Utility functions. */
-
-static GdkPixbuf *
-get_icon_for_item (EShortcutsViewModel *shortcuts_view_model,
- const EShortcutItem *item,
- gboolean want_mini)
-{
- EShortcutsViewModelPrivate *priv;
-
- priv = shortcuts_view_model->priv;
-
- if (item->custom_icon_name != NULL)
- return e_icon_factory_get_icon (item->custom_icon_name, want_mini);
-
- if (item->type != NULL) {
- EStorageSet *storage_set;
- EFolderTypeRegistry *folder_type_registry;
-
- storage_set = e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts));
- folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
-
- return e_folder_type_registry_get_icon_for_type (folder_type_registry,
- item->type,
- want_mini);
- }
-
- return NULL;
-}
-
-
-/* View initialization. */
-
-static char *
-get_name_with_unread (const EShortcutItem *item)
-{
- if (item->unread_count > 0)
- return g_strdup_printf ("%s (%d)", item->name, item->unread_count);
- else
- return g_strdup (item->name);
-}
-
-static void
-load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
- int group_num)
-{
- EShortcutsViewModelPrivate *priv;
- const GSList *shortcut_list;
- const GSList *p;
-
- priv = shortcuts_view_model->priv;
-
- shortcut_list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_num);
- if (shortcut_list == NULL)
- return;
-
- for (p = shortcut_list; p != NULL; p = p->next) {
- const EShortcutItem *item;
- char *name_with_unread;
-
- item = (const EShortcutItem *) p->data;
- name_with_unread = get_name_with_unread (item);
-
- e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model),
- group_num, -1,
- item->uri,
- name_with_unread,
- get_icon_for_item (shortcuts_view_model, item, FALSE));
-
- g_free (name_with_unread);
- }
-}
-
-static void
-load_all_shortcuts_into_model (EShortcutsViewModel *shortcuts_view_model)
-{
- EShortcutsViewModelPrivate *priv;
- const GSList *group_titles;
- const GSList *p;
- int group_num;
-
- priv = shortcuts_view_model->priv;
-
- group_titles = e_shortcuts_get_group_titles (priv->shortcuts);
-
- for (p = group_titles; p != NULL; p = p->next) {
- const char *group_title;
-
- group_title = (const char *) p->data;
- group_num = e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), -1, group_title);
-
- load_group_into_model (shortcuts_view_model, group_num);
- }
-}
-
-
-/* EShortcuts callbacks. */
-
-static void
-shortcuts_new_group_cb (EShortcuts *shortcuts,
- int group_num,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
- EShortcutsViewModelPrivate *priv;
- const char *title;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
- priv = shortcuts_view_model->priv;
-
- title = e_shortcuts_get_group_title (priv->shortcuts, group_num);
- e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, title);
-}
-
-static void
-shortcuts_remove_group_cb (EShortcuts *shortcuts,
- int group_num,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
- e_shortcut_model_remove_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num);
-}
-
-static void
-shortcuts_rename_group_cb (EShortcuts *shortcuts,
- int group_num,
- const char *new_title,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
-
- /* FIXME: Ideally there should be an
- e_shortcut_model_rename_group(), removing then re-add
- actually causes a flip to the next group, which we work
- around in e-shortcuts-view.c */
- e_shortcut_model_remove_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num);
- e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, new_title);
- load_group_into_model (shortcuts_view_model, group_num);
-}
-
-static void
-shortcuts_new_shortcut_cb (EShortcuts *shortcuts,
- int group_num,
- int item_num,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
- EShortcutsViewModelPrivate *priv;
- const EShortcutItem *shortcut_item;
- char *name_with_unread;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
- priv = shortcuts_view_model->priv;
-
- shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
- g_assert (shortcut_item != NULL);
-
- name_with_unread = get_name_with_unread (shortcut_item);
- e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model),
- group_num, item_num,
- shortcut_item->uri,
- name_with_unread,
- get_icon_for_item (shortcuts_view_model, shortcut_item, FALSE));
-
- g_free (name_with_unread);
-}
-
-static void
-shortcuts_remove_shortcut_cb (EShortcuts *shortcuts,
- int group_num,
- int item_num,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
- e_shortcut_model_remove_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, item_num);
-}
-
-static void
-shortcuts_update_shortcut_cb (EShortcuts *shortcuts,
- int group_num,
- int item_num,
- void *data)
-{
- EShortcutsViewModel *shortcuts_view_model;
- EShortcutsViewModelPrivate *priv;
- const EShortcutItem *shortcut_item;
- char *name_with_unread;
-
- shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
- priv = shortcuts_view_model->priv;
-
- shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
- g_assert (shortcut_item != NULL);
-
- name_with_unread = get_name_with_unread (shortcut_item);
- e_shortcut_model_update_item (E_SHORTCUT_MODEL (shortcuts_view_model),
- group_num, item_num,
- shortcut_item->uri,
- name_with_unread,
- get_icon_for_item (shortcuts_view_model, shortcut_item, FALSE));
-
- g_free (name_with_unread);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_finalize (GObject *object)
-{
- EShortcutsViewModel *view_model;
- EShortcutsViewModelPrivate *priv;
-
- view_model = E_SHORTCUTS_VIEW_MODEL (object);
- priv = view_model->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-static void
-class_init (EShortcutsViewModelClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = impl_finalize;
-
- parent_class = g_type_class_ref(e_shortcut_model_get_type ());
-}
-
-static void
-init (EShortcutsViewModel *shortcuts_view_model)
-{
- EShortcutsViewModelPrivate *priv;
-
- priv = g_new (EShortcutsViewModelPrivate, 1);
- priv->shortcuts = NULL;
-
- shortcuts_view_model->priv = priv;
-}
-
-
-void
-e_shortcuts_view_model_construct (EShortcutsViewModel *model,
- EShortcuts *shortcuts)
-{
- EShortcutsViewModelPrivate *priv;
-
- g_return_if_fail (model != NULL);
- g_return_if_fail (E_IS_SHORTCUTS_VIEW_MODEL (model));
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = model->priv;
- g_return_if_fail (priv->shortcuts == NULL);
-
- priv->shortcuts = shortcuts;
-
- load_all_shortcuts_into_model (model);
-
- g_signal_connect_object (priv->shortcuts, "new_group", G_CALLBACK (shortcuts_new_group_cb), model, 0);
- g_signal_connect_object (priv->shortcuts, "remove_group", G_CALLBACK (shortcuts_remove_group_cb), model, 0);
- g_signal_connect_object (priv->shortcuts, "rename_group", G_CALLBACK (shortcuts_rename_group_cb), model, 0);
- g_signal_connect_object (priv->shortcuts, "new_shortcut", G_CALLBACK (shortcuts_new_shortcut_cb), model, 0);
- g_signal_connect_object (priv->shortcuts, "remove_shortcut", G_CALLBACK (shortcuts_remove_shortcut_cb), model, 0);
- g_signal_connect_object (priv->shortcuts, "update_shortcut", G_CALLBACK (shortcuts_update_shortcut_cb), model, 0);
-}
-
-EShortcutsViewModel *
-e_shortcuts_view_model_new (EShortcuts *shortcuts)
-{
- EShortcutsViewModel *new;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- new = g_object_new (e_shortcuts_view_model_get_type (), NULL);
-
- e_shortcuts_view_model_construct (new, shortcuts);
-
- return new;
-}
-
-
-E_MAKE_TYPE (e_shortcuts_view_model, "EShortcutsViewModel", EShortcutsViewModel, class_init, init, PARENT_TYPE)
diff --git a/shell/e-shortcuts-view-model.h b/shell/e-shortcuts-view-model.h
deleted file mode 100644
index 45e680ecb3..0000000000
--- a/shell/e-shortcuts-view-model.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts-view-model.h
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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_SHORTCUTS_VIEW_MODEL_H_
-#define _E_SHORTCUTS_VIEW_MODEL_H_
-
-#include <gal/shortcut-bar/e-shortcut-model.h>
-
-#include "e-shortcuts.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_SHORTCUTS_VIEW_MODEL (e_shortcuts_view_model_get_type ())
-#define E_SHORTCUTS_VIEW_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHORTCUTS_VIEW_MODEL, EShortcutsViewModel))
-#define E_SHORTCUTS_VIEW_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHORTCUTS_VIEW_MODEL, EShortcutsViewModelClass))
-#define E_IS_SHORTCUTS_VIEW_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW_MODEL))
-#define E_IS_SHORTCUTS_VIEW_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW_MODEL))
-
-
-typedef struct _EShortcutsViewModel EShortcutsViewModel;
-typedef struct _EShortcutsViewModelPrivate EShortcutsViewModelPrivate;
-typedef struct _EShortcutsViewModelClass EShortcutsViewModelClass;
-
-struct _EShortcutsViewModel {
- EShortcutModel parent;
-
- EShortcutsViewModelPrivate *priv;
-};
-
-struct _EShortcutsViewModelClass {
- EShortcutModelClass parent_class;
-};
-
-
-GtkType e_shortcuts_view_model_get_type (void);
-void e_shortcuts_view_model_construct (EShortcutsViewModel *model,
- EShortcuts *shortcuts);
-EShortcutsViewModel *e_shortcuts_view_model_new (EShortcuts *shortcuts);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUTS_VIEW_MODEL_H_ */
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
deleted file mode 100644
index 1837e67eab..0000000000
--- a/shell/e-shortcuts-view.c
+++ /dev/null
@@ -1,800 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts-view.c
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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 "e-shortcuts-view.h"
-
-#include "e-folder-dnd-bridge.h"
-#include "e-shell-constants.h"
-#include "e-shell-marshal.h"
-#include "e-shortcuts-view-model.h"
-
-#include "e-util/e-request.h"
-
-#include <glib.h>
-#include <gtk/gtkcheckmenuitem.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtklabel.h>
-
-#include <libgnome/gnome-i18n.h>
-
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gnome-app-helper.h>
-#include <libgnomeui/gnome-popup-menu.h>
-#include <libgnomeui/gnome-uidefs.h>
-
-#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtkstock.h>
-
-#include <gal/util/e-util.h>
-
-#include <string.h>
-
-
-#define PARENT_TYPE E_TYPE_SHORTCUT_BAR
-static EShortcutBarClass *parent_class = NULL;
-
-struct _EShortcutsViewPrivate {
- EShortcuts *shortcuts;
-};
-
-enum {
- ACTIVATE_SHORTCUT,
- HIDE_REQUESTED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
-/* Utility functions. */
-
-static void
-show_new_group_dialog (EShortcutsView *view)
-{
- char *group_name;
-
- group_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- _("Create New Shortcut Group"),
- _("Group name:"),
- NULL);
-
- if (group_name == NULL)
- return;
-
- e_shortcuts_add_group (view->priv->shortcuts, -1, group_name);
-
- g_free (group_name);
-}
-
-
-/* Shortcut bar right-click menu. */
-
-struct _RightClickMenuData {
- EShortcutsView *shortcuts_view;
- int group_num;
-};
-typedef struct _RightClickMenuData RightClickMenuData;
-
-static void
-toggle_large_icons_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
-
- menu_data = (RightClickMenuData *) data;
-
- if (menu_data == NULL)
- return;
-
- if (! GTK_CHECK_MENU_ITEM (widget)->active)
- return;
-
- e_shortcuts_set_group_uses_small_icons (menu_data->shortcuts_view->priv->shortcuts, menu_data->group_num, FALSE);
-}
-
-static void
-toggle_small_icons_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
-
- menu_data = (RightClickMenuData *) data;
- if (menu_data == NULL)
- return;
-
- if (! GTK_CHECK_MENU_ITEM (widget)->active)
- return;
-
- e_shortcuts_set_group_uses_small_icons (menu_data->shortcuts_view->priv->shortcuts, menu_data->group_num, TRUE);
-}
-
-static void
-hide_shortcut_bar_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
- EShortcutsView *shortcut_view;
-
- menu_data = (RightClickMenuData *) data;
-
- shortcut_view = E_SHORTCUTS_VIEW (menu_data->shortcuts_view);
-
- g_signal_emit (shortcut_view, signals[HIDE_REQUESTED], 0);
-}
-
-static void
-create_new_group_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
-
- menu_data = (RightClickMenuData *) data;
-
- show_new_group_dialog (menu_data->shortcuts_view);
-}
-
-static void
-destroy_group_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
- EShortcuts *shortcuts;
- EShortcutsView *shortcuts_view;
- EShortcutsViewPrivate *priv;
- GtkWidget *message_dialog;
- GtkResponseType response;
-
- menu_data = (RightClickMenuData *) data;
- shortcuts_view = menu_data->shortcuts_view;
- priv = shortcuts_view->priv;
- shortcuts = priv->shortcuts;
-
- message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (menu_data->shortcuts_view))),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("Do you really want to remove group "
- "\"%s\" from the shortcut bar?"),
- e_shortcuts_get_group_title (shortcuts, menu_data->group_num));
-
- gtk_dialog_add_buttons (GTK_DIALOG (message_dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_DELETE, GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (message_dialog), "Remove Shortcut Group");
-
- gtk_container_set_border_width (GTK_CONTAINER (message_dialog), 6);
-
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (message_dialog)->vbox), 6);
-
- gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_OK);
-
- response = gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
-
- if (response == GTK_RESPONSE_OK)
- e_shortcuts_remove_group (shortcuts, menu_data->group_num);
-}
-
-static void
-rename_group_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
- EShortcuts *shortcuts;
- EShortcutsView *shortcuts_view;
- EIconBarViewType original_view_type;
- const char *old_name;
- char *new_name;
- int group;
-
- menu_data = (RightClickMenuData *) data;
- shortcuts_view = menu_data->shortcuts_view;
- shortcuts = shortcuts_view->priv->shortcuts;
-
- old_name = e_shortcuts_get_group_title (shortcuts, menu_data->group_num);
-
- new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shortcuts_view))),
- _("Rename Shortcut Group"),
- _("Rename selected shortcut group to:"),
- old_name);
-
- if (new_name == NULL)
- return;
-
- /* Remember the group and flip back to it. FIXME: This is a workaround
- to an actual ShortcutBar bug. */
-
- group = e_group_bar_get_current_group_num (E_GROUP_BAR (shortcuts_view));
- original_view_type = e_shortcut_bar_get_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), group);
- e_shortcuts_rename_group (shortcuts, menu_data->group_num, new_name);
-
- g_free (new_name);
- e_group_bar_set_current_group_num (E_GROUP_BAR (shortcuts_view), group, FALSE);
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), group, original_view_type);
-}
-
-static void
-create_default_shortcuts_cb (GtkWidget *widget,
- void *data)
-{
- RightClickMenuData *menu_data;
- EShortcutsView *shortcuts_view;
-
- menu_data = (RightClickMenuData *) data;
- shortcuts_view = menu_data->shortcuts_view;
- e_shortcuts_add_default_shortcuts (shortcuts_view->priv->shortcuts,
- e_group_bar_get_current_group_num (E_GROUP_BAR (shortcuts_view)));
-}
-
-static GnomeUIInfo icon_size_radio_group_uiinfo[] = {
- { GNOME_APP_UI_ITEM, N_("_Small Icons"),
- N_("Show the shortcuts as small icons"), toggle_small_icons_cb, NULL,
- NULL, 0, 0, 0, 0 },
- { GNOME_APP_UI_ITEM, N_("_Large Icons"),
- N_("Show the shortcuts as large icons"), toggle_large_icons_cb, NULL,
- NULL, 0, 0, 0, 0 },
-
- GNOMEUIINFO_END
-};
-
-static GnomeUIInfo right_click_menu_uiinfo[] = {
- GNOMEUIINFO_RADIOLIST (icon_size_radio_group_uiinfo),
-
- GNOMEUIINFO_SEPARATOR,
-
- { GNOME_APP_UI_ITEM, N_("_Add Group..."),
- N_("Create a new shortcut group"), create_new_group_cb, NULL,
- NULL, 0, 0, 0, 0 },
- { GNOME_APP_UI_ITEM, N_("_Remove this Group..."),
- N_("Remove this shortcut group"), destroy_group_cb, NULL,
- NULL, 0, 0, 0, 0 },
- { GNOME_APP_UI_ITEM, N_("Re_name this Group..."),
- N_("Rename this shortcut group"), rename_group_cb, NULL,
- NULL, 0, 0, 0, 0 },
-
- GNOMEUIINFO_SEPARATOR,
-
- { GNOME_APP_UI_ITEM, N_("_Hide the Shortcut Bar"),
- N_("Hide the shortcut bar"), hide_shortcut_bar_cb, NULL,
- NULL, 0, 0, 0, 0 },
-
- GNOMEUIINFO_SEPARATOR,
-
- { GNOME_APP_UI_ITEM, N_("Create _Default Shortcuts"),
- N_("Create Default Shortcuts"), create_default_shortcuts_cb, NULL,
- NULL, 0, 0, 0, 0 },
-
- GNOMEUIINFO_END
-};
-
-static void
-pop_up_right_click_menu_for_group (EShortcutsView *shortcuts_view,
- GdkEventButton *event,
- int group_num)
-{
- RightClickMenuData *menu_data;
- GtkWidget *popup_menu;
-
- menu_data = g_new (RightClickMenuData, 1);
- menu_data->shortcuts_view = shortcuts_view;
- menu_data->group_num = group_num;
-
- popup_menu = gnome_popup_menu_new (right_click_menu_uiinfo);
-
- if (e_shortcut_bar_get_view_type (E_SHORTCUT_BAR (shortcuts_view), group_num)
- == E_ICON_BAR_SMALL_ICONS)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (icon_size_radio_group_uiinfo[0].widget),
- TRUE);
- else
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (icon_size_radio_group_uiinfo[1].widget),
- TRUE);
-
- if (group_num == 0)
- gtk_widget_set_sensitive (right_click_menu_uiinfo[3].widget, FALSE);
-
- gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, menu_data, GTK_WIDGET (shortcuts_view));
-
- g_free (menu_data);
- gtk_widget_destroy (popup_menu);
-}
-
-
-/* Data to be passed around for the shortcut right-click menu items. */
-
-struct _ShortcutRightClickMenuData {
- EShortcutsView *shortcuts_view;
- int group_num;
- int item_num;
-};
-typedef struct _ShortcutRightClickMenuData ShortcutRightClickMenuData;
-
-
-/* "Open Shortcut" and "Open Shortcut in New Window" commands. */
-
-static void
-open_shortcut_helper (ShortcutRightClickMenuData *menu_data,
- gboolean in_new_window)
-{
- EShortcutsView *shortcuts_view;
- EShortcuts *shortcuts;
- const EShortcutItem *shortcut_item;
-
- shortcuts_view = menu_data->shortcuts_view;
- shortcuts = shortcuts_view->priv->shortcuts;
-
- shortcut_item = e_shortcuts_get_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
- if (shortcut_item == NULL)
- return;
-
- g_signal_emit (shortcuts_view, signals[ACTIVATE_SHORTCUT], 0,
- shortcuts, shortcut_item->uri, in_new_window);
-}
-
-static void
-open_shortcut_cb (GtkWidget *widget,
- void *data)
-{
- open_shortcut_helper ((ShortcutRightClickMenuData *) data, FALSE);
-}
-
-static void
-open_shortcut_in_new_window_cb (GtkWidget *widget,
- void *data)
-{
- open_shortcut_helper ((ShortcutRightClickMenuData *) data, TRUE);
-}
-
-
-static void
-remove_shortcut_cb (GtkWidget *widget,
- void *data)
-{
- ShortcutRightClickMenuData *menu_data;
- EShortcutsView *shortcuts_view;
- EShortcuts *shortcuts;
-
- menu_data = (ShortcutRightClickMenuData *) data;
- shortcuts_view = menu_data->shortcuts_view;
- shortcuts = shortcuts_view->priv->shortcuts;
-
- e_shortcuts_remove_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
-}
-
-
-/* "Rename Shortcut" command. */
-
-static void
-rename_shortcut_cb (GtkWidget *widget,
- void *data)
-{
- ShortcutRightClickMenuData *menu_data;
- EShortcutsView *shortcuts_view;
- EShortcuts *shortcuts;
- const EShortcutItem *shortcut_item;
- char *new_name;
-
- menu_data = (ShortcutRightClickMenuData *) data;
- shortcuts_view = menu_data->shortcuts_view;
- shortcuts = shortcuts_view->priv->shortcuts;
-
- shortcut_item = e_shortcuts_get_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
-
- new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shortcuts_view))),
- _("Rename Shortcut"),
- _("Rename selected shortcut to:"),
- shortcut_item->name);
-
- if (new_name == NULL)
- return;
-
- e_shortcuts_update_shortcut (shortcuts, menu_data->group_num, menu_data->item_num,
- shortcut_item->uri, new_name, shortcut_item->unread_count,
- shortcut_item->type, shortcut_item->custom_icon_name);
- g_free (new_name);
-}
-
-static GnomeUIInfo shortcut_right_click_menu_uiinfo[] = {
- GNOMEUIINFO_ITEM_STOCK (N_("_Open"), N_("Open the folder linked to this shortcut"),
- open_shortcut_cb, GTK_STOCK_OPEN),
- GNOMEUIINFO_ITEM_NONE (N_("Open in New _Window"), N_("Open the folder linked to this shortcut in a new window"),
- open_shortcut_in_new_window_cb),
- GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("_Rename"), N_("Rename this shortcut"),
- rename_shortcut_cb),
- GNOMEUIINFO_ITEM_STOCK (N_("Re_move"), N_("Remove this shortcut from the shortcut bar"),
- remove_shortcut_cb, GTK_STOCK_REMOVE),
- GNOMEUIINFO_END
-};
-
-static void
-pop_up_right_click_menu_for_shortcut (EShortcutsView *shortcuts_view,
- GdkEventButton *event,
- int group_num,
- int item_num)
-{
- ShortcutRightClickMenuData *menu_data;
- GtkWidget *popup_menu;
-
- menu_data = g_new (ShortcutRightClickMenuData, 1);
- menu_data->shortcuts_view = shortcuts_view;
- menu_data->group_num = group_num;
- menu_data->item_num = item_num;
-
- popup_menu = gnome_popup_menu_new (shortcut_right_click_menu_uiinfo);
-
- gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, menu_data, GTK_WIDGET (shortcuts_view));
-
- g_free (menu_data);
- gtk_widget_destroy (popup_menu);
-}
-
-
-/* View callbacks. This part exists mostly because of breakage in the
- EShortcutBar design. */
-
-static void
-group_change_icon_size_callback (EShortcuts *shortucts,
- int group_num,
- gboolean use_small_icons,
- void *data)
-{
- EShortcutsView *view;
-
- view = E_SHORTCUTS_VIEW (data);
-
- if (use_small_icons)
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (view), group_num, E_ICON_BAR_SMALL_ICONS);
- else
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (view), group_num, E_ICON_BAR_LARGE_ICONS);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EShortcutsViewPrivate *priv;
- EShortcutsView *shortcuts_view;
-
- shortcuts_view = E_SHORTCUTS_VIEW (object);
-
- priv = shortcuts_view->priv;
-
- if (priv->shortcuts != NULL) {
- g_object_unref (priv->shortcuts);
- priv->shortcuts = NULL;
- }
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EShortcutsView *shortcuts_view;
-
- shortcuts_view = E_SHORTCUTS_VIEW (object);
-
- g_free (shortcuts_view->priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-/* EShortcutBar methods. */
-
-static void
-item_selected (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- int group_num,
- int item_num)
-{
- EShortcuts *shortcuts;
- EShortcutsView *shortcuts_view;
- const EShortcutItem *shortcut_item;
-
- shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
- shortcuts = shortcuts_view->priv->shortcuts;
-
- if (event->button.button == 3) {
- if (item_num < 0)
- pop_up_right_click_menu_for_group (shortcuts_view, &event->button,
- group_num);
- else
- pop_up_right_click_menu_for_shortcut (shortcuts_view, &event->button,
- group_num, item_num);
- return;
- } else if (event->button.button != 1) {
- return;
- }
-
- if (item_num < 0)
- return;
-
- shortcut_item = e_shortcuts_get_shortcut (shortcuts, group_num, item_num);
- if (shortcut_item == NULL)
- return;
-
- g_signal_emit (shortcuts_view, signals[ACTIVATE_SHORTCUT], 0,
- shortcuts, shortcut_item->uri, FALSE);
-}
-
-static void
-get_shortcut_info (EShortcutsView *shortcuts_view,
- const char *item_uri,
- int *unread_count_return,
- const char **type_return,
- const char **custom_icon_name_return)
-{
- EShortcutsViewPrivate *priv;
- EStorageSet *storage_set;
- EFolder *folder;
- EShell *shell;
- char *path;
-
- priv = shortcuts_view->priv;
-
- shell = e_shortcuts_get_shell (priv->shortcuts);
-
- if (! e_shell_parse_uri (shell, item_uri, &path, NULL)) {
- *unread_count_return = 0;
- *type_return = NULL;
- *custom_icon_name_return = NULL;
- return;
- }
-
- storage_set = e_shell_get_storage_set (shell);
-
- folder = e_storage_set_get_folder (storage_set, path);
- if (folder != NULL) {
- *unread_count_return = e_folder_get_unread_count (folder);
- *type_return = e_folder_get_type_string (folder);
- *custom_icon_name_return = e_folder_get_custom_icon_name (folder);
- } else {
- *unread_count_return = 0;
- *type_return = NULL;
- *custom_icon_name_return = NULL;
- }
-
- g_free (path);
-}
-
-static void
-impl_shortcut_dropped (EShortcutBar *shortcut_bar,
- int group_num,
- int position,
- const char *item_url,
- const char *item_name)
-{
- EShortcutsView *shortcuts_view;
- EShortcutsViewPrivate *priv;
- int unread_count;
- const char *type;
- const char *custom_icon_name;
- char *tmp;
- char *tp;
- char *name_without_unread;
-
- shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
- priv = shortcuts_view->priv;
-
- get_shortcut_info (shortcuts_view, item_url, &unread_count, &type, &custom_icon_name);
-
- /* Looks funny, but keeps it from adding the unread count
- repeatedly when dragging folders around */
- tmp = g_strdup_printf (" (%d)", unread_count);
- if ((tp = strstr (item_name, tmp)) != NULL)
- name_without_unread = g_strndup (item_name, strlen (item_name) - strlen (tp));
- else
- name_without_unread = g_strdup (item_name);
-
- e_shortcuts_add_shortcut (priv->shortcuts,
- group_num, position,
- item_url,
- name_without_unread,
- unread_count,
- type,
- custom_icon_name);
-
- g_free (tmp);
- g_free (name_without_unread);
-}
-
-static void
-impl_shortcut_dragged (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- EShortcutsView *shortcuts_view;
- EShortcutsViewPrivate *priv;
-
- shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
- priv = shortcuts_view->priv;
-
- e_shortcuts_remove_shortcut (priv->shortcuts, group_num, item_num);
-}
-
-static gboolean
-impl_shortcut_drag_motion (EShortcutBar *shortcut_bar,
- GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- gint group_num,
- gint item_num)
-{
- EShortcutsView *view;
- EShortcutsViewPrivate *priv;
- const EShortcutItem *shortcut;
-
- view = E_SHORTCUTS_VIEW (shortcut_bar);
- priv = view->priv;
-
- shortcut = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
- if (shortcut == NULL)
- return FALSE;
- if (strncmp (shortcut->uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) != 0)
- return FALSE;
-
- if (! e_folder_dnd_bridge_motion (widget, context, time,
- e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)),
- shortcut->uri + E_SHELL_URI_PREFIX_LEN))
- gdk_drag_status (context, 0, time);
-
- return TRUE;
-}
-
-static gboolean
-impl_shortcut_drag_data_received (EShortcutBar *shortcut_bar,
- GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint time,
- gint group_num,
- gint item_num)
-{
- EShortcutsView *view;
- EShortcutsViewPrivate *priv;
- const EShortcutItem *shortcut;
-
- view = E_SHORTCUTS_VIEW (shortcut_bar);
- priv = view->priv;
-
- shortcut = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
- if (shortcut == NULL)
- return FALSE;
- if (strncmp (shortcut->uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) != 0)
- return FALSE;
-
- e_folder_dnd_bridge_data_received (widget, context, selection_data, time,
- e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)),
- shortcut->uri + E_SHELL_URI_PREFIX_LEN);
- return TRUE;
-}
-
-
-static void
-class_init (EShortcutsViewClass *klass)
-{
- GObjectClass *object_class;
- EShortcutBarClass *shortcut_bar_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- shortcut_bar_class = E_SHORTCUT_BAR_CLASS (klass);
- shortcut_bar_class->item_selected = item_selected;
- shortcut_bar_class->shortcut_dropped = impl_shortcut_dropped;
- shortcut_bar_class->shortcut_dragged = impl_shortcut_dragged;
- shortcut_bar_class->shortcut_drag_motion = impl_shortcut_drag_motion;
- shortcut_bar_class->shortcut_drag_data_received = impl_shortcut_drag_data_received;
-
- parent_class = g_type_class_ref(e_shortcut_bar_get_type ());
-
- signals[ACTIVATE_SHORTCUT] =
- g_signal_new ("activate_shortcut",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EShortcutsViewClass, activate_shortcut),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING_BOOL,
- G_TYPE_NONE, 3,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- signals[HIDE_REQUESTED] =
- g_signal_new ("hide_requested",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EShortcutsViewClass,
- hide_requested),
- NULL, NULL,
- e_shell_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
-}
-
-static void
-init (EShortcutsView *shortcuts_view)
-{
- EShortcutsViewPrivate *priv;
-
- priv = g_new (EShortcutsViewPrivate, 1);
- priv->shortcuts = NULL;
-
- shortcuts_view->priv = priv;
-}
-
-
-void
-e_shortcuts_view_construct (EShortcutsView *shortcuts_view,
- EShortcuts *shortcuts)
-{
- EShortcutsViewPrivate *priv;
- int i, num_groups;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts_view->priv;
-
- priv->shortcuts = shortcuts;
- g_object_ref (priv->shortcuts);
-
- e_shortcut_bar_set_model (E_SHORTCUT_BAR (shortcuts_view),
- E_SHORTCUT_MODEL (e_shortcuts_view_model_new (shortcuts)));
-
- g_signal_connect_object (shortcuts, "group_change_icon_size",
- G_CALLBACK (group_change_icon_size_callback), shortcuts_view, 0);
-
- num_groups = e_shortcuts_get_num_groups (shortcuts);
- for (i = 0; i < num_groups; i ++) {
- if (e_shortcuts_get_group_uses_small_icons (shortcuts, i))
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (shortcuts_view), i, E_ICON_BAR_SMALL_ICONS);
- else
- e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (shortcuts_view), i, E_ICON_BAR_LARGE_ICONS);
- }
-}
-
-GtkWidget *
-e_shortcuts_view_new (EShortcuts *shortcuts)
-{
- GtkWidget *new;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- new = g_object_new (e_shortcuts_view_get_type (), NULL);
- e_shortcuts_view_construct (E_SHORTCUTS_VIEW (new), shortcuts);
-
- return new;
-}
-
-
-E_MAKE_TYPE (e_shortcuts_view, "EShortcutsView", EShortcutsView, class_init, init, PARENT_TYPE)
diff --git a/shell/e-shortcuts-view.h b/shell/e-shortcuts-view.h
deleted file mode 100644
index e905fabdc8..0000000000
--- a/shell/e-shortcuts-view.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts-view.h
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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_SHORTCUTS_VIEW_H_
-#define _E_SHORTCUTS_VIEW_H_
-
-#include <gtk/gtkwidget.h>
-
-#include <gal/shortcut-bar/e-shortcut-bar.h>
-#include "e-shortcuts.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_SHORTCUTS_VIEW (e_shortcuts_view_get_type ())
-#define E_SHORTCUTS_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHORTCUTS_VIEW, EShortcutsView))
-#define E_SHORTCUTS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHORTCUTS_VIEW, EShortcutsViewClass))
-#define E_IS_SHORTCUTS_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW))
-#define E_IS_SHORTCUTS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW))
-
-
-typedef struct _EShortcutsView EShortcutsView;
-typedef struct _EShortcutsViewPrivate EShortcutsViewPrivate;
-typedef struct _EShortcutsViewClass EShortcutsViewClass;
-
-struct _EShortcutsView {
- EShortcutBar parent;
-
- EShortcutsViewPrivate *priv;
-};
-
-struct _EShortcutsViewClass {
- EShortcutBarClass parent_class;
-
- void (* activate_shortcut) (EShortcutsView *view,
- EShortcuts *shortcuts,
- const char *uri,
- gboolean in_new_window);
-
- void (* hide_requested) (EShortcutsView *view);
-};
-
-
-GtkType e_shortcuts_view_get_type (void);
-void e_shortcuts_view_construct (EShortcutsView *shortcuts_view,
- EShortcuts *shortcuts);
-GtkWidget *e_shortcuts_view_new (EShortcuts *shortcuts);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUTS_VIEW_H_ */
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
deleted file mode 100644
index 2672dc251d..0000000000
--- a/shell/e-shortcuts.c
+++ /dev/null
@@ -1,1289 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts.c
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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
- */
-
-/* The shortcut list goes like this:
-
- <?xml version="1.0"?>
- <shortcuts>
- <group title="Evolution shortcuts">
- <item name="Inbox" type="mail">evolution:/local/Inbox</item>
- <item name="Trash" type="vtrash">evolution:/local/Trash</item>
- <item name="Spam" type="vspam">evolution:/local/Spam</item>
- <item name="Calendar" type="calendar">evolution:/local/Calendar</item>
- </group>
-
- <group title="Personal shortcuts">
- <item>evolution:/local/Personal</item>
- </group>
- </shortcuts>
-
- FIXME: Do we want to use a namespace for this?
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-shortcuts.h"
-
-#include <string.h>
-
-#include <glib.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktypeutils.h>
-
-#include <libxml/parser.h>
-#include <libxml/xmlmemory.h>
-
-#include <libgnome/gnome-i18n.h>
-
-#include <gal/util/e-xml-utils.h>
-#include <gal/util/e-util.h>
-#include <gal/shortcut-bar/e-shortcut-bar.h>
-
-#include "e-shortcuts-view.h"
-
-#include "e-shell-constants.h"
-#include "e-shell-marshal.h"
-
-
-#define PARENT_TYPE GTK_TYPE_OBJECT
-static GtkObjectClass *parent_class = NULL;
-
-struct _ShortcutGroup {
- /* Title of the group. */
- char *title;
-
- /* A list of shortcuts. */
- GSList *shortcuts;
-
- /* Whether to use small icons for this group. */
- unsigned int use_small_icons : 1;
-};
-typedef struct _ShortcutGroup ShortcutGroup;
-
-struct _EShortcutsPrivate {
- /* Name of the file associated with these shortcuts. Changes in the shortcuts
- will update this file automatically. */
- char *file_name;
-
- /* ID of the idle function that will be called to save the shortcuts when they are
- changed. */
- int save_idle_id;
-
- /* Whether these shortcuts need to be saved to disk. */
- gboolean dirty;
-
- /* The shell that is associated with these shortcuts. */
- EShell *shell;
-
- /* Total number of groups. */
- int num_groups;
-
- /* A list of ShortcutGroups. */
- GSList *groups;
-
- /* A list of ShortcutViews. */
- GSList *views;
-};
-
-enum {
- NEW_GROUP,
- REMOVE_GROUP,
- RENAME_GROUP,
- GROUP_CHANGE_ICON_SIZE,
- NEW_SHORTCUT,
- REMOVE_SHORTCUT,
- UPDATE_SHORTCUT,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
-static void make_dirty (EShortcuts *shortcuts);
-
-
-static EShortcutItem *
-shortcut_item_new (const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name)
-{
- EShortcutItem *new;
-
- new = g_new (EShortcutItem, 1);
-
- if (name == NULL)
- new->name = g_path_get_basename (uri);
- else
- new->name = g_strdup (name);
-
- new->uri = g_strdup (uri);
- new->type = g_strdup (type);
- new->custom_icon_name = g_strdup (custom_icon_name);
- new->unread_count = unread_count;
-
- return new;
-}
-
-static gboolean
-shortcut_item_update (EShortcutItem *shortcut_item,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name)
-{
- char *base_name = g_path_get_basename (uri);
- gboolean changed = FALSE;
-
- if (name == NULL)
- name = base_name;
-
- if (shortcut_item->unread_count != unread_count) {
- shortcut_item->unread_count = unread_count;
- changed = TRUE;
- }
-
-#define UPDATE_STRING(member) \
- if (shortcut_item->member == NULL || member == NULL || \
- strcmp (shortcut_item->member, member) != 0) { \
- g_free (shortcut_item->member); \
- shortcut_item->member = g_strdup (member); \
- changed = TRUE; \
- }
-
- UPDATE_STRING (uri);
- UPDATE_STRING (name);
- UPDATE_STRING (type);
- UPDATE_STRING (custom_icon_name);
-
-#undef UPDATE_STRING
-
- g_free (base_name);
-
- return changed;
-}
-
-static void
-shortcut_item_free (EShortcutItem *shortcut_item)
-{
- g_free (shortcut_item->uri);
- g_free (shortcut_item->name);
- g_free (shortcut_item->type);
-
- g_free (shortcut_item);
-}
-
-static ShortcutGroup *
-shortcut_group_new (const char *title)
-{
- ShortcutGroup *new;
-
- new = g_new (ShortcutGroup, 1);
- new->title = g_strdup (title);
- new->shortcuts = NULL;
- new->use_small_icons = FALSE;
-
- return new;
-}
-
-static void
-shortcut_group_free (ShortcutGroup *group)
-{
- GSList *p;
-
- g_free (group->title);
-
- for (p = group->shortcuts; p != NULL; p = p->next)
- shortcut_item_free ((EShortcutItem *) p->data);
- g_slist_free (group->shortcuts);
-
- g_free (group);
-}
-
-
-/* Utility functions. */
-
-static gboolean
-update_shortcut_and_emit_signal (EShortcuts *shortcuts,
- EShortcutItem *shortcut_item,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name)
-{
- gboolean shortcut_changed;
-
- shortcut_changed = shortcut_item_update (shortcut_item, uri, name, unread_count, type, custom_icon_name);
- if (shortcut_changed) {
- g_signal_emit (shortcuts, signals[UPDATE_SHORTCUT], 0, group_num, num);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-unload_shortcuts (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
- GSList *orig_groups;
- GSList *p;
-
- priv = shortcuts->priv;
- orig_groups = priv->groups;
-
- for (p = priv->groups; p != NULL; p = p->next) {
- ShortcutGroup *group;
-
- g_signal_emit (shortcuts, signals[REMOVE_GROUP], 0, 0);
-
- group = (ShortcutGroup *) p->data;
-
- shortcut_group_free (group);
-
- priv->groups = priv->groups->next;
- }
-
- if (orig_groups != NULL)
- g_slist_free (orig_groups);
-
- priv->groups = NULL;
-}
-
-static gboolean
-load_shortcuts (EShortcuts *shortcuts,
- const char *file_name)
-{
- EShortcutsPrivate *priv;
- xmlDoc *doc;
- xmlNode *root;
- xmlNode *p, *q;
-
- /* FIXME: Update the views by emitting the appropriate signals. */
-
- priv = shortcuts->priv;
-
- doc = xmlParseFile (file_name);
- if (doc == NULL)
- return FALSE;
-
- root = xmlDocGetRootElement (doc);
- if (root == NULL || strcmp (root->name, "shortcuts") != 0) {
- xmlFreeDoc (doc);
- return FALSE;
- }
-
- unload_shortcuts (shortcuts);
-
- for (p = root->children; p != NULL; p = p->next) {
- ShortcutGroup *shortcut_group;
- xmlChar *shortcut_group_title;
- xmlChar *icon_size;
-
- if (strcmp ((char *) p->name, "group") != 0)
- continue;
-
- shortcut_group_title = xmlGetProp (p, "title");
- if (shortcut_group_title == NULL)
- continue;
-
- shortcut_group = shortcut_group_new (shortcut_group_title);
- xmlFree (shortcut_group_title);
-
- icon_size = xmlGetProp (p, "icon_size");
- if (icon_size != NULL && strcmp (icon_size, "small") == 0)
- shortcut_group->use_small_icons = TRUE;
- else
- shortcut_group->use_small_icons = FALSE;
- xmlFree (icon_size);
-
- for (q = p->children; q != NULL; q = q->next) {
- EShortcutItem *shortcut_item;
- xmlChar *uri;
- xmlChar *name;
- xmlChar *type;
- xmlChar *icon;
- char *path;
-
- if (strcmp ((char *) q->name, "item") != 0)
- continue;
-
- uri = xmlNodeListGetString (doc, q->children, 1);
- if (uri == NULL)
- continue;
-
- if (e_shell_parse_uri (priv->shell, uri, &path, NULL)) {
- EFolder *folder;
-
- folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path);
- if (folder != NULL) {
- name = xmlMemStrdup (e_folder_get_name (folder));
- type = xmlMemStrdup (e_folder_get_type_string (folder));
-
- if (e_folder_get_custom_icon_name (folder) != NULL)
- icon = xmlMemStrdup (e_folder_get_custom_icon_name (folder));
- else
- icon = NULL;
- } else {
- name = xmlGetProp (q, "name");
- type = xmlGetProp (q, "type");
- icon = xmlGetProp (q, "icon");
- }
-
- shortcut_item = shortcut_item_new (uri, name, 0, type, icon);
- shortcut_group->shortcuts = g_slist_prepend (shortcut_group->shortcuts,
- shortcut_item);
-
- if (name != NULL)
- xmlFree (name);
- if (type != NULL)
- xmlFree (type);
- if (icon != NULL)
- xmlFree (icon);
- }
-
- g_free (path);
- xmlFree (uri);
- }
-
- shortcut_group->shortcuts = g_slist_reverse (shortcut_group->shortcuts);
-
- priv->groups = g_slist_prepend (priv->groups, shortcut_group);
- priv->num_groups ++;
- }
-
- priv->groups = g_slist_reverse (priv->groups);
-
- xmlFreeDoc (doc);
-
- /* After loading, we always have to re-save ourselves as we have merged
- the information we have with the information we got from the
- StorageSet. */
- /* FIXME: Obviously, this sucks. */
- make_dirty (shortcuts);
-
- return TRUE;
-}
-
-static gboolean
-save_shortcuts (EShortcuts *shortcuts,
- const char *file_name)
-{
- EShortcutsPrivate *priv;
- xmlDoc *doc;
- xmlNode *root;
- GSList *p, *q;
-
- priv = shortcuts->priv;
-
- doc = xmlNewDoc ((xmlChar *) "1.0");
- root = xmlNewDocNode (doc, NULL, (xmlChar *) "shortcuts", NULL);
- xmlDocSetRootElement (doc, root);
-
- for (p = priv->groups; p != NULL; p = p->next) {
- ShortcutGroup *group;
- xmlNode *group_node;
-
- group = (ShortcutGroup *) p->data;
- group_node = xmlNewChild (root, NULL, (xmlChar *) "group", NULL);
-
- xmlSetProp (group_node, (xmlChar *) "title", group->title);
-
- if (group->use_small_icons)
- xmlSetProp (group_node, (xmlChar *) "icon_size", "small");
- else
- xmlSetProp (group_node, (xmlChar *) "icon_size", "large");
-
- for (q = group->shortcuts; q != NULL; q = q->next) {
- EShortcutItem *shortcut;
- xmlNode *shortcut_node;
-
- shortcut = (EShortcutItem *) q->data;
- shortcut_node = xmlNewTextChild (group_node, NULL, (xmlChar *) "item",
- (xmlChar *) shortcut->uri);
-
- if (shortcut->name != NULL)
- xmlSetProp (shortcut_node, (xmlChar *) "name", shortcut->name);
-
- if (shortcut->type != NULL)
- xmlSetProp (shortcut_node, (xmlChar *) "type", shortcut->type);
-
- if (shortcut->custom_icon_name != NULL)
- xmlSetProp (shortcut_node, (xmlChar *) "icon", shortcut->custom_icon_name);
- }
- }
-
- if (xmlSaveFile (file_name, doc) < 0) {
- xmlFreeDoc (doc);
- return FALSE;
- }
-
- xmlFreeDoc (doc);
- return TRUE;
-}
-
-
-/* Idle function to update the file on disk. */
-
-static int
-idle_cb (void *data)
-{
- EShortcuts *shortcuts;
- EShortcutsPrivate *priv;
-
- shortcuts = E_SHORTCUTS (data);
- priv = shortcuts->priv;
-
- if (priv->dirty) {
- if (! e_shortcuts_save (shortcuts, NULL))
- g_warning ("Saving of shortcuts failed -- %s", priv->file_name);
- else
- priv->dirty = FALSE;
- }
-
- priv->save_idle_id = 0;
-
- return FALSE;
-}
-
-static void
-schedule_idle (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
-
- priv = shortcuts->priv;
-
- if (priv->save_idle_id != 0)
- return;
-
- priv->save_idle_id = gtk_idle_add (idle_cb, shortcuts);
-}
-
-static void
-make_dirty (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
-
- priv = shortcuts->priv;
-
- priv->dirty = TRUE;
- schedule_idle (shortcuts);
-}
-
-static void
-update_shortcuts_by_path (EShortcuts *shortcuts,
- const char *path)
-{
- EShortcutsPrivate *priv;
- EFolder *folder;
- const GSList *p, *q;
- char *evolution_uri;
- int group_num, num;
- gboolean changed = FALSE;
-
- priv = shortcuts->priv;
- folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path);
-
- evolution_uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
-
- group_num = 0;
- for (p = priv->groups; p != NULL; p = p->next, group_num++) {
- ShortcutGroup *group;
-
- group = (ShortcutGroup *) p->data;
- num = 0;
- for (q = group->shortcuts; q != NULL; q = q->next, num++) {
- EShortcutItem *shortcut_item;
- char *shortcut_path;
-
- shortcut_item = (EShortcutItem *) q->data;
-
- if (! e_shell_parse_uri (priv->shell, shortcut_item->uri, &shortcut_path, NULL)) {
- /* Ignore bogus URIs. */
- continue;
- }
-
- if (strcmp (shortcut_path, path) == 0) {
- changed = update_shortcut_and_emit_signal (shortcuts,
- shortcut_item,
- group_num,
- num,
- shortcut_item->uri,
- shortcut_item->name,
- e_folder_get_unread_count (folder),
- e_folder_get_type_string (folder),
- e_folder_get_custom_icon_name (folder));
- }
-
- g_free (shortcut_path);
- }
- }
-
- g_free (evolution_uri);
-
- if (changed)
- make_dirty (shortcuts);
-}
-
-
-static EShortcutItem *
-get_item (EShortcuts *shortcuts,
- int group_num,
- int num)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *group_element;
- GSList *shortcut_element;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- priv = shortcuts->priv;
-
- group_element = g_slist_nth (priv->groups, group_num);
- if (group_element == NULL)
- return NULL;
-
- group = (ShortcutGroup *) group_element->data;
-
- shortcut_element = g_slist_nth (group->shortcuts, num);
- if (shortcut_element == NULL)
- return NULL;
-
- return (EShortcutItem *) shortcut_element->data;
-}
-
-
-/* Signal handlers for the views. */
-
-static void
-view_weak_notify (void *data,
- GObject *where_the_object_was)
-{
- EShortcuts *shortcuts;
- EShortcutsPrivate *priv;
-
- shortcuts = E_SHORTCUTS (data);
- priv = shortcuts->priv;
-
- priv->views = g_slist_remove (priv->views, where_the_object_was);
-}
-
-
-/* Signal handlers for the EStorageSet. */
-
-static void
-storage_set_new_folder_callback (EStorageSet *storage_set,
- const char *path,
- void *data)
-{
- EShortcuts *shortcuts;
-
- shortcuts = E_SHORTCUTS (data);
-
- update_shortcuts_by_path (shortcuts, path);
-}
-
-static void
-storage_set_updated_folder_callback (EStorageSet *storage_set,
- const char *path,
- void *data)
-{
- EShortcuts *shortcuts;
-
- shortcuts = E_SHORTCUTS (data);
-
- update_shortcuts_by_path (shortcuts, path);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EShortcuts *shortcuts;
- EShortcutsPrivate *priv;
- GSList *p;
-
- shortcuts = E_SHORTCUTS (object);
- priv = shortcuts->priv;
-
- unload_shortcuts (shortcuts);
-
- if (priv->save_idle_id != 0) {
- gtk_idle_remove (priv->save_idle_id);
- priv->save_idle_id = 0;
- }
-
- if (priv->dirty) {
- if (! e_shortcuts_save (shortcuts, NULL))
- g_warning (_("Error saving shortcuts.")); /* FIXME */
- priv->dirty = FALSE;
- }
-
- for (p = priv->views; p != NULL; p = p->next)
- g_object_weak_unref (G_OBJECT (p->data), view_weak_notify, shortcuts);
- g_slist_free (priv->views);
- priv->views = NULL;
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EShortcuts *shortcuts;
- EShortcutsPrivate *priv;
-
- shortcuts = E_SHORTCUTS (object);
- priv = shortcuts->priv;
-
- g_free (priv->file_name);
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-static void
-class_init (EShortcutsClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- parent_class = g_type_class_ref(gtk_object_get_type ());
-
- signals[NEW_GROUP]
- = g_signal_new ("new_group",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, new_group),
- NULL, NULL,
- e_shell_marshal_NONE__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- signals[REMOVE_GROUP]
- = g_signal_new ("remove_group",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, remove_group),
- NULL, NULL,
- e_shell_marshal_NONE__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- signals[RENAME_GROUP]
- = g_signal_new ("rename_group",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, rename_group),
- NULL, NULL,
- e_shell_marshal_NONE__INT_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_STRING);
-
- signals[GROUP_CHANGE_ICON_SIZE]
- = g_signal_new ("group_change_icon_size",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, group_change_icon_size),
- NULL, NULL,
- e_shell_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[NEW_SHORTCUT]
- = g_signal_new ("new_shortcut",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, new_shortcut),
- NULL, NULL,
- e_shell_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[REMOVE_SHORTCUT]
- = g_signal_new ("remove_shortcut",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, remove_shortcut),
- NULL, NULL,
- e_shell_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- signals[UPDATE_SHORTCUT]
- = g_signal_new ("update_shortcut",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShortcutsClass, update_shortcut),
- NULL, NULL,
- e_shell_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-}
-
-
-static void
-init (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
-
- priv = g_new (EShortcutsPrivate, 1);
-
- priv->file_name = NULL;
- priv->num_groups = 0;
- priv->groups = NULL;
- priv->views = NULL;
- priv->dirty = 0;
- priv->save_idle_id = 0;
- priv->shell = NULL;
-
- shortcuts->priv = priv;
-}
-
-
-void
-e_shortcuts_construct (EShortcuts *shortcuts,
- EShell *shell)
-{
- EShortcutsPrivate *priv;
- EStorageSet *storage_set;
-
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
- g_return_if_fail (E_IS_SHELL (shell));
-
- GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (shortcuts), GTK_FLOATING);
-
- priv = shortcuts->priv;
-
- /* Don't ref it so we don't create a circular dependency. */
- priv->shell = shell;
-
- storage_set = e_shell_get_storage_set (shell);
-
- g_signal_connect_object (storage_set, "new_folder",
- G_CALLBACK (storage_set_new_folder_callback), shortcuts, 0);
- g_signal_connect_object (storage_set, "updated_folder",
- G_CALLBACK (storage_set_updated_folder_callback), shortcuts, 0);
-}
-
-EShortcuts *
-e_shortcuts_new_from_file (EShell *shell,
- const char *file_name)
-{
- EShortcuts *new;
-
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- g_return_val_if_fail (file_name != NULL, NULL);
-
- new = g_object_new (e_shortcuts_get_type (), NULL);
- e_shortcuts_construct (new, shell);
-
- if (! e_shortcuts_load (new, file_name))
- new->priv->file_name = g_strdup (file_name);
-
- return new;
-}
-
-
-int
-e_shortcuts_get_num_groups (EShortcuts *shortcuts)
-{
- g_return_val_if_fail (shortcuts != NULL, 0);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), 0);
-
- return shortcuts->priv->num_groups;
-}
-
-GSList *
-e_shortcuts_get_group_titles (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *list;
- GSList *p;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- priv = shortcuts->priv;
-
- list = NULL;
-
- for (p = priv->groups; p != NULL; p = p->next) {
- group = (ShortcutGroup *) p->data;
- list = g_slist_prepend (list, g_strdup (group->title));
- }
-
- return g_slist_reverse (list);
-}
-
-const GSList *
-e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
- int group_num)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *shortcut_group;
- GSList *shortcut_group_list_item;
-
- priv = shortcuts->priv;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- shortcut_group_list_item = g_slist_nth (priv->groups, group_num);
- if (shortcut_group_list_item == NULL)
- return NULL;
-
- shortcut_group = (ShortcutGroup *) shortcut_group_list_item->data;
-
- return shortcut_group->shortcuts;
-}
-
-
-EShell *
-e_shortcuts_get_shell (EShortcuts *shortcuts)
-{
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- return shortcuts->priv->shell;
-}
-
-
-GtkWidget *
-e_shortcuts_new_view (EShortcuts *shortcuts)
-{
- EShortcutsPrivate *priv;
- GtkWidget *new;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- priv = shortcuts->priv;
-
- new = e_shortcuts_view_new (shortcuts);
- priv->views = g_slist_prepend (priv->views, new);
-
- g_object_weak_ref (G_OBJECT (new), view_weak_notify, shortcuts);
-
- return new;
-}
-
-
-gboolean
-e_shortcuts_load (EShortcuts *shortcuts,
- const char *file_name)
-{
- EShortcutsPrivate *priv;
- char *tmp;
-
- g_return_val_if_fail (shortcuts != NULL, FALSE);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), FALSE);
- g_return_val_if_fail (file_name == NULL || g_path_is_absolute (file_name), FALSE);
-
- priv = shortcuts->priv;
-
- if (file_name == NULL) {
- if (priv->file_name == NULL)
- return FALSE;
- file_name = priv->file_name;
- }
-
- if (! load_shortcuts (shortcuts, file_name))
- return FALSE;
-
- tmp = g_strdup (file_name);
- g_free (priv->file_name);
- priv->file_name = tmp;
-
- return TRUE;
-}
-
-gboolean
-e_shortcuts_save (EShortcuts *shortcuts,
- const char *file_name)
-{
- EShortcutsPrivate *priv;
- char *tmp;
-
- g_return_val_if_fail (shortcuts != NULL, FALSE);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), FALSE);
- g_return_val_if_fail (file_name == NULL || g_path_is_absolute (file_name), FALSE);
-
- priv = shortcuts->priv;
-
- if (file_name == NULL) {
- if (priv->file_name == NULL)
- return FALSE;
- file_name = priv->file_name;
- }
-
- if (! save_shortcuts (shortcuts, file_name))
- return FALSE;
-
- tmp = g_strdup (file_name);
- g_free (priv->file_name);
- priv->file_name = tmp;
-
- return TRUE;
-}
-
-
-const EShortcutItem *
-e_shortcuts_get_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num)
-{
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- return (const EShortcutItem *) get_item (shortcuts, group_num, num);
-}
-
-
-void
-e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *p;
- EShortcutItem *item;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- p = g_slist_nth (priv->groups, group_num);
- g_return_if_fail (p != NULL);
-
- group = (ShortcutGroup *) p->data;
-
- p = g_slist_nth (group->shortcuts, num);
- g_return_if_fail (p != NULL);
-
- g_signal_emit (shortcuts, signals[REMOVE_SHORTCUT], 0, group_num, num);
-
- item = (EShortcutItem *) p->data;
- shortcut_item_free (item);
-
- group->shortcuts = g_slist_remove_link (group->shortcuts, p);
-
- make_dirty (shortcuts);
-}
-
-void
-e_shortcuts_add_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- EShortcutItem *item;
- GSList *p;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- p = g_slist_nth (priv->groups, group_num);
- g_return_if_fail (p != NULL);
-
- group = (ShortcutGroup *) p->data;
-
- if (num == -1)
- num = g_slist_length (group->shortcuts);
-
- item = shortcut_item_new (uri, name, unread_count, type, custom_icon_name);
-
- group->shortcuts = g_slist_insert (group->shortcuts, item, num);
-
- g_signal_emit (shortcuts, signals[NEW_SHORTCUT], 0, group_num, num);
-
- make_dirty (shortcuts);
-}
-
-void
-e_shortcuts_update_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name)
-{
- EShortcutItem *shortcut_item;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- shortcut_item = get_item (shortcuts, group_num, num);
-
- update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num,
- uri, name, unread_count, type, custom_icon_name);
-
- make_dirty (shortcuts);
-}
-
-
-void
-e_shortcuts_add_default_shortcuts (EShortcuts *shortcuts,
- int group_num)
-{
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, E_SUMMARY_URI, _("Summary"), 0, "summary", NULL);
-
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, "default:mail", _("Inbox"), 0, "mail", "inbox");
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, "default:calendar", _("Calendar"), 0, "calendar", NULL);
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, "default:tasks", _("Tasks"), 0, "tasks", NULL);
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, "default:contacts", _("Contacts"), 0, "contacts", NULL);
-}
-
-void
-e_shortcuts_add_default_group (EShortcuts *shortcuts)
-{
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- e_shortcuts_add_group (shortcuts, -1, _("Shortcuts"));
-
- e_shortcuts_add_default_shortcuts (shortcuts, e_shortcuts_get_num_groups (shortcuts) - 1);
-}
-
-void
-e_shortcuts_remove_group (EShortcuts *shortcuts,
- int group_num)
-{
- EShortcutsPrivate *priv;
- GSList *p;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- p = g_slist_nth (priv->groups, group_num);
- g_return_if_fail (p != NULL);
-
- g_signal_emit (shortcuts, signals[REMOVE_GROUP], 0, group_num);
-
- shortcut_group_free ((ShortcutGroup *) p->data);
-
- priv->groups = g_slist_remove_link (priv->groups, p);
- priv->num_groups --;
-
- make_dirty (shortcuts);
-}
-
-void
-e_shortcuts_rename_group (EShortcuts *shortcuts,
- int group_num,
- const char *new_title)
-{
- EShortcutsPrivate *priv;
- GSList *p;
- ShortcutGroup *group;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- p = g_slist_nth (priv->groups, group_num);
- g_return_if_fail (p != NULL);
-
- group = (ShortcutGroup *) p->data;
- if (strcmp (group->title, new_title)) {
- g_free (group->title);
- group->title = g_strdup (new_title);
- } else
- return;
-
- g_signal_emit (shortcuts, signals[RENAME_GROUP], 0, group_num, new_title);
-
- make_dirty (shortcuts);
-}
-
-void
-e_shortcuts_add_group (EShortcuts *shortcuts,
- int group_num,
- const char *group_name)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
-
- g_return_if_fail (shortcuts != NULL);
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- group = shortcut_group_new (group_name);
-
- if (group_num == -1)
- group_num = g_slist_length (priv->groups);
-
- priv->groups = g_slist_insert (priv->groups, group, group_num);
- priv->num_groups ++;
-
- g_signal_emit (shortcuts, signals[NEW_GROUP], 0, group_num);
-
- make_dirty (shortcuts);
-}
-
-
-const char *
-e_shortcuts_get_group_title (EShortcuts *shortcuts,
- int group_num)
-{
- EShortcutsPrivate *priv;
- GSList *group_element;
- const ShortcutGroup *group;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- priv = shortcuts->priv;
-
- group_element = g_slist_nth (priv->groups, group_num);
- if (group_element == NULL)
- return NULL;
-
- group = (ShortcutGroup *) group_element->data;
-
- return group->title;
-}
-
-void
-e_shortcuts_set_group_uses_small_icons (EShortcuts *shortcuts,
- int group_num,
- gboolean use_small_icons)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *group_element;
-
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
- priv = shortcuts->priv;
-
- group_element = g_slist_nth (priv->groups, group_num);
- if (group_element == NULL)
- return;
-
- group = (ShortcutGroup *) group_element->data;
-
- use_small_icons = !! use_small_icons;
- if (group->use_small_icons != use_small_icons) {
- group->use_small_icons = use_small_icons;
- g_signal_emit (shortcuts, signals[GROUP_CHANGE_ICON_SIZE], 0, group_num, use_small_icons);
-
- make_dirty (shortcuts);
- }
-}
-
-gboolean
-e_shortcuts_get_group_uses_small_icons (EShortcuts *shortcuts,
- int group_num)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *group_element;
-
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), FALSE);
-
- priv = shortcuts->priv;
-
- group_element = g_slist_nth (priv->groups, group_num);
- if (group_element == NULL)
- return FALSE;
-
- group = (ShortcutGroup *) group_element->data;
- return group->use_small_icons;
-}
-
-
-void
-e_shortcuts_update_shortcuts_for_changed_uri (EShortcuts *shortcuts,
- const char *old_uri,
- const char *new_uri)
-{
- EShortcutsPrivate *priv;
- GSList *p;
-
- g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
- g_return_if_fail (old_uri != NULL);
- g_return_if_fail (new_uri != NULL);
-
- priv = shortcuts->priv;
-
- for (p = priv->groups; p != NULL; p = p->next) {
- ShortcutGroup *group;
- GSList *q;
-
- group = (ShortcutGroup *) p->data;
- for (q = group->shortcuts; q != NULL; q = q->next) {
- EShortcutItem *item;
-
- item = (EShortcutItem *) q->data;
-
- if (strcmp (item->uri, old_uri) == 0) {
- g_free (item->uri);
- item->uri = g_strdup (new_uri);
-
- make_dirty (shortcuts);
- }
- }
- }
-}
-
-
-E_MAKE_TYPE (e_shortcuts, "EShortcuts", EShortcuts, class_init, init, PARENT_TYPE)
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
deleted file mode 100644
index 30e2ff01e8..0000000000
--- a/shell/e-shortcuts.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shortcuts.h
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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_SHORTCUTS_H_
-#define _E_SHORTCUTS_H_
-
-#include <gtk/gtkwidget.h>
-
-#include "e-folder-type-registry.h"
-#include "e-storage-set.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_SHORTCUTS (e_shortcuts_get_type ())
-#define E_SHORTCUTS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHORTCUTS, EShortcuts))
-#define E_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHORTCUTS, EShortcutsClass))
-#define E_IS_SHORTCUTS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS))
-#define E_IS_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS))
-
-
-typedef struct _EShortcuts EShortcuts;
-typedef struct _EShortcutsPrivate EShortcutsPrivate;
-typedef struct _EShortcutsClass EShortcutsClass;
-
-struct _EShortcutItem {
- /* URI of the shortcut. */
- char *uri;
-
- /* Name of the shortcut. */
- char *name;
-
- /* Folder type for the shortcut. If the shortcut doesn't point to a
- folder, this is NULL. */
- char *type;
-
- /* Custom icon for the shortcut. If this is NULL, then the shortcut
- should just use the icon for the type. */
- char *custom_icon_name;
-
- /* Number of unread items in the folder. Zero if not a folder. */
- int unread_count;
-};
-typedef struct _EShortcutItem EShortcutItem;
-
-struct _EShortcuts {
- GtkObject parent;
-
- EShortcutsPrivate *priv;
-};
-
-struct _EShortcutsClass {
- GtkObjectClass parent_class;
-
- /* Signals. */
-
- void (* new_group) (EShortcuts *shortcuts, int group_num);
- void (* remove_group) (EShortcuts *shortcuts, int group_num);
- void (* rename_group) (EShortcuts *shortcuts, int group_num, const char *new_title);
-
- void (* group_change_icon_size) (EShortcuts *shortcuts, int group_num, gboolean use_small_icons);
-
- void (* new_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);
- void (* remove_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);
- void (* update_shortcut) (EShortcuts *shortcuts, int group_num, int item_num);
-};
-
-
-#include "e-shell.h"
-
-
-GtkType e_shortcuts_get_type (void);
-void e_shortcuts_construct (EShortcuts *shortcuts,
- EShell *shell);
-EShortcuts *e_shortcuts_new_from_file (EShell *shell,
- const char *file_name);
-
-int e_shortcuts_get_num_groups (EShortcuts *shortcuts);
-
-GSList *e_shortcuts_get_group_titles (EShortcuts *shortcuts);
-const char *e_shortcuts_get_group_title (EShortcuts *shortcuts,
- int group_num);
-const GSList *e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
- int group_num);
-
-const EShortcutItem *e_shortcuts_get_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num);
-
-EShell *e_shortcuts_get_shell (EShortcuts *shortcuts);
-
-GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts);
-
-gboolean e_shortcuts_load (EShortcuts *shortcuts,
- const char *path);
-gboolean e_shortcuts_save (EShortcuts *shortcuts,
- const char *path);
-
-void e_shortcuts_add_default_shortcuts (EShortcuts *shortcuts,
- int group_num);
-void e_shortcuts_add_default_group (EShortcuts *shortcuts);
-
-void e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num);
-void e_shortcuts_add_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name);
-void e_shortcuts_update_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- int unread_count,
- const char *type,
- const char *custom_icon_name);
-
-void e_shortcuts_remove_group (EShortcuts *shortcuts,
- int group_num);
-void e_shortcuts_add_group (EShortcuts *shortcuts,
- int group_num,
- const char *group_title);
-void e_shortcuts_rename_group (EShortcuts *shortcuts,
- int group_num,
- const char *new_title);
-
-void e_shortcuts_set_group_uses_small_icons (EShortcuts *shortcuts,
- int group_num,
- gboolean use_small_icons);
-gboolean e_shortcuts_get_group_uses_small_icons (EShortcuts *shortcuts,
- int group_num);
-
-void e_shortcuts_update_shortcuts_for_changed_uri (EShortcuts *shortcuts,
- const char *old_uri_,
- const char *new_uri);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUTS_H_ */
diff --git a/shell/evolution-folder-selector-button.c b/shell/evolution-folder-selector-button.c
deleted file mode 100644
index f3b9ab6179..0000000000
--- a/shell/evolution-folder-selector-button.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* evolution-folder-selector-button.c
- *
- * Copyright (C) 2002 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-folder-selector-button.h"
-
-#include "e-shell-marshal.h"
-
-#include <gal/util/e-util.h>
-
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtklabel.h>
-
-#include <libgnome/gnome-i18n.h>
-
-#include <string.h>
-
-
-struct _EvolutionFolderSelectorButtonPrivate {
- EvolutionShellClient *shell_client;
- GNOME_Evolution_StorageRegistry corba_storage_registry;
- GNOME_Evolution_Folder *selected_folder;
- GtkWidget *icon, *label;
- char *title, **possible_types;
-};
-
-enum {
- POPPED_UP,
- SELECTED,
- CANCELED,
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-#define PARENT_TYPE gtk_button_get_type ()
-static GtkButtonClass *parent_class = NULL;
-
-
-static GNOME_Evolution_Folder *
-get_folder_for_uri (EvolutionFolderSelectorButton *folder_selector_button,
- const char *uri)
-{
- EvolutionFolderSelectorButtonPrivate *priv = folder_selector_button->priv;
- CORBA_Environment ev;
- GNOME_Evolution_Folder *folder;
-
- if (!uri)
- return NULL;
-
- CORBA_exception_init (&ev);
- folder = GNOME_Evolution_StorageRegistry_getFolderByUri (
- priv->corba_storage_registry, uri, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- folder = CORBA_OBJECT_NIL;
- CORBA_exception_free (&ev);
-
- return folder;
-}
-
-static void
-set_folder (EvolutionFolderSelectorButton *folder_selector_button,
- GNOME_Evolution_Folder *folder)
-{
- EvolutionFolderSelectorButtonPrivate *priv;
- GdkPixbuf *pixbuf;
- char *storage_lname;
- char *label_text;
- const char *p;
-
- priv = folder_selector_button->priv;
-
- if (priv->selected_folder)
- CORBA_free (priv->selected_folder);
- priv->selected_folder = folder;
-
- if (!folder) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), NULL);
- gtk_label_set_text (GTK_LABEL (priv->label),
- _("<click here to select a folder>"));
- return;
- }
-
- pixbuf = evolution_shell_client_get_pixbuf_for_type (priv->shell_client, folder->type, TRUE);
- if (pixbuf != NULL) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf);
- g_object_unref (pixbuf);
- }
-
- storage_lname = NULL;
- p = strchr (folder->evolutionUri, '/');
- if (p) {
- p = strchr (p + 1, '/');
- if (p) {
- GNOME_Evolution_Folder *storage_folder;
- char *storage_uri;
-
- storage_uri = g_strndup (folder->evolutionUri,
- p - folder->evolutionUri);
- storage_folder = get_folder_for_uri (folder_selector_button, storage_uri);
- storage_lname = g_strdup (storage_folder->displayName);
- CORBA_free (storage_folder);
- g_free (storage_uri);
- }
- }
-
- if (storage_lname) {
- label_text = g_strdup_printf (_("\"%s\" in \"%s\""), folder->displayName,
- storage_lname);
- g_free (storage_lname);
- } else {
- label_text = g_strdup_printf ("\"%s\"", folder->displayName);
- }
-
- gtk_label_set_text (GTK_LABEL (priv->label), label_text);
- g_free (label_text);
-}
-
-static void
-clicked (GtkButton *button)
-{
- EvolutionFolderSelectorButton *folder_selector_button;
- EvolutionFolderSelectorButtonPrivate *priv;
- GNOME_Evolution_Folder *return_folder;
- GtkWidget *toplevel_container;
- GtkWindow *parent_window;
- char *initial_uri;
-
- /* We want to disable the window the button is in, since the
- * folder selection dialog may be in another process and the WM
- * won't enforce modality cross-process. In Evo 1.2, this code
- * called gtk_widget_set_sensitive on the button's parent
- * window, but in GNOME 2 that seems to cause bad things to
- * happen (the window doesn't resensitize properly at the end).
- * So we desensitize the top-level container inside the window
- * instead.
- */
- toplevel_container = GTK_WIDGET (button);
- while (toplevel_container->parent &&
- !GTK_IS_WINDOW (toplevel_container->parent))
- toplevel_container = toplevel_container->parent;
- parent_window = (GtkWindow *)toplevel_container->parent;
-
- gtk_widget_set_sensitive (GTK_WIDGET (toplevel_container), FALSE);
-
- folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (button);
- priv = folder_selector_button->priv;
-
- if (priv->selected_folder)
- initial_uri = priv->selected_folder->evolutionUri;
- else
- initial_uri = "";
-
- g_signal_emit (folder_selector_button, signals[POPPED_UP], 0);
-
- g_object_add_weak_pointer (G_OBJECT (button), (void **) &button);
-
- evolution_shell_client_user_select_folder (priv->shell_client,
- parent_window,
- priv->title,
- initial_uri,
- (const char **)priv->possible_types,
- &return_folder);
-
- /* Bail out if the parent window was destroyed */
- if (button == NULL)
- return;
- g_object_remove_weak_pointer (G_OBJECT (button), (void **) &button);
-
- gtk_widget_set_sensitive (GTK_WIDGET (toplevel_container), TRUE);
-
- if (!return_folder) {
- g_signal_emit (folder_selector_button, signals[CANCELED], 0);
- return;
- }
-
- set_folder (folder_selector_button, return_folder);
-
- g_signal_emit (folder_selector_button, signals[SELECTED], 0, return_folder);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EvolutionFolderSelectorButton *folder_selector_button;
- EvolutionFolderSelectorButtonPrivate *priv;
-
- folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (object);
- priv = folder_selector_button->priv;
-
- if (priv->shell_client != NULL) {
- g_object_unref (priv->shell_client);
- priv->shell_client = NULL;
- }
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EvolutionFolderSelectorButton *folder_selector_button;
- EvolutionFolderSelectorButtonPrivate *priv;
- int i;
-
- folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (object);
- priv = folder_selector_button->priv;
-
- g_free (priv->title);
-
- if (priv->possible_types != NULL) {
- for (i = 0; priv->possible_types[i]; i++)
- g_free (priv->possible_types[i]);
- g_free (priv->possible_types);
- }
-
- if (priv->selected_folder)
- CORBA_free (priv->selected_folder);
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-static void
-class_init (EvolutionFolderSelectorButtonClass *klass)
-{
- GObjectClass *object_class;
- GtkButtonClass *button_class;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
-
- object_class = G_OBJECT_CLASS (klass);
- button_class = GTK_BUTTON_CLASS (klass);
-
- button_class->clicked = clicked;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- signals[POPPED_UP] = g_signal_new ("popped_up",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, popped_up),
- NULL, NULL,
- e_shell_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
- signals[SELECTED] = g_signal_new ("selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, selected),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- signals[CANCELED] = g_signal_new ("canceled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, canceled),
- NULL, NULL,
- e_shell_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
-}
-
-static void
-init (EvolutionFolderSelectorButton *folder_selector_button)
-{
- EvolutionFolderSelectorButtonPrivate *priv;
- GtkWidget *box;
-
- priv = g_new0 (EvolutionFolderSelectorButtonPrivate, 1);
-
- priv->icon = gtk_image_new ();
- priv->label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (priv->label), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.0);
- box = gtk_hbox_new (FALSE, 4);
- gtk_box_pack_start (GTK_BOX (box), priv->icon, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
- gtk_widget_show_all (GTK_WIDGET (box));
- gtk_container_add (GTK_CONTAINER (folder_selector_button), box);
-
- folder_selector_button->priv = priv;
-}
-
-
-
-/**
- * evolution_folder_selector_button_construct:
- * @folder_selector_button:
- * @shell_client: the shell client that will be used for folder selection
- * @title: the title to use for the selection dialog
- * @initial_uri: the URI (evolution: or physical) of the
- * initially-selected folder
- * @possible_types: a %NULL-terminated array of selectable types.
- *
- * Construct @folder_selector_button.
- **/
-void
-evolution_folder_selector_button_construct (EvolutionFolderSelectorButton *folder_selector_button,
- EvolutionShellClient *shell_client,
- const char *title,
- const char *initial_uri,
- const char *possible_types[])
-{
- EvolutionFolderSelectorButtonPrivate *priv;
- GNOME_Evolution_Folder *folder;
- int count;
-
- g_return_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button));
- g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client));
- g_return_if_fail (possible_types != NULL);
-
- priv = folder_selector_button->priv;
-
- priv->shell_client = shell_client;
- g_object_ref (shell_client);
- priv->corba_storage_registry = evolution_shell_client_get_storage_registry_interface (shell_client);
-
- priv->title = g_strdup (title);
-
- folder = get_folder_for_uri (folder_selector_button, initial_uri);
- set_folder (folder_selector_button, folder);
-
- for (count = 0; possible_types[count]; count++)
- ;
- priv->possible_types = g_new (char *, count + 1);
- for (count = 0; possible_types[count]; count++)
- priv->possible_types[count] = g_strdup (possible_types[count]);
- priv->possible_types[count] = NULL;
-}
-
-/**
- * evolution_folder_selector_button_new:
- * @shell_client: the shell client that will be used for folder selection
- * @title: the title to use for the selection dialog
- * @initial_uri: the URI (evolution: or physical) of the
- * initially-selected folder
- * @possible_types: a %NULL-terminated array of selectable types.
- *
- * Return value: a new folder selector button.
- **/
-GtkWidget *
-evolution_folder_selector_button_new (EvolutionShellClient *shell_client,
- const char *title,
- const char *initial_uri,
- const char *possible_types[])
-{
- EvolutionFolderSelectorButton *folder_selector_button;
-
- folder_selector_button = g_object_new (evolution_folder_selector_button_get_type (), NULL);
-
- evolution_folder_selector_button_construct (folder_selector_button,
- shell_client,
- title,
- initial_uri,
- possible_types);
- return (GtkWidget *)folder_selector_button;
-}
-
-/**
- * evolution_folder_selector_button_set_uri:
- * @folder_selector_button:
- * @uri: the URI (evolution: or physical) to select, or %NULL
- *
- * Attempts to make @folder_selector_button select @uri. If @uri
- * doesn't point to a folder, or points to a folder of an incorrect
- * type for this button, then the selected URI will be unchanged.
- *
- * If @uri is %NULL, the button will be returned to an unselected
- * state.
- *
- * Return value: whether or not the URI was successfully set.
- **/
-gboolean
-evolution_folder_selector_button_set_uri (EvolutionFolderSelectorButton *folder_selector_button,
- const char *uri)
-{
- EvolutionFolderSelectorButtonPrivate *priv;
- GNOME_Evolution_Folder *folder;
- char *slash;
- int i;
-
- g_return_val_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button), FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
-
- priv = folder_selector_button->priv;
-
- if (!uri) {
- set_folder (folder_selector_button, NULL);
- return TRUE;
- }
-
- folder = get_folder_for_uri (folder_selector_button, uri);
- if (!folder)
- return FALSE;
-
- for (i = 0; priv->possible_types[i]; i++) {
- if (!strcmp (folder->type, priv->possible_types[i])) {
- set_folder (folder_selector_button, folder);
- return TRUE;
- }
- slash = strchr (priv->possible_types[i], '/');
- if (slash && slash[1] == '*' &&
- !strncmp (folder->type, priv->possible_types[i],
- slash - priv->possible_types[i])) {
- set_folder (folder_selector_button, folder);
- return TRUE;
- }
- }
-
- CORBA_free (folder);
- return FALSE;
-}
-
-/**
- * evolution_folder_selector_button_get_folder:
- * @folder_selector_button:
- *
- * Return value: the currently-selected folder, or %NULL
- **/
-GNOME_Evolution_Folder *
-evolution_folder_selector_button_get_folder (EvolutionFolderSelectorButton *folder_selector_button)
-{
- g_return_val_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button), NULL);
-
- return folder_selector_button->priv->selected_folder;
-}
-
-
-E_MAKE_TYPE (evolution_folder_selector_button, "EvolutionFolderSelectorButton", EvolutionFolderSelectorButton, class_init, init, PARENT_TYPE)
diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c
deleted file mode 100644
index 46908f79b2..0000000000
--- a/shell/evolution-shell-client.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* evolution-shell-client.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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 <gal/util/e-util.h>
-
-#include "evolution-shell-client.h"
-#include "e-shell-corba-icon-utils.h"
-
-#define PARENT_TYPE G_TYPE_OBJECT
-
-
-static void
-class_init (EvolutionShellClientClass *klass)
-{
-}
-
-static void
-init (EvolutionShellClient *shell_client)
-{
-}
-
-
-void
-evolution_shell_client_construct (EvolutionShellClient *shell_client,
- GNOME_Evolution_Shell corba_shell)
-{
- g_assert_not_reached ();
-}
-
-EvolutionShellClient *
-evolution_shell_client_new (GNOME_Evolution_Shell corba_shell)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-GNOME_Evolution_Shell
-evolution_shell_client_corba_objref (EvolutionShellClient *shell_client)
-{
- g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL);
- return CORBA_OBJECT_NIL;
-}
-
-
-void
-evolution_shell_client_user_select_folder (EvolutionShellClient *shell_client,
- GtkWindow *parent,
- const char *title,
- const char *default_folder,
- const char **possible_types,
- GNOME_Evolution_Folder **folder_return)
-{
- g_assert_not_reached ();
-}
-
-
-GNOME_Evolution_Activity
-evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client)
-{
- g_assert_not_reached ();
- return CORBA_OBJECT_NIL;
-}
-
-GNOME_Evolution_Shortcuts
-evolution_shell_client_get_shortcuts_interface (EvolutionShellClient *shell_client)
-{
- g_assert_not_reached ();
- return CORBA_OBJECT_NIL;
-}
-
-GNOME_Evolution_StorageRegistry
-evolution_shell_client_get_storage_registry_interface (EvolutionShellClient *shell_client)
-{
- g_assert_not_reached ();
- return CORBA_OBJECT_NIL;
-}
-
-
-GNOME_Evolution_Storage
-evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client)
-{
- g_assert_not_reached ();
- return CORBA_OBJECT_NIL;
-}
-
-void
-evolution_shell_client_set_line_status (EvolutionShellClient *shell_client,
- gboolean line_status)
-{
- g_assert_not_reached ();
-}
-
-
-GdkPixbuf *
-evolution_shell_client_get_pixbuf_for_type (EvolutionShellClient *shell_client,
- const char *folder_type,
- gboolean mini)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-
-GtkWidget *
-evolution_shell_client_create_storage_set_view (EvolutionShellClient *shell_client,
- Bonobo_UIComponent uic,
- Bonobo_Control *bonobo_control_iface_return,
- GNOME_Evolution_StorageSetView *storage_set_view_iface_return,
- CORBA_Environment *ev)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-
-E_MAKE_TYPE (evolution_shell_client, "EvolutionShellClient", EvolutionShellClient, class_init, init, PARENT_TYPE)
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
deleted file mode 100644
index 6ea4fddead..0000000000
--- a/shell/evolution-storage.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* evolution-storage.c
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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 "evolution-storage.h"
-
-#include "Evolution.h"
-
-#include "e-folder.h"
-#include "e-folder-tree.h"
-#include "e-shell-constants.h"
-#include "e-shell-corba-icon-utils.h"
-
-#include "e-shell-marshal.h"
-
-#include <string.h>
-#include <gal/util/e-util.h>
-#include <gtk/gtksignal.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-exception.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <glib.h>
-
-
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-static BonoboObjectClass *parent_class = NULL;
-
-struct _FolderPropertyItem {
- char *label;
- char *tooltip;
- GdkPixbuf *icon;
-};
-typedef struct _FolderPropertyItem FolderPropertyItem;
-
-struct _EvolutionStoragePrivate {
- /* Name of the storage. */
- char *name;
-
- /* Whether there are shared folders in this storage. */
- gboolean has_shared_folders;
-
- /* What we will display as the name of the storage. */
- char *display_name;
-
- /* The set of folders we have in this storage. */
- EFolderTree *folder_tree;
-
- /* Mappings from URIs to folder tree paths. */
- GHashTable *uri_to_path;
-
- /* The listener registered on this storage. */
- GList *corba_storage_listeners;
-
- /* The property items. */
- GSList *folder_property_items;
-};
-
-
-enum {
- CREATE_FOLDER,
- REMOVE_FOLDER,
- XFER_FOLDER,
- UPDATE_FOLDER,
- OPEN_FOLDER,
- DISCOVER_SHARED_FOLDER,
- CANCEL_DISCOVER_SHARED_FOLDER,
- REMOVE_SHARED_FOLDER,
- SHOW_FOLDER_PROPERTIES,
-
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
-/* Utility functions. */
-
-static void
-list_through_listener_foreach (EFolderTree *tree,
- const char *path,
- void *data,
- void *closure)
-{
- const GNOME_Evolution_Folder *corba_folder;
- GNOME_Evolution_StorageListener corba_listener;
- CORBA_Environment ev;
-
- corba_folder = (GNOME_Evolution_Folder *) data;
- corba_listener = (GNOME_Evolution_StorageListener) closure;
-
- /* The root folder has no data. */
- if (corba_folder == NULL)
- return;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_StorageListener_notifyFolderCreated (corba_listener, path, corba_folder, &ev);
- CORBA_exception_free (&ev);
-}
-
-static void
-list_through_listener (EvolutionStorage *storage,
- GNOME_Evolution_StorageListener listener,
- CORBA_Environment *ev)
-{
- EvolutionStoragePrivate *priv;
-
- priv = storage->priv;
-
- e_folder_tree_foreach (priv->folder_tree,
- list_through_listener_foreach,
- listener);
-}
-
-static GList *
-find_listener_in_list (const GNOME_Evolution_StorageListener listener,
- GList *list)
-{
- CORBA_Environment ev;
- GList *p;
-
- CORBA_exception_init (&ev);
-
- for (p = list; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener_item;
-
- listener_item = (GNOME_Evolution_StorageListener) p->data;
-
- if (CORBA_Object_is_equivalent (listener_item, listener, &ev) && ev._major == CORBA_NO_EXCEPTION)
- return p;
- }
-
- CORBA_exception_free (&ev);
-
- return NULL;
-}
-
-static gboolean
-add_listener (EvolutionStorage *storage,
- const GNOME_Evolution_StorageListener listener)
-{
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_StorageListener listener_copy;
- CORBA_Environment ev;
-
- priv = storage->priv;
-
- if (find_listener_in_list (listener, priv->corba_storage_listeners) != NULL)
- return FALSE;
-
- CORBA_exception_init (&ev);
-
- listener_copy = CORBA_Object_duplicate (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- /* Panic. */
- g_warning ("EvolutionStorage -- Cannot duplicate listener.");
- CORBA_exception_free (&ev);
-
- /* FIXME this will cause the ::add_listener implementation to
- incorrectly raise `AlreadyListening' */
- return FALSE;
- }
-
- priv->corba_storage_listeners = g_list_prepend (priv->corba_storage_listeners,
- listener_copy);
-
- list_through_listener (storage, listener_copy, &ev);
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-static gboolean
-remove_listener (EvolutionStorage *storage,
- const GNOME_Evolution_StorageListener listener)
-{
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
- GList *p;
-
- priv = storage->priv;
-
- p = find_listener_in_list (listener, priv->corba_storage_listeners);
- if (p == NULL)
- return FALSE;
-
- CORBA_exception_init (&ev);
- CORBA_Object_release ((CORBA_Object) p->data, &ev);
- CORBA_exception_free (&ev);
-
- priv->corba_storage_listeners = g_list_remove_link (priv->corba_storage_listeners, p);
-
- return TRUE;
-}
-
-
-/* Functions for the EFolderTree in the storage. */
-
-static void
-folder_destroy_notify (EFolderTree *tree,
- const char *path,
- void *data,
- void *closure)
-{
- GNOME_Evolution_Folder *corba_folder;
-
- corba_folder = (GNOME_Evolution_Folder *) data;
- CORBA_free (data);
-}
-
-
-/* CORBA interface implementation. */
-
-static CORBA_char *
-impl_Storage__get_name (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
- priv = storage->priv;
-
- return CORBA_string_dup (priv->name);
-}
-
-static CORBA_boolean
-impl_Storage__get_hasSharedFolders (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
- priv = storage->priv;
-
- return priv->has_shared_folders;
-}
-
-static GNOME_Evolution_Folder *
-impl_Storage_getFolderAtPath (PortableServer_Servant servant,
- const CORBA_char *path,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_Folder *corba_folder;
- GNOME_Evolution_Folder *return_value;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
- priv = storage->priv;
-
- corba_folder = e_folder_tree_get_folder (priv->folder_tree, path);
- if (corba_folder == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Storage_NotFound, NULL);
- return NULL;
- }
-
- /* duplicate CORBA structure */
- return_value = GNOME_Evolution_Folder__alloc ();
- return_value->type = CORBA_string_dup (corba_folder->type);
- return_value->description = CORBA_string_dup (corba_folder->description);
- return_value->displayName = CORBA_string_dup (corba_folder->displayName);
- return_value->physicalUri = CORBA_string_dup (corba_folder->physicalUri);
- return_value->evolutionUri = CORBA_string_dup (corba_folder->evolutionUri);
- return_value->customIconName = CORBA_string_dup (corba_folder->customIconName);
- return_value->unreadCount = corba_folder->unreadCount;
- return_value->canSyncOffline = corba_folder->canSyncOffline;
- return_value->sortingPriority = corba_folder->sortingPriority;
-
- return return_value;
-}
-
-static void
-get_folder_list_foreach (EFolderTree *tree,
- const char *path,
- void *data,
- void *closure)
-{
- const GNOME_Evolution_Folder *corba_folder;
- GNOME_Evolution_Folder *new_corba_folder;
- GNOME_Evolution_FolderList *folder_list;
-
- corba_folder = (GNOME_Evolution_Folder *) data;
- folder_list = (GNOME_Evolution_FolderList *) closure;
-
- if (corba_folder == NULL)
- return;
-
- new_corba_folder = folder_list->_buffer + folder_list->_length;
- new_corba_folder->displayName = CORBA_string_dup (corba_folder->displayName);
- new_corba_folder->description = CORBA_string_dup (corba_folder->description);
- new_corba_folder->type = CORBA_string_dup (corba_folder->type);
- new_corba_folder->physicalUri = CORBA_string_dup (corba_folder->physicalUri);
- new_corba_folder->evolutionUri = CORBA_string_dup (corba_folder->evolutionUri);
- new_corba_folder->unreadCount = corba_folder->unreadCount;
- new_corba_folder->sortingPriority = corba_folder->sortingPriority;
- new_corba_folder->customIconName = CORBA_string_dup (corba_folder->customIconName);
-
- folder_list->_length++;
-}
-
-static GNOME_Evolution_FolderList *
-impl_Storage__get_folderList (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_FolderList *folder_list;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
- priv = storage->priv;
-
- folder_list = GNOME_Evolution_FolderList__alloc ();
- folder_list->_maximum = e_folder_tree_get_count (priv->folder_tree);
- folder_list->_length = 0;
- folder_list->_buffer = CORBA_sequence_GNOME_Evolution_Folder_allocbuf (folder_list->_maximum);
-
- e_folder_tree_foreach (priv->folder_tree, get_folder_list_foreach, folder_list);
-
- CORBA_sequence_set_release (folder_list, TRUE);
- return folder_list;
-}
-
-static void
-impl_Storage_asyncCreateFolder (PortableServer_Servant servant,
- const CORBA_char *path,
- const CORBA_char *type,
- const CORBA_char *description,
- const CORBA_char *parent_physical_uri,
- const Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- CORBA_Object obj_dup;
- EvolutionStorage *storage;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[CREATE_FOLDER], 0,
- obj_dup, path, type, description, parent_physical_uri);
-}
-
-
-static void
-impl_Storage_asyncRemoveFolder (PortableServer_Servant servant,
- const CORBA_char *path,
- const CORBA_char *physical_uri,
- const Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- CORBA_Object obj_dup;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[REMOVE_FOLDER], 0,
- obj_dup, path, physical_uri);
-}
-
-static void
-impl_Storage_asyncXferFolder (PortableServer_Servant servant,
- const CORBA_char *source_path,
- const CORBA_char *destination_path,
- const CORBA_boolean remove_source,
- const Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- CORBA_Object obj_dup;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[XFER_FOLDER], 0,
- obj_dup, source_path, destination_path, remove_source);
-}
-
-static void
-impl_Storage_updateFolder (PortableServer_Servant servant,
- const CORBA_char *path,
- CORBA_long unread_count,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStoragePrivate *priv;
- EvolutionStorage *storage;
- GList *p;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- g_signal_emit (storage, signals[UPDATE_FOLDER], 0,
- path, unread_count);
-
- priv = storage->priv;
-
- if (priv->corba_storage_listeners == NULL)
- return;
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
- CORBA_Environment my_ev;
-
- CORBA_exception_init (&my_ev);
-
- listener = p->data;
- GNOME_Evolution_StorageListener_notifyFolderUpdated (listener, path,
- unread_count, &my_ev);
-
- CORBA_exception_free (&my_ev);
- }
-}
-
-static void
-impl_Storage_asyncOpenFolder (PortableServer_Servant servant,
- const CORBA_char *path,
- Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- CORBA_Object obj_dup;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[OPEN_FOLDER], 0,
- obj_dup, path);
-}
-
-static void
-impl_Storage_asyncDiscoverSharedFolder (PortableServer_Servant servant,
- const CORBA_char *user,
- const CORBA_char *folder_name,
- Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- CORBA_Object obj_dup;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[DISCOVER_SHARED_FOLDER], 0,
- obj_dup, user, folder_name);
-}
-
-static void
-impl_Storage_cancelDiscoverSharedFolder (PortableServer_Servant servant,
- const CORBA_char *user,
- const CORBA_char *folder_name,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- g_signal_emit (storage, signals[CANCEL_DISCOVER_SHARED_FOLDER], 0,
- user, folder_name);
-}
-
-static void
-impl_Storage_asyncRemoveSharedFolder (PortableServer_Servant servant,
- const CORBA_char *path,
- const Bonobo_Listener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
- CORBA_Object obj_dup;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- obj_dup = CORBA_Object_duplicate (listener, ev);
- g_signal_emit (storage, signals[REMOVE_SHARED_FOLDER], 0,
- obj_dup, path);
-}
-
-static void
-impl_Storage_addListener (PortableServer_Servant servant,
- const GNOME_Evolution_StorageListener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- if (! add_listener (storage, listener))
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Storage_AlreadyListening, NULL);
-}
-
-static void
-impl_Storage_removeListener (PortableServer_Servant servant,
- const GNOME_Evolution_StorageListener listener,
- CORBA_Environment *ev)
-{
- BonoboObject *bonobo_object;
- EvolutionStorage *storage;
-
- bonobo_object = bonobo_object_from_servant (servant);
- storage = EVOLUTION_STORAGE (bonobo_object);
-
- if (! remove_listener (storage, listener))
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Storage_NotFound, NULL);
-}
-
-static void
-impl_Storage_showFolderProperties (PortableServer_Servant servant,
- const CORBA_char *path,
- const CORBA_short item_number,
- const CORBA_long parent_window_id,
- CORBA_Environment *ev)
-{
- EvolutionStorage *storage;
-
- storage = EVOLUTION_STORAGE (bonobo_object_from_servant (servant));
- g_signal_emit (storage, signals[SHOW_FOLDER_PROPERTIES], 0,
- path, item_number, parent_window_id);
-}
-
-static GNOME_Evolution_Storage_FolderPropertyItemList *
-impl_Storage__get_folderPropertyItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_Storage_FolderPropertyItemList *list;
- GSList *p;
- int count;
- int i;
-
- storage = EVOLUTION_STORAGE (bonobo_object_from_servant (servant));
- priv = storage->priv;
-
- count = g_slist_length (priv->folder_property_items);
-
- list = GNOME_Evolution_Storage_FolderPropertyItemList__alloc ();
- list->_length = list->_maximum = count;
- list->_buffer = CORBA_sequence_GNOME_Evolution_Storage_FolderPropertyItem_allocbuf (list->_maximum);
-
- for (i = 0, p = priv->folder_property_items; p != NULL; i ++, p = p->next) {
- const FolderPropertyItem *item;
-
- item = (const FolderPropertyItem *) p->data;
-
- list->_buffer[i].label = CORBA_string_dup (item->label);
- list->_buffer[i].tooltip = CORBA_string_dup (item->tooltip);
- e_store_corba_icon_from_pixbuf (item->icon, & list->_buffer[i].icon);
- }
-
- CORBA_sequence_set_release (list, TRUE);
-
- return list;
-}
-
-
-/* GObject methods. */
-
-static void
-free_mapping (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
- g_free (value);
-}
-
-static void
-impl_dispose (GObject *object)
-{
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
- GList *p;
-
- storage = EVOLUTION_STORAGE (object);
- priv = storage->priv;
-
- CORBA_exception_init (&ev);
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
-
- listener = p->data;
-
- GNOME_Evolution_StorageListener_notifyDestroyed (listener, &ev);
-
- /* (This is not a Bonobo object, so no unref.) */
- CORBA_Object_release (listener, &ev);
- }
-
- g_list_free (priv->corba_storage_listeners);
- priv->corba_storage_listeners = NULL;
-
- CORBA_exception_free (&ev);
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EvolutionStorage *storage;
- EvolutionStoragePrivate *priv;
- GSList *sp;
-
- storage = EVOLUTION_STORAGE (object);
- priv = storage->priv;
-
- g_free (priv->name);
- if (priv->folder_tree != NULL)
- e_folder_tree_destroy (priv->folder_tree);
- if (priv->uri_to_path != NULL) {
- g_hash_table_foreach (priv->uri_to_path, free_mapping, NULL);
- g_hash_table_destroy (priv->uri_to_path);
- }
-
- for (sp = priv->folder_property_items; sp != NULL; sp = sp->next) {
- FolderPropertyItem *item;
-
- item = (FolderPropertyItem *) sp->data;
-
- g_free (item->label);
- g_free (item->tooltip);
- if (item->icon != NULL)
- g_object_unref (item->icon);
- g_free (item);
- }
- g_slist_free (priv->folder_property_items);
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-static void
-evolution_storage_class_init (EvolutionStorageClass *klass)
-{
- POA_GNOME_Evolution_Storage__epv *epv;
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- epv = & klass->epv;
- epv->_get_name = impl_Storage__get_name;
- epv->_get_hasSharedFolders = impl_Storage__get_hasSharedFolders;
- epv->getFolderAtPath = impl_Storage_getFolderAtPath;
- epv->_get_folderList = impl_Storage__get_folderList;
- epv->asyncCreateFolder = impl_Storage_asyncCreateFolder;
- epv->asyncRemoveFolder = impl_Storage_asyncRemoveFolder;
- epv->asyncXferFolder = impl_Storage_asyncXferFolder;
- epv->asyncOpenFolder = impl_Storage_asyncOpenFolder;
- epv->updateFolder = impl_Storage_updateFolder;
- epv->asyncDiscoverSharedFolder = impl_Storage_asyncDiscoverSharedFolder;
- epv->cancelDiscoverSharedFolder = impl_Storage_cancelDiscoverSharedFolder;
- epv->asyncRemoveSharedFolder = impl_Storage_asyncRemoveSharedFolder;
- epv->addListener = impl_Storage_addListener;
- epv->removeListener = impl_Storage_removeListener;
- epv->showFolderProperties = impl_Storage_showFolderProperties;
- epv->_get_folderPropertyItems = impl_Storage__get_folderPropertyItems;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
-
- signals[CREATE_FOLDER]
- = g_signal_new ("create_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, create_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, 5,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- signals[REMOVE_FOLDER]
- = g_signal_new ("remove_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, remove_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING_STRING,
- G_TYPE_NONE, 3,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- signals[XFER_FOLDER]
- = g_signal_new ("xfer_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, xfer_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING_STRING_BOOL,
- G_TYPE_NONE, 4,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN);
-
- signals[UPDATE_FOLDER]
- = g_signal_new ("update_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EvolutionStorageClass, update_folder),
- NULL, NULL,
- e_shell_marshal_NONE__STRING_INT,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_INT);
-
- signals[OPEN_FOLDER]
- = g_signal_new ("open_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, open_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER,
- G_TYPE_STRING);
-
- signals[DISCOVER_SHARED_FOLDER]
- = g_signal_new ("discover_shared_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, discover_shared_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING_STRING,
- G_TYPE_NONE, 3,
- G_TYPE_POINTER,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- signals[CANCEL_DISCOVER_SHARED_FOLDER]
- = g_signal_new ("cancel_discover_shared_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, cancel_discover_shared_folder),
- NULL, NULL,
- e_shell_marshal_NONE__STRING_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- signals[REMOVE_SHARED_FOLDER]
- = g_signal_new ("remove_shared_folder",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, remove_shared_folder),
- NULL, NULL,
- e_shell_marshal_NONE__POINTER_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER,
- G_TYPE_STRING);
-
- signals[SHOW_FOLDER_PROPERTIES]
- = g_signal_new ("show_folder_properties",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EvolutionStorageClass, show_folder_properties),
- NULL, NULL,
- e_shell_marshal_NONE__STRING_INT_INT,
- G_TYPE_NONE, 3,
- G_TYPE_STRING,
- G_TYPE_INT,
- G_TYPE_INT);
-}
-
-static void
-evolution_storage_init (EvolutionStorage *storage)
-{
- EvolutionStoragePrivate *priv;
-
- priv = g_new (EvolutionStoragePrivate, 1);
- priv->name = NULL;
- priv->has_shared_folders = FALSE;
- priv->folder_tree = e_folder_tree_new (folder_destroy_notify, storage);
- priv->uri_to_path = g_hash_table_new (g_str_hash, g_str_equal);
- priv->corba_storage_listeners = NULL;
- priv->folder_property_items = NULL;
-
- storage->priv = priv;
-}
-
-
-void
-evolution_storage_construct (EvolutionStorage *storage,
- const char *name,
- gboolean has_shared_folders)
-{
- EvolutionStoragePrivate *priv;
-
- g_return_if_fail (EVOLUTION_IS_STORAGE (storage));
- g_return_if_fail (name != NULL);
- g_return_if_fail (name[0] != '\0');
-
- priv = storage->priv;
- priv->name = g_strdup (name);
- priv->has_shared_folders = !! has_shared_folders;
-}
-
-EvolutionStorage *
-evolution_storage_new (const char *name,
- gboolean has_shared_folders)
-{
- EvolutionStorage *new;
-
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (name[0] != '\0', NULL);
-
- new = g_object_new (evolution_storage_get_type (), 0);
-
- evolution_storage_construct (new, name, has_shared_folders);
-
- return new;
-}
-
-void
-evolution_storage_rename (EvolutionStorage *evolution_storage,
- const char *new_name)
-{
- /* FIXME: Implement me */
-}
-
-EvolutionStorageResult
-evolution_storage_register (EvolutionStorage *evolution_storage,
- GNOME_Evolution_StorageRegistry corba_storage_registry)
-{
- EvolutionStorageResult result;
- GNOME_Evolution_StorageListener corba_storage_listener;
- GNOME_Evolution_Storage corba_storage;
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (corba_storage_registry != CORBA_OBJECT_NIL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- if (priv->corba_storage_listeners != NULL)
- return EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED;
-
- CORBA_exception_init (&ev);
-
- corba_storage = bonobo_object_corba_objref (BONOBO_OBJECT (evolution_storage));
- corba_storage_listener = GNOME_Evolution_StorageRegistry_addStorage (corba_storage_registry,
- corba_storage,
- priv->name,
- &ev);
-
- if (ev._major == CORBA_NO_EXCEPTION) {
- add_listener (evolution_storage, corba_storage_listener);
- result = EVOLUTION_STORAGE_OK;
- } else {
- if (ev._major != CORBA_USER_EXCEPTION)
- result = EVOLUTION_STORAGE_ERROR_CORBA;
- else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageRegistry_Exists) == 0)
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
- }
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-EvolutionStorageResult
-evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
- GNOME_Evolution_Shell corba_shell)
-{
- GNOME_Evolution_StorageRegistry corba_storage_registry;
- EvolutionStorageResult result;
- CORBA_Environment ev;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (corba_shell != CORBA_OBJECT_NIL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- CORBA_exception_init (&ev);
-
- corba_storage_registry = Bonobo_Unknown_queryInterface (corba_shell,
- "IDL:GNOME/Evolution/StorageRegistry:" BASE_VERSION,
- &ev);
- if (corba_storage_registry == CORBA_OBJECT_NIL || ev._major != CORBA_NO_EXCEPTION) {
- CORBA_exception_free (&ev);
- return EVOLUTION_STORAGE_ERROR_NOREGISTRY;
- }
-
- result = evolution_storage_register (evolution_storage, corba_storage_registry);
-
- Bonobo_Unknown_unref (corba_storage_registry, &ev);
- CORBA_Object_release (corba_storage_registry, &ev);
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-EvolutionStorageResult
-evolution_storage_deregister_on_shell (EvolutionStorage *evolution_storage,
- GNOME_Evolution_Shell corba_shell)
-{
- GNOME_Evolution_StorageRegistry corba_storage_registry;
- EvolutionStorageResult result;
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (corba_shell != CORBA_OBJECT_NIL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- CORBA_exception_init (&ev);
-
- corba_storage_registry = Bonobo_Unknown_queryInterface (corba_shell,
- "IDL:GNOME/Evolution/StorageRegistry:" BASE_VERSION,
- &ev);
- if (corba_storage_registry == CORBA_OBJECT_NIL || ev._major != CORBA_NO_EXCEPTION) {
- CORBA_exception_free (&ev);
- return EVOLUTION_STORAGE_ERROR_NOREGISTRY;
- }
-
- GNOME_Evolution_StorageRegistry_removeStorageByName (corba_storage_registry,
- priv->name,
- &ev);
-
- if (ev._major == CORBA_NO_EXCEPTION)
- result = EVOLUTION_STORAGE_OK;
- else {
- if (ev._major != CORBA_USER_EXCEPTION)
- result = EVOLUTION_STORAGE_ERROR_CORBA;
- else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageRegistry_NotFound) == 0)
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
- }
-
- /* Now unref the EvolutionStorage */
- bonobo_object_unref (BONOBO_OBJECT (evolution_storage));
-
- Bonobo_Unknown_unref (corba_storage_registry, &ev);
- CORBA_Object_release (corba_storage_registry, &ev);
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-static char *
-make_full_uri (EvolutionStorage *storage,
- const char *path)
-{
- const char *storage_name;
- char *full_path;
-
- storage_name = storage->priv->name;
-
- if (strcmp (path, E_PATH_SEPARATOR_S) == 0)
- full_path = g_strconcat (E_SHELL_URI_PREFIX,
- E_PATH_SEPARATOR_S, storage_name,
- NULL);
- else if (! g_path_is_absolute (path))
- full_path = g_strconcat (E_SHELL_URI_PREFIX,
- E_PATH_SEPARATOR_S, storage_name,
- E_PATH_SEPARATOR_S, path, NULL);
- else
- full_path = g_strconcat (E_SHELL_URI_PREFIX,
- E_PATH_SEPARATOR_S, storage_name,
- path, NULL);
-
- return full_path;
-}
-
-EvolutionStorageResult
-evolution_storage_new_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- const char *type,
- const char *physical_uri,
- const char *description,
- const char *custom_icon_name,
- int unread_count,
- gboolean can_sync_offline,
- int sorting_priority)
-{
- EvolutionStorageResult result;
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_Folder *corba_folder;
- CORBA_Environment ev;
- GList *p;
- char *evolutionUri;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (path != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (g_path_is_absolute (path), EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (display_name != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (type != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (physical_uri != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- if (description == NULL)
- description = "";
-
- priv = evolution_storage->priv;
-
- CORBA_exception_init (&ev);
-
- corba_folder = GNOME_Evolution_Folder__alloc ();
- corba_folder->displayName = CORBA_string_dup (display_name);
- corba_folder->description = CORBA_string_dup (description);
- corba_folder->type = CORBA_string_dup (type);
- corba_folder->physicalUri = CORBA_string_dup (physical_uri);
- corba_folder->canSyncOffline = (CORBA_boolean) can_sync_offline;
- corba_folder->sortingPriority = sorting_priority;
-
- if (custom_icon_name != NULL)
- corba_folder->customIconName = CORBA_string_dup (custom_icon_name);
- else
- corba_folder->customIconName = CORBA_string_dup ("");
-
- evolutionUri = make_full_uri (evolution_storage, path);
- corba_folder->evolutionUri = CORBA_string_dup (evolutionUri);
- g_free (evolutionUri);
-
- corba_folder->unreadCount = unread_count;
-
- if (! e_folder_tree_add (priv->folder_tree, path, corba_folder)) {
- CORBA_free (corba_folder);
- return EVOLUTION_STORAGE_ERROR_EXISTS;
- }
- g_hash_table_insert (priv->uri_to_path, g_strdup (physical_uri), g_strdup (path));
-
- result = EVOLUTION_STORAGE_OK;
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
-
- listener = p->data;
- GNOME_Evolution_StorageListener_notifyFolderCreated (listener, path, corba_folder, &ev);
-
- if (ev._major == CORBA_NO_EXCEPTION)
- continue;
-
- if (ev._major != CORBA_USER_EXCEPTION)
- result = EVOLUTION_STORAGE_ERROR_CORBA;
- else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageListener_Exists) == 0)
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
-
- break;
- }
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-EvolutionStorageResult
-evolution_storage_update_folder (EvolutionStorage *evolution_storage,
- const char *path,
- int unread_count)
-{
- EvolutionStorageResult result;
- EvolutionStoragePrivate *priv;
- GNOME_Evolution_Folder *corba_folder;
- GList *p;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (path != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (g_path_is_absolute (path), EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- g_signal_emit (evolution_storage, signals[UPDATE_FOLDER], 0,
- path, unread_count);
-
- if (priv->corba_storage_listeners == NULL)
- return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
-
- result = EVOLUTION_STORAGE_OK;
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- listener = p->data;
- GNOME_Evolution_StorageListener_notifyFolderUpdated (listener, path, unread_count, &ev);
-
- CORBA_exception_free (&ev);
- }
-
- if (result == EVOLUTION_STORAGE_OK) {
- corba_folder = e_folder_tree_get_folder (priv->folder_tree, path);
- if (corba_folder != NULL)
- corba_folder->unreadCount = unread_count;
- else
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- }
-
- return result;
-}
-
-EvolutionStorageResult
-evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage,
- const char *physical_uri,
- int unread_count)
-{
- EvolutionStoragePrivate *priv;
- char *path;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (physical_uri != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- path = g_hash_table_lookup (priv->uri_to_path, physical_uri);
- return evolution_storage_update_folder (evolution_storage, path, unread_count);
-}
-
-EvolutionStorageResult
-evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
- const char *path)
-{
- EvolutionStorageResult result;
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Folder *corba_folder;
- gpointer key, value;
- GList *p;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (path != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (g_path_is_absolute (path), EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- if (priv->corba_storage_listeners == NULL)
- return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
-
- corba_folder = e_folder_tree_get_folder (priv->folder_tree, path);
- if (corba_folder == NULL)
- return EVOLUTION_STORAGE_ERROR_NOTFOUND;
- if (g_hash_table_lookup_extended (priv->uri_to_path, corba_folder->physicalUri, &key, &value)) {
- g_hash_table_remove (priv->uri_to_path, key);
- g_free (key);
- g_free (value);
- }
- e_folder_tree_remove (priv->folder_tree, path);
-
- CORBA_exception_init (&ev);
-
- result = EVOLUTION_STORAGE_OK;
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
-
- listener = p->data;
- GNOME_Evolution_StorageListener_notifyFolderRemoved (listener, path, &ev);
-
- if (ev._major == CORBA_NO_EXCEPTION)
- continue;
-
- if (ev._major != CORBA_USER_EXCEPTION)
- result = EVOLUTION_STORAGE_ERROR_CORBA;
- else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageListener_NotFound) == 0)
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
-
- break;
- }
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-gboolean
-evolution_storage_folder_exists (EvolutionStorage *evolution_storage,
- const char *path)
-{
- EvolutionStoragePrivate *priv;
-
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (path != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (g_path_is_absolute (path), EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- return e_folder_tree_get_folder (priv->folder_tree, path) != NULL;
-}
-
-EvolutionStorageResult
-evolution_storage_has_subfolders (EvolutionStorage *evolution_storage,
- const char *path,
- const char *message)
-{
- EvolutionStorageResult result;
- EvolutionStoragePrivate *priv;
- CORBA_Environment ev;
- GList *p;
-
- g_return_val_if_fail (evolution_storage != NULL,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (path != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (g_path_is_absolute (path), EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
- g_return_val_if_fail (message != NULL, EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
-
- priv = evolution_storage->priv;
-
- if (priv->corba_storage_listeners == NULL)
- return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
-
- CORBA_exception_init (&ev);
-
- result = EVOLUTION_STORAGE_OK;
-
- for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
- GNOME_Evolution_StorageListener listener;
-
- listener = p->data;
- GNOME_Evolution_StorageListener_notifyHasSubfolders (listener, path, message, &ev);
-
- if (ev._major == CORBA_NO_EXCEPTION)
- continue;
- if (ev._major != CORBA_USER_EXCEPTION)
- result = EVOLUTION_STORAGE_ERROR_CORBA;
- else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageListener_NotFound) == 0)
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
-
- break;
- }
-
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-
-/* Setting up property items. */
-
-void
-evolution_storage_add_property_item (EvolutionStorage *evolution_storage,
- const char *label,
- const char *tooltip,
- GdkPixbuf *icon)
-{
- FolderPropertyItem *item;
-
- g_return_if_fail (EVOLUTION_IS_STORAGE (evolution_storage));
- g_return_if_fail (label != NULL);
-
- item = g_new (FolderPropertyItem, 1);
- item->label = g_strdup (label);
- item->tooltip = g_strdup (tooltip);
- item->icon = icon;
- if (icon != NULL)
- g_object_ref (icon);
-
- evolution_storage->priv->folder_property_items = g_slist_append (evolution_storage->priv->folder_property_items,
- item);
-}
-
-
-BONOBO_TYPE_FUNC_FULL (EvolutionStorage,
- GNOME_Evolution_Storage,
- PARENT_TYPE,
- evolution_storage)