Files
evolution/shell/e-shell-folder-commands.c
Ettore Perazzoli 8691f8584f Renamed from GNOME_Evolution_Shell.oaf.in.
* GNOME_Evolution_Shell.server.in: Renamed from
GNOME_Evolution_Shell.oaf.in.

* Makefile.am: Port from OAF to bonobo-activation.
(INCLUDES): Define SYSCONFDIR, DATADIR, LIBDIR.

* main.c (main): Use gnome_program_init().

* e-corba-storage-registry.c (e_corba_storage_registry_new):
g_object_new(), not gtk_type_new().
(impl_finalize): New, ported over from destroy.
(destroy): Removed.
(class_init): Install finalize handler, not destroy handler, since
we are not a GtkObject anymore.

* e-corba-storage.c (e_corba_storage_new): g_object_new(), not
gtk_type_new().

* e-shell.c (class_init): Override finalize, not destroy.
(impl_finalize): Finalize implementation, basically the old
destroy renamed.
(e_shell_new): g_object_new(), not gtk_type_new().
(class_init): Use e_shell_marshal_NONE__INT for
line_status_changed instead of using an ENUM.
(e_shell_construct): Use g_signal_connect_object() instead of
gtk_signal_connect_while_alive().

* e-setup.c (e_setup): Do not unref local_folder if NULL.

* e-folder.c (init): Make not floating.
(e_folder_construct): No need to make it floating here anymore.

* e-shell.c (impl_Shell_selectUserFolder): For now don't set
dialog parent from xid.

* main.c (no_views_left_cb): Add missing GTK_SIGNAL_FUNC() cast.
(new_view_created_callback): Likewise.
(warning_dialog_clicked_callback): Update to use the
EConfigListener from the shell instead of bonobo-conf.
(show_development_warning): Likewise.
(upgrade_from_1_0_if_needed): BONOBO_EX_ID -> BONOBO_EX_REPOID.
(idle_cb): Use bonobo-activation and BONOBO_EX_REPOID().
(main): Cleaned up the various things that are unneeded in GNOME
2.
(upgrade_from_1_0_if_needed): Use EConfigListener.

* evolution-storage-set-view.h, evolution-storage-set-view.c:
BonoboXObjectified.

* e-storage.c (class_init): GLIB2-ified and made to use
e-shell-marshal.h.
(ES_CLASS): Use GTK_OBJECT_GET_CLASS().
(e_storage_new_folder): Added missing GTK_SIGNAL_FUNC() prototype.

* e-storage-set.c (class_init): GLIB2-ified and made to use
e-shell-marshal.h.

* e-storage-set-view.c (popup_folder_menu): For now, do not add
the pop-up since we lack bonobo_ui_container_get_win() and I am
not sure how to work around it.
(popup_folder_menu): Pass self as the for_widget arg to
gnome_popup_menu_do_popup_modal().
(class_init): GLIB2-ified, and got to use e-shell-marshal.h.
(marshal_NONE__GDKDRAGCONTEXT_STRING_STRING_STRING): Removed.
(impl_tree_drag_data_get): Don't set the selection for now -- we
have to fix the CORBA target stuff to match GTK 2.
(e_storage_set_view_construct): Pass NULL as the opt_ev arg to
bonobo_ui_component_set_container().

* e-splash.c: #include <libgnomecanvas/gnome-canvas-pixbuf.h>
instead of <gdk-pixbuf/gnome-canvas-pixbuf.h>.
(e_splash_new): Pass NULL as the error arg to
gdk_pixbuf_new_from_file().

* e-shortcuts.c (class_init): GLIB2-ified.  Also use the
e-shell-marshal marshallers.
(e_shortcuts_new_view): Add missing GTK_SIGNAL_FUNC() cast.

* e-shortcuts-view.c: Use GTK_STOCK_* stuff instead of
GNOME_STOCK_* stuff.
(pop_up_right_click_menu_for_group): Pass self as the for_widget
arg to gnome_popup_menu_do_popup_modal().
(pop_up_right_click_menu_for_shortcut): Likewise.
(class_init): GLIB2-ified.

