Do not #include "e-local-folder.h".

* e-setup.c: Do not #include "e-local-folder.h".

* Makefile.am: Don't build evolution-test-component for now since
it's all out of date.

* main.c (evolution_debug_log): Make static instead of extern.

* e-user-creatable-items-handler.c: #include
<bonobo/bonobo-control.h>.

* e-shell.h: Do not include "e-uri-schema-registry.h" or
"evolution-shell-component-client.h".
* e-shell.c: Likewise.

* e-shell.c (struct _EShellPrivate): Removed member
uri_schema_registry.
(impl_Shell_handleURI): #if 0 it out for now.
(e_shell_peek_uri_schema_registry): Disabled for now.

* e-corba-storage-registry.c: Remove.
* e-corba-storage-registry.h: Remove.
* e-corba-storage.c: Remove.
* e-corba-storage.h: Remove.
* e-folder-dnd-bridge.c: Remove.
* e-folder-dnd-bridge.h: Remove.
* e-folder-selection-dialog.c: Remove.
* e-folder-selection-dialog.h: Remove.
* e-folder-type-registry.c: Remove.
* e-folder-type-registry.h: Remove.
* e-local-folder.c: Remove.
* e-local-folder.h: Remove.
* e-local-storage.c: Remove.
* e-local-storage.h: Remove.
* e-shell-folder-selection-dialog.c: Remove.
* e-shell-folder-selection-dialog.h: Remove.
* e-shell-view.c: Remove.
* e-shell-view.h: Remove.
* e-storage-browser.c: Remove.
* e-storage-browser.h: Remove.
* e-storage-set-view.c: Remove.
* e-storage-set-view.h: Remove.
* e-storage-set.c: Remove.
* e-storage-set.h: Remove.
* e-storage.c: Remove.
* e-storage.h: Remove.
* evolution-shell-component-client.c: Remove.
* evolution-shell-component-client.h: Remove.
* evolution-shell-component-dnd.c: Remove.
* evolution-shell-component-dnd.h: Remove.
* evolution-storage-listener.c: Remove.
* evolution-storage-listener.h: Remove.
* evolution-storage-set-view-listener.c: Remove.
* evolution-storage-set-view-listener.h: Remove.

svn path=/trunk/; revision=23396
This commit is contained in:
Ettore Perazzoli
2003-11-17 19:12:04 +00:00
parent f9cf09a8bd
commit 8f502cffbc
43 changed files with 83 additions and 16605 deletions

View File

@ -1,3 +1,61 @@
2003-11-17 Ettore Perazzoli <ettore@ximian.com>
* e-setup.c: Do not #include "e-local-folder.h".
* Makefile.am: Don't build evolution-test-component for now since
it's all out of date.
* main.c (evolution_debug_log): Make static instead of extern.
* e-user-creatable-items-handler.c: #include
<bonobo/bonobo-control.h>.
* e-shell.h: Do not include "e-uri-schema-registry.h" or
"evolution-shell-component-client.h".
* e-shell.c: Likewise.
* e-shell.c (struct _EShellPrivate): Removed member
uri_schema_registry.
(impl_Shell_handleURI): #if 0 it out for now.
(e_shell_peek_uri_schema_registry): Disabled for now.
* e-uri-schema-registry.c: Don't compile for now.
* e-corba-storage-registry.c: Remove.
* e-corba-storage-registry.h: Remove.
* e-corba-storage.c: Remove.
* e-corba-storage.h: Remove.
* e-folder-dnd-bridge.c: Remove.
* e-folder-dnd-bridge.h: Remove.
* e-folder-selection-dialog.c: Remove.
* e-folder-selection-dialog.h: Remove.
* e-folder-type-registry.c: Remove.
* e-folder-type-registry.h: Remove.
* e-local-folder.c: Remove.
* e-local-folder.h: Remove.
* e-local-storage.c: Remove.
* e-local-storage.h: Remove.
* e-shell-folder-selection-dialog.c: Remove.
* e-shell-folder-selection-dialog.h: Remove.
* e-shell-view.c: Remove.
* e-shell-view.h: Remove.
* e-storage-browser.c: Remove.
* e-storage-browser.h: Remove.
* e-storage-set-view.c: Remove.
* e-storage-set-view.h: Remove.
* e-storage-set.c: Remove.
* e-storage-set.h: Remove.
* e-storage.c: Remove.
* e-storage.h: Remove.
* evolution-shell-component-client.c: Remove.
* evolution-shell-component-client.h: Remove.
* evolution-shell-component-dnd.c: Remove.
* evolution-shell-component-dnd.h: Remove.
* evolution-storage-listener.c: Remove.
* evolution-storage-listener.h: Remove.
* evolution-storage-set-view-listener.c: Remove.
* evolution-storage-set-view-listener.h: Remove.
2003-11-13 Ettore Perazzoli <ettore@ximian.com>
* main.c (DEVELOPMENT_WARNING): Define.

View File

@ -21,7 +21,7 @@ INCLUDES = \
$(TZDIALOG_CFLAGS) \
$(SHELL_CFLAGS)
noinst_PROGRAMS = evolution evolution-test-component
noinst_PROGRAMS = evolution
# Shell CORBA stuff
@ -109,64 +109,40 @@ eshellincludedir = $(privincludedir)/shell
eshellinclude_HEADERS = \
Evolution.h \
e-corba-storage.h \
e-folder-dnd-bridge.h \
e-folder-list.h \
e-folder-selection-dialog.h \
e-folder-tree.h \
e-folder-type-registry.h \
e-folder.h \
e-icon-factory.h \
e-shell-corba-icon-utils.h \
e-shell-utils.h \
e-storage-browser.h \
e-storage-set-view.h \
e-storage-set.h \
e-storage.h \
evolution-activity-client.h \
evolution-config-control.h \
evolution-folder-selector-button.h \
evolution-session.h \
evolution-shell-client.h \
evolution-shell-component-client.h \
evolution-shell-component-dnd.h \
evolution-shell-component-utils.h \
evolution-shell-component.h \
evolution-shell-component-utils.h \
evolution-shell-view.h \
evolution-storage-listener.h \
evolution-storage-set-view-listener.h \
evolution-storage.h \
evolution-wizard.h
libeshell_la_SOURCES = \
$(IDL_GENERATED) \
$(MARSHAL_GENERATED) \
e-corba-storage.c \
e-folder-dnd-bridge.c \
e-folder-list.c \
e-folder-selection-dialog.c \
e-folder-tree.c \
e-folder-type-registry.c \
e-folder.c \
e-icon-factory.c \
e-shell-corba-icon-utils.c \
e-shell-utils.c \
e-storage-browser.c \
e-storage-set-view.c \
e-storage-set.c \
e-storage.c \
evolution-activity-client.c \
evolution-config-control.c \
evolution-folder-selector-button.c \
evolution-session.c \
evolution-shell-client.c \
evolution-shell-component-client.c \
evolution-shell-component-dnd.c \
evolution-shell-component-utils.c \
evolution-shell-component.c \
evolution-shell-component-utils.c \
evolution-shell-view.c \
evolution-storage-listener.c \
evolution-storage-set-view-listener.c \
evolution-storage.c \
evolution-wizard.c \
$(eshellinclude_HEADERS)
@ -185,14 +161,8 @@ evolution_SOURCES = \
e-config-upgrade.h \
e-corba-config-page.c \
e-corba-config-page.h \
e-corba-storage-registry.c \
e-corba-storage-registry.h \
e-history.c \
e-history.h \
e-local-folder.c \
e-local-folder.h \
e-local-storage.c \
e-local-storage.h \
e-setup.c \
e-setup.h \
e-shell-about-box.c \
@ -204,7 +174,6 @@ evolution_SOURCES = \
e-shell-settings-dialog.h \
e-shell-startup-wizard.c \
e-shell-startup-wizard.h \
e-shell-view.h \
e-shell-window-commands.c \
e-shell-window-commands.h \
e-shell-window.c \
@ -219,8 +188,6 @@ evolution_SOURCES = \
e-task-bar.h \
e-task-widget.c \
e-task-widget.h \
e-uri-schema-registry.c \
e-uri-schema-registry.h \
main.c
evolution_LDADD = \
@ -234,17 +201,17 @@ evolution_LDADD = \
# Test component
evolution_test_component_SOURCES = \
evolution-test-component.c
# evolution_test_component_SOURCES = \
# evolution-test-component.c
evolution_test_component_LDADD = \
libeshell.la \
$(SHELL_LIBS)
# evolution_test_component_LDADD = \
# libeshell.la \
# $(SHELL_LIBS)
install-test-component: evolution-test-component
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) evolution-test-component $(DESTDIR)$(bindir)/evolution-test-component
$(mkinstalldirs) $(DESTDIR)$(serverdir)
$(INSTALL_DATA) $(srcdir)/GNOME_Evolution_TestComponent.server $(DESTDIR)$(serverdir)/GNOME_Evolution_TestComponent.server
# install-test-component: evolution-test-component
# $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) evolution-test-component $(DESTDIR)$(bindir)/evolution-test-component
# $(mkinstalldirs) $(DESTDIR)$(serverdir)
# $(INSTALL_DATA) $(srcdir)/GNOME_Evolution_TestComponent.server $(DESTDIR)$(serverdir)/GNOME_Evolution_TestComponent.server
# Misc stuff

View File

@ -1,349 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-corba-shortcuts.c
*
* 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 <ettore@ximian.com>
*/
/* FIXME: Doesn't throw exceptions properly. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-corba-shortcuts.h"
#include "e-util/e-corba-utils.h"
#include <gal/util/e-util.h>
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
struct _ECorbaShortcutsPrivate {
EShortcuts *shortcuts;
};
/* Utility functions. */
static const char *
string_from_corba (CORBA_char *corba_string)
{
if (corba_string[0] == '\0')
return NULL;
return corba_string;
}
static void
shortcut_list_to_corba (const GSList *shortcut_list,
GNOME_Evolution_Shortcuts_ShortcutList *shortcut_list_return)
{
GNOME_Evolution_Shortcuts_Shortcut *buffer;
const GSList *p;
int num_shortcuts;
int i;
num_shortcuts = g_slist_length ((GSList *) shortcut_list); /* safe cast, GLib sucks */
shortcut_list_return->_maximum = num_shortcuts;
shortcut_list_return->_length = num_shortcuts;
buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Shortcut_allocbuf (num_shortcuts);
shortcut_list_return->_buffer = buffer;
for (p = shortcut_list, i = 0; p != NULL; p = p->next, i++) {
const EShortcutItem *item;
item = (const EShortcutItem *) p->data;
buffer[i].uri = CORBA_string_dup (e_safe_corba_string (item->uri));
buffer[i].name = CORBA_string_dup (e_safe_corba_string (item->name));
buffer[i].type = CORBA_string_dup (e_safe_corba_string (item->type));
buffer[i].customIconName = CORBA_string_dup (e_safe_corba_string (item->custom_icon_name));
}
CORBA_sequence_set_release (shortcut_list_return, TRUE);
}
/* GObject methods. */
static void
impl_dispose (GObject *object)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
corba_shortcuts = E_CORBA_SHORTCUTS (object);
priv = corba_shortcuts->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)
{
ECorbaShortcuts *corba_shortcuts;
corba_shortcuts = E_CORBA_SHORTCUTS (object);
g_free (corba_shortcuts->priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Evolution::Shortcuts CORBA methods. */
static void
impl_add (PortableServer_Servant servant,
const CORBA_short group_num,
const CORBA_short position,
const GNOME_Evolution_Shortcuts_Shortcut *shortcut,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
e_shortcuts_add_shortcut (priv->shortcuts, group_num, position,
string_from_corba (shortcut->uri),
string_from_corba (shortcut->name),
0,
string_from_corba (shortcut->type),
string_from_corba (shortcut->customIconName));
}
static void
impl_remove (PortableServer_Servant servant,
const CORBA_short group_num,
const CORBA_short item_num,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
e_shortcuts_remove_shortcut (priv->shortcuts, group_num, item_num);
}
static GNOME_Evolution_Shortcuts_Shortcut *
impl_get (PortableServer_Servant servant,
const CORBA_short group_num,
const CORBA_short item_num,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
GNOME_Evolution_Shortcuts_Shortcut *retval;
const EShortcutItem *item;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
if (item == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Shortcuts_NotFound, NULL);
return NULL;
}
retval = GNOME_Evolution_Shortcuts_Shortcut__alloc ();
retval->uri = CORBA_string_dup (e_safe_corba_string (item->uri));
retval->name = CORBA_string_dup (e_safe_corba_string (item->name));
retval->type = CORBA_string_dup (e_safe_corba_string (item->type));
retval->customIconName = CORBA_string_dup (e_safe_corba_string (item->custom_icon_name));
return retval;
}
static void
impl_addGroup (PortableServer_Servant servant,
const CORBA_short position,
const CORBA_char *name,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
if (position == 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Shortcuts_InvalidPosition, NULL);
return;
}
e_shortcuts_add_group (priv->shortcuts, position, name);
}
static void
impl_removeGroup (PortableServer_Servant servant,
const CORBA_short group_num,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
if (group_num == 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Shortcuts_CannotRemove, NULL);
return;
}
e_shortcuts_remove_group (priv->shortcuts, group_num);
}
static GNOME_Evolution_Shortcuts_Group *
impl_getGroup (PortableServer_Servant servant,
const CORBA_short group_num,
CORBA_Environment *ev)
{
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
GNOME_Evolution_Shortcuts_Group *group;
const GSList *list;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_num);
group = GNOME_Evolution_Shortcuts_Group__alloc ();
group->name = CORBA_string_dup (e_shortcuts_get_group_title (priv->shortcuts, group_num));
shortcut_list_to_corba (list, & group->shortcuts);
return group;
}
static CORBA_sequence_GNOME_Evolution_Shortcuts_Group *
impl__get_groups (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GNOME_Evolution_Shortcuts_GroupList *list;
ECorbaShortcuts *corba_shortcuts;
ECorbaShortcutsPrivate *priv;
GSList *group_titles;
const GSList *p;
int i;
corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant));
priv = corba_shortcuts->priv;
list = GNOME_Evolution_Shortcuts_GroupList__alloc ();
list->_length = e_shortcuts_get_num_groups (priv->shortcuts);
list->_maximum = list->_length;
list->_buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Group_allocbuf (list->_maximum);
CORBA_sequence_set_release (list, TRUE);
group_titles = e_shortcuts_get_group_titles (priv->shortcuts);
for (p = group_titles, i = 0; p != NULL; p = p->next, i ++) {
char *group_title;
const GSList *shortcuts;
group_title = (char *) p->data;
shortcuts = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, i);
list->_buffer[i].name = CORBA_string_dup (group_title);
shortcut_list_to_corba (shortcuts, &list->_buffer[i].shortcuts);
g_free (group_title);
}
g_slist_free (group_titles);
return list;
}
static void
e_corba_shortcuts_class_init (GObjectClass *object_class)
{
ECorbaShortcutsClass *corba_shortcuts_class;
POA_GNOME_Evolution_Shortcuts__epv *epv;
parent_class = g_type_class_ref(PARENT_TYPE);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
corba_shortcuts_class = E_CORBA_SHORTCUTS_CLASS (object_class);
epv = & corba_shortcuts_class->epv;
epv->add = impl_add;
epv->remove = impl_remove;
epv->get = impl_get;
epv->addGroup = impl_addGroup;
epv->removeGroup = impl_removeGroup;
epv->getGroup = impl_getGroup;
epv->_get_groups = impl__get_groups;
}
static void
e_corba_shortcuts_init (ECorbaShortcuts *corba_shortcuts)
{
ECorbaShortcutsPrivate *priv;
priv = g_new (ECorbaShortcutsPrivate, 1);
priv->shortcuts = NULL;
corba_shortcuts->priv = priv;
}
ECorbaShortcuts *
e_corba_shortcuts_new (EShortcuts *shortcuts)
{
ECorbaShortcuts *corba_shortcuts;
g_return_val_if_fail (shortcuts != NULL, NULL);
g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
corba_shortcuts = g_object_new (e_corba_shortcuts_get_type (), NULL);
g_object_ref (shortcuts);
corba_shortcuts->priv->shortcuts = shortcuts;
return corba_shortcuts;
}
BONOBO_TYPE_FUNC_FULL (ECorbaShortcuts,
GNOME_Evolution_Shortcuts,
PARENT_TYPE,
e_corba_shortcuts)

View File

@ -1,66 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-corba-shortcuts.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 <ettore@ximian.com>
*/
#ifndef _E_CORBA_SHORTCUTS_H_
#define _E_CORBA_SHORTCUTS_H_
#include "e-shortcuts.h"
#include <bonobo/bonobo-object.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_CORBA_SHORTCUTS (e_corba_shortcuts_get_type ())
#define E_CORBA_SHORTCUTS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcuts))
#define E_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcutsClass))
#define E_IS_CORBA_SHORTCUTS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS))
#define E_IS_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS))
typedef struct _ECorbaShortcuts ECorbaShortcuts;
typedef struct _ECorbaShortcutsPrivate ECorbaShortcutsPrivate;
typedef struct _ECorbaShortcutsClass ECorbaShortcutsClass;
struct _ECorbaShortcuts {
BonoboObject parent;
ECorbaShortcutsPrivate *priv;
};
struct _ECorbaShortcutsClass {
BonoboObjectClass parent_class;
POA_GNOME_Evolution_Shortcuts__epv epv;
};
GtkType e_corba_shortcuts_get_type (void);
ECorbaShortcuts *e_corba_shortcuts_new (EShortcuts *shortcuts);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_CORBA_SHORTCUTS_H_ */

View File

