aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-folder.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-05-07 09:57:49 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-05-07 09:57:49 +0800
commit725d0a088ddafd5f5665f4415c54f12411103e83 (patch)
tree5cf59c14ca05b80fa206bda3a6ee27a075f8ad22 /shell/e-folder.c
parentd92547ebaa21c0175f9cab9cb828d31d5896e5c5 (diff)
downloadgsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar.gz
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar.bz2
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar.lz
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar.xz
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.tar.zst
gsoc2013-evolution-725d0a088ddafd5f5665f4415c54f12411103e83.zip
Big shell reorganization.
svn path=/trunk/; revision=2848
Diffstat (limited to 'shell/e-folder.c')
-rw-r--r--shell/e-folder.c377
1 files changed, 193 insertions, 184 deletions
diff --git a/shell/e-folder.c b/shell/e-folder.c
index ba6e10b22e..c5be881180 100644
--- a/shell/e-folder.c
+++ b/shell/e-folder.c
@@ -1,266 +1,275 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * e-folder.c: Abstract class for Evolution folders
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-folder.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
- * Author:
- * Miguel de Icaza (miguel@helixcode.com)
+ * 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.
*
- * (C) 2000 Helix Code, Inc.
+ * Author: Ettore Perazzoli
*/
-
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
+#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
-#include <libgnome/libgnome.h>
+
#include "e-util/e-util.h"
+
#include "e-folder.h"
-#define PARENT_TYPE gtk_object_get_type ()
+
+#define PARENT_TYPE GTK_TYPE_OBJECT
+static GtkObjectClass *parent_class = NULL;
-static GtkObjectClass *parent_class;
+struct _EFolderPrivate {
+ char *name;
+ char *type;
+ char *description;
+};
-#define EFC(o) E_FOLDER_CLASS (GTK_OBJECT (o)->klass)
+#define EF_CLASS(obj) \
+ E_FOLDER_CLASS (GTK_OBJECT (obj)->klass)
+
enum {
CHANGED,
LAST_SIGNAL
};
-static guint efolder_signals [LAST_SIGNAL] = { 0, };
-static void
-e_folder_destroy (GtkObject *object)
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/* EFolder methods. */
+
+static gboolean
+save_info (EFolder *folder)
{
- EFolder *efolder = E_FOLDER (object);
-
- if (efolder->uri)
- g_free (efolder->uri);
-
- if (efolder->desc)
- g_free (efolder->desc);
-
- if (efolder->home_page)
- g_free (efolder->home_page);
-
- parent_class->destroy (object);
+ g_warning ("`%s' does not implement `EFolder::save_info()'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ return FALSE;
}
-static void
-e_folder_class_init (GtkObjectClass *object_class)
+static gboolean
+load_info (EFolder *folder)
{
- parent_class = gtk_type_class (PARENT_TYPE);
-
- object_class->destroy = e_folder_destroy;
-
- efolder_signals [CHANGED] =
- gtk_signal_new ("changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EFolderClass, changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE,
- 0);
-
- /* Register our signals */
- gtk_object_class_add_signals (
- object_class, efolder_signals, LAST_SIGNAL);
+ g_warning ("`%s' does not implement `EFolder::load_info()'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ return FALSE;
}
-static void
-e_folder_init (GtkObject *object)
+static gboolean
+remove (EFolder *folder)
{
+ g_warning ("`%s' does not implement `EFolder::remove()'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ return FALSE;
}
-E_MAKE_TYPE (e_folder, "EFolder", EFolder, e_folder_class_init, e_folder_init, PARENT_TYPE)
-
-void
-e_folder_set_uri (EFolder *efolder, const char *uri)
+static const char *
+get_physical_uri (EFolder *folder)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
- g_return_if_fail (uri != NULL);
-
- if (efolder->uri)
- g_free (efolder->uri);
-
- efolder->uri = g_strdup (uri);
+ g_warning ("`%s' does not implement `EFolder::remove()'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ return NULL;
}
-const char *
-e_folder_get_uri (EFolder *efolder)
+
+/* GtkObject methods. */
+
+static void
+destroy (GtkObject *object)
{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
+ EFolder *folder;
+ EFolderPrivate *priv;
+
+ folder = E_FOLDER (object);
+ priv = folder->priv;
+
+ g_free (priv->name);
+ g_free (priv->type);
+ g_free (priv->description);
- return efolder->uri;
+ g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
-void
-e_folder_set_description (EFolder *efolder, const char *desc)
+
+static void
+class_init (EFolderClass *klass)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
- g_return_if_fail (desc != NULL);
-
- if (efolder->desc)
- g_free (efolder->desc);
-
- efolder->desc = g_strdup (desc);
+ GtkObjectClass *object_class;
+
+ parent_class = gtk_type_class (gtk_object_get_type ());
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = destroy;
+
+ signals[CHANGED] = gtk_signal_new ("changed",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EFolderClass, changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
+ klass->save_info = save_info;
+ klass->load_info = load_info;
+ klass->remove = remove;
+ klass->get_physical_uri = get_physical_uri;
}
-const char *
-e_folder_get_description (EFolder *efolder)
+static void
+init (EFolder *folder)
{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
+ EFolderPrivate *priv;
+
+ priv = g_new (EFolderPrivate, 1);
+ priv->type = NULL;
+ priv->name = NULL;
+ priv->description = NULL;
- return efolder->desc;
+ folder->priv = priv;
}
+
void
-e_folder_set_home_page (EFolder *efolder, const char *home_page)
+e_folder_construct (EFolder *folder,
+ const char *name,
+ const char *type,
+ const char *description)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
- g_return_if_fail (home_page != NULL);
-
- if (efolder->home_page)
- g_free (efolder->home_page);
-
- efolder->home_page = g_strdup (home_page);
-}
+ EFolderPrivate *priv;
-const char *
-e_folder_get_home_page (EFolder *efolder)
-{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (E_IS_FOLDER (folder));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (type != NULL);
+ g_return_if_fail (description != NULL);
- return efolder->home_page;
-}
+ GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (folder), GTK_FLOATING);
-const char *
-e_folder_get_type_name (EFolder *efolder)
-{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
-
- switch (efolder->type){
- case E_FOLDER_MAIL:
- return _("A folder containing mail items");
-
- case E_FOLDER_CONTACTS:
- return _("A folder containing contacts");
-
- case E_FOLDER_CALENDAR:
- return _("A folder containing calendar entries");
-
- case E_FOLDER_TASKS:
- return _("A folder containing tasks");
-
- default:
- g_assert_not_reached ();
- }
+ priv = folder->priv;
- return NULL;
+ priv->name = g_strdup (name);
+ priv->type = g_strdup (type);
+ priv->description = g_strdup (description);
}
-
-EFolderType
-e_folder_get_folder_type (EFolder *efolder)
+EFolder *
+e_folder_new (const char *name,
+ const char *type,
+ const char *description)
{
- g_return_val_if_fail (efolder != NULL, E_FOLDER_OTHER);
- g_return_val_if_fail (E_IS_FOLDER (efolder), E_FOLDER_OTHER);
-
- return (efolder->type);
-}
+ EFolder *folder;
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (type != NULL, NULL);
+ g_return_val_if_fail (description != NULL, NULL);
+ folder = gtk_type_new (E_TYPE_FOLDER);
+ e_folder_construct (folder, name, type, description);
-void
-e_folder_construct (EFolder *efolder, EFolderType type,
- const char *uri, const char *name,
- const char *desc, const char *home_page,
- const char *view_name)
+ return folder;
+}
+
+
+const char *
+e_folder_get_name (EFolder *folder)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
-
- /* EFolders are self-owned */
- GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (efolder), GTK_FLOATING);
-
- if (uri)
- efolder->uri = g_strdup (uri);
- if (name)
- efolder->name = g_strdup (name);
- if (desc)
- efolder->desc = g_strdup (desc);
- if (home_page)
- efolder->home_page = g_strdup (home_page);
- if (view_name)
- efolder->view_name = g_strdup (view_name);
-
- efolder->type = type;
+ g_return_val_if_fail (folder != NULL, NULL);
+ g_return_val_if_fail (E_IS_FOLDER (folder), NULL);
+
+ return folder->priv->name;
}
-EFolder *
-e_folder_new (EFolderType type,
- const char *uri, const char *name,
- const char *desc, const char *home_page,
- const char *view_name)
+const char *
+e_folder_get_type_string (EFolder *folder)
{
- EFolder *efolder;
-
- efolder = gtk_type_new (e_folder_get_type ());
+ g_return_val_if_fail (folder != NULL, NULL);
+ g_return_val_if_fail (E_IS_FOLDER (folder), NULL);
- e_folder_construct (efolder, type, uri, name, desc, home_page, view_name);
- return efolder;
+ return folder->priv->type;
}
const char *
-e_folder_get_name (EFolder *efolder)
+e_folder_get_description (EFolder *folder)
{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
+ g_return_val_if_fail (folder != NULL, NULL);
+ g_return_val_if_fail (E_IS_FOLDER (folder), NULL);
- return efolder->name;
+ return folder->priv->description;
}
+
void
-e_folder_set_name (EFolder *efolder, const char *name)
+e_folder_set_name (EFolder *folder,
+ const char *name)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (E_IS_FOLDER (folder));
+ g_return_if_fail (name != NULL);
- if (efolder->name)
- g_free (efolder->name);
+ g_free (folder->priv->name);
+ folder->priv->name = g_strdup (name);
- efolder->name = g_strdup (name);
+ gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]);
}
-const char *
-e_folder_get_view_name (EFolder *efolder)
+void
+e_folder_set_type_string (EFolder *folder,
+ const char *type)
{
- g_return_val_if_fail (efolder != NULL, NULL);
- g_return_val_if_fail (E_IS_FOLDER (efolder), NULL);
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (E_IS_FOLDER (folder));
+ g_return_if_fail (type != NULL);
+
+ g_free (folder->priv->type);
+ folder->priv->type = g_strdup (type);
- return efolder->view_name;
+ gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]);
}
void
-e_folder_set_view_name (EFolder *efolder, const char *view_name)
+e_folder_set_description (EFolder *folder,
+ const char *description)
{
- g_return_if_fail (efolder != NULL);
- g_return_if_fail (E_IS_FOLDER (efolder));
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (E_IS_FOLDER (folder));
+ g_return_if_fail (description != NULL);
- if (efolder->view_name)
- g_free (efolder->view_name);
+ g_free (folder->priv->description);
+ folder->priv->description = g_strdup (description);
- efolder->view_name = g_strdup (view_name);
-
- gtk_signal_emit (GTK_OBJECT (efolder),
- efolder_signals [CHANGED]);
+ gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]);
}
+
+const char *
+e_folder_get_physical_uri (EFolder *folder)
+{
+ g_return_val_if_fail (folder != NULL, NULL);
+ g_return_val_if_fail (E_IS_FOLDER (folder), NULL);
+
+ return (* EF_CLASS (folder)->get_physical_uri) (folder);
+}
+
+E_MAKE_TYPE (e_folder, "EFolder", EFolder, class_init, init, PARENT_TYPE)