* e-shell.c: Do not #include <gal/util/e-unicode-i18n.h> or
#include <libgnome/gnome-defs.h>.
(set_interactive): Use BONOBO_EX_REPOID().
(setup_local_storage): Use _() not U_().
(destroy): Use gtk_widget_destroy() instead of
gtk_object_destroy() on priv->settings_dialog.
(class_init): GLIB2-ized.
(init): Initialize config_listener member.
(get_icon_path_for_component_info): Port to bonobo-activation from
OAF.
(setup_components): Likewise.
(destroy): Likewise.
(e_shell_construct): Use e_setup_check_config(), not
e_setup_check_db ().  Use the e_config_listener instead of
bonobo-conf.
(save_settings_for_views): Likewise.
(save_misc_settings): Likewise.
(e_shell_restore_from_settings): Likewise.
(parse_default_uri): Likewise.
(e_shell_component_maybe_crashed): Pass NULL for opt_ev arg to
bonobo_unkown_ping()
(e_shell_component_maybe_crashed): Use
bonobo_engine_deregister_dead_components() instead of
bonobo_window_deregister_component_by_ref() which is no more.
(e_shell_send_receive): BONOBO_EX_REPOID() instead of
BONOBO_EX_ID().
(e_shell_get_config_listener): Return the config_listener.

* e-shell-view.c (find_inbox_in_storage): Use _() instead of U_().
(load_images): Pass NULL as the error arg to
gdk_pixbuf_new_from_file().
(load_images): Likewise.
(find_inbox_in_storage): Work around the lack of
g_utf8_strcasecmp() in glib-2.0.
(class_init): GLIB2-ified.  Also, use the marshallers in
e-shell-marshal.h.
(pop_up_folder_bar): Use gtk_window_move()/gtk_widget_show()
instead gtk_widget_popup().
(unmerge_on_error): Work around the death of
bonobo_ui_component_get_win() and
bonobo_window_deregister_component_by_ref().
(e_shell_view_construct): Pass NULL as the uic arg to
bonobo_window_construct().  Add missing GTK_SIGNAL_FUNC() cast.
Match the new BonoboWindow behavior wrt the UIContainer and the
new opt_ev args.
(display_uri): Use bonobo_ui_engine_freeze() and
bonobo_ui_engine_thaw() since bonobo_window_freeze() and
bonobo_window_thaw() got axed [sigh].
(e_shell_view_save_settings): Use EConfigListener.
(e_shell_view_load_settings): Likewise.
(get_view_for_uri): Use bonobo_widget_new_control_from_objref()
instead of e_bonobo_widget_new_control_from_objref().

* e-shell-view-menu.c (command_help_faq): Pass NULL for the error
arg to gnome_url_show().
(command_about_box): Use GtkDialog instead of a GtkWindow of a
type GTK_WINDOW_DIALOG [which does not exist anymore].
(command_xml_dump): Removed.
(menu_do_misc): Do not add the corresponding verb.

* e-shell-user-creatable-items-handler.c (execute_verb): Use
BONOBO_EX_REPOID().

* e-shell-startup-wizard.c: Remove id member from SWData.  Replace
member db with config_listener.
(e_shell_startup_wizard_create): Initialize config_listener.
(make_mail_dialog_pages): Do not set the listener id here.
(druid_event_notify_cb): Pass FALSE as the help_sensitive arg to
gnome_druid_set_buttons_sensitive().
(e_shell_startup_wizard_create): Likewise.
(make_mail_dialog_pages): Use bonobo-activation instead of OAF.
(get_intelligent_importers): Likewise.
(prepare_importer_page): Likewise.
(start_importers): Do nothing here for now.
(finish_func): Constify local variable displayname.
(finish_func): Updated to use the config_listener instead of the
bono-conf db.
(prepare_importer_page): Do not actually run the importer yet.
(e_shell_startup_wizard_create): Pass NULL as the domain arg to
glade_xml_new().  Use the config_listener.

