GLib/GTK+ functions, except for a couple of places were we use
GtkCList.]
* Makefile.am (INCLUDES): Add `-DG_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED'.
* evolution-test-component.c (create_new_folder_selector): No
gtk_window_set_policy().
* main.c (quit_box_new): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(view_map_callback): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(main): No need to push the GdkRGB visual/cmap anymore.
(new_view_created_callback): Likewise.
* e-task-widget.c: Renamed member pixmap of ETaskWidgetPrivate to
`image'.
(init): Updated accordingly.
(e_task_widget_construct): Use GtkImage, not GtkPixmap.
* e-storage.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set-view.c
(setup_folder_properties_items_if_corba_storage_clicked):
g_string_append_printf() instead of g_string_sprintfa().
(class_init): Converted from gtk_signal_new() to g_signal_new().
(setup_folder_changed_callbacks): Use
e_signal_connect_while_alive() and
e_signal_connect_full_while_alive().
* e-splash.c (e_splash_construct): gtk_window_set_resizable()
instead of gtk_window_set_policy().
* e-shortcuts.c: Do not #include e-unicode.h.
(shortcut_item_update): Use g_path_get_basename() instead of
g_basename().
(e_shortcuts_add_default_shortcuts): No need to de-utfize strings.
(e_shortcuts_add_default_group): Same here.
* e-shortcuts-view.c: Do not #include <e-unicode.h>.
(class_init): Converted from gtk_signal_new() to g_signal_new().
(destroy_group_cb): No need to convert the text from UTF8.
* e-shell.c (impl_dispose): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(class_init): Use g_signal_new() instead of gtk_signal_new().
* e-shell-view.c: Do not #include e-unicode.h. Renamed member
offline_toggle_pixmap to offline_toggle_image in
EShellViewPrivate.
(update_folder_title_bar): No need to de-UTF8-ize the title.
(cleanup_delayed_selection):
g_signal_handlers_disconnect_by_func() instead of
gtk_signal_disconnect_by_func().
(ui_engine_add_hint_callback): gtk_label_set_text(), not
gtk_label_set().
(class_init): Use g_signal_new() instead of gtk_signal_new().
(update_for_current_uri): No need to convert the title from UTF8.
(setup_offline_toggle): Changed to set up a GtkImage, not a
GtkPixmap.
(update_offline_toggle_status): Accordingly (gtk_image* instead of
gtk_pixmap*).
(set_current_notebook_page): gtk_notebook_set_current_page(), not
gtk_notebook_set_page().
(get_storage_set_path_from_uri): g_ascii_strncasecmp() instead of
g_strncasecmp().
(folder_bar_popup_map_callback): Use
e_signal_connect_while_alive() instead of
gtk_signal_connect_while_alive().
(e_shell_view_construct): Likewise.
(display_uri): g_signal_connect_after() instead of
gtk_signal_connect_full().
(update_for_current_uri):
g_signal_handlers_{block,unblock}_by_func() instead of
gtk_signal_handler_{block,unblock}_by_func().
* e-shell-view-menu.c (command_about_box):
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-shell-utils.c (get_mini_name): g_path_get_basename() instead
of g_basename().
* e-shell-user-creatable-items-handler.c
(append_xml_for_menu_item): g_string_append_printf() instead of
g_string_sprintfa().
(create_menu_xml): Likewise.
* e-shell-shared-folder-picker-dialog.c: Do not #include
e-unicode.h.
(progress_bar_timeout_callback): Expect a GtkProgressBar data and
just use gtk_progress_bar_pulse().
(create_progress_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy(). No gtk_progress_set_activity_mode().
(setup_server_option_menu): Just use
gtk_menu_item_new_with_label() instead of
e_utf8_gtk_menu_item_new_with_label().
* e-shell-settings-dialog.c (set_dialog_size): Ported to Pango.
* e-shell-offline-sync.c
(impl_SyncFolderProgressListener_updateProgress):
gtk_progress_set_fraction() instead of
gtk_progress_bar_set_percentage().
(sync_folder): Likewise.
(setup_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(sync_folder): No gtk_progress_set_activity_mode().
* e-shell-offline-handler.c: #undef {G,GTK}_DISABLE_DEPRECATED
here for now (need to port from GtkCList).
(class_init): Use g_signal_new()
* e-shell-importer.c: #undef {G,GTK}_DISABLE_DEPRECATED here for
now (need to port from GtkCList).
* e-shell-folder-title-bar.c (create_image_widget_from_xpm):
Renamed from create_pixmap_widget_from_xpm(); handle GtkImage
instead of GtkPixmap.
(new_empty_image_widget): Renamed from new_empty_pixmap_widget();
return a GtkImage instead of a GtkPixmap.
(add_navigation_buttons): Updated accordingly; so use GtkImages
instead of GtkPixmaps.
(e_shell_folder_title_bar_construct): Likewise.
(e_shell_folder_title_bar_set_icon): Use gtk_image_* instead of
gtk_pixmap_* on the image widgets.
(class_init): Converted to use g_signal_new() instead of
gtk_signal_new().
(e_shell_folder_title_bar_new): No need for pushing the GdkRGB
visual/cmap anymore.
* e-shell-folder-selection-dialog.c (check_folder_type_valid):
Just use strcmp instead of strcasecmp().
(class_init): g_signal_new() instead of gtk_signal_new().
(e_shell_folder_selection_dialog_construct): Removed call to
gtk_window_set_policy().
* e-shell-folder-creation-dialog.c
(type_with_display_name_compare_func): Changed to use
g_utf8_casefold().
* e-shell-folder-commands.c: Do not #include e-unicode.h.
(e_shell_command_rename_folder): g_path_get_dirname() instead of
g_dirname().
(folder_selection_dialog_folder_selected_callback):
g_path_get_basename() instead of g_basename().
(rename_cb): Likewise.
(delete_dialog): Do not convert from UTF8 for display purposes.
(e_shell_command_rename_folder): Likewise.
* e-shell-about-box.c (timeout_callback): Ported to Pango and use
gdk_window_invalidate_rect() instead of gtk_widget_draw().
* e-setup.c (check_evolution_directory): Use
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-local-storage.c: Do not include e-unicode.h.
(create_folder): Use g_path_get_basename() instead of
g_basename().
(create_folder_directory): Likewise.
(remove_folder_directory): Likewise.
(append_xfer_item_list): Likewise.
* e-local-folder.c (construct_loading_metadata): Use
g_path_get_basename() instead of g_basename().
* e-folder-dnd-bridge.c (handle_evolution_path_drag_motion): Use
g_path_get_basename() instead of g_basename().
* e-corba-storage-registry.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-corba-shortcuts.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-component-registry.c
(sleep_with_g_main_loop_timeout_callback): g_main_loop_* instead
of g_main_*.
(sleep_with_g_main_loop): Likewise.
* e-activity-handler.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-wizard.c (evolution_wizard_class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-storage-listener.c (class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-shell-view.c (class_init): g_signal_new() instead of
gtk_signal_new().
* evolution-shell-component-dnd.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-shell-component.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-session.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-folder-selector-button.c: Do not include e-unicode.h.
(set_folder): No need to convert from UTF8 to locale encoding
anymore. Removed unused variable.
* evolution-config-control.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* evolution-activity-client.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* e-folder-list.c: Do not include e-unicode.h. Use E_MAKE_TYPE().
(e_folder_list_get_type): Removed explicit implementation of this.
(e_folder_list_set_arg): Removed.
(e_folder_list_get_arg): Removed.
(e_folder_list_set_property): New.
(e_folder_list_get_property): New.
(e_folder_list_destroy): Removed.
(e_folder_list_dispose): New.
(e_folder_list_class_init): Updated accordingly.
* e-folder.c (impl_save_info): Use G_OBJECT_TYPE_NAME() instead of
gtk_type_name().
(impl_load_info): Likewise.
(impl_remove): Likewise.
(class_init): Use g_signal_new() instead of gtk_signal_new().
svn path=/trunk/; revision=19170
488 lines
14 KiB
C
488 lines
14 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* e-folder-dnd-bridge.c - Utility functions for handling dnd to Evolution
|
||
* folders using the ShellComponentDnd interface.
|
||
*
|
||
* 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.
|
||
*
|
||
* Author: Ettore Perazzoli <ettore@ximian.com>
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "e-folder-dnd-bridge.h"
|
||
|
||
#include "Evolution.h"
|
||
#include "e-storage-set-view.h"
|
||
#include "e-shell-constants.h"
|
||
|
||
#include <gal/widgets/e-gui-utils.h>
|
||
|
||
#include <libgnome/gnome-i18n.h>
|
||
#include <libgnome/gnome-util.h>
|
||
|
||
#include <string.h>
|
||
|
||
|
||
/* Callbacks for folder operations. */
|
||
|
||
static void
|
||
folder_xfer_callback (EStorageSet *storage_set,
|
||
EStorageResult result,
|
||
void *data)
|
||
{
|
||
GtkWindow *parent;
|
||
|
||
if (result == E_STORAGE_OK)
|
||
return;
|
||
|
||
parent = GTK_WINDOW (data);
|
||
e_notice (parent, GTK_MESSAGE_ERROR, _("Cannot transfer folder:\n%s"),
|
||
e_storage_result_to_string (result));
|
||
}
|
||
|
||
|
||
/* Utility functions. */
|
||
|
||
static GNOME_Evolution_ShellComponentDnd_ActionSet
|
||
convert_gdk_drag_action_set_to_corba (GdkDragAction action)
|
||
{
|
||
GNOME_Evolution_ShellComponentDnd_Action retval;
|
||
|
||
retval = GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT;
|
||
|
||
if (action & GDK_ACTION_COPY)
|
||
retval |= GNOME_Evolution_ShellComponentDnd_ACTION_COPY;
|
||
if (action & GDK_ACTION_MOVE)
|
||
retval |= GNOME_Evolution_ShellComponentDnd_ACTION_MOVE;
|
||
if (action & GDK_ACTION_LINK)
|
||
retval |= GNOME_Evolution_ShellComponentDnd_ACTION_LINK;
|
||
if (action & GDK_ACTION_ASK)
|
||
retval |= GNOME_Evolution_ShellComponentDnd_ACTION_ASK;
|
||
|
||
return retval;
|
||
}
|
||
|
||
static GNOME_Evolution_ShellComponentDnd_ActionSet
|
||
convert_gdk_drag_action_to_corba (GdkDragAction action)
|
||
{
|
||
if (action == GDK_ACTION_COPY)
|
||
return GNOME_Evolution_ShellComponentDnd_ACTION_COPY;
|
||
else if (action == GDK_ACTION_MOVE)
|
||
return GNOME_Evolution_ShellComponentDnd_ACTION_MOVE;
|
||
else if (action == GDK_ACTION_LINK)
|
||
return GNOME_Evolution_ShellComponentDnd_ACTION_LINK;
|
||
else if (action == GDK_ACTION_ASK)
|
||
return GNOME_Evolution_ShellComponentDnd_ACTION_ASK;
|
||
else {
|
||
g_warning ("Unknown GdkDragAction %d", action);
|
||
return GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT;
|
||
}
|
||
}
|
||
|
||
static GdkDragAction
|
||
convert_corba_drag_action_to_gdk (GNOME_Evolution_ShellComponentDnd_ActionSet action)
|
||
{
|
||
if (action == GNOME_Evolution_ShellComponentDnd_ACTION_COPY)
|
||
return GDK_ACTION_COPY;
|
||
else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE)
|
||
return GDK_ACTION_MOVE;
|
||
else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK)
|
||
return GDK_ACTION_LINK;
|
||
else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_ASK)
|
||
return GDK_ACTION_ASK;
|
||
else {
|
||
g_warning ("unknown GNOME_Evolution_ShellComponentDnd_ActionSet %d", action);
|
||
return GDK_ACTION_DEFAULT;
|
||
}
|
||
}
|
||
|
||
static EvolutionShellComponentClient *
|
||
get_component_at_path (EStorageSet *storage_set,
|
||
const char *path)
|
||
{
|
||
EvolutionShellComponentClient *component_client;
|
||
EFolderTypeRegistry *folder_type_registry;
|
||
EFolder *folder;
|
||
|
||
folder = e_storage_set_get_folder (storage_set, path);
|
||
if (folder == NULL)
|
||
return NULL;
|
||
|
||
folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
|
||
g_assert (folder_type_registry != NULL);
|
||
|
||
component_client = e_folder_type_registry_get_handler_for_type (folder_type_registry,
|
||
e_folder_get_type_string (folder));
|
||
|
||
return component_client;
|
||
}
|
||
|
||
/* This will look for the targets in @drag_context, choose one that matches
|
||
with the allowed types at @path, and return its name. The EVOLUTION_PATH
|
||
type always matches. */
|
||
static const char *
|
||
find_matching_target_for_drag_context (EStorageSet *storage_set,
|
||
const char *path,
|
||
GdkDragContext *drag_context,
|
||
GdkAtom *atom_return)
|
||
{
|
||
EFolderTypeRegistry *folder_type_registry;
|
||
EFolder *folder;
|
||
GList *accepted_types;
|
||
GList *p, *q;
|
||
|
||
folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
|
||
|
||
folder = e_storage_set_get_folder (storage_set, path);
|
||
if (folder == NULL)
|
||
return E_FOLDER_DND_PATH_TARGET_TYPE;
|
||
|
||
accepted_types = e_folder_type_registry_get_accepted_dnd_types_for_type (folder_type_registry,
|
||
e_folder_get_type_string (folder));
|
||
|
||
for (p = drag_context->targets; p != NULL; p = p->next) {
|
||
char *possible_type;
|
||
|
||
possible_type = gdk_atom_name (*((GdkAtom *) p->data));
|
||
if (strcmp (possible_type, E_FOLDER_DND_PATH_TARGET_TYPE) == 0) {
|
||
g_free (possible_type);
|
||
|
||
if (atom_return != NULL)
|
||
*atom_return = *((GdkAtom *) p->data);
|
||
|
||
return E_FOLDER_DND_PATH_TARGET_TYPE;
|
||
}
|
||
|
||
for (q = accepted_types; q != NULL; q = q->next) {
|
||
const char *accepted_type;
|
||
|
||
accepted_type = (const char *) q->data;
|
||
if (strcmp (possible_type, accepted_type) == 0) {
|
||
g_free (possible_type);
|
||
|
||
if (atom_return != NULL)
|
||
*atom_return = *((GdkAtom *) p->data);
|
||
|
||
return accepted_type;
|
||
}
|
||
}
|
||
|
||
g_free (possible_type);
|
||
}
|
||
|
||
if (atom_return != NULL)
|
||
*atom_return = 0;
|
||
|
||
return NULL;
|
||
}
|
||
|
||
static gboolean
|
||
handle_evolution_path_drag_motion (EStorageSet *storage_set,
|
||
const char *path,
|
||
GdkDragContext *context,
|
||
unsigned int time)
|
||
{
|
||
GdkModifierType modifiers;
|
||
GdkDragAction action;
|
||
|
||
gdk_window_get_pointer (NULL, NULL, NULL, &modifiers);
|
||
|
||
if ((modifiers & GDK_CONTROL_MASK) != 0) {
|
||
action = GDK_ACTION_COPY;
|
||
} else {
|
||
GtkWidget *source_widget;
|
||
|
||
action = GDK_ACTION_MOVE;
|
||
|
||
source_widget = gtk_drag_get_source_widget (context);
|
||
if (source_widget != NULL
|
||
&& E_IS_STORAGE_SET_VIEW (source_widget)) {
|
||
const char *source_path;
|
||
|
||
source_path = e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (source_widget));
|
||
if (source_path != NULL) {
|
||
EFolder *folder;
|
||
int source_path_len;
|
||
char *destination_path;
|
||
char *base_name;
|
||
|
||
folder = e_storage_set_get_folder (storage_set, source_path);
|
||
if (folder != NULL && e_folder_get_is_stock (folder))
|
||
return FALSE;
|
||
|
||
source_path_len = strlen (path);
|
||
if (strcmp (path, source_path) == 0)
|
||
return FALSE;
|
||
|
||
base_name = g_path_get_basename (source_path);
|
||
destination_path = g_strconcat (path, "/", base_name, NULL);
|
||
g_free (base_name);
|
||
|
||
if (strncmp (destination_path, source_path, source_path_len) == 0) {
|
||
g_free (destination_path);
|
||
return FALSE;
|
||
}
|
||
|
||
g_free (destination_path);
|
||
}
|
||
}
|
||
}
|
||
|
||
gdk_drag_status (context, action, time);
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
/* Bridge for the DnD motion event. */
|
||
|
||
gboolean
|
||
e_folder_dnd_bridge_motion (GtkWidget *widget,
|
||
GdkDragContext *context,
|
||
unsigned int time,
|
||
EStorageSet *storage_set,
|
||
const char *path)
|
||
{
|
||
EvolutionShellComponentClient *component_client;
|
||
GNOME_Evolution_ShellComponentDnd_DestinationFolder destination_folder_interface;
|
||
GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context corba_context;
|
||
GNOME_Evolution_ShellComponentDnd_Action suggested_action;
|
||
CORBA_Environment ev;
|
||
CORBA_boolean can_handle;
|
||
EFolder *folder;
|
||
const char *dnd_type;
|
||
|
||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||
g_return_val_if_fail (context != NULL, FALSE);
|
||
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE);
|
||
g_return_val_if_fail (path != NULL, FALSE);
|
||
|
||
dnd_type = find_matching_target_for_drag_context (storage_set, path, context, NULL);
|
||
if (dnd_type == NULL)
|
||
return FALSE;
|
||
|
||
if (strcmp (dnd_type, E_FOLDER_DND_PATH_TARGET_TYPE) == 0)
|
||
return handle_evolution_path_drag_motion (storage_set, path, context, time);
|
||
|
||
component_client = get_component_at_path (storage_set, path);
|
||
if (component_client == NULL)
|
||
return FALSE;
|
||
|
||
destination_folder_interface = evolution_shell_component_client_get_dnd_destination_interface (component_client);
|
||
if (destination_folder_interface == NULL)
|
||
return FALSE;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
corba_context.dndType = (char *) dnd_type; /* (Safe cast, as we don't actually free the corba_context.) */
|
||
corba_context.possibleActions = convert_gdk_drag_action_set_to_corba (context->actions);
|
||
corba_context.suggestedAction = convert_gdk_drag_action_to_corba (context->suggested_action);
|
||
|
||
folder = e_storage_set_get_folder (storage_set, path);
|
||
|
||
can_handle = GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion (destination_folder_interface,
|
||
e_folder_get_physical_uri (folder),
|
||
e_folder_get_type_string (folder),
|
||
&corba_context,
|
||
&suggested_action,
|
||
&ev);
|
||
if (ev._major != CORBA_NO_EXCEPTION || ! can_handle) {
|
||
CORBA_exception_free (&ev);
|
||
return FALSE;
|
||
}
|
||
|
||
CORBA_exception_free (&ev);
|
||
|
||
gdk_drag_status (context, convert_corba_drag_action_to_gdk (suggested_action), time);
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
/* Bridge for the drop event. */
|
||
|
||
gboolean
|
||
e_folder_dnd_bridge_drop (GtkWidget *widget,
|
||
GdkDragContext *context,
|
||
unsigned int time,
|
||
EStorageSet *storage_set,
|
||
const char *path)
|
||
{
|
||
GdkAtom atom;
|
||
|
||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||
g_return_val_if_fail (context != NULL, FALSE);
|
||
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE);
|
||
g_return_val_if_fail (path != NULL, FALSE);
|
||
|
||
if (context->targets == NULL)
|
||
return FALSE;
|
||
|
||
if (find_matching_target_for_drag_context (storage_set, path, context, &atom) == NULL)
|
||
return FALSE;
|
||
|
||
gtk_drag_get_data (widget, context, atom, time);
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
|
||
/* Bridge for the data_received event. */
|
||
|
||
static gboolean
|
||
handle_data_received_path (GdkDragContext *context,
|
||
GtkSelectionData *selection_data,
|
||
EStorageSet *storage_set,
|
||
const char *path,
|
||
GtkWindow *toplevel_window)
|
||
{
|
||
const char *source_path;
|
||
char *destination_path;
|
||
char *base_name;
|
||
gboolean handled;
|
||
|
||
source_path = (const char *) selection_data->data;
|
||
|
||
/* (Basic sanity checks.) */
|
||
if (source_path == NULL || source_path[0] != E_PATH_SEPARATOR || source_path[1] == '\0')
|
||
return FALSE;
|
||
|
||
base_name = g_path_get_basename (source_path);
|
||
destination_path = g_concat_dir_and_file (path, base_name);
|
||
g_free (base_name);
|
||
|
||
switch (context->action) {
|
||
case GDK_ACTION_MOVE:
|
||
e_storage_set_async_xfer_folder (storage_set,
|
||
source_path,
|
||
destination_path,
|
||
TRUE,
|
||
folder_xfer_callback,
|
||
toplevel_window);
|
||
handled = TRUE;
|
||
break;
|
||
case GDK_ACTION_COPY:
|
||
e_storage_set_async_xfer_folder (storage_set,
|
||
source_path,
|
||
destination_path,
|
||
FALSE,
|
||
folder_xfer_callback,
|
||
toplevel_window);
|
||
handled = TRUE;
|
||
break;
|
||
default:
|
||
handled = FALSE;
|
||
g_warning ("EStorageSetView: Unknown action %d", context->action);
|
||
}
|
||
|
||
g_free (destination_path);
|
||
|
||
return handled;
|
||
}
|
||
|
||
static gboolean
|
||
handle_data_received_non_path (GdkDragContext *context,
|
||
GtkSelectionData *selection_data,
|
||
EStorageSet *storage_set,
|
||
const char *path,
|
||
const char *target_type)
|
||
{
|
||
GNOME_Evolution_ShellComponentDnd_DestinationFolder destination_folder_interface;
|
||
GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context corba_context;
|
||
GNOME_Evolution_ShellComponentDnd_Data corba_data;
|
||
EvolutionShellComponentClient *component_client;
|
||
EFolder *folder;
|
||
CORBA_Environment ev;
|
||
|
||
component_client = get_component_at_path (storage_set, path);
|
||
if (component_client == NULL)
|
||
return FALSE;
|
||
|
||
destination_folder_interface = evolution_shell_component_client_get_dnd_destination_interface (component_client);
|
||
if (destination_folder_interface == NULL)
|
||
return FALSE;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
folder = e_storage_set_get_folder (storage_set, path);
|
||
|
||
corba_context.dndType = (char *) target_type;
|
||
corba_context.possibleActions = convert_gdk_drag_action_set_to_corba (context->actions);
|
||
corba_context.suggestedAction = convert_gdk_drag_action_to_corba (context->suggested_action);
|
||
|
||
corba_data.format = selection_data->format;
|
||
corba_data.target = 0; /* selection_data->target FIXME */
|
||
|
||
corba_data.bytes._release = FALSE;
|
||
|
||
if (selection_data->data == NULL) {
|
||
/* If data is NULL the length is -1 and this would mess things
|
||
up so we handle it separately. */
|
||
corba_data.bytes._length = 0;
|
||
corba_data.bytes._buffer = NULL;
|
||
} else {
|
||
corba_data.bytes._length = selection_data->length;
|
||
corba_data.bytes._buffer = selection_data->data;
|
||
}
|
||
|
||
/* pass off the data to the component's DestinationFolderInterface */
|
||
return GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop (destination_folder_interface,
|
||
e_folder_get_physical_uri (folder),
|
||
e_folder_get_type_string (folder),
|
||
&corba_context,
|
||
convert_gdk_drag_action_to_corba (context->action),
|
||
&corba_data,
|
||
&ev);
|
||
}
|
||
|
||
void
|
||
e_folder_dnd_bridge_data_received (GtkWidget *widget,
|
||
GdkDragContext *context,
|
||
GtkSelectionData *selection_data,
|
||
unsigned int time,
|
||
EStorageSet *storage_set,
|
||
const char *path)
|
||
{
|
||
char *target_type;
|
||
gboolean handled;
|
||
|
||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||
g_return_if_fail (context != NULL);
|
||
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
|
||
g_return_if_fail (path != NULL);
|
||
|
||
if (selection_data->data == NULL && selection_data->length == -1)
|
||
return;
|
||
|
||
target_type = gdk_atom_name (selection_data->target);
|
||
|
||
if (strcmp (target_type, E_FOLDER_DND_PATH_TARGET_TYPE) != 0) {
|
||
handled = handle_data_received_non_path (context, selection_data, storage_set,
|
||
path, target_type);
|
||
} else {
|
||
GtkWindow *toplevel_window;
|
||
|
||
toplevel_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
|
||
handled = handle_data_received_path (context, selection_data, storage_set, path,
|
||
toplevel_window);
|
||
}
|
||
|
||
g_free (target_type);
|
||
gtk_drag_finish (context, handled, FALSE, time);
|
||
}
|
||
|