@ -1,494 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-corba-storage-registry.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 "e-local-storage.h"
#include "e-corba-storage.h"
#include "e-corba-storage-registry.h"
#include "e-shell-constants.h"
#include "e-util/e-corba-utils.h"
#include <bonobo/bonobo-exception.h>
#include <gal/util/e-util.h>
#include <string.h>
#define PARENT_TYPE BONOBO_OBJECT_TYPE
static BonoboObjectClass *parent_class = NULL;
struct _ECorbaStorageRegistryPrivate {
EStorageSet *storage_set;
GSList *listeners;
};
/* CORBA interface implementation. */
static void
listener_notify (Bonobo_Listener listener,
GNOME_Evolution_StorageRegistry_MessageType type,
const char *name)
{
CORBA_any any;
GNOME_Evolution_StorageRegistry_NotifyResult nr;
CORBA_Environment ev;
nr.type = type;
nr.name = CORBA_string_dup (name ? name : "");
any._type = (CORBA_TypeCode) TC_GNOME_Evolution_StorageRegistry_NotifyResult;
any._value = &nr;
CORBA_exception_init (&ev);
Bonobo_Listener_event (listener,
"Evolution::StorageRegistry::NotifyResult",
&any, &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Could not send notify event for %s\n%s", name,
CORBA_exception_id (&ev));
}
CORBA_exception_free (&ev);
CORBA_free (nr.name);
}
static GNOME_Evolution_StorageListener
impl_StorageRegistry_addStorage (PortableServer_Servant servant,
const GNOME_Evolution_Storage storage_interface,
const CORBA_char *name,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
EStorage *storage;
GNOME_Evolution_StorageListener listener_interface;
GSList *iter;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
storage = e_corba_storage_new (storage_interface, name);
if (! e_storage_set_add_storage (priv->storage_set, storage)) {
CORBA_exception_set (ev,
CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_Exists,
NULL);
return CORBA_OBJECT_NIL;
}
g_object_unref (storage);
/* FIXME: if we remove a listener while looping through the list we can
* crash. Yay CORBA reentrancy. */
for (iter = priv->listeners; iter; iter = iter->next) {
listener_notify (iter->data,
GNOME_Evolution_StorageRegistry_STORAGE_CREATED,
name);
}
listener_interface = CORBA_Object_duplicate (e_corba_storage_get_StorageListener
(E_CORBA_STORAGE (storage)), ev);
return listener_interface;
}
static GNOME_Evolution_StorageRegistry_StorageList *
impl_StorageRegistry_getStorageList (PortableServer_Servant servant,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
GNOME_Evolution_StorageRegistry_StorageList *storage_list;
GList *sl, *l;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
sl = e_storage_set_get_storage_list (priv->storage_set);
storage_list = GNOME_Evolution_StorageRegistry_StorageList__alloc ();
storage_list->_maximum = g_list_length (sl);
storage_list->_length = 0;
storage_list->_buffer = CORBA_sequence_GNOME_Evolution_Storage_allocbuf (storage_list->_maximum);
for (l = sl; l != NULL; l = l->next) {
EStorage *storage;
GNOME_Evolution_Storage corba_storage;
CORBA_Environment ev2;
CORBA_exception_init (&ev2);
storage = l->data;
if (E_IS_LOCAL_STORAGE (storage)) {
corba_storage = e_local_storage_get_corba_interface (E_LOCAL_STORAGE (storage));
} else if (E_IS_CORBA_STORAGE (storage)) {
corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage));
} else {
continue;
}
corba_storage = CORBA_Object_duplicate (corba_storage, &ev2);
if (BONOBO_EX (&ev2)) {
CORBA_exception_free (&ev2);
continue;
}
storage_list->_buffer[storage_list->_length] = corba_storage;
storage_list->_length++;
}
CORBA_sequence_set_release (storage_list, TRUE);
return storage_list;
}
static GNOME_Evolution_Storage
impl_StorageRegistry_getStorageByName (PortableServer_Servant servant,
const CORBA_char *name,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
GNOME_Evolution_Storage corba_storage;
EStorage *storage;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
storage = e_storage_set_get_storage (priv->storage_set, name);
if (storage == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_NotFound,
NULL);
return CORBA_OBJECT_NIL;
}
corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage));
return bonobo_object_dup_ref (corba_storage, NULL);
}
static void
impl_StorageRegistry_removeStorageByName (PortableServer_Servant servant,
const CORBA_char *name,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
EStorage *storage;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
storage = e_storage_set_get_storage (priv->storage_set, name);
if (storage == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_NotFound,
NULL);
return;
}
/* FIXME: Yucky to get the storage by name and then remove it. */
/* FIXME: Check failure. */
e_storage_set_remove_storage (priv->storage_set, storage);
}
static void
storage_set_foreach (EStorageSet *set,
Bonobo_Listener listener)
{
GList *storage_list, *p;
storage_list = e_storage_set_get_storage_list (set);
for (p = storage_list; p; p = p->next) {
const char *name;
name = e_storage_get_name (E_STORAGE (p->data));
listener_notify (listener, GNOME_Evolution_StorageRegistry_STORAGE_CREATED, name);
g_object_unref (p->data);
}
g_list_free (storage_list);
}
static GSList *
find_listener (GSList *p,
Bonobo_Listener listener)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
for (; p; p = p->next) {
if (CORBA_Object_is_equivalent (p->data, listener, &ev) == TRUE) {
CORBA_exception_free (&ev);
return p;
}
}
CORBA_exception_free (&ev);
return NULL;
}
static void
impl_StorageRegistry_addListener (PortableServer_Servant servant,
Bonobo_Listener listener,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
Bonobo_Listener listener_copy;
CORBA_Environment ev2;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
if (find_listener (priv->listeners, listener) != NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_AlreadyListening,
NULL);
return;
}
CORBA_exception_init (&ev2);
listener_copy = CORBA_Object_duplicate ((CORBA_Object) listener, &ev2);
if (BONOBO_EX (&ev2)) {
g_warning ("EvolutionStorageRegistry -- Cannot duplicate listener.");
CORBA_exception_free (&ev2);
return;
}
CORBA_exception_free (&ev2);
priv->listeners = g_slist_prepend (priv->listeners, listener_copy);
storage_set_foreach (priv->storage_set, listener_copy);
}
static void
impl_StorageRegistry_removeListener (PortableServer_Servant servant,
Bonobo_Listener listener,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
ECorbaStorageRegistryPrivate *priv;
CORBA_Environment ev2;
GSList *p;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
priv = storage_registry->priv;
p = find_listener (priv->listeners, listener);
if (p == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_NotFound,
NULL);
return;
}
CORBA_exception_init (&ev2);
CORBA_Object_release ((CORBA_Object) p->data, &ev2);
CORBA_exception_free (&ev2);
priv->listeners = g_slist_remove_link (priv->listeners, p);
g_slist_free (p);
}
static GNOME_Evolution_Folder *
impl_StorageRegistry_getFolderByUri (PortableServer_Servant servant,
const CORBA_char *uri,
CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
ECorbaStorageRegistry *storage_registry;
GNOME_Evolution_Folder *corba_folder;
EStorageSet *storage_set;
EFolder *folder;
char *path;
CORBA_char *corba_evolution_uri;
bonobo_object = bonobo_object_from_servant (servant);
storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object);
storage_set = storage_registry->priv->storage_set;
if (!strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN)) {
corba_evolution_uri = CORBA_string_dup (uri);
path = (char *)uri + E_SHELL_URI_PREFIX_LEN;
folder = e_storage_set_get_folder (storage_set, path);
} else {
path = e_storage_set_get_path_for_physical_uri (storage_set, uri);
if (path) {
corba_evolution_uri = CORBA_string_alloc (strlen (path) + E_SHELL_URI_PREFIX_LEN + 1);
strcpy (corba_evolution_uri, E_SHELL_URI_PREFIX);
strcat (corba_evolution_uri, path);
folder = e_storage_set_get_folder (storage_set, path);
g_free (path);
} else {
corba_evolution_uri = NULL;
folder = NULL;
}
}
if (!folder) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_StorageRegistry_NotFound,
NULL);
return CORBA_OBJECT_NIL;
}
corba_folder = GNOME_Evolution_Folder__alloc ();
corba_folder->displayName = CORBA_string_dup (e_folder_get_name (folder));
corba_folder->description = CORBA_string_dup (e_safe_corba_string (e_folder_get_description (folder)));
corba_folder->type = CORBA_string_dup (e_folder_get_type_string (folder));
corba_folder->physicalUri = CORBA_string_dup (e_safe_corba_string (e_folder_get_physical_uri (folder)));
corba_folder->customIconName = CORBA_string_dup (e_safe_corba_string (e_folder_get_custom_icon_name (folder)));
corba_folder->evolutionUri = corba_evolution_uri;
corba_folder->unreadCount = e_folder_get_unread_count (folder);
corba_folder->sortingPriority = e_folder_get_sorting_priority (folder);
return corba_folder;
}
/* GObject methods. */
static void
impl_dispose (GObject *object)
{
ECorbaStorageRegistry *corba_storage_registry;
ECorbaStorageRegistryPrivate *priv;
corba_storage_registry = E_CORBA_STORAGE_REGISTRY (object);
priv = corba_storage_registry->priv;
if (priv->storage_set != NULL) {
g_object_unref (priv->storage_set);
priv->storage_set = NULL;
}
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
ECorbaStorageRegistry *corba_storage_registry;
ECorbaStorageRegistryPrivate *priv;
corba_storage_registry = E_CORBA_STORAGE_REGISTRY (object);
priv = corba_storage_registry->priv;
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
e_corba_storage_registry_class_init (ECorbaStorageRegistryClass *klass)
{
GObjectClass *object_class;
POA_GNOME_Evolution_StorageRegistry__epv *epv;
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
epv = & klass->epv;
epv->addStorage = impl_StorageRegistry_addStorage;
epv->getStorageList = impl_StorageRegistry_getStorageList;
epv->getStorageByName = impl_StorageRegistry_getStorageByName;
epv->removeStorageByName = impl_StorageRegistry_removeStorageByName;
epv->addListener = impl_StorageRegistry_addListener;
epv->removeListener = impl_StorageRegistry_removeListener;
epv->getFolderByUri = impl_StorageRegistry_getFolderByUri;
parent_class = g_type_class_ref(PARENT_TYPE);
}
static void
e_corba_storage_registry_init (ECorbaStorageRegistry *corba_storage_registry)
{
ECorbaStorageRegistryPrivate *priv;
priv = g_new (ECorbaStorageRegistryPrivate, 1);
priv->storage_set = NULL;
priv->listeners = NULL;
corba_storage_registry->priv = priv;
}
void
e_corba_storage_registry_construct (ECorbaStorageRegistry *corba_storage_registry,
EStorageSet *storage_set)
{
ECorbaStorageRegistryPrivate *priv;
g_return_if_fail (E_IS_CORBA_STORAGE_REGISTRY (corba_storage_registry));
priv = corba_storage_registry->priv;
g_object_ref (storage_set);
priv->storage_set = storage_set;
}
ECorbaStorageRegistry *
e_corba_storage_registry_new (EStorageSet *storage_set)
{
ECorbaStorageRegistry *corba_storage_registry;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
corba_storage_registry = g_object_new (e_corba_storage_registry_get_type (), NULL);
e_corba_storage_registry_construct (corba_storage_registry, storage_set);
return corba_storage_registry;
}
BONOBO_TYPE_FUNC_FULL (ECorbaStorageRegistry,
GNOME_Evolution_StorageRegistry,
PARENT_TYPE,
e_corba_storage_registry)

View File

@ -1,69 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-corba-storage-registry.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_CORBA_STORAGE_REGISTRY_H__
#define __E_CORBA_STORAGE_REGISTRY_H__
#include <bonobo/bonobo-object.h>
#include "Evolution.h"
#include "e-storage-set.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_CORBA_STORAGE_REGISTRY (e_corba_storage_registry_get_type ())
#define E_CORBA_STORAGE_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_STORAGE_REGISTRY, ECorbaStorageRegistry))
#define E_CORBA_STORAGE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_STORAGE_REGISTRY, ECorbaStorageRegistryClass))
#define E_IS_CORBA_STORAGE_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_STORAGE_REGISTRY))
#define E_IS_CORBA_STORAGE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_STORAGE_REGISTRY))
typedef struct _ECorbaStorageRegistry ECorbaStorageRegistry;
typedef struct _ECorbaStorageRegistryPrivate ECorbaStorageRegistryPrivate;
typedef struct _ECorbaStorageRegistryClass ECorbaStorageRegistryClass;
struct _ECorbaStorageRegistry {
BonoboObject parent;
ECorbaStorageRegistryPrivate *priv;
};
struct _ECorbaStorageRegistryClass {
BonoboObjectClass parent_class;
POA_GNOME_Evolution_StorageRegistry__epv epv;
};
GtkType e_corba_storage_registry_get_type (void);
void e_corba_storage_registry_construct (ECorbaStorageRegistry *corba_storage_registry,
EStorageSet *storage_set);
ECorbaStorageRegistry *e_corba_storage_registry_new (EStorageSet *storage_set);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __E_CORBA_STORAGE_REGISTRY_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-corba-storage.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_CORBA_STORAGE_H__
#define __E_CORBA_STORAGE_H__
#include "e-storage.h"
#include "Evolution.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_CORBA_STORAGE (e_corba_storage_get_type ())
#define E_CORBA_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_STORAGE, ECorbaStorage))
#define E_CORBA_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_STORAGE, ECorbaStorageClass))
#define E_IS_CORBA_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_STORAGE))
#define E_IS_CORBA_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_STORAGE))
typedef struct _ECorbaStorage ECorbaStorage;
typedef struct _ECorbaStoragePrivate ECorbaStoragePrivate;
typedef struct _ECorbaStorageClass ECorbaStorageClass;
struct _ECorbaStorage {
EStorage parent;
ECorbaStoragePrivate *priv;
};
struct _ECorbaStorageClass {
EStorageClass parent_class;
};
struct _ECorbaStoragePropertyItem {
char *label;
char *tooltip;
GdkPixbuf *icon;
};
typedef struct _ECorbaStoragePropertyItem ECorbaStoragePropertyItem;
GtkType e_corba_storage_get_type (void);
void e_corba_storage_construct (ECorbaStorage *corba_storage,
const GNOME_Evolution_Storage storage_interface,
const char *name);
EStorage *e_corba_storage_new (const GNOME_Evolution_Storage storage_interface,
const char *name);
GNOME_Evolution_Storage e_corba_storage_get_corba_objref (ECorbaStorage *corba_storage);
const GNOME_Evolution_StorageListener e_corba_storage_get_StorageListener (ECorbaStorage *corba_storage);
GSList *e_corba_storage_get_folder_property_items (ECorbaStorage *corba_storage);
void e_corba_storage_free_property_items_list (GSList *list);
void e_corba_storage_show_folder_properties (ECorbaStorage *corba_storage,
const char *path,
int property_item_id,
GdkWindow *parent_window);
EStorageResult e_corba_storage_corba_result_to_storage_result (GNOME_Evolution_Storage_Result corba_result);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __E_CORBA_STORAGE_H__ */

View File

@ -1,487 +0,0 @@
/* -*- 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 "e-util/e-dialog-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 (p->data);
if (strcmp (possible_type, E_FOLDER_DND_PATH_TARGET_TYPE) == 0) {
g_free (possible_type);
if (atom_return != NULL)
*atom_return = 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 = 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_build_filename (path, base_name, NULL);
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 = gdk_atom_name (selection_data->target);
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);
}

View File

@ -1,55 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-component-dnd-bridge.h - 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>
*/
/* The purpose of this file is to share the logic for dropping objects into
folders between different widgets that handle the display of EStorageSets
(namely, the shortcut bar and the folder bar). */
#ifndef E_FOLDER_BAR_DND_BRIDGE_H
#define E_FOLDER_BAR_DND_BRIDGE_H
#include "e-storage-set.h"
#include <gtk/gtkwidget.h>
#include <gtk/gtkdnd.h>
#define E_FOLDER_DND_PATH_TARGET_TYPE "_EVOLUTION_PRIVATE_PATH"
gboolean e_folder_dnd_bridge_motion (GtkWidget *widget,
GdkDragContext *context,
unsigned int time,
EStorageSet *storage_set,
const char *path);
gboolean e_folder_dnd_bridge_drop (GtkWidget *widget,
GdkDragContext *context,
unsigned int time,
EStorageSet *storage_set,
const char *path);
void e_folder_dnd_bridge_data_received (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
unsigned int time,
EStorageSet *storage_set,
const char *path);
#endif /* E_FOLDER_BAR_DND_BRIDGE_H */

View File

@ -1,479 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-folder-selection-dialog.c
*
* Copyright (C) 2000, 2001, 2002, 2003 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-folder-selection-dialog.h"
#include "e-shell-marshal.h"
#include "e-storage-set-view.h"
#include "e-storage-set.h"
#include <libgnome/gnome-i18n.h>
#include <gal/util/e-util.h>
#include <gal/widgets/e-gui-utils.h>
#include <gtk/gtkbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkstock.h>
#include <string.h>
#define PARENT_TYPE (gtk_dialog_get_type ())
static GtkDialogClass *parent_class = NULL;
struct _EFolderSelectionDialogPrivate {
GList *allowed_types;
EStorageSet *storage_set;
GtkWidget *storage_set_view;
gboolean allow_creation;
};
enum {
FOLDER_SELECTED,
CANCELLED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
enum {
RESPONSE_NEW
};
/* Utility functions. */
static gboolean
check_folder_type_valid (EFolderSelectionDialog *folder_selection_dialog)
{
EFolderSelectionDialogPrivate *priv;
const char *selected_path;
EFolder *folder;
const char *folder_type;
GList *p;
priv = folder_selection_dialog->priv;
if (priv->allowed_types == NULL)
return TRUE;
selected_path = e_folder_selection_dialog_get_selected_path (folder_selection_dialog);
if (selected_path == NULL)
return FALSE;
folder = e_storage_set_get_folder (priv->storage_set, selected_path);
if (folder == NULL)
return FALSE;
folder_type = e_folder_get_type_string (folder);
for (p = priv->allowed_types; p != NULL; p = p->next) {
const char *type, *slash;
type = (const char *) p->data;
if (strcmp (folder_type, type) == 0)
return TRUE;
slash = strchr (type, '/');
if (slash && slash[1] == '*' && strncmp (folder_type, type, slash - type) == 0)
return TRUE;
}
return FALSE;
}
/* Folder creation dialog callback. */
#if 0 /* EPFIXME */
static void
folder_creation_dialog_result_cb (EShell *shell,
EShellFolderCreationDialogResult result,
const char *path,
void *data)
{
EFolderSelectionDialog *dialog;
EFolderSelectionDialogPrivate *priv;
dialog = E_FOLDER_SELECTION_DIALOG (data);
priv = dialog->priv;
if (priv == NULL) {
g_warning ("dialog->priv is NULL, and should not be");
return;
}
if (result == E_SHELL_FOLDER_CREATION_DIALOG_RESULT_SUCCESS)
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
path);
}
#endif
/* GtkObject methods. */
static void
impl_dispose (GObject *object)
{
EFolderSelectionDialog *folder_selection_dialog;
EFolderSelectionDialogPrivate *priv;
folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object);
priv = folder_selection_dialog->priv;
if (priv->storage_set != NULL) {
g_object_unref (priv->storage_set);
priv->storage_set = NULL;
}
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
EFolderSelectionDialog *folder_selection_dialog;
EFolderSelectionDialogPrivate *priv;
folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object);
priv = folder_selection_dialog->priv;
e_free_string_list (priv->allowed_types);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* GtkDialog methods. */
static void
impl_response (GtkDialog *dialog,
int response)
{
EFolderSelectionDialog *folder_selection_dialog;
EFolderSelectionDialogPrivate *priv;
EStorageSetView *storage_set_view;
const char *default_parent_folder;
const char *default_subtype;
char *default_type;
folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (dialog);
priv = folder_selection_dialog->priv;
switch (response) {
case GTK_RESPONSE_OK:
if (check_folder_type_valid (folder_selection_dialog)) {
g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0,
e_folder_selection_dialog_get_selected_path (folder_selection_dialog));
}
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
g_signal_emit (folder_selection_dialog, signals[CANCELLED], 0);
break;
case RESPONSE_NEW:
storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view);
default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view);
/* The default type in the folder creation dialog will be the
first of the allowed types. If all types are allowed,
hardcode to "mail". */
if (priv->allowed_types == NULL)
default_type = g_strdup ("mail");
else {
default_subtype = (const char *) priv->allowed_types->data;
default_type = g_strndup (default_subtype,
strcspn (default_subtype, "/"));
}
#if 0 /* EPFIXME */
e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog),
default_parent_folder,
default_type,
folder_creation_dialog_result_cb,
dialog);
#endif
g_free (default_type);
break;
}
}
/* GTK+ type initialization. */
static void
class_init (EFolderSelectionDialogClass *klass)
{
GObjectClass *object_class;
GtkDialogClass *dialog_class;
parent_class = g_type_class_ref(PARENT_TYPE);
object_class = G_OBJECT_CLASS (klass);
dialog_class = GTK_DIALOG_CLASS (klass);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
dialog_class->response = impl_response;
signals[FOLDER_SELECTED]
= g_signal_new ("folder_selected",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EFolderSelectionDialogClass, folder_selected),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[CANCELLED]
= g_signal_new ("cancelled",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EFolderSelectionDialogClass, cancelled),
NULL, NULL,
e_shell_marshal_NONE__NONE,
G_TYPE_NONE, 0);
}
static void
init (EFolderSelectionDialog *folder_selection_dialog)
{
EFolderSelectionDialogPrivate *priv;
priv = g_new (EFolderSelectionDialogPrivate, 1);
priv->storage_set = NULL;
priv->storage_set_view = NULL;
priv->allowed_types = NULL;
priv->allow_creation = TRUE;
folder_selection_dialog->priv = priv;
}
/* ETable callbacks. */
static void
folder_selected_cb (EStorageSetView *storage_set_view,
const char *path,
void *data)
{
EFolderSelectionDialog *dialog;
dialog = E_FOLDER_SELECTION_DIALOG (data);
if (check_folder_type_valid (dialog))
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
else
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
}
static void
double_click_cb (EStorageSetView *essv,
int row,
ETreePath path,
int col,
GdkEvent *event,
EFolderSelectionDialog *folder_selection_dialog)
{
g_return_if_fail (folder_selection_dialog != NULL);
if (check_folder_type_valid (folder_selection_dialog)) {
g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0,
e_folder_selection_dialog_get_selected_path (folder_selection_dialog));
}
}
/**
* e_folder_selection_dialog_construct:
* @folder_selection_dialog: A folder selection dialog widget
* @storage_set: The storage set this folder selection dialog is for
* @title: Title of the window
* @caption: A brief text to be put on top of the storage view
* @default_path: The path of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Construct @folder_selection_dialog.
**/
/* EPFIXME: Should be allowed to get the expanded state from a model
EStorageSetView. */
void
e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog,
EStorageSet *storage_set,
const char *title,
const char *caption,
const char *default_path,
const char *allowed_types[],
gboolean allow_creation)
{
EFolderSelectionDialogPrivate *priv;
GtkWidget *scrolled_window;
GtkWidget *caption_label;
int i;
g_return_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog));
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
priv = folder_selection_dialog->priv;
/* Basic dialog setup. */
gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300);
gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title);
gtk_container_set_border_width (GTK_CONTAINER (folder_selection_dialog), 6);
if (allow_creation)
gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog),
GTK_STOCK_NEW, RESPONSE_NEW,
NULL);
gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_response_sensitive (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK, FALSE);
gtk_dialog_set_default_response (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK);
/* Set up the label. */
if (caption != NULL) {
caption_label = gtk_label_new (caption);
gtk_label_set_justify (GTK_LABEL (caption_label), GTK_JUSTIFY_LEFT);
gtk_widget_show (caption_label);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
caption_label, FALSE, TRUE, 6);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
6);
}
/* Set up the storage set and its view. */
priv->storage_set = storage_set;
g_object_ref (storage_set);
priv->storage_set_view = e_storage_set_create_new_view (priv->storage_set, NULL);
e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE);
e_storage_set_view_enable_search (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE);
g_signal_connect (priv->storage_set_view, "double_click", G_CALLBACK (double_click_cb), folder_selection_dialog);
g_signal_connect (priv->storage_set_view, "folder_selected", G_CALLBACK (folder_selected_cb), folder_selection_dialog);
g_assert (priv->allowed_types == NULL);
if (allowed_types != NULL) {
for (i = 0; allowed_types[i] != NULL; i++)
priv->allowed_types = g_list_prepend (priv->allowed_types,
g_strdup (allowed_types[i]));
/* Preserve the order so we can use the first type listed as
the default for the folder creation dialog invoked by the
"New..." button. */
priv->allowed_types = g_list_reverse (priv->allowed_types);
}
if (default_path != NULL)
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), default_path);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scrolled_window), priv->storage_set_view);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
scrolled_window, TRUE, TRUE, 6);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), 6);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (folder_selection_dialog)->vbox), 6);
gtk_widget_show (priv->storage_set_view);
gtk_widget_show (scrolled_window);
GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS);
gtk_widget_grab_focus (priv->storage_set_view);
}
/**
* e_folder_selection_dialog_new:
* @storage_set: The storage set this folder selection dialog is for
* @title: Title of the window
* @caption: A brief text to be put on top of the storage view
* @default_path: The path of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Create a new folder selection dialog widget.
*
* Return value:
**/
GtkWidget *
e_folder_selection_dialog_new (EStorageSet *storage_set,
const char *title,
const char *caption,
const char *default_path,
const char *allowed_types[],
gboolean allow_creation)
{
EFolderSelectionDialog *folder_selection_dialog;
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
folder_selection_dialog = g_object_new (e_folder_selection_dialog_get_type (), NULL);
e_folder_selection_dialog_construct (folder_selection_dialog, storage_set,
title, caption, default_path, allowed_types,
allow_creation);
return GTK_WIDGET (folder_selection_dialog);
}
const char *
e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog)
{
EFolderSelectionDialogPrivate *priv;
g_return_val_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL);
priv = folder_selection_dialog->priv;
return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view));
}
E_MAKE_TYPE (e_folder_selection_dialog, "EFolderSelectionDialog", EFolderSelectionDialog, class_init, init, PARENT_TYPE)

View File

@ -1,82 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-folder-selection-dialog.h
*
* Copyright (C) 2000, 2001, 2002, 2003 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_FOLDER_SELECTION_DIALOG_H
#define E_FOLDER_SELECTION_DIALOG_H
#include "e-storage-set.h"
#include <gtk/gtkdialog.h>
#ifdef cplusplus
extern "C" {
#pragma }
#endif /* cplusplus */
#define E_TYPE_FOLDER_SELECTION_DIALOG (e_folder_selection_dialog_get_type ())
#define E_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialog))
#define E_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialogClass))
#define E_IS_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG))
#define E_IS_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG))
typedef struct _EFolderSelectionDialog EFolderSelectionDialog;
typedef struct _EFolderSelectionDialogPrivate EFolderSelectionDialogPrivate;
typedef struct _EFolderSelectionDialogClass EFolderSelectionDialogClass;
struct _EFolderSelectionDialog {
GtkDialog parent;
EFolderSelectionDialogPrivate *priv;
};
struct _EFolderSelectionDialogClass {
GtkDialogClass parent_class;
void (* folder_selected) (EFolderSelectionDialog *folder_selection_dialog,
const char *path);
void (* cancelled) (EFolderSelectionDialog *folder_selection_dialog);
};
GtkType e_folder_selection_dialog_get_type (void);
void e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog,
EStorageSet *storage_set,
const char *title,
const char *caption,
const char *default_path,
const char *allowed_types[],
gboolean allow_creation);
GtkWidget *e_folder_selection_dialog_new (EStorageSet *storage_set,
const char *title,
const char *caption,
const char *default_path,
const char *allowed_types[],
gboolean allow_creation);
const char *e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog);
#ifdef cplusplus
}
#endif /* cplusplus */
#endif /* E_FOLDER_SELECTION_DIALOG_H */

View File

@ -1,536 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-folder-type-registry.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 <glib.h>
#include <gtk/gtktypeutils.h>
#include <gal/util/e-util.h>
#include "e-shell-utils.h"
#include "e-folder-type-registry.h"
#define PARENT_TYPE GTK_TYPE_OBJECT
static GtkObjectClass *parent_class = NULL;
struct _FolderType {
char *name;
char *icon_name;
char *display_name;
char *description;
gboolean user_creatable;
GList *exported_dnd_types; /* char * */
GList *accepted_dnd_types; /* char * */
EvolutionShellComponentClient *handler;
/* The icon, standard (48x48) and mini (16x16) versions. */
GdkPixbuf *icon_pixbuf;
GdkPixbuf *mini_icon_pixbuf;
};
typedef struct _FolderType FolderType;
struct _EFolderTypeRegistryPrivate {
GHashTable *name_to_type;
};
/* FolderType handling. */
static FolderType *
folder_type_new (const char *name,
const char *icon_name,
const char *display_name,
const char *description,
gboolean user_creatable,
int num_exported_dnd_types,
const char **exported_dnd_types,
int num_accepted_dnd_types,
const char **accepted_dnd_types)
{
FolderType *new;
char *icon_path;
int i;
new = g_new (FolderType, 1);
new->name = g_strdup (name);
new->icon_name = g_strdup (icon_name);
new->display_name = g_strdup (display_name);
new->description = g_strdup (description);
new->user_creatable = user_creatable;
new->exported_dnd_types = NULL;
for (i = 0; i < num_exported_dnd_types; i++)
new->exported_dnd_types = g_list_prepend (new->exported_dnd_types,
g_strdup (exported_dnd_types[i]));
new->exported_dnd_types = g_list_reverse (new->exported_dnd_types);
new->accepted_dnd_types = NULL;
for (i = 0; i < num_accepted_dnd_types; i++)
new->accepted_dnd_types = g_list_prepend (new->accepted_dnd_types,
g_strdup (accepted_dnd_types[i]));
new->accepted_dnd_types = g_list_reverse (new->accepted_dnd_types);
new->handler = NULL;
icon_path = e_shell_get_icon_path (icon_name, FALSE);
if (icon_path == NULL)
new->icon_pixbuf = NULL;
else
new->icon_pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
g_free (icon_path);
icon_path = e_shell_get_icon_path (icon_name, TRUE);
if (icon_path != NULL) {
new->mini_icon_pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
} else {
if (new->icon_pixbuf != NULL)
new->mini_icon_pixbuf = g_object_ref (new->icon_pixbuf);
else
new->mini_icon_pixbuf = NULL;
}
g_free (icon_path);
return new;
}
static void
folder_type_free (FolderType *folder_type)
{
g_free (folder_type->name);
g_free (folder_type->icon_name);
g_free (folder_type->display_name);
g_free (folder_type->description);
if (folder_type->icon_pixbuf != NULL)
g_object_unref (folder_type->icon_pixbuf);
if (folder_type->mini_icon_pixbuf != NULL)
g_object_unref (folder_type->mini_icon_pixbuf);
if (folder_type->handler != NULL)
g_object_unref (folder_type->handler);
g_free (folder_type);
}
static FolderType *
get_folder_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
EFolderTypeRegistryPrivate *priv;
priv = folder_type_registry->priv;
return g_hash_table_lookup (priv->name_to_type, type_name);
}
static gboolean
register_folder_type (EFolderTypeRegistry *folder_type_registry,
const char *name,
const char *icon_name,
const char *display_name,
const char *description,
gboolean user_creatable,
int num_exported_dnd_types,
const char **exported_dnd_types,
int num_accepted_dnd_types,
const char **accepted_dnd_types)
{
EFolderTypeRegistryPrivate *priv;
FolderType *folder_type;
priv = folder_type_registry->priv;
/* Make sure we don't add the same type twice. */
if (get_folder_type (folder_type_registry, name) != NULL)
return FALSE;
folder_type = folder_type_new (name, icon_name,
display_name, description,
user_creatable,
num_exported_dnd_types, exported_dnd_types,
num_accepted_dnd_types, accepted_dnd_types);
g_hash_table_insert (priv->name_to_type, folder_type->name, folder_type);
return TRUE;
}
static gboolean
set_handler (EFolderTypeRegistry *folder_type_registry,
const char *name,
EvolutionShellComponentClient *handler)
{
EFolderTypeRegistryPrivate *priv;
FolderType *folder_type;
priv = folder_type_registry->priv;
folder_type = get_folder_type (folder_type_registry, name);
if (folder_type == NULL)
return FALSE;
if (folder_type->handler != NULL)
return FALSE;
g_object_ref (handler);
folder_type->handler = handler;
return TRUE;
}
/* GtkObject methods. */
static void
hash_forall_free_folder_type (gpointer key,
gpointer value,
gpointer data)
{
FolderType *folder_type;
folder_type = (FolderType *) value;
folder_type_free (folder_type);
}
static void
impl_finalize (GObject *object)
{
EFolderTypeRegistry *folder_type_registry;
EFolderTypeRegistryPrivate *priv;
folder_type_registry = E_FOLDER_TYPE_REGISTRY (object);
priv = folder_type_registry->priv;
g_hash_table_foreach (priv->name_to_type, hash_forall_free_folder_type, NULL);
g_hash_table_destroy (priv->name_to_type);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
class_init (EFolderTypeRegistryClass *class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
object_class->finalize = impl_finalize;
parent_class = g_type_class_ref(gtk_object_get_type ());
}
static void
init (EFolderTypeRegistry *folder_type_registry)
{
EFolderTypeRegistryPrivate *priv;
priv = g_new (EFolderTypeRegistryPrivate, 1);
priv->name_to_type = g_hash_table_new (g_str_hash, g_str_equal);
folder_type_registry->priv = priv;
}
void
e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry)
{
g_return_if_fail (folder_type_registry != NULL);
g_return_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry));
GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (folder_type_registry), GTK_FLOATING);
}
EFolderTypeRegistry *
e_folder_type_registry_new (void)
{
EFolderTypeRegistry *new;
new = g_object_new (e_folder_type_registry_get_type (), NULL);
e_folder_type_registry_construct (new);
return new;
}
gboolean
e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
const char *icon_name,
const char *display_name,
const char *description,
gboolean user_creatable,
int num_exported_dnd_types,
const char **exported_dnd_types,
int num_accepted_dnd_types,
const char **accepted_dnd_types)
{
g_return_val_if_fail (folder_type_registry != NULL, FALSE);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE);
g_return_val_if_fail (type_name != NULL, FALSE);
g_return_val_if_fail (icon_name != NULL, FALSE);
return register_folder_type (folder_type_registry, type_name, icon_name,
display_name, description, user_creatable,
num_exported_dnd_types, exported_dnd_types,
num_accepted_dnd_types, accepted_dnd_types);
}
gboolean
e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
EvolutionShellComponentClient *handler)
{
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE);
g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (handler), FALSE);
return set_handler (folder_type_registry, type_name, handler);
}
gboolean
e_folder_type_registry_type_registered (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
EFolderTypeRegistryPrivate *priv;
g_return_val_if_fail (folder_type_registry != NULL, FALSE);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE);
g_return_val_if_fail (type_name != NULL, FALSE);
priv = folder_type_registry->priv;
if (get_folder_type (folder_type_registry, type_name) == NULL)
return FALSE;
return TRUE;
}
void
e_folder_type_registry_unregister_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
EFolderTypeRegistryPrivate *priv;
FolderType *folder_type;
g_return_if_fail (folder_type_registry != NULL);
g_return_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry));
g_return_if_fail (type_name != NULL);
priv = folder_type_registry->priv;
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return;
g_hash_table_remove (priv->name_to_type, folder_type->name);
folder_type_free (folder_type);
}
static void
get_type_names_hash_forall (void *key,
void *value,
void *data)
{
GList **type_name_list;
type_name_list = (GList **) data;
*type_name_list = g_list_prepend (*type_name_list, g_strdup ((const char *) key));
}
GList *
e_folder_type_registry_get_type_names (EFolderTypeRegistry *folder_type_registry)
{
GList *type_name_list;
EFolderTypeRegistryPrivate *priv;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
priv = folder_type_registry->priv;
type_name_list = NULL;
g_hash_table_foreach (priv->name_to_type, get_type_names_hash_forall, &type_name_list);
return type_name_list;
}
const char *
e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return NULL;
return folder_type->icon_name;
}
GdkPixbuf *
e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
gboolean mini)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return NULL;
if (mini)
return folder_type->mini_icon_pixbuf;
else
return folder_type->icon_pixbuf;
}
EvolutionShellComponentClient *
e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return NULL;
return folder_type->handler;
}
gboolean
e_folder_type_registry_type_is_user_creatable (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, FALSE);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE);
g_return_val_if_fail (type_name != NULL, FALSE);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return FALSE;
return folder_type->user_creatable;
}
const char *
e_folder_type_registry_get_display_name_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return FALSE;
return folder_type->display_name;
}
const char *
e_folder_type_registry_get_description_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return FALSE;
return folder_type->description;
}
GList *
e_folder_type_registry_get_exported_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return NULL;
return folder_type->exported_dnd_types;
}
GList *
e_folder_type_registry_get_accepted_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name)
{
const FolderType *folder_type;
g_return_val_if_fail (folder_type_registry != NULL, NULL);
g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL);
g_return_val_if_fail (type_name != NULL, NULL);
folder_type = get_folder_type (folder_type_registry, type_name);
if (folder_type == NULL)
return NULL;
return folder_type->accepted_dnd_types;
}
E_MAKE_TYPE (e_folder_type_registry, "EFolderTypeRegistry", EFolderTypeRegistry,
class_init, init, PARENT_TYPE)