* e-shell-shared-folder-picker-dialog.c (user_clicked):
BONOBO_EX_REPOID() instead of BONOBO_EX_ID().
(setup_name_selector): Likewise.
(setup_name_selector): Use bonobo-activation.
(show_dialog): Pass NULL as the domain arg to glade_xml_new().
(setup_name_selector): Add a missing GTK_SIGNAL_FUNC() cast.

* e-shell-settings-dialog.c: #include
<bonobo-activation/bonobo-activation.h>.  Use
Bonobo_ActivationProperty instead of OAF_Property.
(set_dialog_size): Use gtk_style_get_font() to get the font from
the widget->style.
(load_pages): Converted to use bonobo-activation instead of OAF.
Pass NULL as the error arg to gdk_pixbuf_new_from_file().

* e-shell-offline-sync.c (sync_folder): BONOBO_EX_REPOID(), not
BONOBO_EX_ID().
(e_shell_offline_sync_all_folders): For now, avoid doing anything
[see changes to e-shell-config-offline.c below].
(setup_progress_listener): #if 0 for now.
(setup_dialog): Likewise.
(sync_folder): Likewise.
(cleanup): Likewise.
(progress_listener_servant_free): Likewise.
(progress_listener_servant_new): Likewise.
(impl_SyncFolderProgressListener_updateProgress): Likewise.
(impl_SyncFolderProgressListener_reportSuccess): Likewise.
(impl_SyncFolderProgressListener_reportFailure): Likewise.
(progress_dialog_close_callback): Likewise.
(progress_dialog_clicked_callback): Likewise.

* e-shell-offline-handler.c (prepare_for_offline): Use
BONOBO_EX_REPOID().
(pop_up_confirmation_dialog): Pass NULL as the domain arg to
glade_xml_new().
(class_init): GLIB2-ified.

* Makefile.am: Do not compile e-shell-importer.c,
e-shell-importer.h for now.

* e-shell-folder-title-bar.c (get_max_clipped_label_width): Use
gtk_style_get_font() to retrieve the font.
(class_init): GLIB2-ified.
(e_shell_folder_title_bar_construct): Get {x,y}thickness from
widget->style, not from widget->style->klass.

* e-shell-folder-selection-dialog.c: #include <string.h>,
<gtk/gtklabel.h> and <gtk/gtksignal.h>.
(class_init): GLIB2-ified.

* e-shell-folder-creation-dialog.c: No <libgnome/gnome-defs.h>,
add some GTK includes.
(e_shell_show_folder_creation_dialog): Pass NULL as the domain arg
to glade_xml_new().  Added missing GTK_SIGNAL_FUNC() cast.

* e-shell-folder-commands.c: Do not #include
<libgnomeui/gnome-stock.h> and #include
<bonobo-conf/Bonobo_Config.h>.

* e-shell-config-default-folders.c: Replace member db in
EvolutionDefaultFolderConfig with config_listener.
(e_shell_config_default_folders_create_widget): Init here.
(config_control_destroy_cb): Unref here.
(config_control_apply_cb): Use EConfigListener instead of
BonoboConf.
(setup_folder_selector): Likewise.
(e_shell_config_default_folders_create_widget): Pass NULL as the
domain arg to glade_xml_new().

* e-shell-config-offline.c (config_control_apply_callback): For
now, do not change the configuration.  [Needs to be ported to
EConfigListener or something, but we were storing a sequence using
typecodes here and there is no trivial way to do that right now.]
(init_storage_set_view_status_from_config): Likewise, do not
retrieve the configuration here.

svn path=/trunk/; revision=18510
2002-11-03 16:43:18 +00:00

