[monkey-bubble: 684/753] Put this back.



commit 8d1f6b41e0f9fc0ad83a62c1a1c7f359f9eb5a2e
Author: Martin Baulig <baulig suse de>
Date:   Tue Aug 28 09:27:12 2001 +0000

    Put this back.
    
    2001-08-28  Martin Baulig  <baulig suse de>
    
    	* bonobo-config-ditem-utils.[ch], bonobo-config-ditem.[ch],
    	bonobo-moniker-ditem.c, test-ditem.c: Put this back.

 monikers/ChangeLog         |    5 +
 monikers/Makefile.am-50588 |   61 +++++++++++
 monikers/test-ditem.c      |  250 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 316 insertions(+), 0 deletions(-)
---
diff --git a/monikers/ChangeLog b/monikers/ChangeLog
index ad19af6..8fb3fe3 100644
--- a/monikers/ChangeLog
+++ b/monikers/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-28  Martin Baulig  <baulig suse de>
+
+	* bonobo-config-ditem-utils.[ch], bonobo-config-ditem.[ch],
+	bonobo-moniker-ditem.c, test-ditem.c: Put this back.
+
 2001-07-31  Martin Baulig  <baulig suse de>
 
 	Removed the "ditem" moniker. We'll put it in gnome-core and
diff --git a/monikers/Makefile.am-50588 b/monikers/Makefile.am-50588
index e69de29..46036f7 100644
--- a/monikers/Makefile.am-50588
+++ b/monikers/Makefile.am-50588
@@ -0,0 +1,61 @@
+INCLUDES = \
+	-I..					\
+	-I$(srcdir)/..				\
+	$(WARN_CFLAGS)				\
+	$(MONIKER_CFLAGS)			\
+	-Wno-unused				\
+	-DLIBGNOME_PREFIX=\""$(prefix)"\"		\
+	-DLIBGNOME_LIBDIR=\""$(libdir)"\"		\
+	-DLIBGNOME_DATADIR=\""$(datadir)"\"		\
+	-DLIBGNOME_BINDIR=\""$(bindir)"\"		\
+	-DLIBGNOME_LOCALSTATEDIR=\""$(localstatedir)"\" \
+	-DLIBGNOME_LOCALEDIR=\""$(gnomelocaledir)"\"	\
+	-DLIBGNOME_SYSCONFDIR=\""$(sysconfdir)"\"	\
+	-DVERSION=\""$(VERSION)"\"			\
+	-DG_LOG_DOMAIN=\"GnomeMonikers\"
+
+EXTRA_DIST = \
+	Bonobo_Moniker_ditem.oaf.in
+
+moniker_LTLIBRARIES = libmoniker_ditem.la
+monikerdir = $(libdir)/bonobo/monikers
+
+# Desktop Item specific bits...
+
+# Data
+gnomesysconfdir = $(sysconfdir)/gnome-2.0
+gnomesysconf_DATA = gnome-desktop.xmldb
+
+# DItem moniker
+
+Bonobo_Moniker_ditem.oaf : $(srcdir)/Bonobo_Moniker_ditem.oaf.in $(top_builddir)/config.status
+	sed -e "s|\ MONIKER_LIBDIR\@|$(monikerdir)|" \
+	$(srcdir)/Bonobo_Moniker_ditem.oaf.in > Bonobo_Moniker_ditem.oaf 
+
+libmoniker_ditem_la_SOURCES =	 		\
+	bonobo-moniker-ditem.c 			\
+	bonobo-config-ditem.c			\
+	bonobo-config-ditem.h			\
+	bonobo-config-ditem-utils.c		\
+	bonobo-config-ditem-utils.h
+
+libmoniker_ditem_la_LIBADD = \
+	../libgnome/libgnome-2.la		\
+	$(MONIKER_LIBS)
+
+# DItem tests ...
+
+noinst_PROGRAMS = test-ditem desktop-item-boot
+
+test_ditem_SOURCES = \
+	test-ditem.c
+
+test_ditem_LDADD = \
+	../libgnome/libgnome-2.la		\
+	$(MONIKER_LIBS)
+
+desktop_item_boot_SOURCES = \
+	desktop-item-boot.c
+
+desktop_item_boot_LDADD = \
+	../libgnome/libgnome-2.la
diff --git a/monikers/test-ditem.c b/monikers/test-ditem.c
new file mode 100644
index 0000000..412af1d
--- /dev/null
+++ b/monikers/test-ditem.c
@@ -0,0 +1,250 @@
+/* -*- Mode: C; c-set-style: gnu indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+#include <libbonobo.h>
+#include <libgnome/Gnome.h>
+#include <libgnome/gnome-ditem.h>
+#include <locale.h>
+#include <stdlib.h>
+
+#include "bonobo-config-ditem.h"
+
+static void G_GNUC_UNUSED
+boot_ditem (Bonobo_ConfigDatabase db)
+{
+	BonoboArg *arg;
+	CORBA_Environment ev;
+
+	arg = bonobo_arg_new (TC_GNOME_DesktopEntry);
+	bonobo_pbclient_set_value (db, "/Desktop Entry", arg, NULL);
+	bonobo_arg_release (arg);
+
+	/* For some strange reason, this function causes the config moniker
+	 * (bonobo-config-xmldb) to crash after successfully writing the file.
+	 * So call this function to initialize the file and the comment it out.
+	 */
+
+	CORBA_exception_init (&ev);
+	Bonobo_ConfigDatabase_sync (db, &ev);
+	CORBA_exception_free (&ev);
+}
+
+static void G_GNUC_UNUSED
+test_ditem (Bonobo_ConfigDatabase db)
+{
+	GnomeDesktopItem *ditem;
+	GNOME_DesktopEntryType type;
+	const gchar *text;
+	GSList *list, *c;
+
+	ditem = gnome_desktop_item_new_from_file ("/tmp/test.desktop",
+						  GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS);
+
+	text = gnome_desktop_item_get_location (ditem);
+	g_print ("LOCATION: |%s|\n", text);
+
+	type = gnome_desktop_item_get_type (ditem);
+	g_print ("TYPE: |%d|\n", type);
+
+	text = gnome_desktop_item_get_command (ditem);
+	g_print ("COMMAND: |%s|\n", text);
+
+	text = gnome_desktop_item_get_icon_path (ditem);
+	g_print ("ICON PATH: |%s|\n", text);
+
+	text = gnome_desktop_item_get_name (ditem, NULL);
+	g_print ("NAME: |%s|\n", text);
+
+	text = gnome_desktop_item_get_name (ditem, "de");
+	g_print ("NAME (de): |%s|\n", text);
+
+	text = gnome_desktop_item_get_local_name (ditem);
+	g_print ("LOCAL NAME: |%s|\n", text);
+
+	text = gnome_desktop_item_get_comment (ditem, NULL);
+	g_print ("COMMENT: |%s|\n", text);
+
+	text = gnome_desktop_item_get_comment (ditem, "de");
+	g_print ("COMMENT (de): |%s|\n", text);
+
+	text = gnome_desktop_item_get_local_comment (ditem);
+	g_print ("LOCAL COMMENT: |%s|\n", text);
+
+	list = gnome_desktop_item_get_attributes (ditem);
+	for (c = list; c; c = c->next) {
+		const gchar *attr = c->data;
+
+		g_print ("ATTRIBUTE: |%s|\n", attr);
+	}
+
+#if 1
+	gnome_desktop_item_set_name (ditem, "de", "Neu gesetzt!");
+
+	gnome_desktop_item_save (ditem, NULL);
+#endif
+
+	gnome_desktop_item_save (ditem, "/tmp/foo.desktop");
+}
+
+#if 0
+static void G_GNUC_UNUSED
+test_builtin (void)
+{
+	Bonobo_ConfigDatabase db, parent_db;
+	CORBA_Environment ev;
+	CORBA_TypeCode type;
+	BonoboArg *value;
+	gchar *string;
+
+	db = bonobo_config_ditem_new ("/tmp/test.desktop");
+	g_assert (db != CORBA_OBJECT_NIL);
+
+	CORBA_exception_init (&ev);
+	parent_db = bonobo_get_object ("xmldb:/tmp/foo.xmldb", "Bonobo/ConfigDatabase", &ev);
+	g_assert (!BONOBO_EX (&ev) && parent_db != CORBA_OBJECT_NIL);
+	CORBA_exception_free (&ev);
+
+	CORBA_exception_init (&ev);
+	Bonobo_ConfigDatabase_addDatabase (db, parent_db, "", 
+					   Bonobo_ConfigDatabase_DEFAULT, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	CORBA_exception_free (&ev);
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+	Bonobo_ConfigDatabase db = NULL;
+	Bonobo_ConfigDatabase default_db = NULL;
+	Bonobo_KeyList *dirlist, *keylist;
+        CORBA_Environment  ev;
+	CORBA_TypeCode type;
+	CORBA_any *value;
+	gchar *string;
+	guint i, j;
+
+        CORBA_exception_init (&ev);
+
+	setlocale (LC_ALL, "");
+
+	if (bonobo_init (&argc, argv) == FALSE)
+		g_error ("Cannot init bonobo");
+
+	bonobo_activate ();
+
+	// test_builtin ();
+
+	// db = bonobo_config_ditem_new ("/tmp/test.desktop");
+
+        CORBA_exception_init (&ev);
+	db = bonobo_get_object ("ditem:/tmp/test.desktop", "Bonobo/ConfigDatabase", &ev);
+	g_assert (!BONOBO_EX (&ev));
+        CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	default_db = bonobo_get_object ("xmldb:/tmp/foo.xml", "Bonobo/ConfigDatabase", &ev);
+	g_assert (!BONOBO_EX (&ev));
+        CORBA_exception_free (&ev);
+
+	g_assert (db != NULL);
+	g_assert (default_db != NULL);
+
+	test_ditem (db);
+
+        CORBA_exception_init (&ev);
+	Bonobo_ConfigDatabase_addDatabase (db, default_db, "/gnome-ditem/",
+					   Bonobo_ConfigDatabase_DEFAULT, &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+#if 0
+	dirlist = Bonobo_ConfigDatabase_getDirs (db, "", &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+	if (dirlist) {
+		for (i = 0; i < dirlist->_length; i++) {
+			g_print ("DIR: |%s|\n", dirlist->_buffer [i]);
+
+			keylist = Bonobo_ConfigDatabase_getKeys (db, dirlist->_buffer [i], &ev);
+			g_assert (!BONOBO_EX (&ev));
+
+			if (keylist)
+				for (j = 0; j < keylist->_length; j++)
+					g_print ("KEY (%s): |%s|\n", dirlist->_buffer [i],
+						 keylist->_buffer [j]);
+	    }
+	}
+
+	keylist = Bonobo_ConfigDatabase_getKeys (db, "/Config/Foo", &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+	if (keylist)
+		for (j = 0; j < keylist->_length; j++)
+			g_print ("TEST KEY: |%s|\n", keylist->_buffer [j]);
+#endif
+
+        CORBA_exception_init (&ev);
+	type = bonobo_pbclient_get_type (db, "/Foo/Test", &ev);
+	if (type)
+		printf ("type is %d - %s (%s)\n", type->kind, type->name, type->repo_id);
+
+        CORBA_exception_init (&ev);
+	value = bonobo_pbclient_get_value (db, "/Foo/Test", TC_CORBA_long, &ev);
+	if (value) {
+		printf ("got value as long %d\n", BONOBO_ARG_GET_LONG (value));
+		BONOBO_ARG_SET_LONG (value, 512);
+		bonobo_pbclient_set_value (db, "/Foo/Test", value, &ev);
+	}
+	bonobo_arg_release (value);
+        CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	type = bonobo_pbclient_get_type (db, "/Foo/Test", &ev);
+	if (type)
+		g_message (G_STRLOC ": type is %d - %s (%s)", type->kind, type->name, type->repo_id);
+	CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	value = bonobo_pbclient_get_value (db, "/Foo/Test", TC_CORBA_long, &ev);
+	if (value) {
+		g_message (G_STRLOC ": got value as long %d", BONOBO_ARG_GET_LONG (value));
+		BONOBO_ARG_SET_LONG (value, 512);
+		bonobo_pbclient_set_value (db, "/Foo/Test", value, &ev);
+	}
+	bonobo_arg_release (value);
+        CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	type = bonobo_pbclient_get_type (db, "/Desktop Entry/Terminal", &ev);
+	if (type)
+		g_message (G_STRLOC ": type is %d - %s (%s)", type->kind, type->name, type->repo_id);
+	CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	type = bonobo_pbclient_get_type (db, "/Desktop Entry/Name", &ev);
+	if (type)
+		g_message (G_STRLOC ": type is %d - %s (%s)", type->kind, type->name, type->repo_id);
+	CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	type = bonobo_pbclient_get_type (db, "/Desktop Entry/URL", &ev);
+	if (type)
+		g_message (G_STRLOC ": type is %d - %s (%s)", type->kind, type->name, type->repo_id);
+	CORBA_exception_free (&ev);
+
+	string = bonobo_pbclient_get_string (db, "/Desktop Entry/URL", NULL);
+	g_message (G_STRLOC ": |%s|", string);
+	bonobo_pbclient_set_string (db, "/Desktop Entry/URL", "http://www.gnome.org/";, NULL);
+
+	CORBA_exception_init (&ev);
+	Bonobo_ConfigDatabase_sync (db, &ev);
+	g_assert (!BONOBO_EX (&ev));
+        CORBA_exception_free (&ev);
+
+        CORBA_exception_init (&ev);
+	value = bonobo_pbclient_get_value (db, "/Desktop Entry", TC_GNOME_DesktopEntry, &ev);
+	g_message (G_STRLOC ": %p", value);
+	if (value)
+		printf ("got value as GNOME::DesktopEntry\n");
+        CORBA_exception_free (&ev);
+
+	exit (0);
+}



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