View File

@ -1,107 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-folder-type-registry.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_FOLDER_TYPE_REGISTRY_H_
#define _E_FOLDER_TYPE_REGISTRY_H_
#include <gtk/gtkobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "evolution-shell-component-client.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_FOLDER_TYPE_REGISTRY (e_folder_type_registry_get_type ())
#define E_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistry))
#define E_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistryClass))
#define E_IS_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY))
#define E_IS_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY))
typedef struct _EFolderTypeRegistry EFolderTypeRegistry;
typedef struct _EFolderTypeRegistryPrivate EFolderTypeRegistryPrivate;
typedef struct _EFolderTypeRegistryClass EFolderTypeRegistryClass;
struct _EFolderTypeRegistry {
GtkObject parent;
EFolderTypeRegistryPrivate *priv;
};
struct _EFolderTypeRegistryClass {
GtkObjectClass parent_class;
};
GtkType e_folder_type_registry_get_type (void);
void e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry);
EFolderTypeRegistry *e_folder_type_registry_new (void);
gboolean e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
const char *icon_name,
const char *display_name,
const char *description,
gboolean user_creatable,
int num_exported_dnd_types,
const char **exported_dnd_types,
int num_accepted_dnd_types,
const char **accepted_dnd_types);
gboolean e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
EvolutionShellComponentClient *handler);
GList *e_folder_type_registry_get_type_names (EFolderTypeRegistry *folder_type_registry);
gboolean e_folder_type_registry_type_registered (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
void e_folder_type_registry_unregister_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
GdkPixbuf *e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name,
gboolean mini);
const char *e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
EvolutionShellComponentClient *e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
gboolean e_folder_type_registry_type_is_user_creatable (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
const char *e_folder_type_registry_get_display_name_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
const char *e_folder_type_registry_get_description_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
GList *e_folder_type_registry_get_exported_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
GList *e_folder_type_registry_get_accepted_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry,
const char *type_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_FOLDER_TYPE_REGISTRY_H_ */

View File

@ -1,560 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-local-folder.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
*/
/* The metafile goes like this:
<?xml version="1.0"?>
<efolder>
<type>mail</type>
<name>Inbox</name>
<name locale="it">Posta in Arrivo</name>
<description>This is the default folder for incoming messages</description>
<description locale="it">Cartella che contiene i messaggi in arrivo</description>
<homepage>http://www.somewhere.net</homepage>
</efolder>
FIXME: Do we want to use a namespace for this?
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <unistd.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <libgnome/gnome-util.h>
#include <gal/util/e-util.h>
#include <gal/util/e-xml-utils.h>
#include <libgnome/gnome-util.h>
#include "e-local-folder.h"
#define PARENT_TYPE E_TYPE_FOLDER
static EFolderClass *parent_class = NULL;
#define URI_PREFIX "file://"
#define URI_PREFIX_LEN 7
/* This provides the name and the description for a specific locale. */
struct _I18nInfo {
char *language_id;
char *name;
char *description;
};
typedef struct _I18nInfo I18nInfo;
struct _ELocalFolderPrivate {
GHashTable *language_id_to_i18n_info;
};
/* Locale information. */
static char *global_language_id = NULL;
/* I18nInfo handling. */
static I18nInfo *
i18n_info_new (const char *language_id,
const char *name,
const char *description)
{
I18nInfo *info;
info = g_new (I18nInfo, 1);
info->language_id = g_strdup (language_id);
info->name = g_strdup (name);
info->description = g_strdup (description);
return info;
}
static void
i18n_info_free (I18nInfo *info)
{
g_free (info->language_id);
g_free (info->name);
g_free (info->description);
g_free (info);
}
/* Language ID -> I18nInfo hash table handling. */
static void
add_i18n_info_to_hash (GHashTable *language_id_to_i18n_info_hash,
I18nInfo *i18n_info)
{
I18nInfo *existing_i18n_info;
existing_i18n_info = (I18nInfo *) g_hash_table_lookup (language_id_to_i18n_info_hash,
i18n_info->language_id);
if (existing_i18n_info != NULL) {
g_hash_table_remove (language_id_to_i18n_info_hash,
i18n_info->language_id);
i18n_info_free (existing_i18n_info);
}
g_hash_table_insert (language_id_to_i18n_info_hash, i18n_info->language_id, i18n_info);
}
static void
language_id_to_i18n_info_hash_foreach_free (void *key,
void *value,
void *data)
{
i18n_info_free ((I18nInfo *) value);
}
static I18nInfo *
get_i18n_info_for_language (ELocalFolder *local_folder,
const char *language_id)
{
ELocalFolderPrivate *priv;
I18nInfo *i18n_info;
priv = local_folder->priv;
if (language_id == NULL)
language_id = global_language_id;
i18n_info = g_hash_table_lookup (priv->language_id_to_i18n_info, language_id);
/* For locale info like `en_UK@yadda', we try to use `en' as a backup. */
/* Note: this is exactly the same thing that gnome-config does with the
I18N value handling. I hope it works. */
if (i18n_info == NULL) {
size_t n;
n = strcspn (language_id, "@_");
if (language_id[n] != '\0') {
char *simplified_language_id;
simplified_language_id = g_strndup (language_id, n);
i18n_info = g_hash_table_lookup (priv->language_id_to_i18n_info,
simplified_language_id);
}
}
return i18n_info;
}
/* Locale handling. */
static void
setup_global_language_id (void)
{
/* FIXME: Implement. */
global_language_id = "C";
}
/* Update the EFolder attributes according to the current locale. */
static void
update_for_global_locale (ELocalFolder *local_folder)
{
I18nInfo *i18n_info;
i18n_info = get_i18n_info_for_language (local_folder, NULL);
if (i18n_info == NULL)
i18n_info = get_i18n_info_for_language (local_folder, "C");
g_assert (i18n_info != NULL);
e_folder_set_name (E_FOLDER (local_folder), i18n_info->name);
e_folder_set_description (E_FOLDER (local_folder), i18n_info->description);
}
/* XML tree handling. */
static char *
get_string_value (xmlNode *node,
const char *name)
{
xmlNode *p;
xmlChar *xml_string;
char *retval;
p = e_xml_get_child_by_name (node, (xmlChar *) name);
if (p == NULL)
return NULL;
p = e_xml_get_child_by_name (p, (xmlChar *) "text");
if (p == NULL)
return NULL;
xml_string = xmlNodeListGetString (node->doc, p, TRUE);
retval = g_strdup ((char *) xml_string);
xmlFree (xml_string);
return retval;
}
static void
retrieve_info_item (ELocalFolder *local_folder,
xmlNode *node)
{
xmlChar *lang;
char *name;
char *description;
lang = xmlGetProp (node, "lang");
name = get_string_value (node, "name");
description = get_string_value (node, "description");
if (lang == NULL) {
e_local_folder_add_i18n_info (local_folder, "C", name, description);
} else {
e_local_folder_add_i18n_info (local_folder, lang, name, description);
xmlFree (lang);
}
g_free (name);
g_free (description);
}
static void
retrieve_info (ELocalFolder *local_folder,
xmlNode *root_xml_node)
{
ELocalFolderPrivate *priv;
xmlNode *p;
priv = local_folder->priv;
for (p = root_xml_node->children; p != NULL; p = p->next) {
if (xmlStrcmp (p->name, "info") == 0)
retrieve_info_item (local_folder, p);
}
}
static gboolean
construct_loading_metadata (ELocalFolder *local_folder,
const char *path)
{
EFolder *folder;
xmlDoc *doc;
xmlNode *root;
char *base_name;
char *type;
char *metadata_path;
char *physical_uri;
folder = E_FOLDER (local_folder);
metadata_path = g_build_filename (path, E_LOCAL_FOLDER_METADATA_FILE_NAME, NULL);
doc = xmlParseFile (metadata_path);
if (doc == NULL) {
g_free (metadata_path);
return FALSE;
}
root = xmlDocGetRootElement (doc);
if (root == NULL || root->name == NULL || strcmp (root->name, "efolder") != 0) {
g_free (metadata_path);
xmlFreeDoc (doc);
return FALSE;
}
type = get_string_value (root, "type");
if (type == NULL) {
g_free (metadata_path);
xmlFreeDoc (doc);
return FALSE;
}
base_name = g_path_get_basename (path);
e_local_folder_construct (local_folder, base_name, type, NULL);
g_free (base_name);
g_free (type);
retrieve_info (local_folder, root);
xmlFreeDoc (doc);
physical_uri = g_strconcat (URI_PREFIX, path, NULL);
e_folder_set_physical_uri (folder, physical_uri);
g_free (physical_uri);
g_free (metadata_path);
return TRUE;
}
static gboolean
save_metadata (ELocalFolder *local_folder)
{
EFolder *folder;
xmlDoc *doc;
xmlNode *root;
const char *physical_directory;
char *physical_path;
folder = E_FOLDER (local_folder);
doc = xmlNewDoc ((xmlChar *) "1.0");
root = xmlNewDocNode (doc, NULL, (xmlChar *) "efolder", NULL);
xmlDocSetRootElement (doc, root);
xmlNewChild (root, NULL, (xmlChar *) "type",
(xmlChar *) e_folder_get_type_string (folder));
if (e_folder_get_description (folder) != NULL)
xmlNewTextChild (root, NULL, (xmlChar *) "description",
(xmlChar *) e_folder_get_description (folder));
physical_directory = e_folder_get_physical_uri (folder) + URI_PREFIX_LEN - 1;
physical_path = g_build_filename (physical_directory, E_LOCAL_FOLDER_METADATA_FILE_NAME, NULL);
if (xmlSaveFile (physical_path, doc) < 0) {
unlink (physical_path);
g_free (physical_path);
xmlFreeDoc (doc);
return FALSE;
}
g_free (physical_path);
xmlFreeDoc (doc);
return TRUE;
}
/* GtkObject methods. */
static void
impl_finalize (GObject *object)
{
ELocalFolder *local_folder;
ELocalFolderPrivate *priv;
local_folder = E_LOCAL_FOLDER (object);
priv = local_folder->priv;
g_hash_table_foreach (priv->language_id_to_i18n_info,
language_id_to_i18n_info_hash_foreach_free,
NULL);
g_hash_table_destroy (priv->language_id_to_i18n_info);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
class_init (ELocalFolderClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_ref(e_folder_get_type ());
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = impl_finalize;
setup_global_language_id ();
}
static void
init (ELocalFolder *local_folder)
{
ELocalFolderPrivate *priv;
priv = g_new (ELocalFolderPrivate, 1);
priv->language_id_to_i18n_info = g_hash_table_new (g_str_hash, g_str_equal);
local_folder->priv = priv;
}
void
e_local_folder_construct (ELocalFolder *local_folder,
const char *name,
const char *type,
const char *description)
{
ELocalFolderPrivate *priv;
I18nInfo *i18n_info;
g_return_if_fail (local_folder != NULL);
g_return_if_fail (E_IS_LOCAL_FOLDER (local_folder));
g_return_if_fail (name != NULL);
g_return_if_fail (type != NULL);
priv = local_folder->priv;
e_folder_construct (E_FOLDER (local_folder), name, type, description);
i18n_info = i18n_info_new ("C", name, description);
add_i18n_info_to_hash (priv->language_id_to_i18n_info, i18n_info);
}
EFolder *
e_local_folder_new (const char *name,
const char *type,
const char *description)
{
ELocalFolder *local_folder;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (type != NULL, NULL);
local_folder = g_object_new (e_local_folder_get_type (), NULL);
e_local_folder_construct (local_folder, name, type, description);
return E_FOLDER (local_folder);
}
EFolder *
e_local_folder_new_from_path (const char *path)
{
EFolder *folder;
g_return_val_if_fail (g_path_is_absolute (path), NULL);
folder = g_object_new (e_local_folder_get_type (), NULL);
if (! construct_loading_metadata (E_LOCAL_FOLDER (folder), path)) {
g_object_unref (folder);
return NULL;
}
return folder;
}
gboolean
e_local_folder_save (ELocalFolder *local_folder)
{
g_return_val_if_fail (local_folder != NULL, FALSE);
g_return_val_if_fail (E_IS_LOCAL_FOLDER (local_folder), FALSE);
g_return_val_if_fail (e_folder_get_physical_uri (E_FOLDER (local_folder)) != NULL, FALSE);
return save_metadata (local_folder);
}
/**
* e_local_folder_add_i18n_info:
* @local_folder: A pointer to an ELocalFolder object
* @language_id: An I1I8N locale ID
* @name: Name for @local_folder in the specified @language_id
* @description: Description for @local_folder in the specified @language_id
*
* Set the @name and @description for the specified @language_id locale.
**/
void
e_local_folder_add_i18n_info (ELocalFolder *local_folder,
const char *language_id,
const char *name,
const char *description)
{
ELocalFolderPrivate *priv;
I18nInfo *info;
g_return_if_fail (local_folder != NULL);
g_return_if_fail (E_IS_LOCAL_FOLDER (local_folder));
g_return_if_fail (language_id != NULL);
g_return_if_fail (name != NULL || description != NULL);
priv = local_folder->priv;
info = i18n_info_new (language_id, name, description);
add_i18n_info_to_hash (priv->language_id_to_i18n_info, info);
update_for_global_locale (local_folder);
}
/**
* e_local_folder_get_i18n_info:
* @local_folder: A pointer to an ELocalFolder object
* @language_id: The ID of the language whose locale we want to retrieve name
* and description for
* @language_id_return: The actual locale ID that the name and description are
* saved under (e.g. if you ask for an "en_UK@yadda", we might give you the
* info for just "en")
* @name_return: A pointer to a pointer that will point to the i18nized name on
* return. Can be NULL.
* @description_return: A pointer to a pointer that will point to the i18n
* description on return. Can be NULL.
*
* Retrieve the name and description for @local_folder in the specified locale.
*
* Return value: %TRUE if some info is found for that @language_id, %FALSE
* otherwise.
**/
gboolean
e_local_folder_get_i18n_info (ELocalFolder *local_folder,
const char *language_id,
const char **language_id_return,
const char **name_return,
const char **description_return)
{
ELocalFolderPrivate *priv;
I18nInfo *i18n_info;
g_return_val_if_fail (local_folder != NULL, FALSE);
g_return_val_if_fail (E_IS_LOCAL_FOLDER (local_folder), FALSE);
g_return_val_if_fail (language_id != NULL, FALSE);
priv = local_folder->priv;
i18n_info = get_i18n_info_for_language (local_folder, language_id);
if (i18n_info == NULL) {
if (language_id_return != NULL)
*language_id_return = NULL;
if (name_return != NULL)
*name_return = NULL;
if (description_return != NULL)
*description_return = NULL;
return FALSE;
}
if (language_id_return != NULL)
*language_id_return = i18n_info->language_id;
if (name_return != NULL)
*name_return = i18n_info->name;
if (description_return != NULL)
*description_return = i18n_info->description;
return TRUE;
}
E_MAKE_TYPE (e_local_folder, "ELocalFolder", ELocalFolder, class_init, init, PARENT_TYPE)

View File

@ -1,84 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-local-folder.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_LOCAL_FOLDER_H_
#define _E_LOCAL_FOLDER_H_
#include <gtk/gtkobject.h>
#include "e-folder.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_LOCAL_FOLDER (e_local_folder_get_type ())
#define E_LOCAL_FOLDER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_LOCAL_FOLDER, ELocalFolder))
#define E_LOCAL_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_LOCAL_FOLDER, ELocalFolderClass))
#define E_IS_LOCAL_FOLDER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_LOCAL_FOLDER))
#define E_IS_LOCAL_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_LOCAL_FOLDER))
#define E_LOCAL_FOLDER_METADATA_FILE_NAME "folder-metadata.xml"
#define E_LOCAL_FOLDER_METADATA_FILE_NAME_LEN 19
typedef struct _ELocalFolder ELocalFolder;
typedef struct _ELocalFolderClass ELocalFolderClass;
typedef struct _ELocalFolderPrivate ELocalFolderPrivate;
struct _ELocalFolder {
EFolder parent;
ELocalFolderPrivate *priv;
};
struct _ELocalFolderClass {
EFolderClass parent_class;
};
GtkType e_local_folder_get_type (void);
void e_local_folder_construct (ELocalFolder *local_folder,
const char *name,
const char *type,
const char *description);
EFolder *e_local_folder_new (const char *name,
const char *type,
const char *description);
EFolder *e_local_folder_new_from_path (const char *physical_path);
gboolean e_local_folder_save (ELocalFolder *local_folder);
void e_local_folder_add_i18n_info (ELocalFolder *local_folder,
const char *language_id,
const char *name,
const char *description);
gboolean e_local_folder_get_i18n_info (ELocalFolder *local_folder,
const char *language_id,
const char **language_id_return,
const char **name_return,
const char **description_return);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __E_LOCAL_FOLDER_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-local-storage.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_LOCAL_STORAGE_H_
#define _E_LOCAL_STORAGE_H_
#include "e-folder-type-registry.h"
#include "e-storage.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_LOCAL_STORAGE (e_local_storage_get_type ())
#define E_LOCAL_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_LOCAL_STORAGE, ELocalStorage))
#define E_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_LOCAL_STORAGE, ELocalStorageClass))
#define E_IS_LOCAL_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_LOCAL_STORAGE))
#define E_IS_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_LOCAL_STORAGE))
typedef struct _ELocalStorage ELocalStorage;
typedef struct _ELocalStoragePrivate ELocalStoragePrivate;
typedef struct _ELocalStorageClass ELocalStorageClass;
struct _ELocalStorage {
EStorage parent;
ELocalStoragePrivate *priv;
};
struct _ELocalStorageClass {
EStorageClass parent_class;
};
GtkType e_local_storage_get_type (void);
EStorage *e_local_storage_open (EFolderTypeRegistry *folder_type_registry,
const char *base_path);
const char *e_local_storage_get_base_path (ELocalStorage *storage);
const GNOME_Evolution_Storage e_local_storage_get_corba_interface (ELocalStorage *storage);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __E_LOCAL_STORAGE_H__ */

View File

@ -27,7 +27,6 @@
#include "e-setup.h"
#include "e-local-folder.h"
#include "e-shell-constants.h"
#include "e-util/e-dialog-utils.h"

View File

@ -1,548 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-shell-folder-selection-dialog.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-shell-folder-selection-dialog.h"
#include "e-shell-constants.h"
#include "e-shell-marshal.h"
#include "e-storage-set-view.h"
#include "e-storage-set.h"
#include "e-shell-folder-creation-dialog.h"
#include <libgnome/gnome-i18n.h>
#include <gal/util/e-util.h>
#include <gal/widgets/e-gui-utils.h>
#include <gtk/gtksignal.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkscrolledwindow.h>
#include <string.h>
#define PARENT_TYPE (gtk_dialog_get_type ())
static GtkDialogClass *parent_class = NULL;
struct _EShellFolderSelectionDialogPrivate {
EShell *shell;
GList *allowed_types;
EStorageSet *storage_set;
GtkWidget *storage_set_view;
gboolean allow_creation;
};
enum {
FOLDER_SELECTED,
CANCELLED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
enum {
RESPONSE_NEW
};
/* Utility functions. */
static gboolean
check_folder_type_valid (EShellFolderSelectionDialog *folder_selection_dialog)
{
EShellFolderSelectionDialogPrivate *priv;
const char *selected_path;
EFolder *folder;
const char *folder_type;
GList *p;
priv = folder_selection_dialog->priv;
if (priv->allowed_types == NULL)
return TRUE;
selected_path = e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog);
if (selected_path == NULL)
return FALSE;
folder = e_storage_set_get_folder (priv->storage_set, selected_path);
if (folder == NULL)
return FALSE;
folder_type = e_folder_get_type_string (folder);
for (p = priv->allowed_types; p != NULL; p = p->next) {
const char *type, *slash;
type = (const char *) p->data;
if (strcmp (folder_type, type) == 0)
return TRUE;
slash = strchr (type, '/');
if (slash && slash[1] == '*' && strncmp (folder_type, type, slash - type) == 0)
return TRUE;
}
return FALSE;
}
static void
set_default_folder (EShellFolderSelectionDialog *shell_folder_selection_dialog,
const char *default_uri)
{
EShellFolderSelectionDialogPrivate *priv;
char *default_path;
g_assert (default_uri != NULL);
priv = shell_folder_selection_dialog->priv;
if (strncmp (default_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) {
/* `evolution:' URI. */
default_path = g_strdup (default_uri + E_SHELL_URI_PREFIX_LEN);
} else {
/* Physical URI. */
default_path = e_storage_set_get_path_for_physical_uri (priv->storage_set,
default_uri);
}
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
default_path);
g_free (default_path);
}
/* Folder creation dialog callback. */
static void
folder_creation_dialog_result_cb (EShell *shell,
EShellFolderCreationDialogResult result,
const char *path,
void *data)
{
EShellFolderSelectionDialog *dialog;
EShellFolderSelectionDialogPrivate *priv;
dialog = E_SHELL_FOLDER_SELECTION_DIALOG (data);
priv = dialog->priv;
if (priv == NULL) {
g_warning ("dialog->priv is NULL, and should not be");
return;
}
if (result == E_SHELL_FOLDER_CREATION_DIALOG_RESULT_SUCCESS)
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view),
path);
}
/* GtkObject methods. */
/* Saves the expanded state of the tree to a common filename */
static void
save_expanded_state (EShellFolderSelectionDialog *folder_selection_dialog)
{
EShellFolderSelectionDialogPrivate *priv;
char *filename;
priv = folder_selection_dialog->priv;
filename = g_strdup_printf ("%s/config/storage-set-view-expanded:folder-selection-dialog",
e_shell_get_local_directory (priv->shell));
e_tree_save_expanded_state (E_TREE (priv->storage_set_view), filename);
g_free (filename);
}
static void
impl_dispose (GObject *object)
{
EShellFolderSelectionDialog *folder_selection_dialog;
EShellFolderSelectionDialogPrivate *priv;
folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (object);
priv = folder_selection_dialog->priv;
if (priv->storage_set != NULL) {
save_expanded_state (folder_selection_dialog);
g_object_unref (priv->storage_set);
priv->storage_set = NULL;
}
if (priv->shell != NULL) {
g_object_weak_unref (G_OBJECT (priv->shell), (GWeakNotify) gtk_widget_destroy, folder_selection_dialog);
priv->shell = NULL;
}
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
EShellFolderSelectionDialog *folder_selection_dialog;
EShellFolderSelectionDialogPrivate *priv;
folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (object);
priv = folder_selection_dialog->priv;
e_free_string_list (priv->allowed_types);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* GtkDialog methods. */
static void
impl_response (GtkDialog *dialog,
int response)
{
EShellFolderSelectionDialog *folder_selection_dialog;
EShellFolderSelectionDialogPrivate *priv;
EStorageSetView *storage_set_view;
const char *default_parent_folder;
const char *default_subtype;
char *default_type;
folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (dialog);
priv = folder_selection_dialog->priv;
switch (response) {
case GTK_RESPONSE_OK:
if (check_folder_type_valid (folder_selection_dialog)) {
g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0,
e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
}
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
g_signal_emit (folder_selection_dialog, signals[CANCELLED], 0);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case RESPONSE_NEW:
storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view);
default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view);
/* The default type in the folder creation dialog will be the
first of the allowed types. If all types are allowed,
hardcode to "mail". */
if (priv->allowed_types == NULL)
default_type = g_strdup ("mail");
else {
default_subtype = (const char *) priv->allowed_types->data;
default_type = g_strndup (default_subtype,
strcspn (default_subtype, "/"));
}
e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog),
default_parent_folder,
default_type,
folder_creation_dialog_result_cb,
dialog);
g_free (default_type);
break;
}
}
/* GTK+ type initialization. */
static void
class_init (EShellFolderSelectionDialogClass *klass)
{
GObjectClass *object_class;
GtkDialogClass *dialog_class;
parent_class = g_type_class_ref(PARENT_TYPE);
object_class = G_OBJECT_CLASS (klass);
dialog_class = GTK_DIALOG_CLASS (klass);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
dialog_class->response = impl_response;
signals[FOLDER_SELECTED]
= g_signal_new ("folder_selected",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EShellFolderSelectionDialogClass, folder_selected),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[CANCELLED]
= g_signal_new ("cancelled",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EShellFolderSelectionDialogClass, cancelled),
NULL, NULL,
e_shell_marshal_NONE__NONE,
G_TYPE_NONE, 0);
}
static void
init (EShellFolderSelectionDialog *shell_folder_selection_dialog)
{
EShellFolderSelectionDialogPrivate *priv;
priv = g_new (EShellFolderSelectionDialogPrivate, 1);
priv->shell = NULL;
priv->storage_set = NULL;
priv->storage_set_view = NULL;
priv->allowed_types = NULL;
priv->allow_creation = TRUE;
shell_folder_selection_dialog->priv = priv;
}
/* ETable callbacks. */
static void
folder_selected_cb (EStorageSetView *storage_set_view,
const char *path,
void *data)
{
EShellFolderSelectionDialog *dialog;
dialog = E_SHELL_FOLDER_SELECTION_DIALOG (data);
if (check_folder_type_valid (dialog))
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
else
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
}
static void
double_click_cb (EStorageSetView *essv,
int row,
ETreePath path,
int col,
GdkEvent *event,
EShellFolderSelectionDialog *folder_selection_dialog)
{
g_return_if_fail (folder_selection_dialog != NULL);
if (check_folder_type_valid (folder_selection_dialog)) {
g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0,
e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog));
gtk_widget_destroy (GTK_WIDGET (folder_selection_dialog));
}
}
/**
* e_shell_folder_selection_dialog_construct:
* @folder_selection_dialog: A folder selection dialog widget
* @shell: The this folder selection dialog is for
* @title: Title of the window
* @caption: A brief text to be put on top of the storage view
* @default_uri: The URI of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Construct @folder_selection_dialog.
**/
void
e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog,
EShell *shell,
const char *title,
const char *caption,
const char *default_uri,
const char *allowed_types[],
gboolean allow_creation)
{
EShellFolderSelectionDialogPrivate *priv;
GtkWidget *scrolled_window;
GtkWidget *caption_label;
int i;
char *filename;
g_return_if_fail (folder_selection_dialog != NULL);
g_return_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog));
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
priv = folder_selection_dialog->priv;
/* Basic dialog setup. */
gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300);
gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title);
gtk_container_set_border_width (GTK_CONTAINER (folder_selection_dialog), 6);
if (allow_creation)
gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog),
GTK_STOCK_NEW, RESPONSE_NEW,
NULL);
gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_response_sensitive (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK, FALSE);
gtk_dialog_set_default_response (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK);
/* Make sure we get destroyed if the shell gets destroyed. */
priv->shell = shell;
g_object_weak_ref (G_OBJECT (shell), (GWeakNotify) gtk_widget_destroy, folder_selection_dialog);
/* Set up the label. */
if (caption != NULL) {
caption_label = gtk_label_new (caption);
gtk_label_set_justify (GTK_LABEL (caption_label), GTK_JUSTIFY_LEFT);
gtk_widget_show (caption_label);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
caption_label, FALSE, TRUE, 6);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
6);
}
/* Set up the storage set and its view. */
priv->storage_set = e_shell_get_storage_set (shell);
g_object_ref (priv->storage_set);
priv->storage_set_view = e_storage_set_create_new_view (priv->storage_set, NULL);
e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE);
e_storage_set_view_enable_search (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE);
/* Load the expanded state for this StorageSetView */
filename = g_strdup_printf ("%s/config/storage-set-view-expanded:folder-selection-dialog",
e_shell_get_local_directory (priv->shell));
e_tree_load_expanded_state (E_TREE (priv->storage_set_view),
filename);
g_free (filename);
g_signal_connect (priv->storage_set_view, "double_click", G_CALLBACK (double_click_cb), folder_selection_dialog);
g_signal_connect (priv->storage_set_view, "folder_selected", G_CALLBACK (folder_selected_cb), folder_selection_dialog);
g_assert (priv->allowed_types == NULL);
if (allowed_types != NULL) {
for (i = 0; allowed_types[i] != NULL; i++)
priv->allowed_types = g_list_prepend (priv->allowed_types,
g_strdup (allowed_types[i]));
/* Preserve the order so we can use the first type listed as
the default for the folder creation dialog invoked by the
"New..." button. */
priv->allowed_types = g_list_reverse (priv->allowed_types);
}
if (default_uri != NULL)
set_default_folder (folder_selection_dialog, default_uri);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scrolled_window), priv->storage_set_view);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox),
scrolled_window, TRUE, TRUE, 6);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), 6);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (folder_selection_dialog)->vbox), 6);
gtk_widget_show (priv->storage_set_view);
gtk_widget_show (scrolled_window);
GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS);
gtk_widget_grab_focus (priv->storage_set_view);
}
/**
* e_shell_folder_selection_dialog_new:
* @shell: The this folder selection dialog is for
* @title: Title of the window
* @caption: A brief text to be put on top of the storage view
* @default_uri: The URI of the folder to be selected by default
* @allowed_types: List of the names of the allowed types
*
* Create a new folder selection dialog widget. @default_uri can be either an
* `evolution:' URI or a physical URI (all the non-`evolution:' URIs are
* considered to be physical URIs).
*
* Return value:
**/
GtkWidget *
e_shell_folder_selection_dialog_new (EShell *shell,
const char *title,
const char *caption,
const char *default_uri,
const char *allowed_types[],
gboolean allow_creation)
{
EShellFolderSelectionDialog *folder_selection_dialog;
g_return_val_if_fail (shell != NULL, NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
folder_selection_dialog = g_object_new (e_shell_folder_selection_dialog_get_type (), NULL);
e_shell_folder_selection_dialog_construct (folder_selection_dialog, shell,
title, caption, default_uri, allowed_types,
allow_creation);
return GTK_WIDGET (folder_selection_dialog);
}
const char *
e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog)
{
EShellFolderSelectionDialogPrivate *priv;
g_return_val_if_fail (folder_selection_dialog != NULL, NULL);
g_return_val_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL);
priv = folder_selection_dialog->priv;
return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view));
}
E_MAKE_TYPE (e_shell_folder_selection_dialog, "EShellFolderSelectionDialog", EShellFolderSelectionDialog,
class_init, init, PARENT_TYPE)

