[Evolution-hackers] ESourceList



Hello,

I have committed (to the new-ui-branch) a first draft of the API that we
could use to track down the list of configured calendars/addressbooks in
the new UI.

It's loosely modeled after EAccountList and organized as a hierarchy of
three widgets:

      * ESource, one "source", i.e. a calendar, addressbook, etc.

      * ESourceGroup, a group of sources.  This will be used to group
        e.g. all local calendars, all web calendars, all calendars on a
        certain server, and so on.

      * ESourceList, a list of groups of sources, i.e. the toplevel
        object.

Each of these emit "changed" signals when anything changes, and
ESourceList and ESourceGroup emit "removed" and "added" signals when
groups/sources get removed.

The list gets stored in GConf as a list of XML blobs (i.e. each element
of the list is an XML blob with the info for one group).  When the list
changes on GConf it gets parsed again and the appropriate signals are
emitted.

Things left to figure out:

      * Right now it assumes the name of the source or the group is
        unique and uses that to identify the source/group univocally. 
        This works fine, but it also makes it impossible to distinguish
        a rename from a remove/add...  Maybe I should use a UID like in
        EAccountList instead.  (In that case, should I lift the
        requirement that names are unique?  Probably not, since you
        still don't want to have ten calendars named the same way in a
        group.)

      * We need a color property for doing colorization of overlayed
        calendars.  (The color is going to be assigned automatically by
        the UI when you create a calendar, but it will stay attached to
        it unless the user changes it.)

      * We need a GtkTreeModel so that we can display this in a
        GtkTreeView and use it for selection.

Comments?  The headers are attached.

-- Ettore
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-source-list.h
 *
 * Copyright (C) 2003  Ettore Perazzoli
 *
 * 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_SOURCE_LIST_H_
#define _E_SOURCE_LIST_H_

#include <libxml/tree.h>
#include <gconf/gconf-client.h>

#include "e-source-group.h"

#define E_TYPE_SOURCE_LIST			(e_source_list_get_type ())
#define E_SOURCE_LIST(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_LIST, ESourceList))
#define E_SOURCE_LIST_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_LIST, ESourceListClass))
#define E_IS_SOURCE_LIST(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_LIST))
#define E_IS_SOURCE_LIST_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_LIST))


typedef struct _ESourceList        ESourceList;
typedef struct _ESourceListPrivate ESourceListPrivate;
typedef struct _ESourceListClass   ESourceListClass;

struct _ESourceList {
	GObject parent;

	ESourceListPrivate *priv;
};

struct _ESourceListClass {
	GObjectClass parent_class;

	/* Signals.  */

	void (* changed) (ESourceList *source_list);

	void (* group_removed) (ESourceList *source_list, ESourceGroup *group);
	void (* group_added) (ESourceList *source_list, ESourceGroup *group);
};


GType    e_source_list_get_type (void);

ESourceList *e_source_list_new            (void);
ESourceList *e_source_list_new_for_gconf  (GConfClient *client,
					   const char  *path);

GSList       *e_source_list_peek_groups          (ESourceList *list);
ESourceGroup *e_source_list_peek_group_by_name   (ESourceList *list,
						  const char  *source_group);
ESource      *e_source_list_peek_source_by_name  (ESourceList *list,
						  const char  *group_name,
						  const char  *source_name);

gboolean  e_source_list_add_group              (ESourceList  *list,
						ESourceGroup *group,
						int           position);
gboolean  e_source_list_remove_group           (ESourceList  *list,
						ESourceGroup *group);
gboolean  e_source_list_remove_group_by_name   (ESourceList  *list,
						const char   *name);
gboolean  e_source_list_remove_source_by_name  (ESourceList  *list,
						const char   *group_name,
						const char   *source_name);

gboolean  e_source_list_sync  (ESourceList  *list,
			       GError      **error);


#endif /* _E_SOURCE_LIST_H_ */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-source-group.h
 *
 * Copyright (C) 2003  Ettore Perazzoli
 *
 * 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_SOURCE_GROUP_H_
#define _E_SOURCE_GROUP_H_

#include <glib-object.h>
#include <libxml/tree.h>

