aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-07-03 10:57:58 +0800
committerChris Lahey <clahey@src.gnome.org>2001-07-03 10:57:58 +0800
commite3997d78ae0e2451090c934983568ed89b86e87e (patch)
tree9d585beca9bec6951b830d9a9032179b6d4ca985 /e-util
parente1e2d6393df2a7e1af08a18330fe65c49d81d9c9 (diff)
downloadgsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar.gz
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar.bz2
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar.lz
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar.xz
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.tar.zst
gsoc2013-evolution-e3997d78ae0e2451090c934983568ed89b86e87e.zip
Added e-categories-master-list-wombat.c and
2001-07-02 Christopher James Lahey <clahey@ximian.com> * Makefile.am (libeutil_la_SOURCES): Added e-categories-master-list-wombat.c and e-categories-master-list-wombat.h. (INCLUDES): Added $(BONOBO_CONF_CFLAGS). * e-categories-master-list-wombat.c, e-categories-master-list-wombat.h: New class implementing a master list that stores its state using bonobo-conf. svn path=/trunk/; revision=10720
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog11
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-categories-master-list-wombat.c199
-rw-r--r--e-util/e-categories-master-list-wombat.h35
4 files changed, 247 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 1f7b49db1c..b965827fef 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,14 @@
+2001-07-02 Christopher James Lahey <clahey@ximian.com>
+
+ * Makefile.am (libeutil_la_SOURCES): Added
+ e-categories-master-list-wombat.c and
+ e-categories-master-list-wombat.h.
+ (INCLUDES): Added $(BONOBO_CONF_CFLAGS).
+
+ * e-categories-master-list-wombat.c,
+ e-categories-master-list-wombat.h: New class implementing a master
+ list that stores its state using bonobo-conf.
+
2001-07-02 Rodrigo Moya <rodrigo@ximian.com>
* e-categories-config.[ch]: new file for a set of functions for
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 08b1f19b0b..d9c6ed7d43 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -16,6 +16,8 @@ noinst_LTLIBRARIES = libeutil.la libeutil-static.la \
libedb3util.la
libeutil_la_SOURCES = \
+ e-categories-master-list-wombat.c \
+ e-categories-master-list-wombat.h \
e-categories-config.c \
e-categories-config.h \
e-corba-utils.c \
diff --git a/e-util/e-categories-master-list-wombat.c b/e-util/e-categories-master-list-wombat.c
new file mode 100644
index 0000000000..4410b6f009
--- /dev/null
+++ b/e-util/e-categories-master-list-wombat.c
@@ -0,0 +1,199 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-categories-master-list.c: the master list of categories.
+ *
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * (C) 1999, 2000 Ximian, Inc.
+ */
+#include <config.h>
+
+#include "e-categories-master-list-wombat.h"
+
+#include <gal/util/e-i18n.h>
+#include <bonobo-conf/bonobo-config-database.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-listener.h>
+#include <bonobo/bonobo-event-source.h>
+
+#define PARENT_TYPE e_categories_master_list_array_get_type ()
+
+#define d(x)
+
+struct _ECategoriesMasterListWombatPriv {
+ Bonobo_ConfigDatabase db;
+ Bonobo_EventSource_ListenerId listener_id;
+};
+
+static ECategoriesMasterListArrayClass *parent_class;
+
+static void
+ecmlw_load (ECategoriesMasterListWombat *ecmlw)
+{
+ char *string;
+ gboolean def;
+
+ string = bonobo_config_get_string_with_default
+ (ecmlw->priv->db,
+ "General/CategoryMasterList",
+ NULL,
+ &def);
+
+ if (!def)
+ e_categories_master_list_array_from_string
+ (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw),
+ string);
+
+ g_print ("load: %s\n", string);
+
+ g_free (string);
+}
+
+static void
+ecmlw_save (ECategoriesMasterListWombat *ecmlw)
+{
+ char *string;
+ CORBA_Environment ev;
+
+ string = e_categories_master_list_array_to_string (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw));
+
+ g_print ("save: %s\n", string);
+
+ CORBA_exception_init (&ev);
+
+ bonobo_config_set_string (ecmlw->priv->db,
+ "General/CategoryMasterList",
+ string,
+ &ev);
+
+ CORBA_exception_free (&ev);
+
+ g_free (string);
+}
+
+/**
+ * ecmlw_commit:
+ * @ecml: the master list to remove from.
+ */
+static void
+ecmlw_commit (ECategoriesMasterList *ecml)
+{
+ ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (ecml);
+
+ ((ECategoriesMasterListClass *) parent_class)->commit (ecml);
+
+ ecmlw_save (ecmlw);
+}
+
+
+/**
+ * ecmlw_reset:
+ * @ecml: the master list to reset.
+ */
+static void
+ecmlw_reset (ECategoriesMasterList *ecml)
+{
+ ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (ecml);
+
+ ((ECategoriesMasterListClass *) parent_class)->reset (ecml);
+
+ ecmlw_save (ecmlw);
+}
+
+static void
+ecmlw_destroy (GtkObject *object)
+{
+ ECategoriesMasterListWombat *ecmlw = E_CATEGORIES_MASTER_LIST_WOMBAT (object);
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ /* remove the listener */
+
+ bonobo_event_source_client_remove_listener (ecmlw->priv->db,
+ ecmlw->priv->listener_id,
+ &ev);
+ bonobo_object_release_unref (ecmlw->priv->db, &ev);
+
+ CORBA_exception_free (&ev);
+}
+
+
+static void
+ecmlw_class_init (GtkObjectClass *object_class)
+{
+ ECategoriesMasterListClass *ecml_class = E_CATEGORIES_MASTER_LIST_CLASS(object_class);
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ ecml_class->commit = ecmlw_commit;
+
+ ecml_class->reset = ecmlw_reset ;
+
+ object_class->destroy = ecmlw_destroy;
+}
+
+static void
+property_change_cb (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *any,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ ecmlw_load (user_data);
+}
+
+static void
+ecmlw_init (ECategoriesMasterListWombat *ecmlw)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ ecmlw->priv = g_new (ECategoriesMasterListWombatPriv, 1);
+ ecmlw->priv->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ /* add a listener */
+ ecmlw->priv->listener_id =
+ bonobo_event_source_client_add_listener (ecmlw->priv->db, property_change_cb,
+ NULL, &ev, ecmlw);
+ if (BONOBO_EX (&ev)) {
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ CORBA_exception_free (&ev);
+
+ ecmlw_load (ecmlw);
+}
+
+guint
+e_categories_master_list_wombat_get_type (void)
+{
+ static guint type = 0;
+
+ if (!type) {
+ GtkTypeInfo info = {
+ "ECategoriesMasterListWombat",
+ sizeof (ECategoriesMasterListWombat),
+ sizeof (ECategoriesMasterListWombatClass),
+ (GtkClassInitFunc) ecmlw_class_init,
+ (GtkObjectInitFunc) ecmlw_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ type = gtk_type_unique (PARENT_TYPE, &info);
+ }
+
+ return type;
+}
+
+ECategoriesMasterList *
+e_categories_master_list_wombat_new (void)
+{
+ return E_CATEGORIES_MASTER_LIST (gtk_type_new (e_categories_master_list_wombat_get_type ()));
+}
diff --git a/e-util/e-categories-master-list-wombat.h b/e-util/e-categories-master-list-wombat.h
new file mode 100644
index 0000000000..a6fe2a04ff
--- /dev/null
+++ b/e-util/e-categories-master-list-wombat.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+#ifndef _E_CATEGORIES_MASTER_LIST_WOMBAT_H_
+#define _E_CATEGORIES_MASTER_LIST_WOMBAT_H_
+
+#include <gal/widgets/e-categories-master-list-array.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define E_CATEGORIES_MASTER_LIST_WOMBAT_TYPE (e_categories_master_list_wombat_get_type ())
+#define E_CATEGORIES_MASTER_LIST_WOMBAT(o) (GTK_CHECK_CAST ((o), E_CATEGORIES_MASTER_LIST_WOMBAT_TYPE, ECategoriesMasterListWombat))
+#define E_CATEGORIES_MASTER_LIST_WOMBAT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CATEGORIES_MASTER_LIST_WOMBAT_TYPE, ECategoriesMasterListWombatClass))
+#define E_IS_CATEGORIES_MASTER_LIST_WOMBAT(o) (GTK_CHECK_TYPE ((o), E_CATEGORIES_MASTER_LIST_WOMBAT_TYPE))
+#define E_IS_CATEGORIES_MASTER_LIST_WOMBAT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CATEGORIES_MASTER_LIST_WOMBAT_TYPE))
+
+typedef struct _ECategoriesMasterListWombatPriv ECategoriesMasterListWombatPriv;
+
+typedef struct {
+ ECategoriesMasterListArray base;
+ ECategoriesMasterListWombatPriv *priv;
+} ECategoriesMasterListWombat;
+
+typedef struct {
+ ECategoriesMasterListArrayClass parent_class;
+} ECategoriesMasterListWombatClass;
+
+GtkType e_categories_master_list_wombat_get_type (void);
+ECategoriesMasterList *e_categories_master_list_wombat_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _E_CATEGORIES_MASTER_LIST_WOMBAT_H_ */