View File

@ -1,82 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-shell-folder-selection-dialog.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_SHELL_FOLDER_SELECTION_DIALOG_H
#define E_SHELL_FOLDER_SELECTION_DIALOG_H
#include <gtk/gtkdialog.h>
#include "e-shell.h"
#ifdef cplusplus
extern "C" {
#pragma }
#endif /* cplusplus */
#define E_TYPE_SHELL_FOLDER_SELECTION_DIALOG (e_shell_folder_selection_dialog_get_type ())
#define E_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialog))
#define E_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialogClass))
#define E_IS_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG))
#define E_IS_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG))
typedef struct _EShellFolderSelectionDialog EShellFolderSelectionDialog;
typedef struct _EShellFolderSelectionDialogPrivate EShellFolderSelectionDialogPrivate;
typedef struct _EShellFolderSelectionDialogClass EShellFolderSelectionDialogClass;
struct _EShellFolderSelectionDialog {
GtkDialog parent;
EShellFolderSelectionDialogPrivate *priv;
};
struct _EShellFolderSelectionDialogClass {
GtkDialogClass parent_class;
void (* folder_selected) (EShellFolderSelectionDialog *folder_selection_dialog,
const char *path);
void (* cancelled) (EShellFolderSelectionDialog *folder_selection_dialog);
};
GtkType e_shell_folder_selection_dialog_get_type (void);
void e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog,
EShell *shell,
const char *title,
const char *caption,
const char *default_uri,
const char *allowed_types[],
gboolean allow_creation);
GtkWidget *e_shell_folder_selection_dialog_new (EShell *shell,
const char *title,
const char *caption,
const char *default_uri,
const char *allowed_types[],
gboolean allow_creation);
const char *e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog);
#ifdef cplusplus
}
#endif /* cplusplus */
#endif /* E_SHELL_FOLDER_SELECTION_DIALOG_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-shell-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_SHELL_VIEW_H_
#define _E_SHELL_VIEW_H_
#include "e-task-bar.h"
#include <bonobo/bonobo-window.h>
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-ui-container.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_SHELL_VIEW (e_shell_view_get_type ())
#define E_SHELL_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL_VIEW, EShellView))
#define E_SHELL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_VIEW, EShellViewClass))
#define E_IS_SHELL_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL_VIEW))
#define E_IS_SHELL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_VIEW))
typedef struct _EShellView EShellView;
typedef struct _EShellViewPrivate EShellViewPrivate;
typedef struct _EShellViewClass EShellViewClass;
#include "e-shell.h"
#define E_SHELL_VIEW_DEFAULT_URI "evolution:/summary"
struct _EShellView {
BonoboWindow parent;
EShellViewPrivate *priv;
};
struct _EShellViewClass {
BonoboWindowClass parent_class;
/* Signals. */
void (* shortcut_bar_visibility_changed) (EShellView *shell_view,
gboolean visible);
void (* folder_bar_visibility_changed) (EShellView *shell_view,
gboolean visible);
void (* view_changed) (EShellView *shell_view,
const char *evolution_path,
const char *physical_uri,
const char *folder_type,
const char *component_id);
};
/* WARNING: Don't use `e_shell_view_new()' to create new views for the shell
unless you know what you are doing; this is just the standard GTK+
constructor thing and it won't allow the shell to do the required
bookkeeping for the created views. Instead, the right way to create a new
view is calling `e_shell_new_view()'. */
GtkType e_shell_view_get_type (void);
EShellView *e_shell_view_construct (EShellView *shell_view,
EShell *shell,
const char *uri);
EShellView *e_shell_view_new (EShell *shell,
const char *uri);
const GNOME_Evolution_ShellView e_shell_view_get_corba_interface (EShellView *view);
gboolean e_shell_view_display_uri (EShellView *shell_view,
const char *uri,
gboolean queue);
void e_shell_view_show_shortcut_bar (EShellView *shell_view,
gboolean show);
gboolean e_shell_view_shortcut_bar_shown (EShellView *shell_view);
void e_shell_view_show_folder_bar (EShellView *shell_view,
gboolean show);
gboolean e_shell_view_folder_bar_shown (EShellView *shell_view);
void e_shell_view_show_settings (EShellView *shell_view);
ETaskBar *e_shell_view_get_task_bar (EShellView *shell_view);
EShell *e_shell_view_get_shell (EShellView *shell_view);
BonoboUIComponent *e_shell_view_get_bonobo_ui_component (EShellView *shell_view);
BonoboUIContainer *e_shell_view_get_bonobo_ui_container (EShellView *shell_view);
GtkWidget *e_shell_view_get_appbar (EShellView *shell_view);
const char *e_shell_view_get_current_uri (EShellView *shell_view);
const char *e_shell_view_get_current_physical_uri (EShellView *shell_view);
const char *e_shell_view_get_current_folder_type (EShellView *shell_view);
const char *e_shell_view_get_current_component_id (EShellView *shell_view);
const char *e_shell_view_get_current_path (EShellView *shell_view);
void e_shell_view_save_defaults (EShellView *shell_view);
int e_shell_view_get_current_shortcuts_group_num (EShellView *shell_view);
void e_shell_view_set_current_shortcuts_group_num (EShellView *shell_view,
int group_num);
/* Private -- */
const char *e_shell_view_get_folder_bar_right_click_path (EShellView *shell_view);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_SHELL_VIEW_H_ */

View File

@ -32,11 +32,9 @@
#include "e-shell-constants.h"
#include "e-shell-settings-dialog.h"
#include "e-shell-startup-wizard.h"
#include "e-uri-schema-registry.h"
#include "e-shell-marshal.h"
#include "evolution-shell-component-client.h"
#include "evolution-shell-component-utils.h"
#include "importer/intelligent.h"
@ -79,7 +77,7 @@ struct _EShellPrivate {
GList *windows;
EUserCreatableItemsHandler *user_creatable_items_handler;
EUriSchemaRegistry *uri_schema_registry;
/* EUriSchemaRegistry *uri_schema_registry; FIXME */
EComponentRegistry *component_registry;
/* Names for the types of the folders that have maybe crashed. */
@ -195,6 +193,7 @@ impl_Shell_handleURI (PortableServer_Servant servant,
const CORBA_char *uri,
CORBA_Environment *ev)
{
#if 0
EvolutionShellComponentClient *schema_handler;
EShell *shell;
EShellPrivate *priv;
@ -239,6 +238,7 @@ impl_Shell_handleURI (PortableServer_Servant servant,
ex_GNOME_Evolution_Shell_NotFound, NULL);
return;
}
#endif
}
static void
@ -360,10 +360,12 @@ impl_dispose (GObject *object)
priv->user_creatable_items_handler = NULL;
}
#if 0 /* FIXME */
if (priv->uri_schema_registry != NULL) {
g_object_unref (priv->uri_schema_registry);
priv->uri_schema_registry = NULL;
}
#endif
for (p = priv->windows; p != NULL; p = p->next) {
EShellWindow *window;
@ -644,6 +646,7 @@ e_shell_request_close_window (EShell *shell,
}
#if 0 /* FIXME */
/**
* e_shell_peek_uri_schema_registry:
* @shell: An EShell object.
@ -659,6 +662,8 @@ e_shell_peek_uri_schema_registry (EShell *shell)
return shell->priv->uri_schema_registry;
}
#endif
/**
* e_shell_peek_component_registry:

View File

@ -39,7 +39,6 @@ typedef struct _EShellClass EShellClass;
#include "e-component-registry.h"
#include "e-shell-window.h"
#include "e-uri-schema-registry.h"
#include "e-user-creatable-items-handler.h"
@ -108,7 +107,10 @@ gboolean e_shell_request_close_window (EShell *shell,
EShellWindow *window);
#if 0
EUriSchemaRegistry *e_shell_peek_uri_schema_registry (EShell *shell);
#endif
EComponentRegistry *e_shell_peek_component_registry (EShell *shell);
gboolean e_shell_save_settings (EShell *shell);

View File

@ -1,347 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage-browser.c
*
* Copyright (C) 2003 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>
*/
/* TODO:
- Currently it assumes that the starting path always exists, and you
can't remove it. It might be a limitation, but it makes the logic
very simple and robust.
- Doesn't save expansion state for nodes.
- Context menu handling?
*/
#include <config.h>
#include "e-storage-browser.h"
#include "e-shell-marshal.h"
#include "e-storage-set-view.h"
#include <gal/util/e-util.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtkscrolledwindow.h>
#include <string.h>
#define PARENT_TYPE G_TYPE_OBJECT
static GObjectClass *parent_class = NULL;
struct _EStorageBrowserPrivate {
char *starting_path;
char *current_path;
GtkWidget *view_notebook;
GtkWidget *storage_set_view;
GtkWidget *storage_set_view_scrolled;
GHashTable *path_to_view; /* (char *, GtkWidget *) */
EStorageBrowserCreateViewCallback create_view_callback;
void *create_view_callback_data;
};
enum {
WIDGETS_GONE,
PAGE_SWITCHED,
NUM_SIGNALS
};
static unsigned int signals[NUM_SIGNALS] = { 0 };
/* Callbacks. */
static void
storage_set_view_folder_selected_callback (EStorageSetView *storage_set_view,
const char *path,
EStorageBrowser *browser)
{
if (! e_storage_browser_show_path (browser, path)) {
/* Make the selection go back to where it was. */
e_storage_browser_show_path (browser, browser->priv->current_path);
}
}
static void
storage_set_removed_folder_callback (EStorageSet *storage_set,
const char *path,
EStorageBrowser *browser)
{
if (g_hash_table_lookup (browser->priv->path_to_view, path) != NULL)
e_storage_browser_remove_view_for_path (browser, path);
}
static void
view_notebook_weak_notify (EStorageBrowser *browser)
{
browser->priv->view_notebook = NULL;
if (browser->priv->storage_set_view == NULL)
g_signal_emit (browser, signals[WIDGETS_GONE], 0);
}
static void
storage_set_view_weak_notify (EStorageBrowser *browser)
{
browser->priv->storage_set_view = NULL;
if (browser->priv->view_notebook == NULL)
g_signal_emit (browser, signals[WIDGETS_GONE], 0);
}
/* GObject methods. */
static void
impl_dispose (GObject *object)
{
EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv;
if (priv->view_notebook != NULL) {
g_object_weak_unref (G_OBJECT (priv->view_notebook),
(GWeakNotify) view_notebook_weak_notify,
object);
priv->view_notebook = NULL;
}
if (priv->storage_set_view != NULL) {
g_object_weak_unref (G_OBJECT (priv->storage_set_view),
(GWeakNotify) storage_set_view_weak_notify,
object);
priv->storage_set_view = NULL;
}
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv;
g_free (priv->starting_path);
g_free (priv->current_path);
g_hash_table_destroy (priv->path_to_view);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
class_init (EStorageBrowserClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
parent_class = g_type_class_peek_parent (class);
signals[WIDGETS_GONE]
= g_signal_new ("widgets_gone",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EStorageBrowserClass, widgets_gone),
NULL, NULL,
e_shell_marshal_NONE__NONE,
G_TYPE_NONE, 0);
signals[PAGE_SWITCHED]
= g_signal_new ("page_switched",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EStorageBrowserClass, page_switched),
NULL, NULL,
e_shell_marshal_NONE__POINTER_POINTER,
G_TYPE_NONE, 2,
G_TYPE_POINTER, G_TYPE_POINTER);
}
static void
init (EStorageBrowser *browser)
{
EStorageBrowserPrivate *priv;
priv = g_new0 (EStorageBrowserPrivate, 1);
priv->path_to_view = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
priv->view_notebook = gtk_notebook_new ();
g_object_weak_ref (G_OBJECT (priv->view_notebook), (GWeakNotify) view_notebook_weak_notify, browser);
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE);
browser->priv = priv;
}
EStorageBrowser *
e_storage_browser_new (EStorageSet *storage_set,
const char *starting_path,
EStorageBrowserCreateViewCallback create_view_callback,
void *callback_data)
{
EStorageBrowser *new;
g_return_val_if_fail (create_view_callback != NULL, NULL);
new = g_object_new (e_storage_browser_get_type (), NULL);
new->priv->create_view_callback = create_view_callback;
new->priv->create_view_callback_data = callback_data;
new->priv->starting_path = g_strdup (starting_path);
new->priv->storage_set_view = e_storage_set_create_new_view (storage_set, NULL);
gtk_widget_show (new->priv->storage_set_view);
new->priv->storage_set_view_scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (new->priv->storage_set_view_scrolled), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (new->priv->storage_set_view_scrolled), new->priv->storage_set_view);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (new->priv->storage_set_view_scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
g_object_weak_ref (G_OBJECT (new->priv->storage_set_view), (GWeakNotify) storage_set_view_weak_notify, new);
g_signal_connect_object (new->priv->storage_set_view,
"folder_selected", G_CALLBACK (storage_set_view_folder_selected_callback),
G_OBJECT (new), 0);
g_signal_connect_object (e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (new->priv->storage_set_view)),
"removed_folder", G_CALLBACK (storage_set_removed_folder_callback),
G_OBJECT (new), 0);
if (! e_storage_browser_show_path (new, starting_path)) {
g_object_unref (new);
return NULL;
}
return new;
}
GtkWidget *
e_storage_browser_peek_tree_widget (EStorageBrowser *browser)
{
return browser->priv->storage_set_view;
}
GtkWidget *
e_storage_browser_peek_tree_widget_scrolled (EStorageBrowser *browser)
{
return browser->priv->storage_set_view_scrolled;
}
GtkWidget *
e_storage_browser_peek_view_widget (EStorageBrowser *browser)
{
return browser->priv->view_notebook;
}
EStorageSet *
e_storage_browser_peek_storage_set (EStorageBrowser *browser)
{
return e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (browser->priv->storage_set_view));
}
gboolean
e_storage_browser_show_path (EStorageBrowser *browser,
const char *path)
{
EStorageBrowserPrivate *priv = browser->priv;
GtkWidget *current_view;
GtkWidget *existing_view;
GtkWidget *new_view;
GtkNotebook *notebook;
notebook = GTK_NOTEBOOK (priv->view_notebook);
current_view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->view_notebook),
gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->view_notebook)));
existing_view = g_hash_table_lookup (priv->path_to_view, path);
if (existing_view != NULL) {
gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, existing_view));
g_print ("page switched\n");
g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, existing_view);
return TRUE;
}
new_view = (* priv->create_view_callback) (browser, path, priv->create_view_callback_data);
if (new_view == NULL)
return FALSE;
gtk_widget_show (new_view);
gtk_notebook_append_page (notebook, new_view, NULL);
gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, new_view));
g_print ("page switched\n");
g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, new_view);
g_object_ref(new_view);
g_hash_table_insert (priv->path_to_view, g_strdup (path), new_view);
g_free (priv->current_path);
priv->current_path = g_strdup (path);
e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), path);
return TRUE;
}
void
e_storage_browser_remove_view_for_path (EStorageBrowser *browser,
const char *path)
{
GtkWidget *view;
if (strcmp (path, browser->priv->starting_path) == 0) {
g_warning (G_GNUC_FUNCTION ": cannot remove starting view");
return;
}
view = g_hash_table_lookup (browser->priv->path_to_view, path);
if (view == NULL) {
g_warning (G_GNUC_FUNCTION ": no view for %s", path);
return;
}
g_hash_table_remove (browser->priv->path_to_view, path);
gtk_widget_destroy (view);
e_storage_browser_show_path (browser, browser->priv->starting_path);
}
E_MAKE_TYPE (e_storage_browser, "EStorageBrowser", EStorageBrowser, class_init, init, PARENT_TYPE)

View File

@ -1,84 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage-browser.h
*
* Copyright (C) 2003 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>
*/
#ifndef _E_STORAGE_BROWSER_H_
#define _E_STORAGE_BROWSER_H_
#include "e-storage-set.h"
#include <glib-object.h>
#include <gtk/gtkwidget.h>
#define E_TYPE_STORAGE_BROWSER (e_storage_browser_get_type ())
#define E_STORAGE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_STORAGE_BROWSER, EStorageBrowser))
#define E_STORAGE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_BROWSER, EStorageBrowserClass))
#define E_IS_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_STORAGE_BROWSER))
#define E_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_BROWSER))
typedef struct _EStorageBrowser EStorageBrowser;
typedef struct _EStorageBrowserPrivate EStorageBrowserPrivate;
typedef struct _EStorageBrowserClass EStorageBrowserClass;
/* FIXME: Use a GClosure instead of void *? */
typedef GtkWidget * (* EStorageBrowserCreateViewCallback) (EStorageBrowser *browser,
const char *path,
void *data);
struct _EStorageBrowser {
GObject parent;
EStorageBrowserPrivate *priv;
};
struct _EStorageBrowserClass {
GObjectClass parent_class;
void (* widgets_gone) (EStorageBrowser *browser);
void (* page_switched) (EStorageBrowser *browser,
GtkWidget *old_page,
GtkWidget *new_page);
};
GType e_storage_browser_get_type (void);
EStorageBrowser *e_storage_browser_new (EStorageSet *storage_set,
const char *starting_path,
EStorageBrowserCreateViewCallback create_view_callback,
void *create_view_callback_data);
GtkWidget *e_storage_browser_peek_tree_widget (EStorageBrowser *browser);
GtkWidget *e_storage_browser_peek_tree_widget_scrolled (EStorageBrowser *browser);
GtkWidget *e_storage_browser_peek_view_widget (EStorageBrowser *browser);
EStorageSet *e_storage_browser_peek_storage_set (EStorageBrowser *browser);
gboolean e_storage_browser_show_path (EStorageBrowser *browser,
const char *path);
void e_storage_browser_remove_view_for_path (EStorageBrowser *browser,
const char *path);
#endif /* _E_STORAGE_BROWSER_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage-set-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_STORAGE_SET_VIEW_H__
#define __E_STORAGE_SET_VIEW_H__
#include <gal/e-table/e-tree.h>
#include <bonobo/bonobo-ui-container.h>
#include "e-storage-set.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_STORAGE_SET_VIEW (e_storage_set_view_get_type ())
#define E_STORAGE_SET_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE_SET_VIEW, EStorageSetView))
#define E_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_SET_VIEW, EStorageSetViewClass))
#define E_IS_STORAGE_SET_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE_SET_VIEW))
#define E_IS_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_SET_VIEW))
typedef gboolean (* EStorageSetViewHasCheckBoxFunc) (EStorageSet *storage_set,
const char *path,
void *data);
typedef struct _EStorageSetView EStorageSetView;
typedef struct _EStorageSetViewPrivate EStorageSetViewPrivate;
typedef struct _EStorageSetViewClass EStorageSetViewClass;
struct _EStorageSetView {
ETree parent;
EStorageSetViewPrivate *priv;
};
struct _EStorageSetViewClass {
ETreeClass parent_class;
/* Signals. */
void (* folder_selected) (EStorageSetView *storage_set_view,
const char *path);
void (* folder_opened) (EStorageSetView *storage_set_view,
const char *path);
void (* folder_dragged) (EStorageSetView *view, const char *path, GdkDragContext *context,
GtkSelectionData *selection, guint info, guint time);
void (* folder_receive_drop) (EStorageSetView *view, const char *path, GdkDragContext *context,
GtkSelectionData *selection, guint info, guint time);
void (* folder_context_menu_popping_up) (EStorageSetView *storage_set_view,
const char *path);
void (* folder_context_menu_popped_down) (EStorageSetView *storage_set_view);
void (* checkboxes_changed) (EStorageSetView *storage_set_view);
};
GtkType e_storage_set_view_get_type (void);
/* DON'T USE THIS. Use e_storage_set_new_view() instead. */
GtkWidget *e_storage_set_view_new (EStorageSet *storage_set,
BonoboUIContainer *ui_container);
void e_storage_set_view_construct (EStorageSetView *storage_set_view,
EStorageSet *storage_set,
BonoboUIContainer *ui_container);
EStorageSet *e_storage_set_view_get_storage_set (EStorageSetView *storage_set_view);
void e_storage_set_view_set_drag_types (EStorageSetView *view, const GtkTargetEntry *drag_types, int ntypes);
void e_storage_set_view_set_drop_types (EStorageSetView *view, const GtkTargetEntry *drop_types, int ntypes);
void e_storage_set_view_set_current_folder (EStorageSetView *storage_set_view,
const char *path);
const char *e_storage_set_view_get_current_folder (EStorageSetView *storage_set_view);
void e_storage_set_view_set_show_folders (EStorageSetView *storage_set_view,
gboolean show);
gboolean e_storage_set_view_get_show_folders (EStorageSetView *storage_set_view);
void e_storage_set_view_set_show_checkboxes (EStorageSetView *storage_set_view,
gboolean show,
EStorageSetViewHasCheckBoxFunc has_checkbox_func,
void *func_data);
gboolean e_storage_set_view_get_show_checkboxes (EStorageSetView *storage_set_view);
void e_storage_set_view_enable_search (EStorageSetView *storage_set_view,
gboolean enable);
void e_storage_set_view_set_checkboxes_list (EStorageSetView *storage_set_view,
GSList *checkboxes);
GSList *e_storage_set_view_get_checkboxes_list (EStorageSetView *storage_set_view);
void e_storage_set_view_set_allow_dnd (EStorageSetView *storage_set_view,
gboolean allow_dnd);
gboolean e_storage_set_view_get_allow_dnd (EStorageSetView *storage_set_view);
const char *e_storage_set_view_get_right_click_path (EStorageSetView *storage_set_view);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __E_STORAGE_SET_VIEW_H__ */