#define E_TYPE_SOURCE_GROUP			(e_source_group_get_type ())
#define E_SOURCE_GROUP(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_GROUP, ESourceGroup))
#define E_SOURCE_GROUP_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_GROUP, ESourceGroupClass))
#define E_IS_SOURCE_GROUP(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_GROUP))
#define E_IS_SOURCE_GROUP_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_GROUP))


typedef struct _ESourceGroup        ESourceGroup;
typedef struct _ESourceGroupPrivate ESourceGroupPrivate;
typedef struct _ESourceGroupClass   ESourceGroupClass;

#include "e-source.h"

struct _ESourceGroup {
	GObject parent;

	ESourceGroupPrivate *priv;
};

struct _ESourceGroupClass {
	GObjectClass parent_class;

	/* Signals.  */

	void (* changed) (ESourceGroup *group);

	void (* source_removed) (ESourceGroup *source_list, ESource *source);
	void (* source_added)   (ESourceGroup *source_list, ESource *source);
};


GType    e_source_group_get_type (void);

ESourceGroup *e_source_group_new              (const char *name,
					       const char *base_uri);
ESourceGroup *e_source_group_new_from_xml     (const char *xml);
ESourceGroup *e_source_group_new_from_xmldoc  (xmlDocPtr   doc);

gboolean  e_source_group_update_from_xml     (ESourceGroup *group,
					      const char   *xml,
					      gboolean     *changed_return);
gboolean  e_source_group_update_from_xmldoc  (ESourceGroup *group,
					      xmlDocPtr     doc,
					      gboolean     *changed_return);

char *e_source_group_name_from_xmldoc  (xmlDocPtr doc);

void  e_source_group_set_name      (ESourceGroup *group,
				    const char   *name);
void  e_source_group_set_base_uri  (ESourceGroup *group,
				    const char   *base_uri);

const char *e_source_group_peek_name      (ESourceGroup *group);
const char *e_source_group_peek_base_uri  (ESourceGroup *group);

GSList  *e_source_group_peek_sources         (ESourceGroup *group);
ESource *e_source_group_peek_source_by_name  (ESourceGroup *group,
					      const char   *source_name);

gboolean  e_source_group_add_source             (ESourceGroup *group,
						 ESource      *source,
						 int           position);
gboolean  e_source_group_remove_source          (ESourceGroup *group,
						 ESource      *source);
gboolean  e_source_group_remove_source_by_name  (ESourceGroup *group,
						 const char   *name);

char *e_source_group_to_xml (ESourceGroup *group);


#endif /* _E_SOURCE_GROUP_H_ */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-source.h
 *
 * Copyright (C) 2003  Ettore Perazzoli
 *
 * 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_SOURCE_H_
#define _E_SOURCE_H_

#include <glib-object.h>
#include <libxml/tree.h>

#define E_TYPE_SOURCE			(e_source_get_type ())
#define E_SOURCE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE, ESource))
#define E_SOURCE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE, ESourceClass))
#define E_IS_SOURCE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE))
#define E_IS_SOURCE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE))


typedef struct _ESource        ESource;
typedef struct _ESourcePrivate ESourcePrivate;
typedef struct _ESourceClass   ESourceClass;

#include "e-source-group.h"

struct _ESource {
	GObject parent;

	ESourcePrivate *priv;
};

struct _ESourceClass {
	GObjectClass parent_class;

	/* Signals.  */
	void (* changed) (ESource *source);
};


GType    e_source_get_type (void);

ESource *e_source_new                (const char   *name,
				      const char   *relative_uri);
ESource *e_source_new_from_xml_node  (xmlNodePtr    node);

gboolean  e_source_update_from_xml_node  (ESource    *source,
					  xmlNodePtr  node,
					  gboolean   *changed_return);

char *e_source_name_from_xml_node  (xmlNodePtr node);

void  e_source_set_group         (ESource      *source,
				  ESourceGroup *group);
void  e_source_set_name          (ESource      *source,
				  const char   *name);
void  e_source_set_relative_uri  (ESource      *source,
				  const char   *relative_uri);

ESourceGroup *e_source_peek_group         (ESource *source);
const char   *e_source_peek_name          (ESource *source);
const char   *e_source_peek_relative_uri  (ESource *source);

char *e_source_get_uri  (ESource *source);

void  e_source_dump_to_xml_node  (ESource    *source,
				  xmlNodePtr  parent_node);


#endif /* _E_SOURCE_H_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]