654 lines
18 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* -*- 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-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 <gal/widgets/e-gui-utils.h>
#include <gal/widgets/e-unicode.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-dialog.h>
#include <gtk/gtklabel.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkentry.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) {
char *msg;
if (folder_command_data->command == FOLDER_COMMAND_COPY)
msg = g_strdup_printf (_("Cannot copy folder: %s"),
e_storage_result_to_string (result));
else
msg = g_strdup_printf (_("Cannot move folder: %s"),
e_storage_result_to_string (result));
e_notice (GTK_WINDOW (folder_command_data->shell_view),
GNOME_MESSAGE_BOX_ERROR, msg);
g_free (msg);
}
folder_command_data_free (folder_command_data);
}
/* The signals for the folder selection dialog. This used for the copy and
move commands. */
static void
folder_selection_dialog_folder_selected_callback (EShellFolderSelectionDialog *folder_selection_dialog,
const char *path,
void *data)
{
FolderCommandData *folder_command_data;
EStorageSet *storage_set;
gboolean remove_source;
folder_command_data = (FolderCommandData *) data;
folder_command_data->destination_path = g_concat_dir_and_file (path,
g_basename (folder_command_data->source_path));
switch (folder_command_data->command) {
case FOLDER_COMMAND_COPY:
remove_source = FALSE;
break;
case FOLDER_COMMAND_MOVE:
remove_source = TRUE;
break;
default:
g_assert_not_reached ();
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 (GTK_WINDOW (folder_selection_dialog), GNOME_MESSAGE_BOX_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 (GTK_WINDOW (folder_selection_dialog), GNOME_MESSAGE_BOX_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);
gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "folder_selected",
GTK_SIGNAL_FUNC (folder_selection_dialog_folder_selected_callback),
folder_command_data);
gtk_signal_connect (GTK_OBJECT (folder_selection_dialog), "cancelled",
GTK_SIGNAL_FUNC (folder_selection_dialog_cancelled_callback),
folder_command_data);
}
/* Create new folder. */
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);
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);
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 (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_ERROR,
_("Cannot delete folder:\n%s"), e_storage_result_to_string (result));
}
static int
delete_dialog (EShellView *shell_view, const char *utf8_folder)
{
GtkWidget *dialog;
char *title;
char *question;
char *folder_name;
folder_name = e_utf8_to_gtk_string (GTK_WIDGET (shell_view), (char *) utf8_folder);
title = g_strdup_printf (_("Delete \"%s\""), folder_name);
question = g_strdup_printf (_("Really delete folder \"%s\"?"), folder_name);
dialog = gnome_message_box_new (question,
GNOME_MESSAGE_BOX_QUESTION,
_("Delete"),
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_window_set_title (GTK_WINDOW (dialog), title);
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (shell_view));
gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
g_free (title);
g_free (folder_name);
g_free (question);
return gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
}
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)) == 0)
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);
gtk_object_ref (GTK_OBJECT (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)
{
gtk_object_unref (GTK_OBJECT (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 (GTK_WINDOW (callback_data->shell_view), GNOME_MESSAGE_BOX_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)
e_folder_set_name (folder, g_basename (callback_data->new_path));
}
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 *old_name_locale;
char *prompt;
char *new_name;
char *old_base_path;
char *new_path;
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));
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);
old_name_locale = e_utf8_to_locale_string (old_name);
prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), old_name_locale);
g_free (old_name_locale);
while (1) {
const char *reason;
new_name = e_request_string (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
_("Rename folder"), prompt, old_name);
if (new_name == NULL)
return;
if (e_shell_folder_name_is_valid (new_name, &reason))
break;
e_notice (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
GNOME_MESSAGE_BOX_ERROR,
_("The specified folder name is not valid: %s"), reason);
}
g_free (prompt);
if (strcmp (old_name, new_name) == 0) {
g_free (new_name);
return;
}
old_base_path = g_dirname (folder_path);
new_path = g_concat_dir_and_file (old_base_path, new_name);
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);
g_free (old_base_path);
g_free (new_path);
g_free (new_name);
}
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 (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_ERROR,
_("Selected folder does not belong to another user"));
else if (result != E_STORAGE_OK)
e_notice (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_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;
int group_num;
char *uri;
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));
else
uri = g_strconcat (E_SHELL_URI_PREFIX, folder_path, NULL);
unread_count = get_folder_unread (shell, e_shell_view_get_current_path (shell_view));
storage_set = e_shell_get_storage_set (shell);
folder = e_storage_set_get_folder (storage_set, e_shell_view_get_current_path (shell_view));
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);
}