View File

@ -1,885 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage-set.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 "e-storage-set.h"
#include "e-storage-set-view.h"
#include "e-shell-constants.h"
#include "e-shell-marshal.h"
#include <glib.h>
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktypeutils.h>
#include <gal/util/e-util.h>
#include <string.h>
#define PARENT_TYPE GTK_TYPE_OBJECT
static GtkObjectClass *parent_class = NULL;
/* This is just to make GHashTable happy. */
struct _NamedStorage {
char *name;
EStorage *storage;
};
typedef struct _NamedStorage NamedStorage;
struct _EStorageSetPrivate {
GList *storages; /* EStorage */
GHashTable *name_to_named_storage;
EFolderTypeRegistry *folder_type_registry;
};
enum {
NEW_STORAGE,
REMOVED_STORAGE,
NEW_FOLDER,
UPDATED_FOLDER,
REMOVED_FOLDER,
MOVED_FOLDER,
CLOSE_FOLDER,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static NamedStorage *
named_storage_new (EStorage *storage)
{
NamedStorage *new;
new = g_new (NamedStorage, 1);
new->name = g_strdup (e_storage_get_name (storage));
new->storage = storage;
return new;
}
static void
named_storage_destroy (NamedStorage *named_storage)
{
g_free (named_storage->name);
g_free (named_storage);
}
static gboolean
name_to_named_storage_foreach_destroy (void *key,
void *value,
void *user_data)
{
NamedStorage *named_storage;
named_storage = (NamedStorage *) value;
named_storage_destroy (named_storage);
return TRUE;
}
/* "Callback converter", from `EStorageResultCallback' to
`EStorageSetResultCallback'. */
enum _StorageOperation {
OPERATION_COPY,
OPERATION_MOVE,
OPERATION_REMOVE,
OPERATION_CREATE
};
typedef enum _StorageOperation StorageOperation;
struct _StorageCallbackData {
EStorageSet *storage_set;
EStorageSetResultCallback storage_set_result_callback;
char *source_path;
char *destination_path;
StorageOperation operation;
void *data;
};
typedef struct _StorageCallbackData StorageCallbackData;
static StorageCallbackData *
storage_callback_data_new (EStorageSet *storage_set,
EStorageSetResultCallback callback,
const char *source_path,
const char *destination_path,
StorageOperation operation,
void *data)
{
StorageCallbackData *new;
new = g_new (StorageCallbackData, 1);
new->storage_set = storage_set;
new->storage_set_result_callback = callback;
new->source_path = g_strdup (source_path);
new->destination_path = g_strdup (destination_path);
new->operation = operation;
new->data = data;
return new;
}
static void
storage_callback_data_free (StorageCallbackData *data)
{
g_free (data->source_path);
g_free (data->destination_path);
g_free (data);
}
static void
storage_callback (EStorage *storage,
EStorageResult result,
void *data)
{
StorageCallbackData *storage_callback_data;
storage_callback_data = (StorageCallbackData *) data;
(* storage_callback_data->storage_set_result_callback) (storage_callback_data->storage_set,
result,
storage_callback_data->data);
if (storage_callback_data->operation == OPERATION_MOVE)
g_signal_emit (storage_callback_data->storage_set, signals[MOVED_FOLDER], 0,
storage_callback_data->source_path, storage_callback_data->destination_path);
storage_callback_data_free (storage_callback_data);
}
/* Handling for signals coming from the EStorages. */
static char *
make_full_path (EStorage *storage,
const char *path)
{
const char *storage_name;
char *full_path;
storage_name = e_storage_get_name (storage);
if (strcmp (path, E_PATH_SEPARATOR_S) == 0)
full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name,
NULL);
else if (! g_path_is_absolute (path))
full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name,
E_PATH_SEPARATOR_S, path, NULL);
else
full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name,
path, NULL);
return full_path;
}
static void
storage_new_folder_cb (EStorage *storage,
const char *path,
void *data)
{
EStorageSet *storage_set;
char *full_path;
storage_set = E_STORAGE_SET (data);
full_path = make_full_path (storage, path);
g_signal_emit (storage_set, signals[NEW_FOLDER], 0, full_path);
g_free (full_path);
}
static void
storage_updated_folder_cb (EStorage *storage,
const char *path,
void *data)
{
EStorageSet *storage_set;
char *full_path;
storage_set = E_STORAGE_SET (data);
full_path = make_full_path (storage, path);
g_signal_emit (storage_set, signals[UPDATED_FOLDER], 0, full_path);
g_free (full_path);
}
static void
storage_removed_folder_cb (EStorage *storage,
const char *path,
void *data)
{
EStorageSet *storage_set;
char *full_path;
storage_set = E_STORAGE_SET (data);
full_path = make_full_path (storage, path);
g_signal_emit (storage_set, signals[REMOVED_FOLDER], 0, full_path);
g_free (full_path);
}
static EStorage *
get_storage_for_path (EStorageSet *storage_set,
const char *path,
const char **subpath_return)
{
EStorage *storage;
char *storage_name;
const char *first_separator;
g_return_val_if_fail (g_path_is_absolute (path), NULL);
g_return_val_if_fail (path[1] != E_PATH_SEPARATOR, NULL);
/* Skip initial separator. */
path++;
first_separator = strchr (path, E_PATH_SEPARATOR);
if (first_separator == NULL || first_separator[1] == 0) {
storage = e_storage_set_get_storage (storage_set, path);
*subpath_return = E_PATH_SEPARATOR_S;
} else {
storage_name = g_strndup (path, first_separator - path);
storage = e_storage_set_get_storage (storage_set, storage_name);
g_free (storage_name);
*subpath_return = first_separator;
}
return storage;
}
static void
signal_new_folder_for_all_folders_under_paths (EStorageSet *storage_set,
EStorage *storage,
GList *path_list)
{
GList *p;
for (p = path_list; p != NULL; p = p->next) {
GList *sub_path_list;
const char *path;
char *path_with_storage;
path = (const char *) p->data;
path_with_storage = g_strconcat (E_PATH_SEPARATOR_S, e_storage_get_name (storage), path, NULL);
g_signal_emit (storage_set, signals[NEW_FOLDER], 0, path_with_storage);
g_free (path_with_storage);
sub_path_list = e_storage_get_subfolder_paths (storage, path);
signal_new_folder_for_all_folders_under_paths (storage_set, storage, sub_path_list);
e_free_string_list (sub_path_list);
}
}
static void
signal_new_folder_for_all_folders_in_storage (EStorageSet *storage_set,
EStorage *storage)
{
GList *path_list;
path_list = e_storage_get_subfolder_paths (storage, E_PATH_SEPARATOR_S);
signal_new_folder_for_all_folders_under_paths (storage_set, storage, path_list);
e_free_string_list (path_list);
}
/* GtkObject methods. */
static void
impl_dispose (GObject *object)
{
EStorageSet *storage_set;
EStorageSetPrivate *priv;
storage_set = E_STORAGE_SET (object);
priv = storage_set->priv;
if (priv->storages != NULL) {
e_free_object_list (priv->storages);
priv->storages = NULL;
}
if (priv->folder_type_registry != NULL) {
g_object_unref (priv->folder_type_registry);
priv->folder_type_registry = NULL;
}
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
EStorageSet *storage_set;
EStorageSetPrivate *priv;
storage_set = E_STORAGE_SET (object);
priv = storage_set->priv;
g_hash_table_foreach (priv->name_to_named_storage, (GHFunc) name_to_named_storage_foreach_destroy, NULL);
g_hash_table_destroy (priv->name_to_named_storage);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
class_init (EStorageSetClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_ref(gtk_object_get_type ());
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
signals[NEW_STORAGE] =
g_signal_new ("new_storage",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, new_storage),
NULL, NULL,
e_shell_marshal_NONE__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[REMOVED_STORAGE] =
g_signal_new ("removed_storage",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, removed_storage),
NULL, NULL,
e_shell_marshal_NONE__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[NEW_FOLDER] =
g_signal_new ("new_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, new_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[UPDATED_FOLDER] =
g_signal_new ("updated_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, updated_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[REMOVED_FOLDER] =
g_signal_new ("removed_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, removed_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[MOVED_FOLDER] =
g_signal_new ("moved_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, moved_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING_STRING,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
signals[CLOSE_FOLDER] =
g_signal_new ("close_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageSetClass, close_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
}
static void
init (EStorageSet *storage_set)
{
EStorageSetPrivate *priv;
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
priv = g_new (EStorageSetPrivate, 1);
priv->storages = NULL;
priv->name_to_named_storage = g_hash_table_new (g_str_hash, g_str_equal);
priv->folder_type_registry = NULL;
storage_set->priv = priv;
}
void
e_storage_set_construct (EStorageSet *storage_set,
EFolderTypeRegistry *folder_type_registry)
{
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
GTK_OBJECT_UNSET_FLAGS (storage_set, GTK_FLOATING);
g_object_ref (folder_type_registry);
storage_set->priv->folder_type_registry = folder_type_registry;
}
EStorageSet *
e_storage_set_new (EFolderTypeRegistry *folder_type_registry)
{
EStorageSet *new;
new = g_object_new (e_storage_set_get_type (), NULL);
e_storage_set_construct (new, folder_type_registry);
return new;
}
GList *
e_storage_set_get_storage_list (EStorageSet *storage_set)
{
EStorageSetPrivate *priv;
GList *list;
GList *p;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
priv = storage_set->priv;
list = NULL;
for (p = priv->storages; p != NULL; p = p->next) {
g_object_ref (p->data);
list = g_list_prepend (list, p->data);
}
return g_list_reverse (list); /* Lame. */
}
/**
* e_storage_set_add_storage:
* @storage_set:
* @storage:
*
* Add @storage to @storage_set. Notice that will ref the storage.
**/
gboolean
e_storage_set_add_storage (EStorageSet *storage_set,
EStorage *storage)
{
EStorageSetPrivate *priv;
const char *storage_name;
NamedStorage *named_storage;
g_return_val_if_fail (storage_set != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE);
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
priv = storage_set->priv;
storage_name = e_storage_get_name (storage);
if (g_hash_table_lookup (priv->name_to_named_storage, storage_name) != NULL)
return FALSE;
g_object_ref (storage);
g_signal_connect (storage, "new_folder",
G_CALLBACK (storage_new_folder_cb), storage_set);
g_signal_connect (storage, "updated_folder",
G_CALLBACK (storage_updated_folder_cb), storage_set);
g_signal_connect (storage, "removed_folder",
G_CALLBACK (storage_removed_folder_cb), storage_set);
priv->storages = g_list_append (priv->storages, storage);
named_storage = named_storage_new (storage);
g_hash_table_insert (priv->name_to_named_storage, named_storage->name, named_storage);
g_signal_emit (storage_set, signals[NEW_STORAGE], 0, storage);
signal_new_folder_for_all_folders_in_storage (storage_set, storage);
return TRUE;
}
gboolean
e_storage_set_remove_storage (EStorageSet *storage_set,
EStorage *storage)
{
EStorageSetPrivate *priv;
NamedStorage *named_storage;
g_return_val_if_fail (storage_set != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE);
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
priv = storage_set->priv;
named_storage = g_hash_table_lookup (priv->name_to_named_storage,
e_storage_get_name (storage));
if (named_storage == NULL)
return FALSE;
g_hash_table_remove (priv->name_to_named_storage, named_storage->name);
named_storage_destroy (named_storage);
priv->storages = g_list_remove (priv->storages, storage);
g_signal_emit (storage_set, signals[REMOVED_STORAGE], 0, storage);
g_object_unref (storage);
return TRUE;
}
void
e_storage_set_remove_all_storages (EStorageSet *storage_set)
{
EStorageSetPrivate *priv;
GList *p;
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
priv = storage_set->priv;
for (p = priv->storages; p != NULL; p = p->next) {
EStorage *storage;
storage = E_STORAGE (p->data);
g_signal_emit (storage_set, signals[REMOVED_STORAGE], 0, storage);
g_object_unref (storage);
}
g_hash_table_foreach_remove (priv->name_to_named_storage,
name_to_named_storage_foreach_destroy,
NULL);
g_list_free (priv->storages);
priv->storages = NULL;
}
EStorage *
e_storage_set_get_storage (EStorageSet *storage_set,
const char *name)
{
EStorageSetPrivate *priv;
NamedStorage *named_storage;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
g_return_val_if_fail (name != NULL, NULL);
priv = storage_set->priv;
named_storage = g_hash_table_lookup (priv->name_to_named_storage, name);
if (named_storage == NULL)
return NULL;
else
return named_storage->storage;
}
EFolder *
e_storage_set_get_folder (EStorageSet *storage_set,
const char *path)
{
EStorage *storage;
const char *subpath;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (path), NULL);
storage = get_storage_for_path (storage_set, path, &subpath);
if (storage == NULL)
return NULL;
return e_storage_get_folder (storage, subpath);
}
static void
async_open_cb (EStorage *storage, EStorageResult result,
const char *path, gpointer storage_set)
{
if (result != E_STORAGE_OK) {
char *full_path;
full_path = make_full_path (storage, path);
g_signal_emit (storage_set, signals[CLOSE_FOLDER], 0, full_path);
g_free (full_path);
}
}
static void
storage_set_view_folder_opened (EStorageSetView *storage_set_view,
const char *path,
EStorageSet *storage_set)
{
EStorage *storage;
const char *subpath;
storage = get_storage_for_path (storage_set, path, &subpath);
if (storage == NULL)
return;
e_storage_async_open_folder (storage, subpath,
async_open_cb, storage_set);
}
GtkWidget *
e_storage_set_create_new_view (EStorageSet *storage_set,
BonoboUIContainer *ui_container)
{
GtkWidget *storage_set_view;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
storage_set_view = e_storage_set_view_new (storage_set, ui_container);
g_signal_connect (storage_set_view, "folder_opened",
G_CALLBACK (storage_set_view_folder_opened),
storage_set);
return storage_set_view;
}
void
e_storage_set_async_create_folder (EStorageSet *storage_set,
const char *path,
const char *type,
const char *description,
EStorageSetResultCallback callback,
void *data)
{
EStorage *storage;
const char *subpath;
StorageCallbackData *storage_callback_data;
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (type != NULL);
g_return_if_fail (description != NULL);
g_return_if_fail (callback != NULL);
storage = get_storage_for_path (storage_set, path, &subpath);
storage_callback_data = storage_callback_data_new (storage_set, callback,
path, NULL, OPERATION_CREATE,
data);
e_storage_async_create_folder (storage, subpath, type, description,
storage_callback, storage_callback_data);
}
void
e_storage_set_async_remove_folder (EStorageSet *storage_set,
const char *path,
EStorageSetResultCallback callback,
void *data)
{
EStorage *storage;
const char *subpath;
StorageCallbackData *storage_callback_data;
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (callback != NULL);
storage = get_storage_for_path (storage_set, path, &subpath);
storage_callback_data = storage_callback_data_new (storage_set, callback,
path, NULL, OPERATION_REMOVE,
data);
e_storage_async_remove_folder (storage, subpath,
storage_callback, storage_callback_data);
}
void
e_storage_set_async_xfer_folder (EStorageSet *storage_set,
const char *source_path,
const char *destination_path,
gboolean remove_source,
EStorageSetResultCallback callback,
void *data)
{
EStorage *source_storage;
EStorage *destination_storage;
const char *source_subpath;
const char *destination_subpath;
StorageCallbackData *storage_callback_data;
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
g_return_if_fail (source_path != NULL);
g_return_if_fail (g_path_is_absolute (source_path));
g_return_if_fail (destination_path != NULL);
g_return_if_fail (g_path_is_absolute (destination_path));
g_return_if_fail (callback != NULL);
source_storage = get_storage_for_path (storage_set, source_path, &source_subpath);
destination_storage = get_storage_for_path (storage_set, destination_path, &destination_subpath);
if (source_storage != destination_storage) {
g_warning ("e_storage_set_async_xfer_folder(): "
"Attempt to xfer folders between different storages -- not supported yet.");
(* callback) (storage_set, E_STORAGE_UNSUPPORTEDOPERATION, data);
return;
}
storage_callback_data = storage_callback_data_new (storage_set,
callback,
source_path,
destination_path,
remove_source ? OPERATION_MOVE : OPERATION_COPY,
data);
e_storage_async_xfer_folder (source_storage,
source_subpath, destination_subpath, remove_source,
storage_callback, storage_callback_data);
}
void
e_storage_set_async_remove_shared_folder (EStorageSet *storage_set,
const char *path,
EStorageSetResultCallback callback,
void *data)
{
EStorage *storage;
const char *subpath;
StorageCallbackData *storage_callback_data;
g_return_if_fail (storage_set != NULL);
g_return_if_fail (E_IS_STORAGE_SET (storage_set));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (callback != NULL);
storage = get_storage_for_path (storage_set, path, &subpath);
if (!e_storage_supports_shared_folders (storage)) {
(* callback) (storage_set, E_STORAGE_NOTIMPLEMENTED, data);
return;
}
storage_callback_data = storage_callback_data_new (storage_set, callback,
path, NULL, OPERATION_REMOVE,
data);
e_storage_async_remove_shared_folder (storage, subpath,
storage_callback,
storage_callback_data);
}
EFolderTypeRegistry *
e_storage_set_get_folder_type_registry (EStorageSet *storage_set)
{
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
return storage_set->priv->folder_type_registry;
}
/**
* e_storage_set_get_path_for_physical_uri:
* @storage_set: A storage set
* @physical_uri: A physical URI
*
* Retrieve the path of the folder whose physical URI matches @physical_uri.
*
* Return value:
**/
char *
e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set,
const char *physical_uri)
{
EStorageSetPrivate *priv;
GList *p;
g_return_val_if_fail (storage_set != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL);
g_return_val_if_fail (physical_uri != NULL, NULL);
priv = storage_set->priv;
for (p = priv->storages; p != NULL; p = p->next) {
EStorage *storage;
char *storage_path;
storage = E_STORAGE (p->data);
storage_path = e_storage_get_path_for_physical_uri (storage, physical_uri);
if (storage_path != NULL) {
char *storage_set_path;
storage_set_path = g_strconcat (E_PATH_SEPARATOR_S,
e_storage_get_name (storage),
storage_path,
NULL);
g_free (storage_path);
return storage_set_path;
}
}
return NULL;
}
E_MAKE_TYPE (e_storage_set, "EStorageSet", EStorageSet, class_init, init, PARENT_TYPE)

View File

@ -1,123 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage-set.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_STORAGE_SET_H_
#define _E_STORAGE_SET_H_
#include <gtk/gtkwidget.h>
#include <bonobo/bonobo-ui-container.h>
#include "e-folder-type-registry.h"
#include "e-storage.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_STORAGE_SET (e_storage_set_get_type ())
#define E_STORAGE_SET(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE_SET, EStorageSet))
#define E_STORAGE_SET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_SET, EStorageSetClass))
#define E_IS_STORAGE_SET(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE_SET))
#define E_IS_STORAGE_SET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_SET))
typedef struct _EStorageSet EStorageSet;
typedef struct _EStorageSetPrivate EStorageSetPrivate;
typedef struct _EStorageSetClass EStorageSetClass;
typedef void (* EStorageSetResultCallback) (EStorageSet *storage_set, EStorageResult result, void *data);
struct _EStorageSet {
GtkObject parent;
EStorageSetPrivate *priv;
};
struct _EStorageSetClass {
GtkObjectClass parent_class;
/* Signals. */
void (* new_storage) (EStorageSet *storage_set, EStorage *storage);
void (* removed_storage) (EStorageSet *storage_set, EStorage *storage);
/* FIXME? Inconsistency between storage and folders. */
void (* new_folder) (EStorageSet *storage_set, const char *path);
void (* updated_folder) (EStorageSet *storage_set, const char *path);
void (* removed_folder) (EStorageSet *storage_set, const char *path);
void (* moved_folder) (EStorageSet *storage_set, const char *source_path, const char *destination_path);
void (* close_folder) (EStorageSet *storage_set, const char *path);
};
GtkType e_storage_set_get_type (void);
void e_storage_set_construct (EStorageSet *storage_set,
EFolderTypeRegistry *folder_type_registry);
EStorageSet *e_storage_set_new (EFolderTypeRegistry *folder_type_registry);
gboolean e_storage_set_add_storage (EStorageSet *storage_set,
EStorage *storage);
gboolean e_storage_set_remove_storage (EStorageSet *storage_set,
EStorage *storage);
void e_storage_set_remove_all_storages (EStorageSet *storage_set);
GList *e_storage_set_get_storage_list (EStorageSet *storage_set);
EStorage *e_storage_set_get_storage (EStorageSet *storage_set,
const char *storage_name);
EFolder *e_storage_set_get_folder (EStorageSet *storage_set,
const char *path);
GtkWidget *e_storage_set_create_new_view (EStorageSet *storage_set,
BonoboUIContainer *container);
void e_storage_set_async_create_folder (EStorageSet *storage_set,
const char *path,
const char *type,
const char *description,
EStorageSetResultCallback callback,
void *data);
void e_storage_set_async_remove_folder (EStorageSet *storage_set,
const char *path,
EStorageSetResultCallback callback,
void *data);
void e_storage_set_async_xfer_folder (EStorageSet *storage_set,
const char *source_path,
const char *destination_path,
gboolean remove_source,
EStorageSetResultCallback callback,
void *data);
void e_storage_set_async_remove_shared_folder (EStorageSet *storage_set,
const char *path,
EStorageSetResultCallback callback,
void *data);
EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set);
/* Utility functions. */
char *e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set,
const char *physical_uri);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_STORAGE_SET_H_ */

View File

@ -1,851 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-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
*/
/* FIXME: The EFolderTree is kept both in the EStorage and the
* EvolutionStorage. Bad design.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-storage.h"
#include "e-folder-tree.h"
#include "e-shell-constants.h"
#include "e-shell-marshal.h"
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <gal/util/e-util.h>
#include <string.h>
#define PARENT_TYPE GTK_TYPE_OBJECT
static GtkObjectClass *parent_class = NULL;
#define ES_CLASS(obj) \
E_STORAGE_CLASS (GTK_OBJECT_GET_CLASS (obj))
struct _EStoragePrivate {
/* The set of folders we have in this storage. */
EFolderTree *folder_tree;
/* Internal name of the storage */
char *name;
};
enum {
NEW_FOLDER,
UPDATED_FOLDER,
REMOVED_FOLDER,
ASYNC_OPEN_FOLDER,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/* Destroy notification function for the folders in the tree. */
static void
folder_destroy_notify (EFolderTree *tree,
const char *path,
void *data,
void *closure)
{
EFolder *e_folder;
if (data == NULL) {
/* The root folder has no EFolder associated to it. */
return;
}
e_folder = E_FOLDER (data);
g_object_unref (e_folder);
}
/* Signal callbacks for the EFolders. */
static void
folder_changed_cb (EFolder *folder,
void *data)
{
EStorage *storage;
EStoragePrivate *priv;
const char *path, *p;
gboolean highlight;
g_assert (E_IS_STORAGE (data));
storage = E_STORAGE (data);
priv = storage->priv;
path = e_folder_tree_get_path_for_data (priv->folder_tree, folder);
g_assert (path != NULL);
g_signal_emit (storage, signals[UPDATED_FOLDER], 0, path);
highlight = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (folder), "last_highlight"));
if (highlight != e_folder_get_highlighted (folder)) {
highlight = !highlight;
g_object_set_data (G_OBJECT (folder), "last_highlight", GINT_TO_POINTER (highlight));
p = strrchr (path, '/');
if (p && p != path) {
char *name;
name = g_strndup (path, p - path);
folder = e_folder_tree_get_folder (priv->folder_tree, name);
g_free (name);
if (folder)
e_folder_set_child_highlight (folder, highlight);
}
}
}
/* GObject methods. */
static void
impl_finalize (GObject *object)
{
EStorage *storage;
EStoragePrivate *priv;
storage = E_STORAGE (object);
priv = storage->priv;
if (priv->folder_tree != NULL)
e_folder_tree_destroy (priv->folder_tree);
g_free (priv->name);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* EStorage methods. */
static GList *
impl_get_subfolder_paths (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
priv = storage->priv;
return e_folder_tree_get_subfolders (priv->folder_tree, path);
}
static EFolder *
impl_get_folder (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
EFolder *e_folder;
priv = storage->priv;
e_folder = (EFolder *) e_folder_tree_get_folder (priv->folder_tree, path);
return e_folder;
}
static const char *
impl_get_name (EStorage *storage)
{
return storage->priv->name;
}
static void
impl_async_create_folder (EStorage *storage,
const char *path,
const char *type,
const char *description,
EStorageResultCallback callback,
void *data)
{
(* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
static void
impl_async_remove_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data)
{
(* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
static void
impl_async_xfer_folder (EStorage *storage,
const char *source_path,
const char *destination_path,
gboolean remove_source,
EStorageResultCallback callback,
void *data)
{
(* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
static gboolean
impl_supports_shared_folders (EStorage *storage)
{
return FALSE;
}
static void
impl_async_discover_shared_folder (EStorage *storage,
const char *owner,
const char *folder_name,
EStorageDiscoveryCallback callback,
void *data)
{
(* callback) (storage, E_STORAGE_NOTIMPLEMENTED, NULL, data);
}
static void
impl_async_remove_shared_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data)
{
(* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data);
}
/* Initialization. */
static void
class_init (EStorageClass *class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_ref(gtk_object_get_type ());
object_class->finalize = impl_finalize;
class->get_subfolder_paths = impl_get_subfolder_paths;
class->get_folder = impl_get_folder;
class->get_name = impl_get_name;
class->async_create_folder = impl_async_create_folder;
class->async_remove_folder = impl_async_remove_folder;
class->async_xfer_folder = impl_async_xfer_folder;
class->supports_shared_folders = impl_supports_shared_folders;
class->async_discover_shared_folder = impl_async_discover_shared_folder;
class->async_remove_shared_folder = impl_async_remove_shared_folder;
signals[NEW_FOLDER] =
g_signal_new ("new_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageClass, new_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[UPDATED_FOLDER] =
g_signal_new ("updated_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageClass, updated_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[REMOVED_FOLDER] =
g_signal_new ("removed_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageClass, removed_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[ASYNC_OPEN_FOLDER] =
g_signal_new ("async_open_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EStorageClass, async_open_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING_POINTER_POINTER,
G_TYPE_NONE, 3,
G_TYPE_STRING,
G_TYPE_POINTER,
G_TYPE_POINTER);
}
static void
init (EStorage *storage)
{
EStoragePrivate *priv;
priv = g_new (EStoragePrivate, 1);
priv->folder_tree = e_folder_tree_new (folder_destroy_notify, NULL);
priv->name = NULL;
storage->priv = priv;
}
/* Creation. */
void
e_storage_construct (EStorage *storage,
const char *name,
EFolder *root_folder)
{
EStoragePrivate *priv;
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
priv = storage->priv;
priv->name = g_strdup (name);
e_storage_new_folder (storage, "/", root_folder);
GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (storage), GTK_FLOATING);
}
EStorage *
e_storage_new (const char *name,
EFolder *root_folder)
{
EStorage *new;
new = g_object_new (e_storage_get_type (), NULL);
e_storage_construct (new, name, root_folder);
return new;
}
gboolean
e_storage_path_is_absolute (const char *path)
{
g_return_val_if_fail (path != NULL, FALSE);
return *path == E_PATH_SEPARATOR;
}
gboolean
e_storage_path_is_relative (const char *path)
{
g_return_val_if_fail (path != NULL, FALSE);
return *path != E_PATH_SEPARATOR;
}
GList *
e_storage_get_subfolder_paths (EStorage *storage,
const char *path)
{
g_return_val_if_fail (storage != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE (storage), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (path), NULL);
return (* ES_CLASS (storage)->get_subfolder_paths) (storage, path);
}
EFolder *
e_storage_get_folder (EStorage *storage,
const char *path)
{
g_return_val_if_fail (storage != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE (storage), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (e_storage_path_is_absolute (path), NULL);
return (* ES_CLASS (storage)->get_folder) (storage, path);
}
const char *
e_storage_get_name (EStorage *storage)
{
g_return_val_if_fail (storage != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE (storage), NULL);
return (* ES_CLASS (storage)->get_name) (storage);
}
/* Folder operations. */
void
e_storage_async_create_folder (EStorage *storage,
const char *path,
const char *type,
const char *description,
EStorageResultCallback callback,
void *data)
{
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (type != NULL);
g_return_if_fail (callback != NULL);
(* ES_CLASS (storage)->async_create_folder) (storage, path, type, description, callback, data);
}
void
e_storage_async_remove_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data)
{
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (callback != NULL);
(* ES_CLASS (storage)->async_remove_folder) (storage, path, callback, data);
}
void
e_storage_async_xfer_folder (EStorage *storage,
const char *source_path,
const char *destination_path,
const gboolean remove_source,
EStorageResultCallback callback,
void *data)
{
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (source_path != NULL);
g_return_if_fail (g_path_is_absolute (source_path));
g_return_if_fail (destination_path != NULL);
g_return_if_fail (g_path_is_absolute (destination_path));
if (strcmp (source_path, destination_path) == 0) {
(* callback) (storage, E_STORAGE_OK, data);
return;
}
if (remove_source) {
int destination_len;
int source_len;
source_len = strlen (source_path);
destination_len = strlen (destination_path);
if (source_len < destination_len
&& destination_path[source_len] == E_PATH_SEPARATOR
&& strncmp (destination_path, source_path, source_len) == 0) {
(* callback) (storage, E_STORAGE_CANTMOVETODESCENDANT, data);
return;
}
}
(* ES_CLASS (storage)->async_xfer_folder) (storage, source_path, destination_path, remove_source, callback, data);
}
void
e_storage_async_open_folder (EStorage *storage,
const char *path,
EStorageDiscoveryCallback callback,
void *data)
{
EStoragePrivate *priv;
EFolder *folder;
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
priv = storage->priv;
folder = e_folder_tree_get_folder (priv->folder_tree, path);
if (folder == NULL) {
(* callback) (storage, E_STORAGE_NOTFOUND, path, data);
return;
}
if (! e_folder_get_has_subfolders (folder)) {
(* callback) (storage, E_STORAGE_OK, path, data);
return;
}
g_signal_emit (storage, signals[ASYNC_OPEN_FOLDER], 0,
path, callback, data);
}
/* Shared folders. */
gboolean
e_storage_supports_shared_folders (EStorage *storage)
{
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
return (* ES_CLASS (storage)->supports_shared_folders) (storage);
}
void
e_storage_async_discover_shared_folder (EStorage *storage,
const char *owner,
const char *folder_name,
EStorageDiscoveryCallback callback,
void *data)
{
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (owner != NULL);
g_return_if_fail (folder_name != NULL);
(* ES_CLASS (storage)->async_discover_shared_folder) (storage, owner, folder_name, callback, data);
}
void
e_storage_cancel_discover_shared_folder (EStorage *storage,
const char *owner,
const char *folder_name)
{
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (owner != NULL);
g_return_if_fail (folder_name != NULL);
g_return_if_fail (ES_CLASS (storage)->cancel_discover_shared_folder != NULL);
(* ES_CLASS (storage)->cancel_discover_shared_folder) (storage, owner, folder_name);
}
void
e_storage_async_remove_shared_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data)
{
g_return_if_fail (storage != NULL);
g_return_if_fail (E_IS_STORAGE (storage));
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
(* ES_CLASS (storage)->async_remove_shared_folder) (storage, path, callback, data);
}
const char *
e_storage_result_to_string (EStorageResult result)
{
switch (result) {
case E_STORAGE_OK:
return _("No error");
case E_STORAGE_GENERICERROR:
return _("Generic error");
case E_STORAGE_EXISTS:
return _("A folder with the same name already exists");
case E_STORAGE_INVALIDTYPE:
return _("The specified folder type is not valid");
case E_STORAGE_IOERROR:
return _("I/O error");
case E_STORAGE_NOSPACE:
return _("Not enough space to create the folder");
case E_STORAGE_NOTEMPTY:
return _("The folder is not empty");
case E_STORAGE_NOTFOUND:
return _("The specified folder was not found");
case E_STORAGE_NOTIMPLEMENTED:
return _("Function not implemented in this storage");
case E_STORAGE_PERMISSIONDENIED:
return _("Permission denied");
case E_STORAGE_UNSUPPORTEDOPERATION:
return _("Operation not supported");
case E_STORAGE_UNSUPPORTEDTYPE:
return _("The specified type is not supported in this storage");
case E_STORAGE_CANTCHANGESTOCKFOLDER:
return _("The specified folder cannot be modified or removed");
case E_STORAGE_CANTMOVETODESCENDANT:
return _("Cannot make a folder a child of one of its descendants");
case E_STORAGE_INVALIDNAME:
return _("Cannot create a folder with that name");
case E_STORAGE_NOTONLINE:
return _("This operation cannot be performed in off-line mode");
default:
return _("Unknown error");
}
}
/* Public utility functions. */
struct _GetPathForPhysicalUriForeachData {
const char *physical_uri;
char *retval;
};
typedef struct _GetPathForPhysicalUriForeachData GetPathForPhysicalUriForeachData;
static void
get_path_for_physical_uri_foreach (EFolderTree *folder_tree,
const char *path,
void *path_data,
void *user_data)
{
GetPathForPhysicalUriForeachData *foreach_data;
const char *physical_uri;
EFolder *e_folder;
foreach_data = (GetPathForPhysicalUriForeachData *) user_data;
if (foreach_data->retval != NULL)
return;
e_folder = (EFolder *) path_data;
if (e_folder == NULL)
return;
physical_uri = e_folder_get_physical_uri (e_folder);
if (physical_uri == NULL)
return;
if (strcmp (foreach_data->physical_uri, physical_uri) == 0)
foreach_data->retval = g_strdup (path);
}
/**
* e_storage_get_path_for_physical_uri:
* @storage: A storage
* @physical_uri: A physical URI
*
* Look for the folder having the specified @physical_uri.
*
* Return value: The path of the folder having the specified @physical_uri in
* @storage. If such a folder does not exist, just return NULL. The return
* value must be freed by the caller.
**/
char *
e_storage_get_path_for_physical_uri (EStorage *storage,
const char *physical_uri)
{
GetPathForPhysicalUriForeachData foreach_data;
EStoragePrivate *priv;
g_return_val_if_fail (storage != NULL, NULL);
g_return_val_if_fail (E_IS_STORAGE (storage), NULL);
g_return_val_if_fail (physical_uri != NULL, NULL);
priv = storage->priv;
foreach_data.physical_uri = physical_uri;
foreach_data.retval = NULL;
e_folder_tree_foreach (priv->folder_tree, get_path_for_physical_uri_foreach, &foreach_data);
return foreach_data.retval;
}
/* Protected functions. */
/* These functions are used by subclasses to add and remove folders from the
state stored in the storage object. */
static void
remove_subfolders_except (EStorage *storage, const char *path, const char *except)
{
EStoragePrivate *priv;
GList *subfolders, *f;
const char *folder_path;
priv = storage->priv;
subfolders = e_folder_tree_get_subfolders (priv->folder_tree, path);
for (f = subfolders; f; f = f->next) {
folder_path = f->data;
if (!except || strcmp (folder_path, except) != 0)
e_storage_removed_folder (storage, folder_path);
}
e_free_string_list (subfolders);
}
gboolean
e_storage_new_folder (EStorage *storage,
const char *path,
EFolder *e_folder)
{
EStoragePrivate *priv;
char *parent_path, *p;
EFolder *parent;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (path), FALSE);
g_return_val_if_fail (e_folder != NULL, FALSE);
g_return_val_if_fail (E_IS_FOLDER (e_folder), FALSE);
priv = storage->priv;
if (! e_folder_tree_add (priv->folder_tree, path, e_folder))
return FALSE;
/* If this is the child of a folder that has a pseudo child,
* remove the pseudo child now.
*/
p = strrchr (path, '/');
if (p && p != path)
parent_path = g_strndup (path, p - path);
else
parent_path = g_strdup ("/");
parent = e_folder_tree_get_folder (priv->folder_tree, parent_path);
if (parent && e_folder_get_has_subfolders (parent)) {
remove_subfolders_except (storage, parent_path, path);
e_folder_set_has_subfolders (parent, FALSE);
}
g_free (parent_path);
g_signal_connect_object (e_folder, "changed", G_CALLBACK (folder_changed_cb), storage, 0);
g_signal_emit (storage, signals[NEW_FOLDER], 0, path);
folder_changed_cb (e_folder, storage);
return TRUE;
}
/* This really should be called e_storage_set_has_subfolders, but then
* it would look like it was an EStorageSet function. (Fact o' the
* day: The word "set" has more distinct meanings than any other word
* in the English language.) Anyway, we now return you to your
* regularly scheduled source code, already in progress.
*/
gboolean
e_storage_declare_has_subfolders (EStorage *storage,
const char *path,
const char *message)
{
EStoragePrivate *priv;
EFolder *parent, *pseudofolder;
char *pseudofolder_path;
gboolean ok;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (path), FALSE);
g_return_val_if_fail (message != NULL, FALSE);
priv = storage->priv;
parent = e_folder_tree_get_folder (priv->folder_tree, path);
if (parent == NULL)
return FALSE;
if (e_folder_get_has_subfolders (parent))
return TRUE;
remove_subfolders_except (storage, path, NULL);
pseudofolder = e_folder_new (message, "working", "");
if (strcmp (path, "/") == 0)
pseudofolder_path = g_strdup_printf ("/%s", message);
else
pseudofolder_path = g_strdup_printf ("%s/%s", path, message);
e_folder_set_physical_uri (pseudofolder, pseudofolder_path);
ok = e_storage_new_folder (storage, pseudofolder_path, pseudofolder);
g_free (pseudofolder_path);
if (!ok) {
g_object_unref (pseudofolder);
return FALSE;
}
e_folder_set_has_subfolders (parent, TRUE);
return TRUE;
}
gboolean
e_storage_get_has_subfolders (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
EFolder *folder;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (path), FALSE);
priv = storage->priv;
folder = e_folder_tree_get_folder (priv->folder_tree, path);
return folder && e_folder_get_has_subfolders (folder);
}
gboolean
e_storage_removed_folder (EStorage *storage,
const char *path)
{
EStoragePrivate *priv;
EFolder *folder;
const char *p;
g_return_val_if_fail (storage != NULL, FALSE);
g_return_val_if_fail (E_IS_STORAGE (storage), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (path), FALSE);
priv = storage->priv;
folder = e_folder_tree_get_folder (priv->folder_tree, path);
if (folder == NULL)
return FALSE;
p = strrchr (path, '/');
if (p != NULL && p != path) {
EFolder *parent_folder;
char *parent_path;
parent_path = g_strndup (path, p - path);
parent_folder = e_folder_tree_get_folder (priv->folder_tree, parent_path);
if (e_folder_get_highlighted (folder))
e_folder_set_child_highlight (parent_folder, FALSE);
g_free (parent_path);
}
g_signal_emit (storage, signals[REMOVED_FOLDER], 0, path);
e_folder_tree_remove (priv->folder_tree, path);
return TRUE;
}
E_MAKE_TYPE (e_storage, "EStorage", EStorage, class_init, init, PARENT_TYPE)

View File

@ -1,215 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-storage.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_STORAGE_H_
#define _E_STORAGE_H_
#include <gtk/gtkobject.h>
#include "evolution-shell-component-client.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_STORAGE (e_storage_get_type ())
#define E_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE, EStorage))
#define E_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE, EStorageClass))
#define E_IS_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE))
#define E_IS_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE))
typedef struct _EStorage EStorage;
typedef struct _EStoragePrivate EStoragePrivate;
typedef struct _EStorageClass EStorageClass;
enum _EStorageResult {
E_STORAGE_OK,
E_STORAGE_GENERICERROR,
E_STORAGE_EXISTS,
E_STORAGE_INVALIDTYPE,
E_STORAGE_IOERROR,
E_STORAGE_NOSPACE,
E_STORAGE_NOTEMPTY,
E_STORAGE_NOTFOUND,
E_STORAGE_NOTIMPLEMENTED,
E_STORAGE_PERMISSIONDENIED,
E_STORAGE_UNSUPPORTEDOPERATION,
E_STORAGE_UNSUPPORTEDTYPE,
E_STORAGE_CANTCHANGESTOCKFOLDER,
E_STORAGE_CANTMOVETODESCENDANT,
E_STORAGE_NOTONLINE,
E_STORAGE_INVALIDNAME
};
typedef enum _EStorageResult EStorageResult;
typedef void (* EStorageResultCallback) (EStorage *storage, EStorageResult result, void *data);
typedef void (* EStorageDiscoveryCallback) (EStorage *storage, EStorageResult result, const char *path, void *data);
#include "e-folder.h"
struct _EStorage {
GtkObject parent;
EStoragePrivate *priv;
};
struct _EStorageClass {
GtkObjectClass parent_class;
/* Signals. */
void (* new_folder) (EStorage *storage, const char *path);
void (* updated_folder) (EStorage *storage, const char *path);
void (* removed_folder) (EStorage *storage, const char *path);
/* FIXME: This should NOT be a signal. */
void (* async_open_folder) (EStorage *storage,
const char *path,
EStorageDiscoveryCallback callback,
void *data);
/* Virtual methods. */
GList * (* get_subfolder_paths) (EStorage *storage,
const char *path);
EFolder * (* get_folder) (EStorage *storage,
const char *path);
const char * (* get_name) (EStorage *storage);
void (* async_create_folder) (EStorage *storage,
const char *path,
const char *type,
const char *description,
EStorageResultCallback callback,
void *data);
void (* async_remove_folder) (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data);
void (* async_xfer_folder) (EStorage *storage,
const char *source_path,
const char *destination_path,
const gboolean remove_source,
EStorageResultCallback callback,
void *data);
gboolean (* supports_shared_folders) (EStorage *storage);
void (* async_discover_shared_folder) (EStorage *storage,
const char *owner,
const char *folder_name,
EStorageDiscoveryCallback callback,
void *data);
void (* cancel_discover_shared_folder) (EStorage *storage,
const char *owner,
const char *folder_name);
void (* async_remove_shared_folder) (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data);
};
GtkType e_storage_get_type (void);
void e_storage_construct (EStorage *storage,
const char *name,
EFolder *root_folder);
EStorage *e_storage_new (const char *name,
EFolder *root_folder);
gboolean e_storage_path_is_relative (const char *path);
gboolean e_storage_path_is_absolute (const char *path);
GList *e_storage_get_subfolder_paths (EStorage *storage,
const char *path);
EFolder *e_storage_get_folder (EStorage *storage,
const char *path);
const char *e_storage_get_name (EStorage *storage);
/* Folder operations. */
void e_storage_async_create_folder (EStorage *storage,
const char *path,
const char *type,
const char *description,
EStorageResultCallback callback,
void *data);
void e_storage_async_remove_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data);
void e_storage_async_xfer_folder (EStorage *storage,
const char *source_path,
const char *destination_path,
const gboolean remove_source,
EStorageResultCallback callback,
void *data);
void e_storage_async_open_folder (EStorage *storage,
const char *path,
EStorageDiscoveryCallback callback,
void *data);
const char *e_storage_result_to_string (EStorageResult result);
/* Shared folders. */
gboolean e_storage_supports_shared_folders (EStorage *storage);
void e_storage_async_discover_shared_folder (EStorage *storage,
const char *owner,
const char *folder_name,
EStorageDiscoveryCallback callback,
void *data);
void e_storage_cancel_discover_shared_folder (EStorage *storage,
const char *owner,
const char *folder_name);
void e_storage_async_remove_shared_folder (EStorage *storage,
const char *path,
EStorageResultCallback callback,
void *data);
/* Utility functions. */
char *e_storage_get_path_for_physical_uri (EStorage *storage,
const char *physical_uri);
/* FIXME: Need to rename these. */
gboolean e_storage_new_folder (EStorage *storage,
const char *path,
EFolder *folder);
gboolean e_storage_removed_folder (EStorage *storage,
const char *path);
gboolean e_storage_declare_has_subfolders (EStorage *storage,
const char *path,
const char *message);
gboolean e_storage_get_has_subfolders (EStorage *storage,
const char *path);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_STORAGE_H_ */

View File

@ -36,6 +36,7 @@
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-control.h>
#include <libgnome/gnome-i18n.h>

View File

@ -1,924 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-shell-component-client.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 <string.h>
#include <glib.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktypeutils.h>
#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-widget.h>
#include <gal/util/e-util.h>
#include "evolution-shell-component-client.h"
char *evolution_debug_log;
#define PARENT_TYPE G_TYPE_OBJECT
static GObjectClass *parent_class = NULL;
struct _EvolutionShellComponentClientPrivate {
GNOME_Evolution_ShellComponent corba_objref;
char *id;
EvolutionShellComponentClientCallback callback;
void *callback_data;
GNOME_Evolution_ShellComponentListener listener_interface;
PortableServer_Servant listener_servant;
GNOME_Evolution_ShellComponentDnd_SourceFolder dnd_source_folder_interface;
GNOME_Evolution_ShellComponentDnd_DestinationFolder dnd_destination_folder_interface;
GNOME_Evolution_Offline offline_interface;
};
#define RETURN_ERROR_IF_FAIL(cond) \
g_return_val_if_fail ((cond), EVOLUTION_SHELL_COMPONENT_INVALIDARG)
/* Utility functions. */
static EvolutionShellComponentResult
corba_exception_to_result (const CORBA_Environment *ev)
{
if (ev->_major == CORBA_NO_EXCEPTION)
return EVOLUTION_SHELL_COMPONENT_OK;
if (ev->_major == CORBA_USER_EXCEPTION) {
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_AlreadyOwned) == 0)
return EVOLUTION_SHELL_COMPONENT_ALREADYOWNED;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_OldOwnerHasDied) == 0)
return EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_NotOwned) == 0)
return EVOLUTION_SHELL_COMPONENT_NOTOWNED;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_NotFound) == 0)
return EVOLUTION_SHELL_COMPONENT_NOTFOUND;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_UnsupportedType) == 0)
return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_InternalError) == 0)
return EVOLUTION_SHELL_COMPONENT_INTERNALERROR;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_Busy) == 0)
return EVOLUTION_SHELL_COMPONENT_BUSY;
if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_UnsupportedSchema) == 0)
return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDSCHEMA;
return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR;
} else {
/* FIXME maybe we need something more specific here. */
return EVOLUTION_SHELL_COMPONENT_CORBAERROR;
}
}
static EvolutionShellComponentResult
shell_component_result_from_corba_exception (const CORBA_Environment *ev)
{
if (ev->_major == CORBA_NO_EXCEPTION)
return EVOLUTION_SHELL_COMPONENT_OK;
if (ev->_major == CORBA_SYSTEM_EXCEPTION)
return EVOLUTION_SHELL_COMPONENT_CORBAERROR;
return EVOLUTION_SHELL_COMPONENT_CORBAERROR; /* FIXME? */
}
/* CORBA listener interface implementation. */
static PortableServer_ServantBase__epv ShellComponentListener_base_epv;
static POA_GNOME_Evolution_ShellComponentListener__epv ShellComponentListener_epv;
static POA_GNOME_Evolution_ShellComponentListener__vepv ShellComponentListener_vepv;
static gboolean ShellComponentListener_vepv_initialized = FALSE;
static void ShellComponentListener_vepv_initialize (void);
static void dispatch_callback (EvolutionShellComponentClient *shell_component_client,
EvolutionShellComponentResult result);
struct _ShellComponentListenerServant {
POA_GNOME_Evolution_ShellComponentListener servant;
EvolutionShellComponentClient *component_client;
};
typedef struct _ShellComponentListenerServant ShellComponentListenerServant;
static PortableServer_Servant *
create_ShellComponentListener_servant (EvolutionShellComponentClient *component_client)
{
ShellComponentListenerServant *servant;
if (! ShellComponentListener_vepv_initialized)
ShellComponentListener_vepv_initialize ();
servant = g_new0 (ShellComponentListenerServant, 1);
servant->servant.vepv = &ShellComponentListener_vepv;
servant->component_client = component_client;
return (PortableServer_Servant) servant;
}
static void
free_ShellComponentListener_servant (PortableServer_Servant servant)
{
g_free (servant);
}
static EvolutionShellComponentClient *
component_client_from_ShellComponentListener_servant (PortableServer_Servant servant)
{
ShellComponentListenerServant *listener_servant;
listener_servant = (ShellComponentListenerServant *) servant;
return listener_servant->component_client;
}
static EvolutionShellComponentResult
result_from_async_corba_result (GNOME_Evolution_ShellComponentListener_Result async_corba_result)
{
switch (async_corba_result) {
case GNOME_Evolution_ShellComponentListener_OK:
return EVOLUTION_SHELL_COMPONENT_OK;
case GNOME_Evolution_ShellComponentListener_CANCEL:
return EVOLUTION_SHELL_COMPONENT_CANCEL;
case GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION:
return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDOPERATION;
case GNOME_Evolution_ShellComponentListener_EXISTS:
return EVOLUTION_SHELL_COMPONENT_EXISTS;
case GNOME_Evolution_ShellComponentListener_INVALID_URI:
return EVOLUTION_SHELL_COMPONENT_INVALIDURI;
case GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED:
return EVOLUTION_SHELL_COMPONENT_PERMISSIONDENIED;
case GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS:
return EVOLUTION_SHELL_COMPONENT_HASSUBFOLDERS;
case GNOME_Evolution_ShellComponentListener_NO_SPACE:
return EVOLUTION_SHELL_COMPONENT_NOSPACE;
default:
return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR;
}
}
static void
impl_ShellComponentListener_report_result (PortableServer_Servant servant,
const GNOME_Evolution_ShellComponentListener_Result result,
CORBA_Environment *ev)
{
EvolutionShellComponentClient *component_client;
component_client = component_client_from_ShellComponentListener_servant (servant);
dispatch_callback (component_client, result_from_async_corba_result (result));
}
static void
ShellComponentListener_vepv_initialize (void)
{
ShellComponentListener_base_epv._private = NULL;
ShellComponentListener_base_epv.finalize = NULL;
ShellComponentListener_base_epv.default_POA = NULL;
ShellComponentListener_epv.notifyResult = impl_ShellComponentListener_report_result;
ShellComponentListener_vepv._base_epv = & ShellComponentListener_base_epv;
ShellComponentListener_vepv.GNOME_Evolution_ShellComponentListener_epv = & ShellComponentListener_epv;
ShellComponentListener_vepv_initialized = TRUE;
}
static void
create_listener_interface (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
PortableServer_Servant listener_servant;
GNOME_Evolution_ShellComponentListener corba_interface;
CORBA_Environment ev;
priv = shell_component_client->priv;
listener_servant = create_ShellComponentListener_servant (shell_component_client);
CORBA_exception_init (&ev);
POA_GNOME_Evolution_ShellComponentListener__init (listener_servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
free_ShellComponentListener_servant (listener_servant);
return;
}
CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), listener_servant, &ev));
corba_interface = PortableServer_POA_servant_to_reference (bonobo_poa (), listener_servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
corba_interface = CORBA_OBJECT_NIL;
free_ShellComponentListener_servant (listener_servant);
}
CORBA_exception_free (&ev);
priv->listener_servant = listener_servant;
priv->listener_interface = corba_interface;
}
static void
destroy_listener_interface (EvolutionShellComponentClient *client)
{
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
PortableServer_ObjectId *oid;
priv = client->priv;
CORBA_exception_init (&ev);
oid = PortableServer_POA_servant_to_id (bonobo_poa (), priv->listener_servant, &ev);
PortableServer_POA_deactivate_object (bonobo_poa (), oid, &ev);
CORBA_free (oid);
CORBA_Object_release (priv->listener_interface, &ev);
/* free_ShellComponentListener_servant (priv->listener_servant); */
CORBA_exception_free (&ev);
}
static void
dispatch_callback (EvolutionShellComponentClient *shell_component_client,
EvolutionShellComponentResult result)
{
EvolutionShellComponentClientPrivate *priv;
EvolutionShellComponentClientCallback callback;
void *callback_data;
priv = shell_component_client->priv;
g_return_if_fail (priv->callback != NULL);
g_return_if_fail (priv->listener_servant != NULL);
/* Notice that we destroy the interface and reset the callback information before
dispatching the callback so that the callback can generate another request. */
destroy_listener_interface (shell_component_client);
priv->listener_servant = NULL;
priv->listener_interface = CORBA_OBJECT_NIL;
callback = priv->callback;
callback_data = priv->callback_data;
priv->callback = NULL;
priv->callback_data = NULL;
(* callback) (shell_component_client, result, callback_data);
}
/* GObject methods. */
static void
impl_dispose (GObject *object)
{
EvolutionShellComponentClient *shell_component_client;
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
shell_component_client = EVOLUTION_SHELL_COMPONENT_CLIENT (object);
priv = shell_component_client->priv;
if (priv == NULL)
return;
g_free (priv->id);
priv->id = NULL;
if (priv->callback != NULL) {
dispatch_callback (shell_component_client, EVOLUTION_SHELL_COMPONENT_INTERRUPTED);
priv->callback = NULL;
}
CORBA_exception_init (&ev);
if (priv->corba_objref != CORBA_OBJECT_NIL) {
Bonobo_Unknown_unref (priv->corba_objref, &ev);
CORBA_Object_release (priv->corba_objref, &ev);
priv->corba_objref = CORBA_OBJECT_NIL;
}
if (priv->dnd_source_folder_interface != CORBA_OBJECT_NIL) {
Bonobo_Unknown_unref (priv->dnd_source_folder_interface, &ev);
CORBA_Object_release (priv->dnd_source_folder_interface, &ev);
priv->dnd_source_folder_interface = CORBA_OBJECT_NIL;
}
if (priv->dnd_destination_folder_interface != CORBA_OBJECT_NIL) {
Bonobo_Unknown_unref (priv->dnd_destination_folder_interface, &ev);
CORBA_Object_release (priv->dnd_destination_folder_interface, &ev);
priv->dnd_destination_folder_interface = CORBA_OBJECT_NIL;
}
if (priv->offline_interface != CORBA_OBJECT_NIL) {
Bonobo_Unknown_unref (priv->offline_interface, &ev);
CORBA_Object_release (priv->offline_interface, &ev);
priv->offline_interface = CORBA_OBJECT_NIL;
}
if (priv->listener_interface != CORBA_OBJECT_NIL) {
destroy_listener_interface (shell_component_client);
priv->listener_interface = CORBA_OBJECT_NIL;
}
CORBA_exception_free (&ev);
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
impl_finalize (GObject *object)
{
EvolutionShellComponentClient *client;
client = EVOLUTION_SHELL_COMPONENT_CLIENT (object);
g_free (client->priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
class_init (EvolutionShellComponentClientClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_ref(PARENT_TYPE);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
}
static void
init (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
priv = g_new (EvolutionShellComponentClientPrivate, 1);
priv->corba_objref = CORBA_OBJECT_NIL;
priv->id = NULL;
priv->listener_interface = CORBA_OBJECT_NIL;
priv->listener_servant = NULL;
priv->callback = NULL;
priv->callback_data = NULL;
priv->dnd_source_folder_interface = CORBA_OBJECT_NIL;
priv->dnd_destination_folder_interface = CORBA_OBJECT_NIL;
priv->offline_interface = CORBA_OBJECT_NIL;
shell_component_client->priv = priv;
}
/* Construction. */
void
evolution_shell_component_client_construct (EvolutionShellComponentClient *shell_component_client,
const char *id,
CORBA_Object corba_object)
{
EvolutionShellComponentClientPrivate *priv;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
priv = shell_component_client->priv;
priv->corba_objref = corba_object;
priv->id = g_strdup (id);
}
EvolutionShellComponentClient *
evolution_shell_component_client_new (const char *id,
CORBA_Environment *ev)
{
EvolutionShellComponentClient *new;
CORBA_Object corba_object;
CORBA_Environment *local_ev;
CORBA_Environment static_ev;
g_return_val_if_fail (id != NULL, NULL);
CORBA_exception_init (&static_ev);
if (ev == NULL)
local_ev = &static_ev;
else
local_ev = ev;
corba_object = bonobo_activation_activate_from_id ((char *) id, 0, NULL, ev);
if (ev->_major != CORBA_NO_EXCEPTION || corba_object == NULL) {
CORBA_exception_free (&static_ev);
return NULL;
}
CORBA_exception_free (&static_ev);
new = g_object_new (evolution_shell_component_client_get_type (), NULL);
evolution_shell_component_client_construct (new, id, corba_object);
return new;
}
GNOME_Evolution_ShellComponent
evolution_shell_component_client_corba_objref (EvolutionShellComponentClient *component_client)
{
g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (component_client), NULL);
return component_client->priv->corba_objref;
}
/* Properties. */
const char *
evolution_shell_component_client_get_id (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
g_return_val_if_fail (shell_component_client != NULL, NULL);
g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), NULL);
priv = shell_component_client->priv;
return priv->id;
}
/* Querying DnD interfaces. */
GNOME_Evolution_ShellComponentDnd_SourceFolder
evolution_shell_component_client_get_dnd_source_interface (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
GNOME_Evolution_ShellComponentDnd_SourceFolder interface;
CORBA_Environment ev;
g_return_val_if_fail (shell_component_client != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), CORBA_OBJECT_NIL);
priv = shell_component_client->priv;
if (priv->dnd_source_folder_interface != CORBA_OBJECT_NIL)
return priv->dnd_source_folder_interface;
CORBA_exception_init (&ev);
interface = Bonobo_Unknown_queryInterface (priv->corba_objref,
"IDL:GNOME/Evolution/ShellComponentDnd/SourceFolder:1.0",
&ev);
if (ev._major != CORBA_NO_EXCEPTION)
interface = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
priv->dnd_source_folder_interface = interface;
return interface;
}
GNOME_Evolution_ShellComponentDnd_DestinationFolder
evolution_shell_component_client_get_dnd_destination_interface (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
GNOME_Evolution_ShellComponentDnd_DestinationFolder interface;
CORBA_Environment ev;
g_return_val_if_fail (shell_component_client != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), CORBA_OBJECT_NIL);
priv = shell_component_client->priv;
if (priv->dnd_destination_folder_interface != CORBA_OBJECT_NIL)
return priv->dnd_destination_folder_interface;
CORBA_exception_init (&ev);
interface = Bonobo_Unknown_queryInterface (priv->corba_objref,
"IDL:GNOME/Evolution/ShellComponentDnd/DestinationFolder:1.0",
&ev);
if (ev._major != CORBA_NO_EXCEPTION)
interface = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
priv->dnd_destination_folder_interface = interface;
return interface;
}
/* Querying the offline interface. */
GNOME_Evolution_Offline
evolution_shell_component_client_get_offline_interface (EvolutionShellComponentClient *shell_component_client)
{
EvolutionShellComponentClientPrivate *priv;
GNOME_Evolution_Offline interface;
CORBA_Environment ev;
priv = shell_component_client->priv;
if (priv->offline_interface != CORBA_OBJECT_NIL)
return priv->offline_interface;
CORBA_exception_init (&ev);
interface = Bonobo_Unknown_queryInterface (priv->corba_objref, "IDL:GNOME/Evolution/Offline:1.0", &ev);
if (ev._major != CORBA_NO_EXCEPTION)
interface = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
priv->offline_interface = interface;
return interface;
}
/* Synchronous operations. */
EvolutionShellComponentResult
evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell_component_client,
GNOME_Evolution_Shell shell,
const char *evolution_homedir)
{
EvolutionShellComponentResult result;
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
RETURN_ERROR_IF_FAIL (shell_component_client != NULL);
RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
RETURN_ERROR_IF_FAIL (shell != CORBA_OBJECT_NIL);
priv = shell_component_client->priv;
CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponent_setOwner (priv->corba_objref, shell, evolution_homedir, &ev);
result = corba_exception_to_result (&ev);
if (result == EVOLUTION_SHELL_COMPONENT_OK && evolution_debug_log)
GNOME_Evolution_ShellComponent_debug (priv->corba_objref, evolution_debug_log, &ev);
CORBA_exception_free (&ev);
return result;
}
EvolutionShellComponentResult
evolution_shell_component_client_unset_owner (EvolutionShellComponentClient *shell_component_client,
GNOME_Evolution_Shell shell)
{
EvolutionShellComponentResult result;
CORBA_Environment ev;
RETURN_ERROR_IF_FAIL (shell_component_client != NULL);
RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
RETURN_ERROR_IF_FAIL (shell != CORBA_OBJECT_NIL);
CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponent_unsetOwner (shell_component_client->priv->corba_objref, &ev);
result = corba_exception_to_result (&ev);
CORBA_exception_free (&ev);
return result;
}
EvolutionShellComponentResult
evolution_shell_component_client_create_view (EvolutionShellComponentClient *shell_component_client,
BonoboUIComponent *uih,
const char *physical_uri,
const char *type_string,
const char *view_info,
BonoboControl **control_return)
{
EvolutionShellComponentResult result;
CORBA_Environment ev;
EvolutionShellComponentClientPrivate *priv;
Bonobo_Control corba_control;
RETURN_ERROR_IF_FAIL (shell_component_client != NULL);
RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
RETURN_ERROR_IF_FAIL (uih != NULL);
RETURN_ERROR_IF_FAIL (BONOBO_IS_UI_COMPONENT (uih));
RETURN_ERROR_IF_FAIL (physical_uri != NULL);
RETURN_ERROR_IF_FAIL (type_string != NULL);
RETURN_ERROR_IF_FAIL (view_info != NULL);
RETURN_ERROR_IF_FAIL (control_return != NULL);
priv = shell_component_client->priv;
CORBA_exception_init (&ev);
corba_control = GNOME_Evolution_ShellComponent_createView (priv->corba_objref, physical_uri, type_string, view_info, &ev);
result = corba_exception_to_result (&ev);
if (result != EVOLUTION_SHELL_COMPONENT_OK) {
*control_return = NULL;
} else {
Bonobo_UIContainer corba_uih;
corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (uih));
*control_return = BONOBO_CONTROL (bonobo_widget_new_control_from_objref (corba_control, corba_uih));
}
CORBA_exception_free (&ev);
return result;
}
EvolutionShellComponentResult
evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client,
const char *uri)
{
EvolutionShellComponentResult result;
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
RETURN_ERROR_IF_FAIL (shell_component_client != NULL);
RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
RETURN_ERROR_IF_FAIL (uri != NULL);
CORBA_exception_init (&ev);
priv = shell_component_client->priv;
GNOME_Evolution_ShellComponent_handleExternalURI (priv->corba_objref, uri, &ev);
result = corba_exception_to_result (&ev);
CORBA_exception_free (&ev);
return result;
}
/* Asyncronous operations. */
void
evolution_shell_component_client_async_create_folder (EvolutionShellComponentClient *shell_component_client,
const char *physical_uri,
const char *type,
EvolutionShellComponentClientCallback callback,
void *data)
{
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (physical_uri != NULL);
g_return_if_fail (type != NULL);
g_return_if_fail (callback != NULL);
priv = shell_component_client->priv;
if (priv->callback != NULL) {
(* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data);
return;
}
create_listener_interface (shell_component_client);
CORBA_exception_init (&ev);
priv->callback = callback;
priv->callback_data = data;
GNOME_Evolution_ShellComponent_createFolderAsync (priv->corba_objref, priv->listener_interface, physical_uri, type, &ev);
if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) {
(* callback) (shell_component_client,
shell_component_result_from_corba_exception (&ev),
data);
priv->callback = NULL;
priv->callback_data = NULL;
}
CORBA_exception_free (&ev);
}
void
evolution_shell_component_client_async_remove_folder (EvolutionShellComponentClient *shell_component_client,
const char *physical_uri,
const char *type,
EvolutionShellComponentClientCallback callback,
void *data)
{
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (physical_uri != NULL);
g_return_if_fail (callback != NULL);
priv = shell_component_client->priv;
if (priv->callback != NULL) {
(* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data);
return;
}
create_listener_interface (shell_component_client);
CORBA_exception_init (&ev);
priv->callback = callback;
priv->callback_data = data;
GNOME_Evolution_ShellComponent_removeFolderAsync (priv->corba_objref, priv->listener_interface, physical_uri, type, &ev);
if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) {
(* callback) (shell_component_client,
shell_component_result_from_corba_exception (&ev),
data);
priv->callback = NULL;
priv->callback_data = NULL;
}
CORBA_exception_free (&ev);
}
void
evolution_shell_component_client_async_xfer_folder (EvolutionShellComponentClient *shell_component_client,
const char *source_physical_uri,
const char *destination_physical_uri,
const char *type,
gboolean remove_source,
EvolutionShellComponentClientCallback callback,
void *data)
{
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (source_physical_uri != NULL);
g_return_if_fail (destination_physical_uri != NULL);
g_return_if_fail (data != NULL);
priv = shell_component_client->priv;
if (priv->callback != NULL) {
(* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data);
return;
}
create_listener_interface (shell_component_client);
CORBA_exception_init (&ev);
priv->callback = callback;
priv->callback_data = data;
GNOME_Evolution_ShellComponent_xferFolderAsync (priv->corba_objref, priv->listener_interface,
source_physical_uri, destination_physical_uri, type, remove_source,
&ev);
if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) {
(* callback) (shell_component_client,
shell_component_result_from_corba_exception (&ev),
data);
priv->callback = NULL;
priv->callback_data = NULL;
}
CORBA_exception_free (&ev);
}
void
evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client,
BonoboUIContainer *container,
const char *physical_uri,
const char *type)
{
Bonobo_UIContainer corba_container;
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (physical_uri != NULL);
g_return_if_fail (type != NULL);
priv = shell_component_client->priv;
CORBA_exception_init (&ev);
corba_container = bonobo_object_corba_objref (BONOBO_OBJECT (container));
GNOME_Evolution_ShellComponent_populateFolderContextMenu (priv->corba_objref, corba_container, physical_uri, type, &ev);
CORBA_exception_free (&ev);
}
void
evolution_shell_component_client_unpopulate_folder_context_menu (EvolutionShellComponentClient *shell_component_client,
BonoboUIContainer *container,
const char *physical_uri,
const char *type)
{
Bonobo_UIContainer corba_container;
EvolutionShellComponentClientPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (shell_component_client != NULL);
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (physical_uri != NULL);
g_return_if_fail (type != NULL);
priv = shell_component_client->priv;
CORBA_exception_init (&ev);
corba_container = bonobo_object_corba_objref (BONOBO_OBJECT (container));
GNOME_Evolution_ShellComponent_unpopulateFolderContextMenu (priv->corba_objref, corba_container, physical_uri, type, &ev);
CORBA_exception_free (&ev);
}
void
evolution_shell_component_client_request_quit (EvolutionShellComponentClient *shell_component_client,
EvolutionShellComponentClientCallback callback,
void *data)
{
EvolutionShellComponentClientPrivate *priv;
GNOME_Evolution_ShellComponent corba_shell_component;
CORBA_Environment ev;
g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client));
g_return_if_fail (callback != NULL);
priv = shell_component_client->priv;
if (priv->callback != NULL) {
(* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data);
return;
}
create_listener_interface (shell_component_client);
CORBA_exception_init (&ev);
corba_shell_component = evolution_shell_component_client_corba_objref (shell_component_client);
priv->callback = callback;
priv->callback_data = data;
GNOME_Evolution_ShellComponent_requestQuit (corba_shell_component, priv->listener_interface, &ev);
if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) {
(* callback) (shell_component_client,
shell_component_result_from_corba_exception (&ev),
data);
priv->callback = NULL;
priv->callback_data = NULL;
}
CORBA_exception_free (&ev);
}
E_MAKE_TYPE (evolution_shell_component_client, "EvolutionShellComponentClient",
EvolutionShellComponentClient, class_init, init, PARENT_TYPE)

View File

@ -1,142 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-shell-component-client.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 EVOLUTION_SHELL_COMPONENT_CLIENT_H
#define EVOLUTION_SHELL_COMPONENT_CLIENT_H
#include <glib-object.h>
#include <bonobo/bonobo-ui-container.h>
#include <bonobo/bonobo-ui-component.h>
#include "evolution-shell-component.h"
#ifdef cplusplus
extern "C" {
#pragma }
#endif /* cplusplus */
#define EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT (evolution_shell_component_client_get_type ())
#define EVOLUTION_SHELL_COMPONENT_CLIENT(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT, EvolutionShellComponentClient))
#define EVOLUTION_SHELL_COMPONENT_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT, EvolutionShellComponentClientClass))
#define EVOLUTION_IS_SHELL_COMPONENT_CLIENT(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT))
#define EVOLUTION_IS_SHELL_COMPONENT_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT))
typedef struct _EvolutionShellComponentClient EvolutionShellComponentClient;
typedef struct _EvolutionShellComponentClientPrivate EvolutionShellComponentClientPrivate;
typedef struct _EvolutionShellComponentClientClass EvolutionShellComponentClientClass;
struct _EvolutionShellComponentClient {
GObject parent;
EvolutionShellComponentClientPrivate *priv;
};
struct _EvolutionShellComponentClientClass {
GObjectClass parent_class;
};
typedef void (* EvolutionShellComponentClientCallback) (EvolutionShellComponentClient *shell_component_client,
EvolutionShellComponentResult result,
void *data);
/* Construction. */
GtkType evolution_shell_component_client_get_type (void);
void evolution_shell_component_client_construct (EvolutionShellComponentClient *shell_component_client,
const char *id,
CORBA_Object corba_object);
EvolutionShellComponentClient *evolution_shell_component_client_new (const char *id,
CORBA_Environment *optional_ev);
GNOME_Evolution_ShellComponent evolution_shell_component_client_corba_objref (EvolutionShellComponentClient *client);
/* Properties. */
const char *evolution_shell_component_client_get_id (EvolutionShellComponentClient *shell_component_client);
/* Querying DnD interfaces. */
GNOME_Evolution_ShellComponentDnd_SourceFolder
evolution_shell_component_client_get_dnd_source_interface (EvolutionShellComponentClient *shell_component_client);
GNOME_Evolution_ShellComponentDnd_DestinationFolder
evolution_shell_component_client_get_dnd_destination_interface (EvolutionShellComponentClient *shell_component_client);
/* Querying the offline interface. */
GNOME_Evolution_Offline
evolution_shell_component_client_get_offline_interface (EvolutionShellComponentClient *shell_component_client);
/* Synchronous operations. */
EvolutionShellComponentResult evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell_component_client,
GNOME_Evolution_Shell shell,
const char *evolution_homedir);
EvolutionShellComponentResult evolution_shell_component_client_unset_owner (EvolutionShellComponentClient *shell_component_client,
GNOME_Evolution_Shell shell);
EvolutionShellComponentResult evolution_shell_component_client_create_view (EvolutionShellComponentClient *shell_component_client,
BonoboUIComponent *uih,
const char *physical_uri,
const char *type_string,
const char *view_info,
BonoboControl **control_return);
EvolutionShellComponentResult evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client,
const char *uri);
/* Asyncronous operations. */
void evolution_shell_component_client_async_create_folder (EvolutionShellComponentClient *shell_component_client,
const char *physical_uri,
const char *type,
EvolutionShellComponentClientCallback callback,
void *data);
void evolution_shell_component_client_async_remove_folder (EvolutionShellComponentClient *shell_component_client,
const char *physical_uri,
const char *type,
EvolutionShellComponentClientCallback callback,
void *data);
void evolution_shell_component_client_async_xfer_folder (EvolutionShellComponentClient *shell_component_client,
const char *source_physical_uri,
const char *destination_physical_uri,
const char *type,
gboolean remove_source,
EvolutionShellComponentClientCallback callback,
void *data);
void evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client,
BonoboUIContainer *container,
const char *physical_uri,
const char *type);
void evolution_shell_component_client_unpopulate_folder_context_menu (EvolutionShellComponentClient *shell_component_client,
BonoboUIContainer *container,
const char *physical_uri,
const char *type);
void evolution_shell_component_client_request_quit (EvolutionShellComponentClient *shell_component_client,
EvolutionShellComponentClientCallback callback,
void *data);
#ifdef cplusplus
}
#endif /* cplusplus */
#endif /* EVOLUTION_SHELL_COMPONENT_CLIENT_H */

View File

@ -1,294 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-shell-component-dnd.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: Chris Toshok
*/
#include "Evolution.h"
#include "evolution-shell-component-dnd.h"
#include <gal/util/e-util.h>
#include <gtk/gtkobject.h>
#define PARENT_TYPE (bonobo_object_get_type ())
static BonoboObjectClass *parent_class;
/* Source Folder stuff */
struct _DndSourceFolderPrivate {
DndSourceFolderBeginDragFn begin_drag;
DndSourceFolderGetDataFn get_data;
DndSourceFolderDeleteDataFn delete_data;
DndSourceFolderEndDragFn end_drag;
gpointer user_data;
};
/* GObject methods */
static void
dnd_source_finalize (GObject *object)
{
EvolutionShellComponentDndSourceFolder *folder;
DndSourceFolderPrivate *priv;
folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (object);
priv = folder->priv;
g_return_if_fail (priv != NULL);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_beginDrag (PortableServer_Servant servant, const CORBA_char * physical_uri,
const CORBA_char * folder_type, GNOME_Evolution_ShellComponentDnd_ActionSet * possible_actions,
GNOME_Evolution_ShellComponentDnd_Action * suggested_action, CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndSourceFolder *folder;
DndSourceFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object);
priv = folder->priv;
priv->begin_drag (folder, physical_uri, folder_type, possible_actions, suggested_action, priv->user_data);
}
static void
impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_getData (PortableServer_Servant servant,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context,
const GNOME_Evolution_ShellComponentDnd_Action action, const CORBA_char * dnd_type,
GNOME_Evolution_ShellComponentDnd_Data ** data, CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndSourceFolder *folder;
DndSourceFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object);
priv = folder->priv;
priv->get_data (folder, source_context, action, dnd_type, data, ev, priv->user_data);
}
static void
impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_deleteData (PortableServer_Servant servant,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context,
CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndSourceFolder *folder;
DndSourceFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object);
priv = folder->priv;
priv->delete_data (folder, source_context, priv->user_data);
}
static void
impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_endDrag (PortableServer_Servant servant,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context,
CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndSourceFolder *folder;
DndSourceFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object);
priv = folder->priv;
priv->end_drag (folder, source_context, priv->user_data);
}
static void
evolution_shell_component_dnd_source_folder_class_init (EvolutionShellComponentDndSourceFolderClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = dnd_source_finalize;
klass->epv.beginDrag = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_beginDrag;
klass->epv.getData = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_getData;
klass->epv.deleteData = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_deleteData;
klass->epv.endDrag = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_endDrag;
parent_class = g_type_class_ref(PARENT_TYPE);
}
static void
evolution_shell_component_dnd_source_folder_init (EvolutionShellComponentDndSourceFolder *folder)
{
DndSourceFolderPrivate *priv;
priv = g_new (DndSourceFolderPrivate, 1);
folder->priv = priv;
}
BONOBO_TYPE_FUNC_FULL (EvolutionShellComponentDndSourceFolder,
GNOME_Evolution_ShellComponentDnd_SourceFolder,
PARENT_TYPE,
evolution_shell_component_dnd_source_folder)
EvolutionShellComponentDndSourceFolder*
evolution_shell_component_dnd_source_folder_new (DndSourceFolderBeginDragFn begin_drag,
DndSourceFolderGetDataFn get_data,
DndSourceFolderDeleteDataFn delete_data,
DndSourceFolderEndDragFn end_drag,
gpointer user_data)
{
EvolutionShellComponentDndSourceFolder *dnd_source;
g_return_val_if_fail (begin_drag != NULL, NULL);
g_return_val_if_fail (get_data != NULL, NULL);
g_return_val_if_fail (delete_data != NULL, NULL);
g_return_val_if_fail (end_drag != NULL, NULL);
dnd_source = g_object_new (evolution_shell_component_dnd_source_folder_get_type (), NULL);
dnd_source->priv->begin_drag = begin_drag;
dnd_source->priv->get_data = get_data;
dnd_source->priv->delete_data = delete_data;
dnd_source->priv->end_drag = end_drag;
dnd_source->priv->user_data = user_data;
return dnd_source;
}
/* Destination Folder stuff */
struct _DndDestinationFolderPrivate {
DndDestinationFolderHandleMotionFn handle_motion;
DndDestinationFolderHandleDropFn handle_drop;
gpointer user_data;
};
/* GtkObject methods */
static void
dnd_destination_finalize (GObject *object)
{
EvolutionShellComponentDndDestinationFolder *folder;
DndDestinationFolderPrivate *priv;
folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (object);
priv = folder->priv;
g_return_if_fail (priv != NULL);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* CORBA interface */
static CORBA_boolean
impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion (PortableServer_Servant servant,
const CORBA_char* physical_uri,
const CORBA_char *folder_type,
const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context,
GNOME_Evolution_ShellComponentDnd_Action * suggested_action, CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndDestinationFolder *folder;
DndDestinationFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (bonobo_object);
priv = folder->priv;
return priv->handle_motion (folder, physical_uri, folder_type, destination_context, suggested_action, priv->user_data);
}
static CORBA_boolean
impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop (PortableServer_Servant servant,
const CORBA_char *physical_uri,
const CORBA_char *folder_type,
const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context,
const GNOME_Evolution_ShellComponentDnd_Action action,
const GNOME_Evolution_ShellComponentDnd_Data * data, CORBA_Environment * ev)
{
BonoboObject *bonobo_object;
EvolutionShellComponentDndDestinationFolder *folder;
DndDestinationFolderPrivate *priv;
bonobo_object = bonobo_object_from_servant (servant);
folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (bonobo_object);
priv = folder->priv;
return priv->handle_drop (folder, physical_uri, folder_type, destination_context, action, data, priv->user_data);
}
static void
evolution_shell_component_dnd_destination_folder_class_init (EvolutionShellComponentDndDestinationFolderClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = dnd_destination_finalize;
klass->epv.handleMotion = impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion;
klass->epv.handleDrop = impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop;
parent_class = g_type_class_ref(PARENT_TYPE);
}
static void
evolution_shell_component_dnd_destination_folder_init (EvolutionShellComponentDndDestinationFolder *folder)
{
DndDestinationFolderPrivate *priv;
priv = g_new (DndDestinationFolderPrivate, 1);
folder->priv = priv;
}
BONOBO_TYPE_FUNC_FULL (EvolutionShellComponentDndDestinationFolder,
GNOME_Evolution_ShellComponentDnd_DestinationFolder,
PARENT_TYPE,
evolution_shell_component_dnd_destination_folder)
EvolutionShellComponentDndDestinationFolder *
evolution_shell_component_dnd_destination_folder_new (DndDestinationFolderHandleMotionFn handle_motion,
DndDestinationFolderHandleDropFn handle_drop,
gpointer user_data)
{
EvolutionShellComponentDndDestinationFolder *dnd_destination;
g_return_val_if_fail (handle_motion != NULL, NULL);
g_return_val_if_fail (handle_drop != NULL, NULL);
dnd_destination = g_object_new (evolution_shell_component_dnd_destination_folder_get_type (), NULL);
dnd_destination->priv->handle_motion = handle_motion;
dnd_destination->priv->handle_drop = handle_drop;
dnd_destination->priv->user_data = user_data;
return dnd_destination;
}

View File

@ -1,136 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-shell-component-dnd.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: Chris Toshok
*/
#ifndef EVOLUTION_SHELL_COMPONENT_DND_H
#define EVOLUTION_SHELL_COMPONENT_DND_H
#include <bonobo/bonobo-object.h>
#include <gtk/gtktypeutils.h>
#include "Evolution.h"
#ifdef cplusplus
extern "C" {
#pragma }
#endif /* cplusplus */
/* Source Folder stuff */
#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE (evolution_shell_component_dnd_source_folder_get_type ())
#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE, EvolutionShellComponentDndSourceFolder))
#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE, EvolutionShellComponentDndSourceFolderClass))
#define IS_EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE))
#define IS_EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE))
typedef struct _DndSourceFolderPrivate DndSourceFolderPrivate;
typedef struct _EvolutionShellComponentDndSourceFolder EvolutionShellComponentDndSourceFolder;
typedef struct _EvolutionShellComponentDndSourceFolderClass EvolutionShellComponentDndSourceFolderClass;
typedef void (*DndSourceFolderBeginDragFn)(EvolutionShellComponentDndSourceFolder *folder,
const char *physical_uri,
const char *folder_type,
GNOME_Evolution_ShellComponentDnd_ActionSet *possible_actions_return,
GNOME_Evolution_ShellComponentDnd_Action *suggested_action_return,
gpointer closure);
typedef void (*DndSourceFolderGetDataFn)(EvolutionShellComponentDndSourceFolder *folder,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context,
const GNOME_Evolution_ShellComponentDnd_Action action,
const char * dnd_type,
GNOME_Evolution_ShellComponentDnd_Data ** data_return,
CORBA_Environment *ev,
gpointer closure);
typedef void (*DndSourceFolderDeleteDataFn)(EvolutionShellComponentDndSourceFolder *folder,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context *source_context,
gpointer closure);
typedef void (*DndSourceFolderEndDragFn)(EvolutionShellComponentDndSourceFolder *folder,
const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context *source_context,
gpointer closure);
struct _EvolutionShellComponentDndSourceFolder {
BonoboObject object;
DndSourceFolderPrivate *priv;
};
struct _EvolutionShellComponentDndSourceFolderClass {
BonoboObjectClass parent_class;
POA_GNOME_Evolution_ShellComponentDnd_SourceFolder__epv epv;
};
GtkType evolution_shell_component_dnd_source_folder_get_type (void);
EvolutionShellComponentDndSourceFolder*
evolution_shell_component_dnd_source_folder_new (DndSourceFolderBeginDragFn begin_drag,
DndSourceFolderGetDataFn get_data,
DndSourceFolderDeleteDataFn delete_data,
DndSourceFolderEndDragFn end_drag,
gpointer user_data);
/* Destination Folder stuff */
#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE (evolution_shell_component_dnd_destination_folder_get_type ())
#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE, EvolutionShellComponentDndDestinationFolder))
#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE, EvolutionShellComponentDndDestinationFolderClass))
#define IS_EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE))
#define IS_EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE))
typedef struct _DndDestinationFolderPrivate DndDestinationFolderPrivate;
typedef struct _EvolutionShellComponentDndDestinationFolder EvolutionShellComponentDndDestinationFolder;
typedef struct _EvolutionShellComponentDndDestinationFolderClass EvolutionShellComponentDndDestinationFolderClass;
typedef CORBA_boolean (*DndDestinationFolderHandleMotionFn)(EvolutionShellComponentDndDestinationFolder *folder,
const char *physical_uri,
const char *folder_type,
const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context,
GNOME_Evolution_ShellComponentDnd_Action * suggested_action_return,
gpointer closure);
typedef CORBA_boolean (*DndDestinationFolderHandleDropFn)(EvolutionShellComponentDndDestinationFolder *folder,
const char *physical_uri,
const char *folder_type,
const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context,
const GNOME_Evolution_ShellComponentDnd_Action action,
const GNOME_Evolution_ShellComponentDnd_Data * data,
gpointer closure);
struct _EvolutionShellComponentDndDestinationFolder {
BonoboObject object;
DndDestinationFolderPrivate *priv;
};
struct _EvolutionShellComponentDndDestinationFolderClass {
BonoboObjectClass parent_class;
POA_GNOME_Evolution_ShellComponentDnd_DestinationFolder__epv epv;
};
GtkType evolution_shell_component_dnd_destination_folder_get_type (void);
EvolutionShellComponentDndDestinationFolder*
evolution_shell_component_dnd_destination_folder_new (DndDestinationFolderHandleMotionFn handle_motion,
DndDestinationFolderHandleDropFn handle_drop,
gpointer user_data);
#ifdef cplusplus
}
#endif /* cplusplus */
#endif /* EVOLUTION_SHELL_COMPONENT_DND_H */

View File

@ -1,386 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-storage-listener.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 <gtk/gtksignal.h>
#include <bonobo/bonobo-main.h>
#include <gal/util/e-util.h>
#include "evolution-storage-listener.h"
#include "e-shell-marshal.h"
#define PARENT_TYPE gtk_object_get_type ()
static GtkObjectClass *parent_class = NULL;
struct _EvolutionStorageListenerPrivate {
GNOME_Evolution_StorageListener corba_objref;
EvolutionStorageListenerServant *servant;
};
enum {
DESTROYED,
NEW_FOLDER,
UPDATE_FOLDER,
REMOVED_FOLDER,
HAS_SUBFOLDERS,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/* Evolution::StorageListener implementation. */
static POA_GNOME_Evolution_StorageListener__vepv my_GNOME_Evolution_StorageListener_vepv;
static EvolutionStorageListener *
gtk_object_from_servant (PortableServer_Servant servant)
{
EvolutionStorageListenerServant *my_servant;
my_servant = (EvolutionStorageListenerServant *) servant;
return my_servant->gtk_object;
}
static void
impl_GNOME_Evolution_StorageListener_notifyDestroyed (PortableServer_Servant servant,
CORBA_Environment *ev)
{
EvolutionStorageListener *listener;
EvolutionStorageListenerPrivate *priv;
listener = gtk_object_from_servant (servant);
priv = listener->priv;
g_signal_emit (listener, signals[DESTROYED], 0);
}
static void
impl_GNOME_Evolution_StorageListener_notifyFolderCreated (PortableServer_Servant servant,
const CORBA_char *path,
const GNOME_Evolution_Folder *folder,
CORBA_Environment *ev)
{
EvolutionStorageListener *listener;
EvolutionStorageListenerPrivate *priv;
listener = gtk_object_from_servant (servant);
priv = listener->priv;
g_signal_emit (listener, signals[NEW_FOLDER], 0, path, folder);
}
static void
impl_GNOME_Evolution_StorageListener_notifyFolderUpdated (PortableServer_Servant servant,
const CORBA_char *path,
CORBA_long unread_count,
CORBA_Environment *ev)
{
EvolutionStorageListener *listener;
EvolutionStorageListenerPrivate *priv;
listener = gtk_object_from_servant (servant);
priv = listener->priv;
g_signal_emit (listener, signals[UPDATE_FOLDER], 0, path, unread_count);
}
static void
impl_GNOME_Evolution_StorageListener_notifyFolderRemoved (PortableServer_Servant servant,
const CORBA_char *path,
CORBA_Environment *ev)
{
EvolutionStorageListener *listener;
EvolutionStorageListenerPrivate *priv;
listener = gtk_object_from_servant (servant);
priv = listener->priv;
g_signal_emit (listener, signals[REMOVED_FOLDER], 0, path);
}
static void
impl_GNOME_Evolution_StorageListener_notifyHasSubfolders (PortableServer_Servant servant,
const CORBA_char *path,
const CORBA_char *message,
CORBA_Environment *ev)
{
EvolutionStorageListener *listener;
EvolutionStorageListenerPrivate *priv;
listener = gtk_object_from_servant (servant);
priv = listener->priv;
g_signal_emit (listener, signals[HAS_SUBFOLDERS], 0, path, message);
}
static EvolutionStorageListenerServant *
create_servant (EvolutionStorageListener *listener)
{
EvolutionStorageListenerServant *servant;
POA_GNOME_Evolution_StorageListener *corba_servant;
CORBA_Environment ev;
CORBA_exception_init (&ev);
servant = g_new0 (EvolutionStorageListenerServant, 1);
corba_servant = (POA_GNOME_Evolution_StorageListener *) servant;
corba_servant->vepv = &my_GNOME_Evolution_StorageListener_vepv;
POA_GNOME_Evolution_StorageListener__init ((PortableServer_Servant) corba_servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_free (servant);
CORBA_exception_free (&ev);
return NULL;
}
servant->gtk_object = listener;
CORBA_exception_free (&ev);
return servant;
}
static GNOME_Evolution_StorageListener
activate_servant (EvolutionStorageListener *listener,
POA_GNOME_Evolution_StorageListener *servant)
{
GNOME_Evolution_StorageListener corba_object;
CORBA_Environment ev;
CORBA_exception_init (&ev);
CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev));
corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev);
if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) {
CORBA_exception_free (&ev);
return corba_object;
}
CORBA_exception_free (&ev);
return CORBA_OBJECT_NIL;
}
/* GObject methods. */
static void
impl_finalize (GObject *object)
{
EvolutionStorageListener *storage_listener;
EvolutionStorageListenerPrivate *priv;
CORBA_Environment ev;
storage_listener = EVOLUTION_STORAGE_LISTENER (object);
priv = storage_listener->priv;
CORBA_exception_init (&ev);
if (priv->corba_objref != CORBA_OBJECT_NIL)
CORBA_Object_release (priv->corba_objref, &ev);
if (priv->servant != NULL) {
PortableServer_ObjectId *object_id;
object_id = PortableServer_POA_servant_to_id (bonobo_poa(), priv->servant, &ev);
PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev);
CORBA_free (object_id);
}
CORBA_exception_free (&ev);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
corba_class_init (void)
{
POA_GNOME_Evolution_StorageListener__vepv *vepv;
POA_GNOME_Evolution_StorageListener__epv *epv;
PortableServer_ServantBase__epv *base_epv;
base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
base_epv->_private = NULL;
base_epv->finalize = NULL;
base_epv->default_POA = NULL;
epv = g_new0 (POA_GNOME_Evolution_StorageListener__epv, 1);
epv->notifyDestroyed = impl_GNOME_Evolution_StorageListener_notifyDestroyed;
epv->notifyFolderCreated = impl_GNOME_Evolution_StorageListener_notifyFolderCreated;
epv->notifyFolderUpdated = impl_GNOME_Evolution_StorageListener_notifyFolderUpdated;
epv->notifyFolderRemoved = impl_GNOME_Evolution_StorageListener_notifyFolderRemoved;
epv->notifyHasSubfolders = impl_GNOME_Evolution_StorageListener_notifyHasSubfolders;
vepv = & my_GNOME_Evolution_StorageListener_vepv;
vepv->_base_epv = base_epv;
vepv->GNOME_Evolution_StorageListener_epv = epv;
}
static void
class_init (EvolutionStorageListenerClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_ref(PARENT_TYPE);
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = impl_finalize;
signals[DESTROYED]
= g_signal_new ("destroyed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageListenerClass, destroyed),
NULL, NULL,
e_shell_marshal_NONE__NONE,
G_TYPE_NONE, 0);
signals[NEW_FOLDER]
= g_signal_new ("new_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageListenerClass, new_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING_POINTER,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_POINTER);
signals[UPDATE_FOLDER]
= g_signal_new ("update_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageListenerClass, update_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING_INT,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_INT);
signals[REMOVED_FOLDER]
= g_signal_new ("removed_folder",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageListenerClass, removed_folder),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[HAS_SUBFOLDERS]
= g_signal_new ("has_subfolders",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageListenerClass, has_subfolders),
NULL, NULL,
e_shell_marshal_NONE__STRING_STRING,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
corba_class_init ();
}
static void
init (EvolutionStorageListener *storage_listener)
{
EvolutionStorageListenerPrivate *priv;
priv = g_new (EvolutionStorageListenerPrivate, 1);
priv->corba_objref = CORBA_OBJECT_NIL;
storage_listener->priv = priv;
}
void
evolution_storage_listener_construct (EvolutionStorageListener *listener,
GNOME_Evolution_StorageListener corba_objref)
{
EvolutionStorageListenerPrivate *priv;
g_return_if_fail (listener != NULL);
g_return_if_fail (corba_objref != CORBA_OBJECT_NIL);
priv = listener->priv;
g_return_if_fail (priv->corba_objref == CORBA_OBJECT_NIL);
priv->corba_objref = corba_objref;
GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (listener), GTK_FLOATING);
}
EvolutionStorageListener *
evolution_storage_listener_new (void)
{
EvolutionStorageListener *new;
EvolutionStorageListenerPrivate *priv;
GNOME_Evolution_StorageListener corba_objref;
new = g_object_new (evolution_storage_listener_get_type (), NULL);
priv = new->priv;
priv->servant = create_servant (new);
corba_objref = activate_servant (new, (POA_GNOME_Evolution_StorageListener *) priv->servant);
evolution_storage_listener_construct (new, corba_objref);
return new;
}
/**
* evolution_storage_listener_corba_objref:
* @listener: A pointer to an EvolutionStorageListener
*
* Get the CORBA object reference for the interface embedded in this GTK+
* object wrapper.
*
* Return value: A pointer to the CORBA object reference.
**/
GNOME_Evolution_StorageListener
evolution_storage_listener_corba_objref (EvolutionStorageListener *listener)
{
EvolutionStorageListenerPrivate *priv;
g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (EVOLUTION_IS_STORAGE_LISTENER (listener), CORBA_OBJECT_NIL);
priv = listener->priv;
return priv->corba_objref;
}
E_MAKE_TYPE (evolution_storage_listener, "EvolutionStorageListener", EvolutionStorageListener,
class_init, init, PARENT_TYPE)

View File

@ -1,94 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-storage-listener.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 __EVOLUTION_STORAGE_LISTENER_H__
#define __EVOLUTION_STORAGE_LISTENER_H__
#include <gtk/gtkobject.h>
#include "Evolution.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define EVOLUTION_TYPE_STORAGE_LISTENER (evolution_storage_listener_get_type ())
#define EVOLUTION_STORAGE_LISTENER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListener))
#define EVOLUTION_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListenerClass))
#define EVOLUTION_IS_STORAGE_LISTENER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER))
#define EVOLUTION_IS_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER))
typedef struct _EvolutionStorageListener EvolutionStorageListener;
typedef struct _EvolutionStorageListenerPrivate EvolutionStorageListenerPrivate;
typedef struct _EvolutionStorageListenerClass EvolutionStorageListenerClass;
struct _EvolutionStorageListener {
GtkObject parent;
EvolutionStorageListenerPrivate *priv;
};
struct _EvolutionStorageListenerClass {
GtkObjectClass parent_class;
/* Signals. */
void (* destroyed) (EvolutionStorageListener *storage_listener);
void (* new_folder) (EvolutionStorageListener *storage_listener,
const char *path,
const GNOME_Evolution_Folder *folder);
void (* update_folder) (EvolutionStorageListener *storage_listener,
const char *path,
int unread_count);
void (* removed_folder) (EvolutionStorageListener *storage_listener,
const char *path);
void (* has_subfolders) (EvolutionStorageListener *storage_listener,
const char *path,
const char *message);
void (* shared_folder_discovery_result) (EvolutionStorageListener *storage_listener,
const char *user,
const char *folder_name,
const char *storage_path,
const char *physical_uri);
};
struct _EvolutionStorageListenerServant {
POA_GNOME_Evolution_StorageListener servant_placeholder;
EvolutionStorageListener *gtk_object;
};
typedef struct _EvolutionStorageListenerServant EvolutionStorageListenerServant;
GtkType evolution_storage_listener_get_type (void);
void evolution_storage_listener_construct (EvolutionStorageListener *listener,
GNOME_Evolution_StorageListener corba_objref);
EvolutionStorageListener *evolution_storage_listener_new (void);
GNOME_Evolution_StorageListener evolution_storage_listener_corba_objref (EvolutionStorageListener *listener);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __EVOLUTION_STORAGE_LISTENER_H__ */

View File

@ -1,287 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-storage-set-view-listener.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 <gtk/gtksignal.h>
#include <bonobo/bonobo-main.h>
#include <gal/util/e-util.h>
#include "evolution-storage-set-view-listener.h"
#include "e-shell-marshal.h"
#define PARENT_TYPE gtk_object_get_type ()
static GtkObjectClass *parent_class = NULL;
struct _EvolutionStorageSetViewListenerPrivate {
GNOME_Evolution_StorageSetViewListener corba_listener;
EvolutionStorageSetViewListenerServant *servant;
};
enum {
FOLDER_SELECTED,
FOLDER_TOGGLED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/* Evolution::StorageSetViewListener implementation. */
static POA_GNOME_Evolution_StorageSetViewListener__vepv my_GNOME_Evolution_StorageSetViewListener_vepv;
static EvolutionStorageSetViewListener *
gtk_object_from_servant (PortableServer_Servant servant)
{
EvolutionStorageSetViewListenerServant *my_servant;
my_servant = (EvolutionStorageSetViewListenerServant *) servant;
return my_servant->gtk_object;
}
static void
impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected (PortableServer_Servant servant,
const CORBA_char *uri,
CORBA_Environment *ev)
{
EvolutionStorageSetViewListener *listener;
listener = gtk_object_from_servant (servant);
g_signal_emit (listener, signals[FOLDER_SELECTED], 0, uri);
}
static void
impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled (PortableServer_Servant servant,
CORBA_Environment *ev)
{
EvolutionStorageSetViewListener *listener;
listener = gtk_object_from_servant (servant);
g_signal_emit (listener, signals[FOLDER_TOGGLED], 0);
}
static EvolutionStorageSetViewListenerServant *
create_servant (EvolutionStorageSetViewListener *listener)
{
EvolutionStorageSetViewListenerServant *servant;
POA_GNOME_Evolution_StorageSetViewListener *corba_servant;
CORBA_Environment ev;
CORBA_exception_init (&ev);
servant = g_new0 (EvolutionStorageSetViewListenerServant, 1);
corba_servant = (POA_GNOME_Evolution_StorageSetViewListener *) servant;
corba_servant->vepv = &my_GNOME_Evolution_StorageSetViewListener_vepv;
POA_GNOME_Evolution_StorageSetViewListener__init ((PortableServer_Servant) corba_servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_free (servant);
CORBA_exception_free (&ev);
return NULL;
}
servant->gtk_object = listener;
CORBA_exception_free (&ev);
return servant;
}
static GNOME_Evolution_StorageSetViewListener
activate_servant (EvolutionStorageSetViewListener *listener,
POA_GNOME_Evolution_StorageSetViewListener *servant)
{
GNOME_Evolution_StorageSetViewListener corba_object;
CORBA_Environment ev;
CORBA_exception_init (&ev);
CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev));
corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev);
if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) {
CORBA_exception_free (&ev);
return corba_object;
}
CORBA_exception_free (&ev);
return CORBA_OBJECT_NIL;
}
/* GObject methods. */
static void
impl_finalize (GObject *object)
{
EvolutionStorageSetViewListener *listener;
EvolutionStorageSetViewListenerPrivate *priv;
CORBA_Environment ev;
listener = EVOLUTION_STORAGE_SET_VIEW_LISTENER (object);
priv = listener->priv;
CORBA_exception_init (&ev);
if (priv->corba_listener != CORBA_OBJECT_NIL)
CORBA_Object_release (priv->corba_listener, &ev);
if (priv->servant != NULL) {
PortableServer_ObjectId *object_id;
object_id = PortableServer_POA_servant_to_id (bonobo_poa(), priv->servant, &ev);
PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev);
CORBA_free (object_id);
}
CORBA_exception_free (&ev);
g_free (priv);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
corba_class_init (void)
{
POA_GNOME_Evolution_StorageSetViewListener__vepv *vepv;
POA_GNOME_Evolution_StorageSetViewListener__epv *epv;
PortableServer_ServantBase__epv *base_epv;
base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
base_epv->_private = NULL;
base_epv->finalize = NULL;
base_epv->default_POA = NULL;
epv = g_new0 (POA_GNOME_Evolution_StorageSetViewListener__epv, 1);
epv->notifyFolderSelected = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected;
epv->notifyFolderToggled = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled;
vepv = & my_GNOME_Evolution_StorageSetViewListener_vepv;
vepv->_base_epv = base_epv;
vepv->GNOME_Evolution_StorageSetViewListener_epv = epv;
}
static void
class_init (EvolutionStorageSetViewListenerClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = impl_finalize;
parent_class = g_type_class_ref(gtk_object_get_type ());
signals[FOLDER_SELECTED]
= g_signal_new ("folder_selected",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageSetViewListenerClass, folder_selected),
NULL, NULL,
e_shell_marshal_NONE__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
signals[FOLDER_TOGGLED]
= g_signal_new ("folder_toggled",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EvolutionStorageSetViewListenerClass, folder_toggled),
NULL, NULL,
e_shell_marshal_NONE__NONE,
G_TYPE_NONE, 0);
corba_class_init ();
}
static void
init (EvolutionStorageSetViewListener *storage_set_view_listener)
{
EvolutionStorageSetViewListenerPrivate *priv;
priv = g_new (EvolutionStorageSetViewListenerPrivate, 1);
priv->corba_listener = CORBA_OBJECT_NIL;
storage_set_view_listener->priv = priv;
}
void
evolution_storage_set_view_listener_construct (EvolutionStorageSetViewListener *listener,
GNOME_Evolution_StorageSetViewListener corba_listener)
{
EvolutionStorageSetViewListenerPrivate *priv;
g_return_if_fail (listener != NULL);
g_return_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER (listener));
g_return_if_fail (corba_listener != CORBA_OBJECT_NIL);
priv = listener->priv;
g_return_if_fail (priv->corba_listener == CORBA_OBJECT_NIL);
priv->corba_listener = corba_listener;
GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (listener), GTK_FLOATING);
}
EvolutionStorageSetViewListener *
evolution_storage_set_view_listener_new (void)
{
EvolutionStorageSetViewListener *new;
EvolutionStorageSetViewListenerPrivate *priv;
GNOME_Evolution_StorageSetViewListener corba_listener;
new = g_object_new (evolution_storage_set_view_listener_get_type (), NULL);
priv = new->priv;
priv->servant = create_servant (new);
corba_listener = activate_servant (new, (POA_GNOME_Evolution_StorageSetViewListener *) priv->servant);
evolution_storage_set_view_listener_construct (new, corba_listener);
return new;
}
GNOME_Evolution_StorageSetViewListener
evolution_storage_set_view_listener_corba_objref (EvolutionStorageSetViewListener *listener)
{
EvolutionStorageSetViewListenerPrivate *priv;
g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
g_return_val_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER (listener), CORBA_OBJECT_NIL);
priv = listener->priv;
return priv->corba_listener;
}
E_MAKE_TYPE (evolution_storage_set_view_listener, "EvolutionStorageSetViewListener", EvolutionStorageSetViewListener,
class_init, init, PARENT_TYPE)

View File

@ -1,81 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* evolution-storage-set-view-listener.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 _EVOLUTION_STORAGE_SET_VIEW_LISTENER_H_
#define _EVOLUTION_STORAGE_SET_VIEW_LISTENER_H_
#include <gtk/gtkobject.h>
#include "Evolution.h"
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER (evolution_storage_set_view_listener_get_type ())
#define EVOLUTION_STORAGE_SET_VIEW_LISTENER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER, EvolutionStorageSetViewListener))
#define EVOLUTION_STORAGE_SET_VIEW_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER, EvolutionStorageSetViewListenerClass))
#define EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER))
#define EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER))
typedef struct _EvolutionStorageSetViewListener EvolutionStorageSetViewListener;
typedef struct _EvolutionStorageSetViewListenerPrivate EvolutionStorageSetViewListenerPrivate;
typedef struct _EvolutionStorageSetViewListenerClass EvolutionStorageSetViewListenerClass;
struct _EvolutionStorageSetViewListener {
GtkObject parent;
EvolutionStorageSetViewListenerPrivate *priv;
};
struct _EvolutionStorageSetViewListenerClass {
GtkObjectClass parent_class;
void (* folder_selected) (EvolutionStorageSetViewListener *listener,
const char *uri);
void (* folder_toggled) (EvolutionStorageSetViewListener *listener,
const char *uri,
gboolean active);
};
struct _EvolutionStorageSetViewListenerServant {
POA_GNOME_Evolution_StorageSetViewListener servant_placeholder;
EvolutionStorageSetViewListener *gtk_object;
};
typedef struct _EvolutionStorageSetViewListenerServant EvolutionStorageSetViewListenerServant;
GtkType evolution_storage_set_view_listener_get_type (void);
void evolution_storage_set_view_listener_construct (EvolutionStorageSetViewListener *listener,
GNOME_Evolution_StorageSetViewListener corba_objref);
EvolutionStorageSetViewListener *evolution_storage_set_view_listener_new (void);
GNOME_Evolution_StorageSetViewListener evolution_storage_set_view_listener_corba_objref (EvolutionStorageSetViewListener *listener);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _EVOLUTION_STORAGE_SET_VIEW_LISTENER_H_ */

View File

@ -91,7 +91,7 @@ static gboolean setup_only = FALSE;
static gboolean killev = FALSE;
static char *default_component_id = NULL;
extern char *evolution_debug_log;
static char *evolution_debug_log = NULL;
static GtkWidget *